Basic Linux Commands for Beginners

Basic Linux Commands for Beginners

Linux has a galore of commands. Knowing all of them takes several years of experience and lots and lots of work. If you’re just starting out with Linux then you must begin with the basic Linux commands.

Here in this article, we have provided some of the most elementary CLI commands in Linux, which we often use when we interact with the Linux terminal.

Many of the hosting servers support the Linux dashboard to host a website, so a web developer needs to have knowledge of these basic commands in Linux.

Basic Linux Commands for File Management

Linux Commands for Beginners

Here are some basic commands we frequently use when dealing with files and directories in Linux:

Command Description
pwd It shows the directory on which you are currently in. It stands for print work directory.

This command is useful when you want to check the path of the file.

ls Shows all the content and files present in the directory.
ls -a This command is used to list all the files including the hidden ones.
cd cd stands for change directory. It’s used to move from one directory to another.
mkdir mkdir stands for make directory. This command helps to create a new directory.
rmdir Used to remove an existing directory.

Note: Only removes an empty directory.

lsblk This command is an extension of the ls command. It shows a tree-like structure of your block devices.
mount Used to mount the SD card and USB to the existing files.
df The df command shows the vital information about the disk space.


Basic System Commands

There are many commands in Linux that show information about the device and OS. These commands come in very handy while dealing with software in a Linux system.

Command Description
uname The uname command is used to get the system information, such as system name, version, and operating system.
ps The ps command visualizes the current process running on your system.
kill Used to stop or kill any running or stuck process. This command comes useful when any process is stuck due to limited resources.
service Used to manipulate the system.
batch It is used for automating the script.
shutdown This command is used to close the Linux terminal.


Linux Commands for File Manipulation

Command Description
cat The cat command can be used for multiple purposes, such as to create a new file, view the content of the file and redirect output to another command-line tool or file.
touch The touch command creates a valid empty file.
head Using the head command, we can view the beginning of the file from the terminal.
tail The tail command is just the opposite of the head command. It is used to show the tail of a file.
cp This command is used to copy a file from one folder to another.
mv Used to move a file from one folder to another.
comm Used to compare two files for common and distinct lines.
less The less command is used to view the content of the file. Unlike the cat command, less can view the content of the file in both the directions.
ln The ln command is used to create symbolic links to the specific files.
dd The dd command copies and converts a file from one type to another.
alias This command can only be used by the system admin and it can replace a word with another string in the file.


Basic Linux Commands for Search

In Linux, we have the concept of a regular expression that comes very useful while performing the search operation in the terminal.

Command Description
find With the find command, we can search a file from the terminal.
which It is used to search the executable files.
locate The locate command is used to find the location of a specific file.
grep This command is used along with a regular expression to find a specific pattern from a file.
sed The sed command replaces the specific text from a text file.


Basic Linux Commands for I/O

There are many basic commands in Linux that we use so often to increase the interactivity with the terminal.

Command Description
clear The clear command is used to clear out all the written commands and their output. It refreshes the terminal.
echo Used to show the text output.
sort The sort command can arrange the files in alphabetical order.
sudo With the sudo command, a non-admin or guest user can manipulate the low-permission files.
chmod The chmod command changes or modifies the access permissions of system files or objects.
chown The chown command is used to change the ownership of a file or directory.


Some More Commands

Command Description
tar The tar command extracts the archive files.
history This command shows all the commands that had been entered in that terminal since it was opened.
mail -s ‘subject’ -c ‘cc-address’ -b ‘bcc-address’ ‘to-address’ Used to send mail from the terminal.


If you are an avid Linux user or just getting started with it, the Linux command-line is one of the easiest tools you will come across. Linux command-line lets you perform many operations on files such as create, delete, modify, etc.; It allows you to set and modify permissions and manage users and groups, traverse across directories, find patterns in files, and do a ton of other useful tasks. Therefore, having practical knowledge of Linux terminal commands will be of great help to you in future.

In this comprehensive guide, we will walk you through the top 50 Linux terminal commands that are frequently used by Linux users of all levels of experience. You should only have access to a Linux machine, a terminal, and sudo privileges. Also, please note that working with sudo commands is always risky especially when you are working with important configuration files as you may mess up your system. Therefore, it is strongly advised to use these commands with extreme caution when you are logged in as the root user. So without any further interruptions, let’s go straight.


Basic Linux Commands

1.      Alias

You can use alias command in Linux to give alias to any command. This will allow you to abbreviate long commands and thus save you a lot of time. For example, let’s give aliases to clean commands that can easily be used to clean up the terminal.

$ alias cls=clear

2.      Cat

cat is shorthand for command combination that lets you display all the contents of a file inside the terminal instead of opening it.

$ cat ~/sample/file1.txt

3.      Cd

This command stands for Change Directory and allows you to move back or forward to another directory. You can also specify a new path with the cd command to go to a different location.

