Skip to Content

Basic Linux Commands for Linux Beginners

Basic Linux commands are key skills for Linux beginners. We collect 10 basic Linux commands to help Linux beginners learn faster.

If you want to get a job as Linux admin or Cloud engineer, the command line is fundamental. We can give you a free server on our cloud to try Linux commands if join our mail group on www.howtouselinux.com. No trick. We think it is a good way to start your Linux journey.

Get Your Free Linux training!

Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!

If you want to setup your own cloud server for free, please check this post.

  • pwd command – prints the location of your current working directory
  • ls command – lists contents of current working directory
  • cd command – change directory
  • touch command – create new file or directory
  • echo command – print string
  • cat command – print contents of a file
  • cp command – copy file or directory
  • mv command – move file or directory
  • rm command – remove file or directory
  • mkdir command – create new directory
  • head command – print first few lines of a file
  • tail command – print last few lines of a file

pwd command – prints the location of your current working directory

This command prints the location of your current working directory. It’s important to know actually where you’re before going to a parent or subdirectories.

TO-M-F13P:~ root# pwd
/var/root

ls command – lists contents of current working directory

ls is one of the most used basic linux commands, used to print contents of a directory, by default it lists contents of current working directory(pwd).

TO-M-F13P:~ root# ls
.CFUserTextEncoding .forward .python_history .viminfo Library
.cisco .lesshst .sh_history Application Support test
.datastax_studio .oracle_jre_usage .ssh Documents test.cap

cd command – change directory

After knowing your pwd and getting an overview with the ls, it’s time to move around with cd command. Clarification, assume you’re on your Home directory, you need to go to the /usr/local/share/fonts directory, use cd /usr/local/share/fonts.

TO-M-F13P:~ root# cd /usr/local/share/fonts

touch command – create new file

touch, It’s the equivalent command of mkdir for files. You can create a blank file with touch command.

TO-M-F13P:~ root# touch howtouselinux

echo command – print string

echo command prints (echoes) a string of text to the terminal window.

TO-M-F13P:~ root# echo howtouselinux
howtouselinux

cat command – print contents of a file

It’s used to print the contents of a file to the screen(stdout more precisely), really useful when you want to have a quick look on contents of a file

TO-M-F13P:~ root# cat howtouselinux
howtouselinux

cp command – copy file or directory

cp , You can copy files and directories with this command. Typical usage is like cp file_a file_a_copy or cp dir_a dir_a_copy.

TO-M-F13P:~ root# cp howtouselinux howtouselinux_copy
TO-M-F13P:~ root# ls -lrt howtouselinux*
-rw-r–r– 1 root staff 14 Nov 7 11:39 howtouselinux
-rw-r–r– 1 root staff 14 Nov 7 11:41 howtouselinux_copy

mv command – move file or directory

The mv command is used to move or rename directories and files. To rename a file use mv old_name new_name

TO-M-F13P:~ root# mv howtouselinux howtouselinux_new
TO-M-F13P:~ root# ls -lrt howtouselinux_*
-rw-r–r–@ 1 root staff 14 Nov 7 11:39 howtouselinux_new
-rw-r–r– 1 root staff 14 Nov 7 11:41 howtouselinux_copy

rm command – remove file or directory

The rm command is used to remove directory or files. Like use rm -r /tmp/backup to remove everything that directory. Of course you’ve to be careful before removing anything.

TO-M-F13P:~ root# rm howtouselinux_new
TO-M-F13P:~ root# ls -lrt howtouselinux_*
-rw-r–r– 1 root staff 14 Nov 7 11:41 howtouselinux_copy

mkdir command – create new directory

mkdir, it’s used to make a new directory in linux.  Example, use mkdir my_new_dir to create a new directory named my_new_directory. The -p argument is useful, when you don’t want to make parent directories manually.

TO-M-F13P:~ root# mkdir -p howtouselinux_dir
TO-M-F13P:~ root# ls -lrt howtouselinux_*
-rw-r–r– 1 root staff 14 Nov 7 11:41 howtouselinux_copy
drwxr-xr-x 2 root staff 68 Nov 7 11:44 howtouselinux_dir

head command – print first few lines of a file

If you need to print first few lines of a file(any type) then you can use head command. This will print the first 20 lines of the syslogd log to the stdout. By default head command prints first 10 lines.

head -20 /var/log/syslog

tail command – print last few lines of a file

It’s similar to the head command, but the function is opposite, prints last 10 lines of any file by default. Here’s an example, how to print last 30 lines of the kernel log.

tail -30 /var/log/kern.log