Skip to content
C Codeloom
Linux

20 Essential Linux Commands Every Developer Should Know

Twenty commands that cover the overwhelming majority of day-to-day Linux work — navigation, file management, inspection, search, and processes — with runnable examples for each.

·10 min read · By Yash Kesharwani
Beginner 14 min read

What you'll learn

  • The commands that handle 90% of day-to-day shell work
  • How to navigate, create, copy, move, and delete files safely
  • How to view, search, and edit text from the command line
  • How to inspect processes and disk usage
  • How commands combine with pipes and redirection

Prerequisites

There are thousands of commands available on a typical Linux system. You will use roughly twenty of them constantly. This post covers exactly those twenty, with runnable examples and the options you will actually reach for. The examples assume Ubuntu/Debian or macOS — where they diverge, both versions are shown.

A safe practice directory makes following along easier:

mkdir -p ~/linux-practice && cd ~/linux-practice

Run that once, then run everything else inside it.

1. pwd — print working directory

pwd
# /home/yash/linux-practice

Always tells you where you are. Useful before any destructive command.

2. ls — list directory contents

ls            # files in the current directory
ls -l         # long format with permissions, owner, size, date
ls -la        # long format, including hidden files (starting with .)
ls -lh        # human-readable file sizes (KB, MB, GB)
ls /etc       # list a specific directory

ls -la is the single most common form. Memorise it.

3. cd — change directory

cd ~              # go to your home directory
cd /etc           # go to an absolute path
cd projects       # go to a subdirectory (relative path)
cd ..             # go up one level
cd -              # go back to the previous directory

cd with no arguments takes you home. cd - is a small but constant time-saver.

Creating, copying, moving, removing

4. mkdir — make a directory

mkdir notes                       # one directory
mkdir notes drafts archive        # several at once
mkdir -p projects/2026/january    # create parent directories as needed

The -p flag is what you want most of the time — it never errors if the directory already exists.

5. touch — create an empty file (or update its timestamp)

touch hello.txt
touch a.txt b.txt c.txt

Useful for creating placeholder files during practice.

6. cp — copy

cp hello.txt hello.bak             # copy a file
cp hello.txt notes/                # copy into a directory
cp -r projects projects-backup     # copy a directory recursively

The -r (recursive) flag is required when copying directories.

7. mv — move or rename

mv hello.txt greetings.txt         # rename
mv greetings.txt notes/            # move into a directory
mv a.txt b.txt c.txt archive/      # move multiple files

mv is also how you rename — there is no separate rename command in the basic toolkit.

8. rm — remove

rm hello.bak                       # remove a file
rm a.txt b.txt c.txt               # remove several
rm -r projects-backup              # remove a directory and its contents
rm -i important.txt                # ask before removing each file

rm is permanent. There is no Recycle Bin. Treat rm -rf with respect — the -f (force) flag suppresses all confirmation. Never run rm -rf / or rm -rf ~ for any reason.

9. rmdir — remove an empty directory

mkdir empty && rmdir empty

rmdir only works on empty directories, which is exactly why it is safer than rm -r for the common case of cleaning up.

Viewing files

10. cat — concatenate and print files

cat hello.txt                # print the whole file
cat a.txt b.txt              # print several, concatenated
cat -n notes.md              # number each line

Best for short files. For long files, use less.

11. less — view a file one screen at a time

less /etc/services

Inside less: Space for next page, b for previous page, /text to search, n for next match, q to quit. less does not load the whole file into memory, so it handles enormous files without lag.

12. head and tail — first or last lines of a file

head file.log                # first 10 lines
head -n 20 file.log          # first 20 lines
tail file.log                # last 10 lines
tail -n 50 file.log          # last 50 lines
tail -f server.log           # follow the file as it grows

tail -f is essential for watching log files in real time. Stop it with Ctrl+C.

Searching

13. grep — find lines that match a pattern

grep "error" server.log              # lines containing "error"
grep -i "error" server.log           # case-insensitive
grep -n "TODO" *.py                  # show line numbers, search all .py files
grep -r "deprecated" src/            # recurse into a directory
grep -v "debug" server.log           # invert: lines NOT containing "debug"

grep is the single most-used search tool on Linux. Combined with pipes (covered below), it can answer almost any “where is this string?” question.

14. find — locate files by name, type, or other criteria

find . -name "*.md"                  # all .md files under the current directory
find . -type d -name "node_modules"  # all directories named node_modules
find . -size +10M                    # files larger than 10 MB
find . -mtime -7                     # modified in the last 7 days