$ cd ~/Documents

To move a directory backwards, you can simply put two dots with the command.

4.      Ls

The LS command allows you to list all the sub-directories and files inside a directory. It will simply give you a list of the files and directories without displaying any other information related to them. Also, please note that by default, it doesn’t display hidden files.

$ ls


You can also use it with -l option to print other detailed information regarding a file such as a file type, permissions, date modified, user, and group info, etc. This option is particularly useful when you want to know and modify file permissions or change the user or group ownership of the file. This will give also tell you the file type as well as a 9-character-set which tells you the specific permissions that the user, group members, or other users have on files.

$ ls -l ~/sample/file1.txt

5.      Chmod

The CHMOD command in Linux is used to set or modify file permissions. There’s a specific syntax to understand this command. When you list the information of a file using the ls -l command, you will find that there’s a set of 9 characters which can be divided into 3 sets of 3 characters each. Each set of 3 characters denotes the read, write, and execute permissions of a file for the owner, group member, and rest of the users. We can modify or set this information using the CHMOD command.

For example, the file below has read and write permission for the owner and group members but only the read permission for other users. Let’s modify it to give full permission to all the users.

$ chmod ugo=rwx ~/sample/file1.txt

Linux Commands for Beginners

6.      Chown

This command is used to alter or set the ownership of a directory or any file in Linux. We can use it to set or alter the group or owner or both. When a file in Linux is created for the first time, the one who creates it becomes the owner, and the file is allocated to a group. By default, the group is the same as the username. Let’s try to change the ownership and group of a file.

$ chown test:test1 ~/sample/file1.txt

You need access to sudo privileges to change the permissions. You can see that both types of ownership have now been changed.


7.      Pwd

This command stands for print working directory and is used to print the current working directory in Linux. If you want to get the relative as well as the absolute path of any file inside a directory, you can use the pwd command once you are inside the directory.

$ pwd


8.      Mkdir

This command stands for make directory and is used to create a new directory in Linux. You can specify the path where you want to create the directory. However, it is better to simply create the directories using a GUI-based file manager if you don’t have to get sudo permissions or create files in those directories for which you don’t have the write permission. In such a case, you should always use this command.

$ mkdir {folder name or path}

Linux Commands for Beginners

9.      Cp

This command stands for copy and is used to copy files and directories from one location to another in Linux. You can use this command to copy the files, symbolic links, metadata, directories, or any other type of file. You just need to provide the appropriate options along with the command. Below is the syntax for the cp command in Linux.

$ cp <source-path> <destination-path>

Here, you can see that we have copied a file from the sample folder to the Documents folder.


10. Mv

The mv or the move command is to move a directory or a file from the source location to the target location. You can also use it to rename files or directories in Linux. You can move all types of files and directories if you have the appropriate write permissions in both these directories. Also, please note that if you are moving the file inside the same directory, it works as a rename operation. The syntax is quite simple.

$ mv <source-file-path> <dest-file-path>

In the above example, you can see that we have successfully moved the folder from the sample directory to the Documents directory.

11. Rm

This command is used to remove a directory or a file. To delete a folder, we need to use a -R option along with the command which stands for Recursive. It recursively searches for all the files and sub-directories inside a directory while deleting them one-by-one.

$ rm <file-path>

$ rm -R <directory-path>

You can see that we have removed both the file and the folder inside the sample directory.


12. touch

This command is used to create a new empty file in Linux. We just need to specify the path along with the file name. This command is very handy if you want to create and manipulate files using the command line and it’s generally used along with other commands to insert new content insid the file such as the echo command, etc.

$ touch <path-or-filename>

Linux Commands for Beginners

13. Ln

We can use the ln command to create a soft link or a hard link. A Soft link is just a reference that points to another file in Linux. By default, it creates a hard link, but we can use the -s option to create a soft link.

$ ln -s <source-file> <link>

Here, if we use the ls-l command on the new file, we will see that it’s pointing to the original file.


14. Echo

We can use the echo command to display anything on the terminal. If we want to display a message, we can simply write the message along with the echo statement. It can also print variables in the Linux system.

$ echo “Hello and Welcome to this Tuitorial\!”

15. Less

The cat command is used to print the entire content. What if the content is too large to be displayed on the screen? In such cases, we can use the less command to break the content displayed and allow scrolling through it.

We can even pipe this command with the cat command.

$ cat /boot/grub/grub.cfg  | less

The configuration file is large and you will be able to perform scrolling in the terminal itself to view the entire content.

Linux Commands for Beginners


There are many commands in Linux but here we have only covered the most frequently-used basic commands. As you will use Linux and dive deep into its commands, you will get acquainted with many new ones. Moreover, you will understand these commands better.

We hope that this article covers all the basic commands that will get you started with the Linux Command-Line.

Linux Commands for Beginners

Add a Comment

Your email address will not be published.