Loading...

Top Linux commands every beginner should know

Top Linux commands every beginner should know

Many people use Linux without even knowing the basic commands. This article will provide a list of top Linux commands every beginner should know.

This introduces some of the essential Linux commands for beginners. We’ve provided examples with explanations and in-depth descriptions that may prove useful as you explore more advanced topics in your quest to master this powerful operating system. So what are you waiting for let’s get started.

What are Linux commands?

Most Linux distributions feature graphical user interfaces (GUIs) like windows, making it easier to navigate between files. However, there is another way to do all that stuff using the command line interface(CLI) which offers more control and takes less time. Linux commands are executed on a Terminal similar to the command prompt (cmd) of windows. The terminal is a command line interface this can interact with the system via small texts.

This is the general syntax of Linux commands.

[Command] [-option] [parameter]
Code language: Bash (bash)
  1. The Command is the name of the operation which you want to perform. Ex: ls, cd
  2. The option is to know more about the command performed. You must include the hyphen before writing the option you want to perform. Ex: ls -a (Shows all hidden files)
  3. parameters are the necessary information required for the command to perform. Ex: cd code (changes to code directory here code is the parameter)
  4. Remember all Linux commands are case-sensitive. Most of the Linux commands are small letters by the way 

Top Linux Commands

pwd

The pwd command prints the route of the directory you’re present in. pwd – Present Working Directory. It is a basic command everyone should know and very easy to use.

root@ubuntu:~$ pwd /root
Code language: Bash (bash)

cd

Moving through directories is very much necessary while navigating your files. The cd command allows changing to some other inside directories. Suppose you want to change to Documents directory to a subdirectory of the root. To do that enter the following command.

root@ubuntu:~$ cd Documents root@ubuntu:~/Documents$
Code language: Bash (bash)

You can see your path has been changed to Documents. You can confirm it by using the pwd command.

root@ubuntu:~/Documents$ pwd root/Documents
Code language: Bash (bash)

Some tips to navigate

  • cd ~ directly comes to the user’s root directory
  • cd .. comes to the previous directory
  • Hit the Tab button after entering the cd. It will autocomplete the directory present in it.

ls

The ls command lists all the things present in your path directory. It will show Text files, directories, and everything that’s there in there in your path directory. For example, if you want to see what’s there in your Document folder first navigate to your Documents folder

Then enter the following code

root@ubuntu:~/Documents$ls
Code language: Bash (bash)

It is one of the most frequent commands used. It has a lot of options to 

  • ls -a lists all the hidden files plus visible ones
  • ls -lh shows the space occupied by that file & lost modified date
  • ls -R lists all the files present in your subfolders.

tree

The tree command is used to view the files in a directory in a tree-like fashion

root@ubuntu:~$tree
Code language: Bash (bash)

If you get an error saying that the tree command is not recognised. Just enter the command

sudo apt install tree
Code language: Bash (bash)

this will get rid-off the error. we will learn more about the sudo command in the upcoming section

sudo

Sudo means superuser do. It is the most powerful and most frequently used command in Linux administration. After entering the command the terminal asks for a password just enter your user’s password not the root user password account. sudo allows you to access restricted files and operations. sudo command has a lot of options. We will discuss some here

root@ubuntu:~$sudo --version root@ubuntu:~$sudo -l root@ubuntu:~$sudo shutdown root@ubuntu:~$sudo update
Code language: Bash (bash)
  • sudo --version command prints the version number 
  • sudo -l lists all the commands you can use.
  • sudo shutdown kills the system
  • sudo update command updates your Linux distribution to the latest version.

mkdir,rmdir

You can create directories using the mkdir command. And can remove them using the rmdir command. mkdir means make directory rmdir means remove directory. For example, if you want to create a directory called code 

root@ubuntu:~$mkdir code
Code language: Bash (bash)

mkdir commands have a few options they are 

  • mkdir code-v prints the message “created directory ‘code1’” in terminal
  • mkdir code/web You can create a subdirectory called code directly using the mkdir command

And to remove that directory you can use the command rmdir code 

root@ubuntu:~$rmdir code
Code language: Bash (bash)

touch

We can create files using the touch command. For example to create an hello.txt file, first, navigate through the folders to where you want to create the hello.txt then enter the command

root@ubuntu:~/web$touch hello.txt
Code language: Bash (bash)

Here I created an hello.txt file in the web directory. You can verify that using the ls command

rm

rm stands for remove as you already guessed this command is used to remove files permanently. For example, if we want to remove the hello.txt file we created in the last section. 

root@ubuntu:~$rm hello.txt
Code language: Bash (bash)

mv, cp

mv stands for move and cp stands for the `copy. You can use these commands to move and copy your files from one directory to another. Using the mv command you can rename the files. For example, if I want to change code.txt to codedamn.txt 

root@ubuntu:~$mv code.txt codedamn.txt
Code language: Bash (bash)

cp command is also used in the same way as the mv command. For example, if I want to copy the text in code.txt to codedamn.txt enter the following command

root@ubuntu:~$cp code.txt codedamn.txt
Code language: Bash (bash)

cat

The cat command allows viewing the content inside the files directly from the terminal. cat (concatenate), using the cat command you can view multiple files also 

root@ubuntu:~$cat index.html
Code language: Bash (bash)

history

The command history will show all the commands the user has executed in the past. You can even find information about the commands you executed.

root@ubuntu:~$history
Code language: Bash (bash)

clear

The command clear clears the terminal it erases everything that’s there on the terminal.

root@ubuntu:~$clear
Code language: Bash (bash)

exit

exit command exits the current terminal when you hit the enter button

root@ubuntu:~$exit
Code language: Bash (bash)

whoami

The whoami command display’s current logged in user name.

root@ubuntu:~$whoami root
Code language: Bash (bash)

If your using a single computer you won’t use this command frequently. But when your using multiple systems you are gonna use this a lot.

Conclusion

These are the Linux commands every beginner should learn. To learn even more about these commands just enter the command that you want to learn followed by –help. Example: ls --help you can about it in the terminal itself. You can check out the course on codedamn for a detailed explanation at codedamn.

Now don’t mug up all the commands just consistently keep on using them wherever needed You will automatically remember them. Now You can navigate through your files more quickly and easily. The commands are basic yet essential to anyone who is using Linux. That’s it from this article hope you learned something new. Thank You!

Sharing is caring

Did you like what Thrishank wrote? Thank them for their work by sharing it on social media.

0/10000

No comments so far

Curious about this topic? Continue your journey with these coding courses: