All topics
Frontend · Learning hub

Linux notes for developers

Master Linux with a curated set of 3 developer notes — core concepts, patterns, and interview prep. Maintained by the DevRecall team.

Save this stack to your DevRecallMore Frontend notes
Linux

File System & Navigation

File System & Navigation Navigation & File Operations # Navigation pwd # print working directory cd /var/log # absolute path cd ~/projects # home directory cd -

File System & Navigation

Navigation & File Operations

# Navigation
pwd                          # print working directory
cd /var/log                  # absolute path
cd ~/projects                # home directory
cd -                         # previous directory
cd ..                        # parent directory

# List files
ls                           # basic listing
ls -la                       # long format + hidden files
ls -lh                       # human-readable sizes
ls -lt                       # sorted by modification time
ls -lS                       # sorted by size

# File operations
cp file.txt backup.txt       # copy file
cp -r dir/ newdir/           # copy directory recursively
mv old.txt new.txt           # move/rename
rm file.txt                  # delete file
rm -rf dir/                  # delete directory (DANGER: no undo)
mkdir -p a/b/c               # create nested directories
touch file.txt               # create empty file or update timestamp
ln -s /path/to/target link   # create symlink

# View files
cat file.txt                 # print file contents
less file.txt                # paginated viewer (q to quit)
head -n 20 file.txt          # first 20 lines
tail -n 50 file.txt          # last 50 lines
tail -f /var/log/app.log     # follow log in real time
wc -l file.txt               # count lines
wc -w file.txt               # count words

# Find files
find /var/log -name "*.log"              # find by name
find . -name "*.ts" -not -path "*/node_modules/*"
find . -type f -size +100M              # files larger than 100MB
find . -mtime -7                         # modified in last 7 days
find . -name "*.log" -delete             # find and delete

# Disk usage
df -h                        # disk space by filesystem
du -sh /var/log/*             # size of each item
du -sh .                     # size of current directory
ncdu                         # interactive disk usage browser (install separately)

Text Processing

# grep — search text
grep "error" app.log                    # search for pattern
grep -i "error" app.log                 # case-insensitive
grep -n "error" app.log                 # show line numbers
grep -r "TODO" ./src                    # recursive search
grep -v "debug" app.log                 # invert match (exclude)
grep -E "error|warning" app.log        # extended regex (OR)
grep -l "pattern" *.txt                # only filenames

# sed — stream editor
sed 's/foo/bar/g' file.txt             # replace all foo with bar
sed 's/foo/bar/2' file.txt             # replace 2nd occurrence only
sed -i 's/foo/bar/g' file.txt          # edit in-place
sed -i.bak 's/foo/bar/g' file.txt      # edit with backup
sed '1,5d' file.txt                    # delete lines 1-5
sed -n '10,20p' file.txt              # print lines 10-20

# awk — column processing
awk '{print $1}' file.txt              # print first column
awk '{print $NF}' file.txt            # print last column
awk -F: '{print $1}' /etc/passwd       # colon-separated, field 1
awk '{sum+=$1} END{print sum}' nums    # sum first column
awk 'NR==5' file.txt                  # print line 5

# sort, uniq, cut
sort file.txt                          # sort alphabetically
sort -n numbers.txt                    # sort numerically
sort -rn numbers.txt                   # sort numerically, descending
sort -k2 file.txt                     # sort by 2nd field
sort file.txt | uniq                   # unique lines
sort file.txt | uniq -c                # count occurrences
cut -d: -f1,3 /etc/passwd             # cut fields 1 and 3 (colon delimiter)
cut -c1-10 file.txt                   # cut first 10 characters

Permissions

# Permission format: -rwxrwxrwx (type, owner, group, others)
# r=4, w=2, x=1

chmod 755 script.sh          # rwxr-xr-x (owner all, others read+exec)
chmod 644 file.txt           # rw-r--r-- (owner read+write, others read)
chmod +x script.sh           # add execute to all
chmod -w file.txt            # remove write from all
chmod u+x,g-w file.txt       # add exec to owner, remove write from group

chown user:group file.txt    # change owner and group
chown -R user:group dir/     # recursive

# Special permissions
chmod +s binary              # setuid/setgid
chmod +t /tmp                # sticky bit (only owner can delete)

# sudo
sudo command                 # run as root
sudo -u postgres psql        # run as different user
sudo su -                    # switch to root shell
visudo                       # edit sudoers safely
Linux

Processes, Networking & System

Processes, Networking & System Process Management # View processes ps aux # all processes (BSD format) ps -ef # all processes (UNIX format) ps aux | grep nginx

Processes, Networking & System

Process Management

# View processes
ps aux                       # all processes (BSD format)
ps -ef                       # all processes (UNIX format)
ps aux | grep nginx          # find process by name
top                          # live view (press q to quit)
htop                         # better top (install separately)
pgrep nginx                  # find PID by name
pidof nginx                  # PID of running program

# Kill processes
kill PID                     # send SIGTERM (graceful stop)
kill -9 PID                  # send SIGKILL (force kill)
killall nginx                # kill all processes by name
pkill -f "python app.py"    # kill by pattern

# Background / foreground
command &                    # run in background
jobs                         # list background jobs
fg %1                        # bring job 1 to foreground
bg %1                        # send job to background
nohup command &              # run immune to hangup (terminal close)
disown %1                    # detach from shell

# nice / renice — CPU priority
nice -n 10 command           # run with lower priority (nice value 10)
renice -n 5 -p PID           # change priority of running process

# Signals
SIGTERM (15) — graceful termination
SIGKILL (9)  — force kill (cannot be caught)
SIGHUP (1)   — reload config (nginx, sshd)
SIGUSR1/2    — user-defined

Networking

# IP / interfaces
ip addr show                 # show IP addresses
ip link show                 # show interfaces
ifconfig                     # older alternative
hostname -I                  # show all IP addresses

# Connectivity
ping google.com              # test connectivity
ping -c 4 google.com        # only 4 packets
traceroute google.com        # trace route
mtr google.com               # continuous traceroute

# DNS
nslookup domain.com          # DNS lookup
dig domain.com               # detailed DNS
dig domain.com +short        # just the IPs
dig @8.8.8.8 domain.com     # use specific DNS server

# Ports and connections
ss -tlnp                     # listening TCP ports + processes
ss -anp                      # all connections
netstat -tlnp                # older alternative
lsof -i :8080                # what's on port 8080
lsof -i tcp                  # all TCP connections

# HTTP requests
curl https://api.example.com
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com
curl -u user:pass https://api.example.com
curl -o output.txt https://file.example.com
curl -I https://example.com  # headers only
wget https://file.example.com/file.tar.gz

# Transfer files
scp user@host:/remote/file ./local/     # copy from remote
scp ./local/file user@host:/remote/     # copy to remote
rsync -avz ./src/ user@host:/dst/       # sync directories
rsync -avz --exclude node_modules ./    # exclude

System Administration

# systemd — service management
systemctl status nginx
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx         # reload config without stopping
systemctl enable nginx         # start on boot
systemctl disable nginx
systemctl list-units --type=service

journalctl -u nginx            # logs for service
journalctl -u nginx -f         # follow logs
journalctl --since "1 hour ago"
journalctl -n 100              # last 100 lines

# Users and groups
useradd -m -s /bin/bash username    # create user with home + shell
userdel -r username                 # delete user + home
passwd username                     # set password
usermod -aG docker username         # add user to group
groups username                     # show user's groups
id username                         # user/group IDs
who                                 # who is logged in
last                                # login history

# Cron
crontab -e                     # edit user crontab
crontab -l                     # list crontab
# Format: min hour day month weekday command
# 0 2 * * * /scripts/backup.sh      (2am daily)
# */15 * * * * /scripts/check.sh    (every 15 minutes)
# 0 9 * * 1-5 /scripts/report.sh   (9am weekdays)

