Top 20 Basic Linux Commands

Linux is a Operating System. Kernel is the brain of any operating System. It is the part of the operating system that loads first, and it remains in main memory. Accurately Linux is a kernel for GNU/Linux Operating system. As you are here to learn Linux commands, you probably know the importance of Linux. Importance of Linux Commands could be another topic, For now lets start Top 20 Basic Linux Commands. This article will provide you a head-start on getting started with Linux Command Line, Best for absolute beginners

Linux Commands Structure

There are variety of Linux commands structures. One of the basic Command is a Single Command. A single word command. Commands like ls, date, cal are single command. These commands always perform the same action. Don't worry we will come back on what they do.

options, or flags A command may have some options, These options are indicated using - or --. date -u Here -u is the option for the date command. Options alter the default behavior of the command. Options are also called as flags. Options can be grouped together ls -a -F is similar as ls -aF or ls -Fa

arguments Some commands have arguments. Most common args are the name of the files where these commands operates. cat hello.txt Here hello is a file and a argument for the cat command. A command can have more than two arguments as cp hello.txt hi.txt

operators Commands may have operators. Commonly these operators are used to perform input or output redirection. echo "Hello World" > hello.txt

Basic Commands

Linux Commands Image for Google Play

Now we know how a Linux command looks like. Now lets start using these commands.

ls

The ls command lists the directory contents. It will show all the files and directory in the current location. As we learned above we can use the option -a to list all the contents (including the hidden files, files starting with .). Here is the output for command ls

/home/devkota/Documents/Linux/BasicCommands

The option -l prints display more information including the user, group, space occupied, file permission and date created. Combination of -l and -a display all these information for hidden files too.

cd

The cd command is used to change directory. cd command helps us to move around the system. cd command without any argument takes us to the home directory. cd with args will takes us to that directory. The command cd dir1 will takes us inside the dir1 folder(directory).

/home/devkota/Documents/Linux/BasicCommands/dir1

We can move one step back using cd .. command. Similarly we can move 2 step back using cd ../.. command.

pwd

The pwd will print the working directly. Print working directory. As we had moved inside the dir1 when we run the pwd command it will show.

/home/devkota/Documents/Linux/BasicCommands/dir1

touch

touch is used to create a file in the Linux system. It creates a empty file in the current working directory. First lets move back to the BasicCommands folder from dir1 using cd .. command and create a file file3 (as file1 and file2 already exists) using touch file3 command.

/home/devkota/Documents/Linux/BasicCommands

Once we run the touch command we run ls command to check if the file is created or not and indeed it is created.

nano

nano is a text editor for Unix-like computing systems or operating environments using a command line interface. nano is a text editor in command line. It is used to edit files with in command line. To edit the file file3 That was just created we run the command nano file3 Now you can insert text with in the command line. Some of the options are displayed in the bottom of the screan. Some of them are ctl + x, to exit, and ctl + o to write (save). If you run nano with just nano command when you press ctl + o, you need to provide file name. To open existing file nano filename. If file exist it will be opened else new test file will be created with that name.

Now insert some test. Here is what I insert
    Hello
    Hello How are You?
    Happy New Year 2021.
cat

The cat command, Concatenates and displays files. This is the command you run to view the contents of a file. As we had inserted some contents inside that file3 using nano. We can view the contents in that file using cat file3 command.

/home/devkota/Documents/Linux/BasicCommands

cp

The cp command, Copy is used to copy a file into another. cp takes two argument one the original file and second the destination file name. No Output will be displayed if copy success. Here we will copy from file file3 to newFile, using the command cp file3 newFile

/home/devkota/Documents/Linux/BasicCommands

After copying the file from file3 to newFile. We use that cat newFile command to view the contents of that file.

mv

mv command, move is used to move a file. It takes two arguments. One source file and another destination file. the mv command is used to rename file with in one directory. mv newFile oldFile

/home/devkota/Documents/Linux/BasicCommands

The mv command do exactly the same as the cp command the difference is that it deletes the original file.

rm

The rm command is used to remove the file. We can delete a file using the rm command. Here we will first create a simple test file using touch testFile . Then we using ls command to view if file is created. Then we remove the file using rm testFile .

/home/devkota/Documents/Linux/BasicCommands

echo

echo command will print back what you type in the screen. echo "Happy New year 2021! Let's learn Basic Linux Commands in this Year"

/home/devkota/Documents/Linux/BasicCommands

Video

Here is a video explanning (using exactly) basic Linux commands

Basic Linux Commands - Video


mkdir

mkdir command is used to make directory in the Linux system. Till now we had worked in files lets now create some more directories and move around. We can create a directory using mkdir dir3

/home/devkota/Documents/Linux/BasicCommands/dir3

Then we move to the dir3 using cd dir3 and check present working directory using pwd

rmdir

The rmdir command, Remove Directory. Use rmdir to delete a directory. But rmdir can only be used to delete an empty directory. To delete a directory containing files, use rm.

/home/devkota/Documents/Linux/BasicCommands

Nothing is printed if deletion is success. Else error is printed. Here we create two directories. Then create a file inside one. Remove the directory with no contents using rmdir, but doesn't work for non empty directory. So we use rm -r

clear

clear is used to clear the screen. clear

tree

Tree is used to view the structure of the directory. Here lets first create a file test inside dir3. using command touch dir3/test

/home/devkota/Documents/Linux/BasicCommands

whoami

whoami will print the current username

/home/devkota/Documents/Linux/BasicCommands

history

History will display the list of commands you had used it would be really large list.

/home/devkota/Documents/Linux/BasicCommands

This list is a bit different than what we have here.

wc

wc commands print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified.

/home/devkota/Documents/Linux/BasicCommands

exit, logout, or Ctrl-d

The exit and logout command, Exits the shell or your current session. If you are at local machine exit will exit the terminal. if you are connecting remote server logout will end the session. If you want to terminate a process being executed you need to press ctl + c.

whatis

whatis command simply show one line explanation of the command provided.

/home/devkota/Documents/Linux/BasicCommands

man

This is one of the most important tool. Till now we show some of the commands and only one action of that command. A command can perform a lot based on the options provided. Learn yourself to fish. Using man command. man is a manual page. All the commands are explained on the man page. You can check what kind of other results be printed using different options in ls command. man ls. Now you will get a manual page. Press Enter to go on. and Press q to quite. info is another similar tool.

These are the Most basic commands of Linux and also the most used commands. You would use these commands in your everyday work in Linux System. Get started using these commands and one day these commands would be your daily need. To improve yourself in the Linux system you need to practice and practice. This is the only key.
These basic commands are selected from an Android Application called Linux Commands This application is dedicated for Linux commands Beginners Basic to Advance level. Here we try to improve some visualization presentation of basic section. There is Separate Intermediate and Advance Section to move on.

Conclusion

Here we learn some of the basic commands in Linux. We learn how to use those commands. You learn 20 commands here. Among them what I want you to take is the man command. Learn to fish yourself. From the list of this 20 basic Linux commands which one is really complex and useful on your view? Please comment below.