The Linux kernel is the foundation of a whole series of open-source Unix operating systems. This comprises all of the most prominent Linux-based operating systems, such as Ubuntu, Fedora, Mint, and Debian. These are often known as distributions, or distros, as a more appropriate term.
Having said that, a command-line interface (CLI) is preferred since it is more potent. Tasks that require many steps in a GUI may be completed in a couple of seconds by entering commands into the CLI.
If you’re thinking about adopting Linux, mastering basic command lines can help you a lot. This article is an introduction to some popular Linux commands.
1. Cat: To Display the Content of the File
The cat command is the Linux equivalent of the type command in Windows. In the terminal window, it shows the contents of a file. You may also combine numerous files into a single file by concatenating them. This function gets its name from the “cat” in the middle of “concatenate.”
We have a quote in a file named “verse-1.txt.” By supplying the filename as a command-line input, we may inspect its data with the cat command.
To view the contents of some other file, simply enter the file’s title: cat-verse-2.txt
2. Mimeopen: To Link Actions to File Type
The mimeopen command works similarly to the Windows assoc function. It connects a file type with default software.
File extensions are used by Windows to distinguish file kinds. Linux operates in a unique manner. It identifies the file type by inspecting the information of text files or the cryptographic signature present from the first few bytes of digital copies.
To create a file association, use mimeopen with the -d (ask for default) option and the name of a file of the type you want to associate.
3. Cd Command: To Navigate Through Files and Directories
The cd command is used to traverse across Linux files and directories. Based on the prevailing working directory, it needs either the complete path or the directory name.
Assume you are at /home/username/Documents and wish to navigate to Photos, a subfolder of Documents. Just enter the following command to accomplish this: cd photos.
Another instance is if you wish to change to an entirely another directory, such as /home/username/Movies. In this scenario, type cd followed by the exact path to the folder: cd /home/username/Movies.
4. Is Command: To View the Content of a File
To inspect the contents of a folder, use the ls command. This function, by default, displays the contents of your working directory.
If you wish to see the contents of other directories, type ls followed by the path to the directory. For example, to inspect the contents of Documents, use ls /home/username/Documents.
You may use the ls command in a variety of ways:
- ls -R will also show all of the files in the subdomains.
- The hidden files will be shown using ls -a.
- ls -al will provide a list of files and directories together with specific data such as permissions, size, owner, and so on.
5. Cp Command: To Copy Files
To copy documents from the current working directory to another, use the cp command. The operation cp scenery.jpg /home/username/Pictures, for example, would transfer scenery.jpg (from your root folder) into the Photos database.
6. Locate Command: To Locate Files
This command, much like the search command in Windows, may be used to find a file. Furthermore, providing the -i parameter with this command makes it case-insensitive, allowing you to search for a document even though you don’t know its exact name.
Use an asterisk (*) to find a file that includes words or phrases. For instance, the locate -i school*note command will look for any file that contains the terms “school” and “note,” regardless of case.
7. Chmod Command: To Set File Attributes
The chmod command, like the Windows attrib command, modifies file characteristics. On Linux, you may specify permissions for reading files, creating to files, and executing files, each with its own set of characteristics for the file owner, the user group to which the file belongs, and everyone else. These properties are also applicable to directories.
When the first element is a hyphen “-,” the listing is for a file. When the initial character is a “d,” the entry is a directory.
The remainder of the string consists of three sets of 3 characters. The first three characters on the left represent the owner’s access controls, the next three reveal the group’s file rights, and the last three characters display the authorizations for others.
8. Tar Command: To Archive Multiple Files
The tar command is the most often used tool for archiving several files into a tarball, which is a typical Linux file format comparable to zip format, with compression optional.
This command is fairly complicated, with a lengthy list of tasks including adding new files to a current archive, displaying the information of an old file, pulling material from an archive, among others.
9. Top Command: To List the Current Running Apps
The top command, which is a terminal similar to Task Manager in Windows, will provide a list of ongoing processes as well as how much CPU each process is using. Monitoring system resource utilization is highly useful, especially considering which processes should be stopped since they consume too many resources.
10. Du Command: To Check The Storage
If you want to see how much space a file or directory consumes, use the du (Disk Usage) command. The disk utilization report, on the other hand, will display disk block numbers rather than the standard size format. Add the -h parameter to the command line to show it in bytes, kbps, and megabytes.
Newcomers to Linux are frequently surprised by how much time seasoned Linux users spend at the command line. You have far more commands and choices at your disposal than your traditional desktop and apps, and the command line is significantly faster. To increase productivity, you may also script repeated activities, create aliases, and develop shell functions.