Skip to content

Instantly share code, notes, and snippets.

@thesaadarshad
Created November 24, 2024 22:53
Show Gist options
  • Save thesaadarshad/0e8c9fa27d028df3cb88931c22be044f to your computer and use it in GitHub Desktop.
Save thesaadarshad/0e8c9fa27d028df3cb88931c22be044f to your computer and use it in GitHub Desktop.
Linux Comprehensive
System Monitoring
top: Real-time process and resource usage.
Example: top
htop: Interactive process viewer.
Example: htop
vmstat: System performance (CPU, memory, I/O).
Example: vmstat 5 10
iostat: Disk I/O and CPU usage stats.
Example: iostat -x 1
uptime: System uptime and load averages.
Example: uptime
free: Memory usage.
Example: free -h
dmesg: Kernel and boot logs.
Example: dmesg | tail
sar: System activity reporter.
Example: sar -u 1 5
lsof: List open files.
Example: lsof -i :80 (Processes using port 80)
watch: Run a command periodically.
Example: watch df -h
File and Directory Management
ls: List files.
Example: ls -lah
cp: Copy files.
Example: cp file1 file2
mv: Move or rename files.
Example: mv oldname newname
rm: Delete files or directories.
Example: rm -rf /tmp/test
find: Search for files.
Example: find /var -name "*.log"
locate: Find files quickly.
Example: locate apache.conf
du: Disk usage of files/directories.
Example: du -sh /var/log
df: Disk space usage of filesystems.
Example: df -h
stat: Display detailed file info.
Example: stat myfile
file: Identify file type.
Example: file /bin/bash
touch: Create an empty file.
Example: touch newfile
chmod: Change permissions.
Example: chmod 755 script.sh
chown: Change ownership.
Example: chown user:group file
ln: Create links.
Example: ln -s /path/to/file shortcut
Networking
ip: Manage IP addresses, routes, and devices.
Example: ip addr show
traceroute: Trace the route to a host.
Example: traceroute google.com
ping: Test connectivity.
Example: ping -c 4 8.8.8.8
netstat: Network connections and stats (deprecated, use ss).
Example: netstat -tuln
ss: Modern replacement for netstat.
Example: ss -tuln
curl: Transfer data from/to a URL.
Example: curl -I https://example.com
wget: Download files.
Example: wget https://example.com/file.zip
tcpdump: Capture network packets.
Example: tcpdump -i eth0 port 80
dig: Query DNS information.
Example: dig example.com
nslookup: DNS lookup.
Example: nslookup example.com
nmap: Network scanner.
Example: nmap -p 80 example.com
arp: View ARP table.
Example: arp -a
iptables: Manage firewall rules.
Example: iptables -L -v -n
ethtool: View and modify NIC settings.
Example: ethtool eth0
Process Management
ps: List running processes.
Example: ps aux | grep nginx
kill: Terminate processes by PID.
Example: kill -9 12345
pkill: Terminate processes by name.
Example: pkill nginx
jobs: List background jobs.
Example: jobs
fg: Bring a background job to the foreground.
Example: fg %1
bg: Resume a job in the background.
Example: bg %1
strace: Trace system calls and signals.
Example: strace -p 12345
nice: Start a process with a custom priority.
Example: nice -n 10 ./script.sh
renice: Change priority of a running process.
Example: renice -n 5 -p 12345
System Administration
whoami: Display current username.
Example: whoami
id: Display user ID and group info.
Example: id username
hostname: Display or set hostname.
Example: hostname
uptime: Show uptime and load average.
Example: uptime
uname: Show system info.
Example: uname -a
lsb_release: Show Linux distribution info.
Example: lsb_release -a
shutdown: Shutdown or restart system.
Example: shutdown -h now (Shutdown immediately)
reboot: Reboot system.
Example: reboot
Disk and Filesystem Management
mount: Mount a filesystem.
Example: mount /dev/sda1 /mnt
umount: Unmount a filesystem.
Example: umount /mnt
fsck: Check and repair filesystems.
Example: fsck /dev/sda1
mkfs: Create a filesystem on a device.
Example: mkfs.ext4 /dev/sdb1
blkid: Display block device info.
Example: blkid
lsblk: List block devices.
Example: lsblk
tune2fs: Adjust filesystem parameters.
Example: tune2fs -l /dev/sda1
Security
passwd: Change user password.
Example: passwd
ssh: Connect to a remote server via SSH.
Example: ssh user@hostname
scp: Copy files over SSH.
Example: scp file user@hostname:/path/to/dest
rsync: Synchronize files/directories.
Example: rsync -avz /src /dest
chmod: Change file permissions.
Example: chmod 755 script.sh
chown: Change file ownership.
Example: chown user:group file
gpg: Encrypt and decrypt files.
Example: gpg -c file.txt
Compression and Archiving
tar: Create and extract archives.
Example: tar -czvf archive.tar.gz /path/to/files
zip: Compress files into a zip archive.
Example: zip archive.zip file1 file2
unzip: Extract files from a zip archive.
Example: unzip archive.zip
gzip: Compress files using gzip.
Example: gzip file
gunzip: Decompress gzip files.
Example: gunzip file.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment