FreeTool
Developer Tools

Linux Command Line Essentials Every Developer Should Know

A practical reference for the Linux commands used daily in development — file system navigation, permissions, process management, text processing, and networking.

9 min read

Terminal with green text on a dark screen

The Linux command line is the universal interface for servers, containers, CI pipelines, and development environments. Whether you're SSH'd into a production server at 2am or debugging a Docker container, fluency with these commands is the difference between confusion and confidence.

# Navigate directories
pwd                      # print working directory
cd /var/log              # absolute path
cd ..                    # up one level
cd -                     # go back to previous directory
cd ~                     # home directory

# List files
ls                       # basic listing
ls -la                   # long format + hidden files
ls -lh                   # human-readable file sizes
ls -lt                   # sort by modification time (newest first)

# Create, copy, move, delete
mkdir -p path/to/dir     # create directory + parents
cp -r source/ dest/      # recursive copy
mv oldname newname       # rename or move
rm -rf directory/        # delete directory and contents (irreversible!)
touch file.txt           # create empty file / update timestamp

# View and navigate files
cat file.txt             # print entire file
less file.txt            # paginated viewer (q to quit, / to search)
head -n 20 file.txt      # first 20 lines
tail -n 20 file.txt      # last 20 lines
tail -f /var/log/app.log # follow log in real time

File permissions

Linux permissions are expressed as three sets of read/write/execute bits for owner, group, and others:

-rwxr-xr--  1 alice devs  4096 Apr 8 10:00 script.sh

Reading the permission string: -rwxr-xr--

  • - — file type (d = directory, l = symlink)
  • rwx — owner: read, write, execute
  • r-x — group: read, execute (no write)
  • r-- — others: read only

chmod — change permissions

# Symbolic notation
chmod u+x script.sh      # add execute for owner
chmod g-w file.txt       # remove write for group
chmod o=r file.txt       # set others to read-only
chmod a+r file.txt       # add read for all (a = all)

# Numeric (octal) notation
chmod 755 script.sh      # rwxr-xr-x (common for executables)
chmod 644 file.txt       # rw-r--r-- (common for files)
chmod 600 ~/.ssh/id_rsa  # rw------- (required for SSH keys)
chmod 700 ~/.ssh/        # rwx------ (required for .ssh directory)

Use our Chmod Calculator to build permission strings visually and understand what each octal value means.

Searching and text processing

# Find files
find /var/log -name "*.log"               # find by name
find . -name "*.ts" -newer package.json   # files newer than package.json
find . -type f -size +10M                 # files over 10MB
find . -name "node_modules" -prune        # exclude directories

# Search file contents
grep "error" app.log                      # search in file
grep -r "TODO" ./src                      # recursive search
grep -i "error" app.log                   # case-insensitive
grep -n "error" app.log                   # show line numbers
grep -v "DEBUG" app.log                   # lines NOT matching
grep -E "error|warning" app.log           # regex: error OR warning

# Stream text processing
cat access.log | grep "404" | wc -l       # count 404 errors
cat data.csv | cut -d',' -f1,3            # extract columns 1 and 3
cat file.txt | sort | uniq                # sort and deduplicate
cat file.txt | sort | uniq -c | sort -rn  # count occurrences, sort by frequency

awk — field-based processing

# Print specific fields (tab-separated by default)
awk '{print $1, $3}' file.txt

# Process CSV (comma-separated)
awk -F',' '{print $2}' data.csv

# Sum a column
awk -F',' '{sum += $3} END {print sum}' data.csv

# Print lines matching a pattern
awk '/ERROR/ {print $0}' app.log

sed — stream editor

# Replace text
sed 's/foo/bar/' file.txt          # replace first occurrence per line
sed 's/foo/bar/g' file.txt         # replace all occurrences (global)
sed -i 's/foo/bar/g' file.txt      # in-place edit (modifies the file)

