Site icon LinuxAndUbuntu

Master The Linux Command Line

Master The Linux Command Line

Master The Linux Command Line

If you use Linux long enough, you will most likely have performed actions via the terminal in some capacity, even if it was something as simple as installing a package. You might even know how to create directories or folders, move, copy or rename files and folders, run software, run the odd script now and then, or even attempted to compile software from source code. However, do you consider yourself a master at the command line?

Although the actions mentioned are a good start, the command line is more than just using the system on a daily basis. To master the command line is to become familiar with the tools you have under your belt. These tools include ‘grep’, ‘sudo’, ‘less’, ‘lsblk’; I’m just getting started. ​

What’s Wrong With a GUI Interface?

Nothing really, unless you are the sort of person who likes to tinker with his or her own system. Personally, I much prefer using the terminal to perform tasks that would be tedious in comparison using a graphical user interface (GUI). Whilst a GUI is easy on the beginner, true power lies within the command line.

The other thing to remember is what happens if something breaks and you need to use the command line to diagnose and fix issues? A GUI program isn’t going to be helpful if Xorg is broken. It is highly beneficial and recommended that you can at least use the terminal to run some commands and feel comfortable doing so.  

Where To Begin

How you approach this is up to you. You could look up “Mastering Linux Command Line” and explore several resources to find a set of tutorials that suit you. Another option is to look up “Linux command line exercises” and start on some exercises to get you started working on the command line.

In addition to the numerous resources pertaining to the Linux terminal, you should already have reference manuals for most commands and programs in the form of ‘man’ pages. These can be accessed using the ‘man’ command with the name of the program or command that you seek some guidance on. A wealth of information is found in them and each document follows a consistent structure.  

Most Commonly Used Commands

Let’s start with reading the man pages of the commands used to handle files and directories. As mentioned each man page follows a certain outline for the sake of consistency.  

‘mkdir’

View the man page for ‘mkdir’: $ man mkdir

This will bring up a rendered document that will give a brief description of the command, show how to use it, and provide a full list of parameters that it accepts to enhance output, perform extra tasks, or completely alter its behavior (like only running the program to display its version number). To exit back to the terminal at any time, press ‘q’ to quit.

‘ls’

$ man ls

You will be able to peruse through the list of arguments, mainly for dictating what output appears when listing directory contents.  

‘bash’

$ man bash

This document has more content because bash is more than just a program, it’s the shell interpreter used most commonly, and it is a programming language in of itself.  

Something More Advanced To Try

Let’s try something that you may not have done before: look through files in the /proc directory. The /proc directory is where system, kernel, and hardware information is located. The commands that will be used are ‘cat’ and ‘less’. The difference between the two is ‘cat’ is used to read smaller text files and print its contents onto the terminal, and ‘less’ is a viewer used to read larger text files. Man pages are read using ‘less’.

$ cat /proc/cmdline 

What this did was read the file and printed what parameters were parsed to boot the operating system.

$ less /proc/cpuinfo 

A file containing detailed information about the computer’s CPU was opened.

Also, the files in the /proc folder are generated by the kernel and do not reside on the drive once the system shuts down. The folders with numbers contain files about their processes, that is each running process is given a folder with its ID as the name.  

Alright, What Next?

The only way you will ever master the command line is by taking the time to use it, become familiar with the commands you use. Research if you need to, and practice what you learn. If you like, you can even have a virtual machine to play around with so that if something goes wrong, your main system will remain usable. The other skill worth learning is writing scripts using bash. There are tutorials out there that teach not only the language but also the basics of programming as well.

Exit mobile version