๐ฅ 10 Linux Commands Every Programmer Must Know
Discover 10 essential Linux commands every programmer must know. Boost your terminal skills and become more efficient in coding and development.
๐ป 1. pwd โ Print Working Directory
This command shows the exact path of the directory youโre currently in.
It sounds simple, but itโs the foundation of all terminal navigation.
If you ever get lost among folders, just type pwd and youโll know where you are.
๐ Example:
pwdOutput: /home/milo/dev/project
๐ 2. ls โ List Directory Contents
ls lists all files and folders in the current directory.
With extra options, you can get more details:
ls -lโ detailed view (permissions, size, modification date)ls -aโ shows hidden files
๐ Combo:
ls -la๐ 3. cd โ Change Directory
Use cd to move between directories.
๐ Examples:
cd /home/milo/Documents
cd ..
cd ~
..takes you one level up~brings you to your home directory
๐ 4. cat โ Concatenate and Display Files
cat prints the content of files directly in the terminal.
It can also merge multiple files into one.
๐ Examples:
cat notes.txt
cat part1.txt part2.txt > full.txtPerfect when you need a quick look inside without opening an editor.
โ๏ธ 5. cp and mv โ Copy & Move Files
cpcopies a file from one location to another.mvmoves or renames files.
๐ Examples:
cp file.txt backup/file.txt
mv file.txt /home/milo/Desktop/
mv oldname.txt newname.txtโ ๏ธ Be careful โ once you move a file with mv, itโs gone from the old location.
๐ฅ 6. rm โ Remove Files
Deletes files and directories.
This command has no undo, so use it with caution.
๐ Examples:
rm file.txt
rm -r foldername-rmeans recursive delete, which removes everything inside a folder.
โ ๏ธ One wrong command can literally wipe out your project.
๐ 7. grep โ Search Text in Files
grep searches inside files and finds lines containing specific text.
๐ Examples:
grep "error" logfile.txt
grep -r "function" /home/milo/projects/With -r, it searches through all files in a directory.
Think of it as your personal text detective inside the terminal.
๐งฉ 8. chmod โ Change File Permissions
Changes access permissions for files and directories.
Every file in Linux has permissions for owner, group, and others.
๐ Examples:
chmod +x script.sh # makes the file executable
chmod 644 file.txt # owner can write, others can only readWithout the correct permissions, your scripts wonโt run.
โ๏ธ 9. top โ Display Running Processes
Shows all active processes, their CPU and memory usage, and more.
It lets you monitor your system in real time.
๐ Example:
topPress q to quit.
Thereโs also a modern version called htop, but top is available by default on almost all Linux systems.
๐พ 10. sudo โ Superuser Do
The most powerful command in Linux.
It lets you execute actions as the system administrator (root).
๐ Examples:
sudo apt update
sudo rm -rf /tmp/*Use it only when necessary โ one mistake with sudo rm can destroy your entire system. ๐ฌ
Update
Linux is an essential tool for any programmer or developer. While many know the basic commands like pwd, ls, or cd, thereโs a whole set of more advanced commands that can significantly improve your productivity and system management skills. In this post, weโll cover 10 advanced Linux commands every programmer should know, along with practical examples.
1. top โ Monitor Active Processes
top provides a real-time view of system processes, CPU usage, and memory consumption. Itโs perfect for seeing which programs are consuming the most resources.
topTip: Press q to exit.
2. htop โ Interactive Process Viewer
htop is a more advanced and interactive version of top. It shows a colorful display, allows scrolling, and makes it easy to kill or manage processes.
htop
Tip: Install it via sudo apt install htop if itโs not available.
3. df โ Disk Space Usage
The df command shows available and used disk space for all mounted filesystems.
df -h-h makes the output human-readable (e.g., GB, MB).
4. du โ Directory and File Sizes
du displays the size of directories and files, which is very useful to find large folders.
du -sh /path/to/folder
Tip: -s summarizes total, -h makes it human-readable.
5. chmod โ Change Permissions
chmod changes file or directory permissions, allowing you to control read, write, and execute access.
chmod 755 script.sh
6. chown โ Change Ownership
chown changes the owner of files or directories, which is critical when managing multi-user systems.
chown user:group file.txt7. ps โ List Processes
ps lists currently running processes, helping you debug issues or monitor activity.
ps aux
8. kill โ Stop a Process
kill terminates a process by its PID (process ID).
kill 1234
Tip: Use kill -9 1234 for forceful termination.
9. find โ Search for Files
find searches files or directories based on name, type, size, or other conditions.
find /home/user -name "*.log"
10. tar โ Archive and Extract Files
tar is used to compress and extract files, like .tar.gz archives.
tar -czvf archive.tar.gz /path/to/folder
tar -xzvf archive.tar.gz๐ก Bonus Tips for Programmers
- Combine commands with
|(pipe) for advanced workflows:
ps aux | grep python
Use man to read the manual of any command:
man tarPractice these commands daily in a sandbox Linux environment to build muscle memory.
๐ง Conclusion
If you master these 10 commands, you already understand 80% of what you need to work efficiently in the Linux terminal.
Theyโre the foundation every serious developer should build on.