Top 10 Linux commands you must... no, this is not that kind of article
- Daily , Foundation , How to learn
- January 3, 2023
Knowing Linux and its commands is the foundation of every DevOps engineer. For devs guys that came to DevOps with a… dev background ;) it might be a bit challenging to remember all of them, as they were not using them on a daily basis - at least not as often as the Linux sysadmins. The all of them is a bit misleading, and the truth is that every person has their own set of tools in the Swiss Army Knife - sometimes it is a bit bigger, sometimes smaller - but it is always more about being able to place them in the context of your work rather than remember tons of manuals and help pages.
What is the Linux? What are the commands?
I am not going to explain anything about Linux and commands, as there are a lot of resources on the internet - let’s focus on general reasons and approaches that might help you to learn them.
Why do I need to know Linux commands?
You might think - we have a lot of known quick-search
resources like Sever Fault
/
Stack Overflow
, the powerful Oh My Zsh
with tons of plugins and finally
the LLM-powered “search” (ChatGPT, Bing, etc.) - so why do I need to know them?
For daily work - let’s call it development phase
(as we have in general SDLC
) - you actually don’t need to remember anything.
You will find the answer to your question in a few seconds - and this is the fact - once you use something a dozen times
you will remember it “anyway” and your productivity will increase.
Especially when your practices are based on Infrastructure as Code (IaC) and you are using tools like Terraform, Ansible. Most modern DevOps tools encapsulate the OS commands, so you don’t need to know them for the work on that level of abstraction.
This is a very good question, and the answer is quite simple.
What if I tell you that once you know your Swiss Army Knife well, you will be able to do it in a few milliseconds - without even thinking about it? This is the power of some muscle memory and the knowledge of the context.
But there is more - you might find yourself in a situation where you don't have access to the internet
(yay!), or you
need to react quickly, and you don’t have time to search for the answer. Depending on your job position, company, or team
this situation might never happen, but if it does it might be very stressful (interview?) or even bring some serious consequences (production failures) -
especially if you are not prepared.
How to learn commands?
Practice, practice, practice
… and a bit of theory.
The theory is very important to understand the context of the commands and their usage. Sometimes it is almost impossible to figure out what tool you need without knowing the context and what is going on under the hood.
But for remembering, the theory goes to the second place - you need to practice so that you can build your muscle memory.
Let’s take a look at the examples from the first Google results
for the top linux commands
query:
The Google widget shows the top (?) 7 commands (from What Is the Basic Command of Linux? in the first article):
pwd (Prints the working directory)
cat (Prints file contents)
cp (Copies files and directories)
mv (Moves and renames files and directories)
rm (Remove files and directories)
touch (Creates empty files)
mkdir (Creates directories)
from the top search result we can find the top 40, let’s take a look at the first 10:
ls - Lists the content of a directory
alias - Define or display aliases
unalias - Remove alias definitions
pwd - Prints the working directory
cd - Changes directory
cp - Copies files and directories
rm - Remove files and directories
mv - Moves (renames) files and directories
mkdir - Creates directories
man - Displays the manual pages of commands
As we can see, most of the commands (except man
) are related to the file system and manipulating files and directories.
To understand them we need to know what is the file system, what are the directories, how Linux organizes its files, etc.
So this might be a first hint - let’s group the commands by the context of their usage.
Let’s take a look at the next 10 commands from the top 40:
touch Creates empty files
chmod Changes file permissions
./ Runs an executable
exit Exits the current shell session
sudo Executes commands as superuser
shutdown Shutdowns your machine
htop Displays processes and resources information
unzip Extracts compressed ZIP files
apt, yum, pacman Package managers
echo Prints text to the terminal
Surprise, surprise - the next also includes the file system commands, but some more interesting commands appeared:
chmod
,sudo
- will touch theLinux users/system permissions
(another topic)htop
- will touch the Linux processes ->Linux architecture
->administration
->troubleshooting
apt, yum, pacman
- will touch thepackage managers
(hold on, where is my..brew
though?)echo
,./
- will touch theLinux shell
and any bash scripting (LOL)shutdown
- will touch theLinux administration
(…I would not put it in my top 40 BTW) etc.
This is all user stuff that the developers do daily, and this is definitely a good start point.
What about the real world? There are plenty of contexts where you might need to use the Linux commands:
- file manipulation (cut, pr, )
- searching (for files, within files, for processes, for logs, for errors, for strings, for patterns, for commands, etc.)
- networking (ifconfig, ping, telnet, ssh, scp, netstat, curl, wget, etc.)
- environment variables (export, env, etc.)
- processes (bg, fg, top, ps, kill, mount, etc.)
- and so on
- and so forth
So let’s put hints together - this is how I approach the learning of the Linux commands:
1. Get yourself familiar with overall architecture and the most important concepts <- quick overview should be enough!
2. Touch & practice basic commands and use them - as a part of your daily work.
3. Explore the [roadmaps](https://xmind.app/m/WwtB/) and the [cheat sheets](https://www.youtube.com/watch?v=gd7BXuUQ91w&ab_channel=NetworkChuck).
4. Try to play with the commands in the context of the real world and imagine real-world scenarios.
5. Learn the commands that you can use currently or in the near future (80%) try to explore the rest (20%).
6. Expand your general knowledge with video courses (like [this one](https://www.udemy.com/share/101E2K3@EeVmVAJmiVX--kV1_R2W7RQ4lpYfqk5aqxQm9RJEiyHcZJmSm2G4wqWocQ04xLyG/)).
7. Repeat! (with a different set of commands)
But dude, I do have the UI for that!
This is super cool, and to be honest… sometimes the good UI/app is much faster and safer on daily basis. But if you want to learn these - you need to write it with your own hands. Dozens of times.
Turn off all auto-completion helpers that you can find in your IDEs and shells.
And the most important thing:
Use the time you have DURING THE "DEVELOPMENT PHASE" to LEARN & PREPARE!
Bonus: How does it look on my laptop?
We definitely might use some Linux commands on servers (even in the server-less/no-code cloud era) and in the CI/CD pipelines, but the first place where we are using them is our local CLI… on “our laptops” OS (aka workstations).
It might be even more interesting when you are a junior developer - you might use only local CLI to work with the code, however, the good IDEs provide a lot of shortcuts and automation, so you might not use the CLI at all.
Let’s find some proof for that using the history
command (with some awk
filtering in the pipeline
):
# get the history of commands
$ history
# filter out the commands that are not starting with the "git" word
$ history | awk '{print $2}'| awk 'BEGIN {FS="|"} {print $1}'
# TL;DR extract & sort commands, group by name with counting, sort them by the number of occurrences, and show the top 15
$ history | awk '{print $2}'| awk 'BEGIN {FS="|"} {print $1}'| sort | uniq -c | sort -rn | head -15
Let’s have a look at the top 15 commands that I used on my… Macbook last months (where is my brew
?):
376 sbt (Scala Build Tool) <-- yeah... I am a Scala developer sometimes ;)
259 cd
246 ls
232 git <-- this is the topic for another article
230 vpn
186 pip <-- `python rulezzz`
171 curl <-- surprise, surprise
165 pyenv <-- `python rulezzz`
161 aws
131 exit <-- LOL
117 poetry <-- to be or not to be!
108 cat
105 vim <-- believe me or not, but I know how to exit it!
94 echo
90 python <-- `python rulezzz`