๐ŸŽฅ 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.

๐ŸŽฅ 10 Linux Commands Every Programmer Must Know
Photo by Gabriel Heinzer / Unsplash

๐Ÿ’ป 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:

pwd

Output: /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.txt

Perfect when you need a quick look inside without opening an editor.

โœ‚๏ธ 5. cp and mv โ€” Copy & Move Files

  • cp copies a file from one location to another.
  • mv moves 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
  • -r means 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 read

Without 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:

top

Press 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.

top


Tip: 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.txt

7. 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 tar

Practice 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.