Essential Linux Commands for Developers
A practical reference of the Linux commands every developer should have in their toolkit.
System Information
-
uname -a: Displays all system information, including kernel version and hardware architecture.
-
top: Provides a dynamic real-time view of running system processes.
-
htop (needs installation on some distros): An interactive process viewer, similar to top but more user-friendly.
-
df -h: Shows disk space usage on all mounted filesystems, in human-readable form.
-
free -h: Displays the amount of free and used memory in the system, in human-readable form.
User Management
-
useradd : Creates a new user account.
-
usermod -aG : Adds a user to a specified group.
-
passwd : Sets or changes the password for a user account.
-
chage -l : Lists password aging information for a user.
File and Directory Management
-
ls -lah: Lists all files and directories in the current directory, including hidden files, with detailed information in a human-readable format.
-
find / -name : Searches the entire filesystem for a file or directory named .
-
tar czvf archive.tar.gz /path/to/directory: Creates a compressed tar archive of a directory.
-
chmod +x script.sh: Makes a script executable.
Package Management
-
apt update && apt upgrade (Debian, Ubuntu, and derivatives): Updates the package index and upgrades all packages to their latest versions.
-
yum update (CentOS, RHEL): Updates all installed packages to their latest version.
-
dnf update (Fedora, newer RHEL): Similar to yum, but uses the DNF package manager.
Network Configuration and Troubleshooting
-
ip addr show: Displays IP addresses and all network interfaces.
-
netstat -tulnp: Lists all active listening ports along with the corresponding service.
-
ping google.com: Sends ICMP ECHO_REQUEST packets to google.com to test connectivity.
-
traceroute google.com: Traces the route packets take from your machine to google.com
Process Management
-
ps aux: Shows running processes with detailed information.
-
kill : Sends a SIGTERM to a process with the specified PID, requesting its termination.
-
killall : Terminates all processes with the given name.
-
systemctl restart : Restarts a systemd service.
System Monitoring and Performance
-
vmstat: Reports virtual memory statistics.
-
iostat: Provides CPU and input/output statistics for devices and partitions.
-
lsof: Lists open files and the processes that opened them.
Disk Usage and Files
-
du -sh /path/to/directory: Shows the total size of a directory and its subdirectories in a human-readable format.
-
ncdu (needs installation on some distros): An interactive disk usage viewer, providing a detailed breakdown of which files and directories are using disk space.