Linux Commands for Linux Beginners (Cheat Sheet)

Updated: a day ago

Linux commands are important for Linux beginners. This cheat sheet covers 10 basic Linux commands. It can help Linux beginners learn Linux quickly. Join our email group below. We can send you a free Linux account. You can use this account to login our cloud server and practice these commands.


You can also create your free Linux server on our cloud. Check more for this.

  • ls command - lists contents of current working directory

  • cd command - change directory

  • touch command - create new 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

  • echo command - print string

  • cat command - print contents of a file

  • cp command - copy file or directory

  • mv command - move file or directory

Pwd Command

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

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/

touch command - create new file or directory

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. It is not suitable for a large 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_cop

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


459 views

Join our mail group. Get a free Linux account on Cloud.

Never miss a post!

Want a free Linux account?  This account can be used to login to our cloud server and practice Linux commands.

 
kamateravps.gif
topbackgroud.png

✔ Linux Commands   ✔ Linux Skills    ✔ LinuxPerformance   ✔ Linux Interview

Some articles are from the public internet. If you find your article misused or undesired here and you don't want us to display it, please let us know and we'll remove it immediately.