Complete Linux Tutorial & Handbook
A comprehensive, practical guide to mastering the Linux CLI, administration, networking, process management, and production server hardening.
Linux Filesystem Hierarchy (FHS)
Unlike Windows with drive letters (C:\, D:\), Linux organizes all files, directories, and hardware devices into a single unified tree structure rooted at / (the root directory).
| Directory | Purpose |
|---|---|
| /bin & /usr/bin | Essential user command binaries (ls, cp, grep, python). |
| /etc | System-wide configuration files (nginx.conf, sshd_config). |
| /home | User personal directories (/home/alice). |
| /var/log | System and application log files (syslog, auth.log). |
| /dev | Hardware device files (/dev/sda, /dev/null, /dev/urandom). |
| /tmp | Temporary files, usually cleared automatically on reboot. |
Essential File & Directory Operations
# 1. Inspect current directory and contents
pwd # Print Working Directory
ls -lah # List all files (including hidden .files) with human sizes
# 2. Creating and moving files
mkdir -p /opt/myapp/logs # Create nested directories
touch config.env # Create empty file or update timestamp
cp -r /src/data /backup/ # Recursively copy directory
mv old_name.txt new_name.txt # Rename or move
rm -rf /tmp/scratch # Force recursive delete (caution!)
File Permissions & Ownership (chmod / chown)
Every Linux file has an Owner (User), Group, and Others permission triple consisting of Read (4), Write (2), and Execute (1).
# Change permissions
chmod 755 script.sh # rwxr-xr-x (executable script)
chmod 600 id_ed25519 # rw------- (private SSH key)
chmod +x deploy.sh # Add execute permission for everyone
# Change user and group ownership
sudo chown -R www-data:www-data /var/www/html
Text Processing & Pipelines (grep, awk, sed)
The Unix philosophy is to connect small tools with pipes (|) and redirections (>, >>).
cat /var/log/nginx/access.log | grep "404" | wc -l # Count 404 occurrences
tail -f /var/log/syslog | grep --line-buffered "ERROR" # Live follow errors
awk -F: '{print $1, $3}' /etc/passwd # Print username and UID
sed -i 's/localhost/127.0.0.1/g' config.yaml # In-place search & replace
Processes & Systemd Services
ps aux | grep node # Find process ID (PID)
kill -9 12345 # Force kill PID 12345
sudo systemctl status nginx # Check service status
sudo systemctl restart docker # Restart service
sudo journalctl -u nginx -f --no-tail # Follow systemd service logs
Networking, Ports & SSH
ss -tulpn # Show all listening TCP/UDP ports with processes
curl -I https://techsimplehub.com # Check HTTP response headers
ssh -i ~/.ssh/id_ed25519 user@192.168.1.100 # Secure SSH connection
rsync -avzP ./build/ deploy@server:/var/www/ # Efficient file sync
Production Server Hardening Checklist
- 1.Disable Password Authentication for SSH: In
/etc/ssh/sshd_config, setPasswordAuthentication noandPermitRootLogin prohibit-password. - 2.Configure UFW Firewall:
sudo ufw default deny incoming && sudo ufw allow 22/tcp && sudo ufw allow 80/tcp && sudo ufw allow 443/tcp && sudo ufw enable. - 3.Install Fail2ban: Automatically ban IP addresses that exhibit malicious signs like too many password failures.