# Environment
env                            # all environment variables
export VAR=value               # set env var
echo $PATH
source ~/.bashrc               # reload shell config
which node                     # path to executable
whereis bash                   # find binary + man pages
Linux

Interview Questions

Linux Interview Questions Q: What is the Linux file permission system? Each file has three permission sets: owner, group, others. Each set has read (r=4), write

Linux Interview Questions

Q: What is the Linux file permission system?

Each file has three permission sets: owner, group, others. Each set has read (r=4), write (w=2), execute (x=1). Permissions are displayed as rwxrwxrwx. Use chmod to change: 755 = rwxr-xr-x, 644 = rw-r--r--. For directories, execute means "enter". Use chown to change ownership.

Q: What is the difference between a process and a thread?

A process is an independent program execution with its own memory space, file descriptors, and PID. Threads are lightweight execution units within a process that share the same memory space. Process creation (fork) is expensive; thread creation is cheaper. Processes are isolated — one crash doesn't affect others. Thread communication is fast (shared memory) but requires synchronization.

Q: What is the difference between hard link and symlink?

A hard link is another directory entry pointing to the same inode (actual data). Deleting the original file doesn't remove data until all hard links are removed. Hard links cannot span filesystems or link to directories. A symlink (soft link) is a file containing a path to another file. It breaks if the target is deleted. Symlinks can cross filesystems and link to directories.

Q: What does 2>&1 mean in shell?

Redirects stderr (file descriptor 2) to wherever stdout (file descriptor 1) currently points. command > output.log 2>&1 sends both stdout and stderr to output.log. command 2>/dev/null suppresses only errors. command &>/dev/null suppresses all output.

Q: What is a pipe and how does it work?

A pipe (|) connects the stdout of one command to the stdin of the next. ps aux | grep nginx passes ps output to grep as input. Pipes allow building complex data processing pipelines from simple tools. Commands in a pipeline run concurrently — the kernel buffers data between them.

Q: What is the difference between kill -9 and kill -15?

SIGTERM (15) is the default kill signal — asks the process to terminate gracefully. The process can catch it, clean up resources, and exit cleanly. SIGKILL (9) cannot be caught or ignored — the kernel kills the process immediately. Always try SIGTERM first; use SIGKILL only if the process doesn't respond.

Keep your Linux knowledge sharp.

Save this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.

Get started — free forever