ABC with Linux Shell Commands- Part 1

An Introduction to Essential Shell Commands

Jaishnoor Bajwa
7 min readJul 25, 2024

The “Shell” intimidates many. After all, there are tens of tons of Linux commands, especially if you consider their variations and combinations uniquely. That can seem overwhelming indeed.

So, where should one begin?

With ABC, of course!

In this article, I introduce some very fundamental Linux commands, using the English alphabet as the map. After meticulous filtering, I present: One letter, one command!

Meme of Leonardo DiCaprio holding a glass with the text “Now that’s what I call a guiding light”

For those already ready to tackle more, check out this list.

You can read the expanded list in the article to simultaneously get an initial understanding of these commands, or use the summarized list below as a starting point into commands.

            A is for apt                     L is for ls
B is for bg M is for man
C is for cat N is for nestat
D is for df O is for open
E is for echo P is for pwd
F is for file Q is for queso
G is for grep R is for rm
H is for history S is for sudo
I is for ip T is for top
J is for jobs U is for users
K is for kill V is for vi

W is for whoami

XYZ!!

Let’s get into some detail!

AI generated image of the English alphabet being displayed on the computer screen of a hacker
Generated with Copilot

Ais for apt (& co.): We begin with a command that is essential for anyone who wants to download, update, or delete software on their machine (uhh..all of us?).

Per the manual pages, “apt provides a high level CLI for the APT package management system”, as opposed to something like dpkg which is a low-level tool, and cannot handle dependencies automatically like apt can.

There are also more specialized tools like apt-get and apt-cache. The exact command may differ across distros, but each one will have something or the other to provide this functionality.

Some examples to test out:

sudo apt-get update
reboot
sudo apt install google-chrome-stable
dpkg -S google-chrome

Honorable mention:

apropos, which can search manual page names and descriptions, and can be quite useful for the forgetful among us.

Bis for bg: It is used to send jobs to the background. The job to be background-ed can be specified by the job ID (NOT process ID).

Honorable mention:
Bash, the GNU Bourne-Again (punny much?) SHell, is an “sh-compatible command line interpreter that executes commands read from the standard input or a file” (Man page).

Yes, bash is indeed a valid command. This can be confusing for some, so let’s try to understand it better with an analogy:

Imagine you have a .py file, say “hello.py”. How would you run it through the terminal?
You would write:

python hello.py

and your script would run!

Similarly, you *could* execute a .sh file, say example.sh as:

bash example.sh

This a simplistic understanding of bash, and is wont to give rise to many questions in the minds of the curious. I leave it to you to go down that rabbit hole.

Meme of Alice peeking into the rabbit hole with the text “Gonna look something up real quick on the internet…not sure when I’ll see you again.”

Cis for cat: This command is commonly used to display/ read the contents of files. Technically, it is used to “concatenate files and print on the standard output” (Man page).

Thus, the way the common usage of reading files works is by simply concatenating the file to be read to nothing, so that the contents of that single file are displayed on standard output. Example:

cat foo.txt

Honorable mention(s):

cd: Used to change the working directory. You could live without cat, but you couldn’t without cd.

Imge of angry cat with the text “What did you say?”

clear: Clears the terminal screen- is extremely useful if you need to start afresh or to hide your work from shoulder surfers.

Also check out crontab.

The letter ‘C’ had so many useful commands that it was really hard to pick one — three in the case of honorable mentions — and yet there are many good ones left to explore.

D is for df: This utility can be used to find available and used disk space. It displays <file system name>, <total space>, <space used>, <space free>, <percentage used>, and <file system root>, in that order.

Eis for echo: It displays a line of text by echoing the provided string onto standard output. For example,

echo "apple"

will print the string “apple” on the screen.

Echo can also be used to create a file. For example,

echo "line1" > temp.txt
echo "line2" >> temp.txt

The string “line1” is written onto a file named “tmp.txt”. If the file does not exist, it is created. If it exists, its contents get overwritten as the ‘>’ redirection operator was used. To append, the ‘>>’ operator can be used, as seen in the second command above.

Honorable mention:

exit: Causes the current shell (or subshell) to exit.

F is for file: This command can be used to determine the file type of a given file. This is especially useful when dealing with unknown files.

Honorable mention:

fg: The opposite of bg.

Big brain moment

G is for grep: This command is used to search for patterns in a file and print lines that match the pattern.

Another use for this command is to filter the outputs of other commands. For example,

ls | grep "D"

would list only those files that contain “D” (case sensitive).

Here we used grep to filter the results of the command ls, discussed later in this alphabet list. To briefly explain how this filter works, know that ‘ls’ is used to list the contents of a directory and the pipe symbol ‘|’ is used to redirect the output of one command into the input of the other.

Honorable mention:

getfacl: This command can be used to get the file access control list of a file.

Yes, I am indeed exploiting the honorable mentions section to bring to your attention the concept of file ACLs in Linux. That is definitely something you should familiarize yourself with.

A companion command to getfacl is setfacl.

H is for history: This can be used to view the command line history.

GIF of Boss Baby whispering “It’s a secret” into a telephone

Now you know, it’s not.

Honorable mention:

head: Used to view the first part of a file, by default the first 10 lines.

I is for ip: As the man page for ip states, “show / manipulate routing, network devices, interfaces and tunnels”.

A super basic example:

ip addr

J is for jobs: Jobs displays the status of the jobs that were started in the current session/ shell environment.

Example:

First, we create a new job to test out jobs. I did this by using the top command to display ongoing processes, and pressing Ctrl+Z to suspend the process.

top
Ctrl^Z

It will show something like (if this is the first suspended job):

[1]+  Stopped         top

Now, on using the jobs command by typing:

jobs

it will display the stopped job (or jobs if you have more than one).

K is for kill: The kill command is used to send a specified signal to a specified process. The default signal is TERM whose default behavior is to terminate the process (Man pages).

At this stage we’re almost halfway through the alphabet. Let’s take a pause!

GIF of small girl wiping sweat off her forehead, with text saying “Whew!”

Now is an opportune moment to recap the commands introduced in this article, and to take some time to try them out. The remaining alphabet and corresponding commands can be found in Part-2 (coming soon).

Edit: Part-2 can be found here.

Here is a summary list of commands covered in this part:

A is for apt
B is for bg
C is for cat
D is for df
E is for echo
F is for file
G is for grep
H is for history
I is for ip
J is for jobs
K is for kill

Stay tuned for Part 2!

“To Be Continued” animation with a snail going across the screen

Edit: Part-2 can be found at this link.

--

--