find is verbose but extremely flexible. Start with find . -name "PATTERN" and grow from there.

Try it yourself. In your ~/linux-practice directory, create a handful of files with touch and a couple of subdirectories with mkdir. Then use find . -type f to list every file beneath the current directory, and find . -name "*.txt" to list only the text files. Compare the output.

File information

15. wc — word, line, and byte count

wc file.txt          # lines, words, bytes
wc -l file.txt       # just the line count
wc -w file.txt       # just the word count

wc -l combined with a pipe is the classic way to count anything:

ls | wc -l                   # how many files in this directory?
grep "error" log | wc -l     # how many error lines?

16. du and df — disk usage and free space

du -sh ~/linux-practice      # total size of a directory, human-readable
du -h --max-depth=1 ~        # size of each subdirectory of home
df -h                        # free space on each mounted disk

On macOS, du --max-depth=1 is spelled du -d 1. The macOS versions of these tools come from BSD and have slightly different flags than the GNU versions on Linux.

Processes

17. ps — list running processes

ps                  # processes in the current shell
ps aux              # every process on the system, with details
ps aux | grep node  # filter for Node.js processes

ps aux | grep <name> is the everyday way to check whether a service is running.

18. top / htop — interactive process monitor

top

A live, updating view of CPU and memory usage by process. Press q to quit.

htop is a friendlier alternative with colour and mouse support. Install it once and never go back:

sudo apt install htop      # Ubuntu/Debian
brew install htop          # macOS

19. kill — terminate a process by ID

ps aux | grep node          # find the PID (process ID)
kill 12345                  # ask the process to exit
kill -9 12345               # force-kill if it ignores the polite signal

Use kill -9 only when a plain kill does not work — it gives the process no chance to clean up.

The one editor every Linux user should know

20. nano — a small, friendly terminal editor

nano hello.txt

nano shows its keyboard shortcuts at the bottom of the screen, so there is nothing to memorise. Ctrl+O saves, Ctrl+X exits. It is good enough for every config-file edit you will do for a long time.

Once you are comfortable, you may eventually want to learn vim or emacs. There is no rush. nano ships on every Linux system and is the fastest way to edit a file in a shell.

Try it yourself. Run nano shopping.txt, type a short list, save with Ctrl+O (press Enter to confirm), and exit with Ctrl+X. Then run cat shopping.txt to confirm what you typed is on disk.

Combining commands: pipes and redirection

Two pieces of shell syntax turn the twenty commands above into a small programming language.

Pipes (|) — feed one command’s output into the next

ls -la | grep ".txt"             # only the .txt files
ps aux | grep node | wc -l       # how many node processes?
history | tail -n 20             # last 20 commands you ran

Each | connects the standard output of the command on the left to the standard input of the command on the right. Chains can be as long as you need.

Output redirection (> and >>)

echo "hello" > greeting.txt      # write to a file (overwrites)
echo "world" >> greeting.txt     # append to a file
ls -la > listing.txt             # save command output to a file

> overwrites. >> appends. This is how you save results without copy-pasting.

Input redirection (<)

wc -l < greeting.txt             # count lines from the file

You will use > and | constantly. < shows up occasionally.

A practical session that uses most of this post

Counting how many Python files in a project contain a TODO comment:

cd ~/projects/myapp
find . -name "*.py" | wc -l               # total Python files
grep -r "TODO" --include="*.py" . | wc -l # total TODO lines

Watching a log file for errors as a service runs:

tail -f /var/log/syslog | grep -i "error"

Cleaning up a practice directory safely:

cd ~/linux-practice
ls -la                                    # confirm what's there
rm -i *.txt                               # interactive removal
cd .. && rmdir linux-practice             # only succeeds if empty

Every one of these is built from commands in this post.

Recap

You now know twenty commands that cover the great majority of shell work:

  • Navigation: pwd, ls, cd
  • Creating: mkdir, touch, cp, mv
  • Removing: rm, rmdir
  • Viewing: cat, less, head, tail
  • Searching: grep, find
  • Info: wc, du, df
  • Processes: ps, top/htop, kill
  • Editing: nano
  • Combining: pipes (|), redirection (>, >>, <)

There is more to each of these — find alone has dozens of options — but the forms above will see you through almost everything.

Next steps

The next post zooms out and explains how the Linux file system is organised — what lives in /etc, /var, /home, and /usr, and why knowing the layout helps you find things without guessing.

→ Next: Understanding the Linux File System

Questions or feedback? Email codeloomdevv@gmail.com.