If you are new to Linux, using a Linux Commands in terminal can be a bit overwhelming. New Linux distributions such as Linux Mint have great graphical interfaces, but the heart of Linux is the kernel and that means using the command line.
Even if you are a Windows users you probably had to open a command prompt window at some point in your life to do the task. With the latest version of Windows, Windows 10, you can also install Ubuntu Bash shell in Windows and run Linux commands directly from Windows!
In this article, I’m going to some really basic Linux commands that are quite common in all Linux distributions. Since the bash shell is the most popular shell and which I also use, I will be using that syntax for all commands. Also, I’ll mention some of the most useful arguments for each command, but many more can be found in man pages.
1. Ls (list material)
In my opinion, the first linux commands you should know is the ls command. This command lists the contents of the current working directory. If you just type ls and press enter, you will find a very basic list of files and folders in the current directory.
Most Linux distros, the directory will be highlighted in a different color of green. The files will usually be the standard color of the shell prompt, which in my case is gray. Without any argument, LS is kind of boring. If you use -a with ls, you will be able to see all the hidden files.
Anything that starts with a dot is a hidden file or directory. Hidden directories all have a dark blue color, which is difficult to see. Another useful argument is the -l option shown below.
This gives you a long list of files and folders with much more information such as permissions, links, users, groups, sizes, and last modification dates. If you’re not sure how to interpret permissions, be sure to read my post on Understanding Linux Permissions.
2. CD (Change Directory)
Once you can list the contents of a directory, it is useful to know how to switch to a different directory. By default, when you open the bash shell you will always start in your home directory. This is indicated by the tilde symbol (~) in the shell prompt.
The cd command is how you change a directory in Linux. There really isn’t much to learn with CDs, but there are some shortcuts. A good bus is typing the CD and pressing enter. This will always take you back to the home directory no matter where you are.
Also, if you want, you can use a full path Go to a directory that is not accessible via a relative path. In the example below, I have to use a full path to start from the root (/) so that /ets
3. Man (help page)
The man command is probably one of the most useful commands in Linux. Even advanced Linux users cannot remember every argument in a Linux commands. The man page will give you detailed information on various arguments for the command.
The syntax is also really simple. This is after the man you want to learn. In the screenshot above, I did man ls to learn more about the ls command. A useful argument for humans is -k, which will allow you to search all commands using a keyword.
Above, I searched the keyword zipkey and retrieved all the commands with the zipword in the command name or description. This is an easy way to find commands you might not otherwise know.
With Humans, you can use another command called informator to get more examples of how to use the command. To bring up the information page for that order, just type the information order.
Read More How To Scan For Malware In Windows 10
4. Touch (create file)
If you want to quickly create a new file, the easiest way is to use touch mask. In reality, the touch command is used to change the timestamp on a file, but another use is to create a new file.
There are many ways to create files in Linux and later you will probably never use touch to create a file, but initially, it comes in very handy.
If a file already exists when using the touch command, it updates the last access and last modified timestamp for the file shown above.
5. Cat (print files and print)
Another useful command is the cat command. The main function of CAT is to add multiple files, but it can also be used to print the contents of a file in standard output (which is the screen).
You can use the -n argument to add line numbers to the output. If you use the -b option, it will only add line numbers to lines that are not blank. If you use a cat on a file greater than the height of your terminal window, the file itself will be shown below. To view the contents of the file page by page, you can at least pipe the output of the cat on command.
Read More: Top 10 Best Backup Software for PC
6. mkdir (create directory)
At some point, you want to create a directory to organize your data and that’s where the mkdir command comes from. You can use relative or absolute paths to create a directory using this command.
In the above example, I created two directories in my home directory using a relative path and a full path. If you need to create multiple hierarchical directories at once, you need to use the -p argument.
In these above examples, I used the -p argument to create the acim, data, and pictures directories simultaneously, even though none of them existed.
7. RM (Remove)
The rm command is a powerful command that can be used to delete files and directories. The rm command can remove directories that contain files and directories.
To extract a file, you simply type in the file name. If you need to remove a directory that is not empty, then you need to use the -r argument. It is also a good idea to use the -i and -v arguments when using RM because it will ask you before deleting anything.
So those are seven really simple, yet common commands that you need to know in Linux to get started. There are many more and I will be posting more early articles on more commanders to use more soon. If you have any questions, post a comment. let’s enjoy!