# Delete lines
sed '/^#/d' file.txt               # delete comment lines
sed '5,10d' file.txt               # delete lines 5-10

# Print specific lines
sed -n '10,20p' file.txt           # print lines 10-20

Process management

# View running processes
ps aux                             # all processes with details
ps aux | grep nginx                # find nginx processes
top                                # interactive process viewer
htop                               # better interactive viewer (if installed)

# Process control
kill PID                           # send SIGTERM (graceful)
kill -9 PID                        # send SIGKILL (force kill)
pkill nginx                        # kill by name
killall node                       # kill all matching processes

# Background jobs
command &                          # run in background
jobs                               # list background jobs
fg %1                              # bring job 1 to foreground
nohup command &                    # run immune to hangup (survives logout)

# System resources
free -h                            # memory usage
df -h                              # disk space usage
du -sh /var/log/                   # directory size
lsof -i :3000                      # what's using port 3000

Networking commands

# Connectivity
ping google.com                    # test connectivity
curl -I https://example.com        # HTTP headers only
curl -o file.zip https://example.com/file.zip  # download file
wget https://example.com/file.zip  # alternative downloader

# Inspect connections
ss -tulpn                          # listening ports and processes
netstat -tulpn                     # alternative (older systems)
lsof -i :80                        # what's on port 80

# DNS
dig example.com                    # DNS lookup
dig example.com MX                 # MX records
host example.com                   # simple DNS lookup
nslookup example.com               # interactive DNS query

SSH and remote access

# Connect to a server
ssh user@server.com
ssh -p 2222 user@server.com        # non-standard port
ssh -i ~/.ssh/id_rsa user@server.com  # specific key

# Copy files
scp file.txt user@server.com:~/    # copy to remote home directory
scp user@server.com:~/file.txt .   # copy from remote
scp -r ./dist user@server.com:~/app/  # recursive copy

# SSH tunneling (port forwarding)
ssh -L 5432:localhost:5432 user@server.com  # tunnel remote DB to local port

Generate SSH key pairs for secure authentication with our SSH Key Generator.

Environment and shell

# Environment variables
export API_KEY=abc123              # set for current session and child processes
echo $API_KEY                      # print variable
env                                # list all environment variables
printenv PATH                      # print specific variable
unset API_KEY                      # remove variable

# Shell history
history                            # list previous commands
!!                                 # repeat last command
!grep                              # repeat last grep command
Ctrl+R                             # reverse search history (type to search)

# Useful shortcuts
Ctrl+C                             # interrupt current process
Ctrl+Z                             # suspend to background
Ctrl+L                             # clear screen (same as clear)
Ctrl+A                             # jump to start of line
Ctrl+E                             # jump to end of line
Ctrl+U                             # clear line before cursor

Pipes and redirection

# Pipes — chain commands
ls -la | grep ".log" | wc -l

# Redirect output
command > file.txt                 # overwrite file with stdout
command >> file.txt                # append stdout to file
command 2> errors.txt              # redirect stderr
command > all.txt 2>&1             # redirect stdout + stderr to same file
command &> all.txt                 # shorthand for above

# /dev/null — discard output
command > /dev/null 2>&1           # discard all output (run silently)

Useful one-liners for developers

# Find and replace in all files in a directory
find . -name "*.tsx" | xargs sed -i 's/OldComponent/NewComponent/g'

# Get public IP
curl -s ifconfig.me

# Monitor a file for changes
watch -n 2 "ls -la uploads/"

# Compress a directory
tar -czf archive.tar.gz ./directory/

# Extract a tar.gz
tar -xzf archive.tar.gz

# Show the 10 largest files in current directory
du -sh * | sort -rh | head -10

# Count lines of code by file type
find . -name "*.ts" | xargs wc -l | sort -rn | head -20

The command line rewards investment. Every command you learn becomes a building block for more powerful combinations. Start with navigation and grep, then add pipes, then awk — and you'll handle any text-processing task that comes your way.