Linux Command Line – Essential Skills Every Developer Should Have
The command line intimidates newcomers. A blinking cursor on a black screen offers no hints about what to type next. But once you learn a handful of commands, the terminal transforms from an obstacle into your most efficient tool. This guide covers the commands you will actually use every day, with realistic examples drawn from real development work.
The Philosophy of the Command Line
Unix-based systems are built on a simple philosophy: each program should do one thing well, and programs should be combinable. A complex task is not handled by a single complex program but by chaining simple tools together.
This philosophy, articulated in the 1970s, remains powerful today. Commands like grep, sort, and wc each do one thing. Connected with pipes, they handle tasks that would require dozens of lines of code in a traditional program. Learning the command line is partly learning individual commands, but mostly it is learning how to combine them.
Navigation Basics
These six commands handle 90% of filesystem navigation:
1 | |
The - in cd - is one of those small tricks that, once learned, becomes muscle memory. You are working deep in a directory tree, you need to briefly check something in another directory, and one command brings you right back.
Tab completion is the most important productivity feature of the shell. Start typing a directory or file name and press Tab. The shell completes it. If there are multiple matches, press Tab twice to see them all. This alone saves thousands of keystrokes per day.
File Operations
1 | |
A critical safety note about rm: there is no undo. Files deleted with rm do not go to a trash bin. They are gone. This is a feature, not a bug — the command line assumes you know what you are doing. When you run rm -rf on a directory, double-check that you are in the right directory first. A pwd before a destructive command takes half a second and has saved countless people from deleting the wrong thing.
grep: The Swiss Army Knife of Text Search
grep searches for patterns in text. It is the command I use more than any other besides cd and ls. The basic usage is simple, but the power comes from its options and its ability to combine with other commands through pipes:
1 | |
A realistic scenario: you have a 50-megabyte application log file, and somewhere in it is a stack trace from an error this morning. You know the error involved a database connection. You do not know the exact error message or which line it occurred on.
1 | |
This finds every line containing “database,” shows 20 lines after each match, and pipes the results into less for scrolling. In ten seconds you find the stack trace. This would take minutes in a text editor and might not be possible at all if the file is too large to open.
Pipes and Redirection
The pipe character | takes the output of one command and feeds it as input to another. This is the superpower of the command line:
1 | |
This reads the log file, filters to lines containing “ERROR,” and counts them. Three commands, each doing one thing, combined to answer “how many errors are in the log?”
1 | |
This finds the ten Docker commands you use most often. It reads your shell history, filters to commands containing “docker,” sorts them alphabetically, groups duplicates and counts occurrences, sorts by count descending, and shows the top ten. Try doing that with a GUI.
Redirection sends output to a file instead of the terminal:
1 | |
The tee command is underappreciated. It splits the pipeline, writing to both a file and standard output. This lets you watch a command’s output in real time while also saving it. Useful for long-running builds, test suites, and deployments.
File Permissions
Every file and directory in Linux has three sets of permissions: for the owner, the group, and everyone else. Each set has three possible permissions: read, write, and execute. You will see them displayed like this:
1 | |
The first character indicates type (- for file, d for directory). The next nine characters are three sets of three: owner, group, and others. r is read, w is write, x is execute. A dash means the permission is absent. So rw-r--r-- means the owner can read and write, the group can read, and others can read.
Change permissions with chmod:
1 | |
The numeric mode takes practice to internalize, but the pattern is consistent: read=4, write=2, execute=1. Add them to get the permission set. 7 = 4+2+1 = read+write+execute. 6 = 4+2 = read+write. 5 = 4+1 = read+execute.
Process Management
When a program is running, it occupies your terminal. When it hangs or you need to stop it, you need process management:
- Ctrl+C sends an interrupt signal, politely asking the program to stop. Most programs respond to this.
- Ctrl+Z suspends the program and returns you to the shell. The program is paused, not terminated.
fgbrings the most recently suspended program back to the foreground.bgresumes a suspended program in the background, freeing your terminal.- Add
&after any command to run it in the background from the start.
1 | |
Use kill -9 as a last resort. It does not give the process a chance to clean up — open files, database connections, and temporary data may be left in an inconsistent state. Try kill without flags first.
The Real Value
The command line rewards spending ten minutes to learn something that saves ten seconds every time you use it. Multiplied across a career, the return on that ten minutes is enormous. Start with navigation and file operations. Add grep and pipes when you are comfortable. The rest comes with necessity — each time you find yourself doing something repetitive, ask if there is a command-line way to do it faster. There almost always is.