DEV Community

Dev Cookies
Dev Cookies

Posted on

The Ultimate Linux Command Guide for Developers: Master Your Terminal

Linux is the backbone of modern software development. Whether you’re building microservices, running servers, or managing local development environments, knowing Linux commands can make you significantly more productive. This guide will cover the essential commands every developer should know, organized by category and real-world usage.


1. File and Directory Management

Navigating your filesystem efficiently is crucial. Here are the commands you’ll use daily:

Command Purpose Example
pwd Print working directory pwd/home/user/project
ls List files/directories ls -l
cd Change directory cd /var/log
mkdir Create a new directory mkdir my_folder
rmdir Remove empty directory rmdir old_folder
rm Remove files or directories rm file.txt / rm -rf folder
cp Copy files or directories cp file1.txt file2.txt
mv Move or rename files mv old.txt new.txt
touch Create an empty file touch app.log
find Search files find . -name "*.java"

Tip: Combine ls with grep to quickly filter files:

ls | grep ".log"
Enter fullscreen mode Exit fullscreen mode

2. Viewing and Editing Files

As a developer, inspecting logs or configuration files is common.

Command Purpose Example
cat Display file content cat file.txt
less View file page by page less file.txt
head Show first N lines head -n 10 file.log
tail Show last N lines tail -f app.log
nano / vim / vi Edit files nano config.env

Tip: tail -f is invaluable for watching live log updates.


3. Permissions and Ownership

Linux’s permission system ensures security. Developers often need to adjust access.

Command Purpose Example
chmod Change file permissions chmod 755 script.sh
chown Change owner/group chown user:group file.txt
umask Set default permission mask umask 022

4. Process Management

Monitoring and controlling processes is key for debugging and system maintenance.

Command Purpose Example
ps Show running processes ps aux
top Interactive process monitoring top
htop Enhanced interactive view htop
kill Kill a process by PID kill 1234
killall Kill by name killall java
jobs List background jobs jobs
bg / fg Background / foreground jobs bg %1, fg %1

5. System Information

Check system health and resource usage easily.

Command Purpose Example
uname -a System info uname -a
df -h Disk usage df -h
du -sh * Directory sizes du -sh my_folder
free -h Memory usage free -h
uptime System uptime uptime
who / w Logged-in users who

6. Networking Commands

Debugging connectivity and interacting with network services is frequent for developers.

Command Purpose Example
ping Check host connectivity ping google.com
curl Make HTTP requests curl http://localhost:8080
wget Download files wget https://example.com/file.zip
netstat / ss Network connections & ports netstat -tuln
ifconfig / ip addr Network interfaces ip addr show
traceroute Trace network route traceroute google.com

7. Package Management

Installing and updating software is crucial for a developer environment.

OS Command Purpose
Debian/Ubuntu apt install package Install/update packages
CentOS/Fedora yum install package or dnf install package Install packages
Arch Linux pacman -S package Install packages
Generic snap install package Install snap packages

8. Text Processing and Searching

Useful for logs, configuration, and code analysis.

Command Purpose Example
grep Search inside files grep "ERROR" app.log
awk Process text / columns awk '{print $2}' file.txt
sed Replace text sed 's/foo/bar/g' file.txt
sort Sort lines sort file.txt
uniq Remove duplicates `sort file.txt uniq`
wc Count words, lines, chars wc -l file.txt

9. Compression and Archiving

Manage backups and package projects efficiently.

Command Purpose Example
tar Archive files tar -czvf archive.tar.gz folder/
gzip / gunzip Compress / decompress gzip file.txt
zip / unzip Zip files zip -r archive.zip folder/

10. Git and Version Control

Version control is essential for collaborative development.

Command Purpose Example
git clone Clone repository git clone <repo_url>
git status Check changes git status
git add Stage files git add .
git commit Commit changes git commit -m "message"
git push Push to remote git push origin main
git pull Pull latest changes git pull

11. Development and Build Tools

Run and build your projects directly from the terminal.

Tool Command Example
Java Compile & run javac Main.java && java Main
Maven Build Java project mvn clean install
Gradle Build project gradle build
Node.js Run JS scripts node index.js
npm Manage Node packages npm install
Python Run scripts python3 script.py

12. System Logs

Debugging is easier when you can access logs efficiently.

Command Purpose Example
journalctl View system logs journalctl -xe
dmesg Kernel messages `dmesg tail -n 50`
/var/log Directory for system logs ls /var/log

13. Handy Miscellaneous Commands

Command Purpose Example
alias Create shortcuts alias ll='ls -la'
history Command history `history grep git`
env Show environment variables env
export Set environment variables export PATH=$PATH:/opt/bin
sudo Run commands as root sudo apt install git

Tips for Learning Linux as a Developer

  1. Start with basics: Navigation, file management, and permissions.
  2. Move to process management: Learn to monitor and control running processes.
  3. Master text processing: grep, awk, and sed are your friends.
  4. Practice package management: Installing tools quickly improves workflow.
  5. Combine commands: Use pipes | and redirection > for efficiency.

💡 Conclusion
Linux commands are the secret sauce for developers who want to be fast, efficient, and independent. Mastering them means you can troubleshoot servers, inspect logs, manage dependencies, and run builds—all without leaving your terminal.


Top comments (0)