Linux Terminal Commands

The servers running the internet don't have a mouse. They run Linux. Knowing these commands distinguishes a "User" from an "Admin".

🐧 Core Concepts

The Shell (Bash)

The program that takes your commands and gives them to the OS. If you see a $ prompt, you are talking to the shell.

Root (Superuser)

The "God Mode" user. Can delete the entire operating system with one command. We use sudo to borrow Root's power temporarily.

Everything is a File

In Linux, your hard drive is a file. Your mouse is a file. Your settings are files. If you can edit text files, you can configure anything.

đŸ•šī¸ SysAdmin Crisis Simulator

🚨 ALERT: The web server is offline! Customers are angry.
Mission: Find the error logs and restart the service.
OFFLINE
admin@production-server-01: /var/www
SSH Session
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-generic x86_64)
System load: 0.05, 0.01, 0.00

Hint: Start by listing files with ls

📜 The Cheat Sheet

📂 File Operations

ls -lah List all files (including hidden), detailed view, human readable sizes.
cd /var/log Change Directory. Jump straight to a folder.
cat error.log Print the full content of a file to the screen.
tail -f error.log Watch the end of a file in real-time. Crucial for debugging live logs.
grep "error" file.txt Search for a specific word inside a file.

âš™ī¸ System Administration

sudo [cmd] Run as Root. Required for restarting services or editing system configs.
systemctl restart nginx Control background services (Start, Stop, Restart, Status).
ps aux See every running process on the machine.
top Task Manager. See CPU/RAM usage live.
df -h Disk Free. Check how much hard drive space is left.

🔐 Permissions

chmod 777 file Change Mode. Sets read/write/execute permissions. (777 is dangerous!)
chown user:group file Change Owner. Takes ownership of a file.

đŸ“Ļ Package Manager (APT)

apt update Refresh the list of available software.
apt install [package] Download and install software (e.g., apt install nginx).