Linux might sound scary for first-time Linux users, but actually, it isn’t. Linux is a bunch of open-source Unix operating systems based on Linux Kernel. These operating systems are called Linux distributions, such as Fedora, Debian, Ubuntu, and Mint.
Since its inception in 1991, Linux has garnered popularity for being open-source. People can modify and redistribute Linux under their own brand. When using a Linux OS, you need a shell to access the services provided. Also, it’s recommended to run your Linux OS through a CLI or command-line interface. CLI makes time-consuming processes quicker.
This article presents a guide to 7 important Linux commands for every Linux user to know. So, let’s begin.
cat is the shortened form of “concatenate”. It’s a frequently used multi-purpose Linux command. This command is used to create, display, and copy a file content on the standard output.
cat [OPTION]... [FILE]..
To create a file, type:
cat > <file name> // Enter file content
To save the file created, press Ctrl+D. And to display the file content, execute:
cat <file name>
The cd command is used to navigate through the directories and files in Linux. It needs either the entire path or the directory name depending on the current directory.
cd [Options] [Directory]
Suppose you’re in /home/username/Documents. You want to navigate to a subdirectory of Documents which is Photos. To do that, execute:
To move to an entirely different directory, type cd and then the directory’s absolute path.
The above command will switch to /home/username/Movies. Apart from this, the commands, cd.., cd, and cd- are used to move one directory up, to go to the home folder, and to go to the previous directory respectively.
Reminder: Linux’s shell is case-sensitive. So, make sure you type the name’s directory as it is.
The echo command displays a line of text or string passed as an argument. It’s used for the purpose of debugging shell programs in the Linux terminal.
echo [Option] [String]
Other examples of the echo command are:
echo "String": This displays the string within the quotes.
echo -e "Learn \nBy \nDoing": Here the ‘-e’ tag allows the echo command to understand the backslash escape sequences in the argument.
sudo stands for “SuperUser Do”. The sudo command helps you perform tasks that require root or administrative privileges.
Reminder: It’s not advisable to use this command daily because an error might occur if you did something wrong.
The sudo command can be used with -h, -V, -v, -l, or -k options used to help, version, validate, list, or kill respectively.
Another example is, suppose you want to edit viz.alsa-base.conf file that needs root privileges. For this the command would be:
– sudo nano alsa-base.conf
To enter the root command-line, type:
Then enter your user password.
After using Linux for some time, you’ll notice that it’s pretty easy to run hundreds of commands every day. The history command shows all the previously used commands within the bash terminal. With history, you can review the commands you have entered earlier.
Now try running history and check all the Linux commands you have entered so far.
The ping command helps check if your connection to a server is well established. Ping is a computer administration software utility that checks the host reachability on an IP (Internet Protocol).
ping [option] [hostname] or [IP address]
Suppose, you want to test if you can connect to the Google server and come back. For this, simply type:
If the above command pings the Google server, you can be sure that the internet connection is fine.
Reminder: Use Ctrl+C to stop pinging. Otherwise, it will continue sending packets.
The locate command helps to search a file by its name. Its functions are very similar to the find command. The only difference is that, the locate command searches the file within the database; whereas, the find searches it in the file system. Also, locate works faster than find. Keep your database updated to apply the locate command on it.
locate <file name>
In this article, you have learned about 7 important Linux commands. Hope my article helps you execute your tasks quickly and efficiently.