Linux CLI Training Wheels
Welcome to my first article ever, on anything! This article is going to cover the basic raw commands to get you moving around the FHS ( File Hierarchical System) that all Linux OS function under. From one beginner to another, learning the Linux file system can be ridiculously overwhelming and push a beginner into the realm of never touching a Linux system again. I am here to tell you, if I can navigate the basics, so can you. I will assume you know what a command prompt is (The scary black screen on Linux OS, and Windows, with no graphics). Also known as the command line, cmd, CLI (command line interface), prompt, console or terminal, it all depends on who you’re talking to. I am going to do my best to keep this as simple as I can , so let’s get our fingertips dirty and learn some commands.
The first command we will discuss is the pwd command. This is short for print working directory. This command tells the user in the command prompt where they are working from within the Linux FHS. The leftmost / (forward slash) is always the root directory and the top dog of the Linux FHS.
Our second command we will be going over is the ls command, which is short for list. This command will output a list to the screen of the directories and file(s) within the directory that you are working in. Linux users will be using the ls command quite a bit! A user will need to know what is in the directory which could be files or even more directories, this is where ls command comes to the rescue. In the screenshot below, we have printed the current working directory ( /home/user ) and requested a list of items within the /home directory. (Usually, unless tampered with by the user all directories are blue and files and other output is going to be green within the Linux OS).
Now we are starting to move around a little bit, but how can a user see what is inside of a file within a directory? In linux to view what is in a file the user needs to be in that directory. This can be accomplished with the cd command which is short for change directory. In the screenshot below we went from the user Directory to the Downloads directory. (PRO TIP) Tab complete is your best friend when navigating the FHS. After typing a couple characters of the desired directory hit tab and it should auto fill the rest of the directory you want to move to.
Now to move back to the home directory cd has a couple of options. In the screenshot below the user has moved into different directories and moved back to the home directory with these various options.
Once a user is in a desired directory and can see there are file(s) within the desired directory, the user would most likely want to read the contents of the file. The command that will make that happen is the cat command, which is short for concatenate. This command will display the contents of the specified file to the user in the terminal. The command also has multiple functions like the cd command. This article shows a basic overview of the cat command without its added functionalities. Another great feature in Linux are the man pages, as well as the –help command ( A user will double tack full word commands, single tack for single letters ). These two features are absolute life savers when you are struggling in Linux and do not have access to the web. First, with the man command we can man man and look at the manual of the man pages in Linux, hang in there!
Below is the man man command output.
There is quite a bit of output here but it is valuable information in learning how to use the man pages of Linux. Now with the –help command you can concatenate this command with any other commands such as cat and ls to get help on how to use those commands.
I challenge you to explore these options, do a little googling, and research as my professor would say, they are pretty easy to understand and quite useful.
In the screenshot below we see that the user has moved into the Downloads directory, listed the contents of that directory and we see there is a file named “File_1.txt”, and with the cat command the contents of the file is displayed to the user.
Now let’s say the file we just looked at is not the greatest file in the world and we want to get rid of it. We can do that with the rm command which is short for, you guessed it, remove. The rm command will remove the entire file that you request to be removed. In the screenshot below we have cd into the Downloads directory, opened the text file File_1.txt, read the file with the cat command and decided that the file is not the greatest, and decided to deleted/remove it.
Well, I hope this article helps get your feet wet with some very basic Linux commands and get you moving around the FHS of Linux. These commands are the tip of the tip of the iceberg when it comes to the commands that are available in Linux. I highly suggest going out on the web and downloading a few Linux command cheat sheets just to have them as a quick reference guide and to study. I would like to share a couple of really great sites that will take this article to the next level. The first one I suggest checking out is Linux Survival. This one really helped me wrap my brain around the Linux FHS. The second site I would suggest is Linux Journey. This one is a very user-friendly site and is one of a couple that I am currently in the process of completing. Thanks for hanging with me. I’ll see you in the next article where we will peek into the different layers of the previous commands that were discussed.
Chandar Pass
June 11 2021
Hackhouse.net Author