Knowledge
Essential Linux command line basics for developers
#CommandLine
A practical primer on Linux command line basics: navigating, working with files, pipes and redirection, permissions, and where to go next.
Published by Mark van Eijk on June 23, 2026 · 2 minute read
- Why the command line is worth it
- Knowing where you are and moving around
- Working with files and directories
- Pipes and redirection
- A quick word on permissions
- Where to go next
Why the command line is worth it
If you write code or touch a server, the terminal is unavoidable, and honestly that's a good thing. It's faster than clicking, it's scriptable, and it's the same on your laptop and on a remote box. This is the set of commands I'd hand a new developer to get comfortable. Everything here works on Ubuntu and macOS alike.
Knowing where you are and moving around
The terminal always has a "current directory". Three commands cover navigation:
pwd # print working directory: where am I right now?
ls # list files in the current directory
cd /var/www # change directory
ls becomes much more useful with flags:
ls -l # long format: permissions, owner, size, date
ls -la # also show hidden files (the ones starting with a dot)
ls -lh # human-readable sizes (KB, MB instead of bytes)
A few cd shortcuts save constant typing: cd ~ goes home, cd .. goes up one level, and cd - jumps back to the previous directory.
Working with files and directories
The everyday file commands:
mkdir project # make a directory
touch project/app.js # create an empty file (or update its timestamp)
cp app.js app.bak.js # copy a file
mv app.bak.js backup/ # move or rename a file
rm app.bak.js # remove a file
Be careful with rm. There is no recycle bin. To delete a directory and everything in it you need rm -r directory, and that's exactly the command people regret. Double-check the path before you hit Enter.
To read files without opening an editor:
cat app.js # dump the whole file to the screen
less app.js # scroll through a long file (q to quit)
head -n 20 app.js # first 20 lines
tail -n 20 app.js # last 20 lines
tail -f app.log # follow a log file live
Pipes and redirection
This is where the command line gets powerful. The pipe | sends one command's output into another command's input:
ls -l | less # page through a long listing
cat app.log | grep ERROR # show only lines containing ERROR
Redirection sends output to a file instead of the screen:
echo "hello" > notes.txt # write to a file (OVERWRITES it)
echo "more" >> notes.txt # append to a file (keeps existing content)
The difference between > and >> matters: a single > wipes the file first. Get them mixed up and you'll lose the contents of a file you meant to add to.
A quick word on permissions
Run ls -l and you'll see strings like -rwxr-xr-- at the start of each line. Those are permissions: read (r), write (w), and execute (x), shown for the owner, the group, and everyone else. When a script "won't run" or you get a "permission denied", this is usually why. The full story, including chmod and the numbers like 755, is in the change file permissions with chmod guide.
Where to go next
These basics get you around, but the real productivity comes from a handful of focused tools:
- Finding files by name or type: find files on the Linux command line.
- Searching inside files for text: search files with grep.
- Bundling and compressing directories: create and extract tar archives.
- Working on a remote machine: connect to a server with SSH.
Pick one command, use it for real on something you're actually doing, and it sticks. That beats memorizing a cheat sheet every time.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
Related articles
Argument list too long (Bash: /bin/rm)
A practical primer on Linux command line basics: navigating, working with files, pipes and redirection, permissions, and where to go next.
How to install Composer packages locally
A practical primer on Linux command line basics: navigating, working with files, pipes and redirection, permissions, and where to go next.