
Linux commands are the "magic spells" (instructions) that you type into the command line interface (CLI) of a Linux operating system. They control everything from file management to system operations.
Think of them as shortcuts to get things done more efficiently, often without needing to open up any graphical applications.
Examples of Linux commands
There’s a whole universe of Linux commands out there. For example:
File and Directory Management |
||
| Command | Example | Description |
| ls | ls -la /etc | Lists all files (including hidden) in /etc |
| cd | cd ~/Downloads | Changes to the Downloads folder |
| pwd | pwd | Prints current working directory |
| mkdir | mkdir new_project | Creates a folder named new_project |
| rm | rm old.txt | Deletes old.txt |
| rm -r | rm -r temp_folder | Deletes folder and its contents |
| mv | mv draft.txt final.txt | Renames draft.txt to final.txt |
|
||
| Command | Example | Description |
| cat | cat report.txt | Displays contents of report.txt |
| less | less /var/log/syslog | Scrolls through system log |
| head | head -n 10 data.csv | Shows first 10 lines of data.csv |
| tail | tail -f server.log | Live view of server.log updates |
| nano | nano notes.txt | Opens notes.txt in nano editor |
| touch | touch newfile.txt | Creates an empty file |
| echo | echo "Hello" > greet.txt | Writes "Hello" to greet.txt |
|
||
| Command | Example | Description |
| find | find . -name "*.sh" | Finds all .sh files in current dir |
| grep | grep "error" app.log | Searches for "error" in app.log |
| grep -r | grep -r "TODO" . | Recursively searches for "TODO" |
| locate | locate passwd | Finds files named passwd |
| which | which python3 | Shows path to python3 binary |
| whereis | whereis bash | Shows location of bash binary |
| find | find /home -type f -size +10M | Finds files >10MB in /home |
|
||
| Command | Example | Description |
| top | top | Live view of processes |
| htop | htop | Enhanced process viewer (if installed) |
| ps | ps -aux | grep nginx | Checks if nginx is running |
| df | df -h | Disk usage in human-readable format |
| du | du -sh * | Size of each item in current dir |
| free | free -m | Memory usage in MB |
| uptime | uptime | Shows system uptime and load |
|
||
| Command | Example | Description |
| chmod | chmod 755 script.sh | Gives execute permission |
| chmod | chmod +x runme.sh | Adds execute permission |
| chown | chown miguel:miguel file.txt | Changes owner to miguel |
| chown | sudo chown root:root config.cfg | Sets owner to root |
| ls -l | ls -l | Shows file permissions |
| umask | umask 022 | Sets default permission mask |
| stat | stat file.txt | Shows detailed file info |
|
||
| Command | Example | Description |
| apt update | sudo apt update | Updates package list |
| apt upgrade | sudo apt upgrade | Upgrades installed packages |
| apt install | sudo apt install curl | Installs curl |
| apt remove | sudo apt remove apache2 | Removes apache2 |
| apt search | apt search nginx | Searches for nginx packages |
| apt show | apt show git | Shows details about git |
| dpkg -l | dpkg -l | grep vim | Lists installed vim packages |