Linux is an operating system kernel released on 17th September 1991 by Linus Torvalds. They initially worked on it for his college thesis and later released it as an open source under the Free Software Foundation.
We can see these days that there are numerous distributions of Linux. It includes Debian, Fedora, Ubuntu, and many more. Red Hat Enterprise is one of the widely used commercial operating systems in which we are going to work on implementing several Linux commands.
Here we are going to learn the 10 most essential Linux commands for personal as well as commercial use.
10 Useful Linux Commands to learn
Software: Virtual Box, Linux OS (RedHat, Ubuntu)
1) Screen
It is perhaps the most versatile command Python developers can use to launch and use several shell sessions from a single ssh login. The working is as follows it follows two processes detach and reattach. Detach is you have started some task in that particular session, then you need not have its processing on your screen, and Detach it, and it will keep running in the background. Once you want to check the progress, just reattach the session, and you will find the progressed task. It helps in managing several tasks simultaneously. For instance, we can put a file to unzip using the screen command and start working on other tasks instead of waiting to finish to continue with other work.
1) Yum install screen (REDHAT)
Sudo apt install screen (UBUNTU)
2) screen -S file → Give name to the screen within the window
3) Screen -ls → we can monitor the screens of both the categories here as you can see in the screenshot.
4) screen -d 1111 → Detaches screen with 1111 id
5) screen -r 1111 → Reattaches screen with 1111 id
2) Top
The top command gives real-time information about the CPU processes and the memory being used. It is a continuous task, and press q to exit the command.
Screenshot:
3) Kill
We use the kill command to abruptly kill a process that might lead to data corruption or loss. The syntax to kill command is:
-9 → The process is killed instantly and does not take into reference whether any subprocess associated with it is currently running in the background.
-15 → The process terminates after all the subprocesses associated with it have been completed.
kill all -> We use it to terminate all processes of that particular task for the user. For Eg:- a chrome instance is running, so kill all will kill all its instances.
4) Grep
It is a search utility, and we use it to search or find a particular pattern or a file. It is difficult to check the pattern by scrolling through multiple lines manually. This command creates it a lot smoother.
It also works well with piping, i.e. the output of one command can be used as an input for other commands.
5) Chmod
It sets permissions for a particular file of a folder to be accessed by a particular user or root. A flag is associated, which defines its accessibility for reading and writing operations.
- 0: No permission
- 1: To execute
- 2: To write
- 3: To write and execute
- 4: To read
- 5: To read and execute
- 6: To read and write
- 7: To read, write and execute.
Example: To set permission for a file to be readable, writable, and executable for the owner 6 will be used, and to make it writable for a group, we will use 6. And executable for others 7 will be used. So our syntax will be:
Command: chmod 765 a2.txt
6) Lsblk
The widely used command Lsblk gives us a tree structure of the block devices of our system. It shows partitions within the storage system along with size, type, and mount point. It is installed as part of the util-Linux package.
7) Df
The df command is one of the most dominant Linux terminal commands that example element knowledge about the disk space on your filesystem.
We use this command to do the Real-Time monitoring of Disk Management, and this command shows detailed info about the mount point, size-available, size-used, and no of blocks.
8) Touch
Touch is a very simple command to create a blank validated file that can be written in the future according to the user’s requirement. It’s also the go-to command for changing the timestamps of that particular file.
9) Demicode
Demidecode is an effective command which arranges material about the system hardware. It will list a lot of detail about CPU, Memory, Mainboard, Devices, Network, etc., by default without providing any option.
10) Comm
Firms and developers use this command mainly to manage huge amounts of data to check and reduce redundancy. Basically, it compares two sorted files and shows the output in 3 different columns were in the first column: – contents present distinctly in the first file, the second column: – contents present distinctly in the second file, third column: – content present in both the files.
Learning Python allows us to access Linux commands and use OOP (Object Oriented Programming) concepts, which Python Development Company India describes here.
However, If the two files are not sorted, use the sort command to sort the files using the below-given syntax.
Explanation:Column 1, 2 will be eliminated and only the third column will be outputted which has the contents prevailing in both the files.
TO SORT
Comm Command:
Comm Command with options: