This document provides a cheat sheet of essential Linux operations organized into various categories. It lists common commands for file and directory operations, file viewing and manipulation, permissions and ownership, process management, system information and performance monitoring, networking, package management, file compression and archiving, text processing, disk and file system management, user and group management, system services, system logs and monitoring, security, SSH, scripting and automation, disk and storage management, networking and firewalls, text processing and analysis, archive and compression, disk and partition management, process monitoring and control, remote management, system services and job scheduling, monitoring and performance, system information and hardware details, and logs and auditing. The cheat sheet serves as a quick
This document provides a cheat sheet of essential Linux operations organized into various categories. It lists common commands for file and directory operations, file viewing and manipulation, permissions and ownership, process management, system information and performance monitoring, networking, package management, file compression and archiving, text processing, disk and file system management, user and group management, system services, system logs and monitoring, security, SSH, scripting and automation, disk and storage management, networking and firewalls, text processing and analysis, archive and compression, disk and partition management, process monitoring and control, remote management, system services and job scheduling, monitoring and performance, system information and hardware details, and logs and auditing. The cheat sheet serves as a quick
This document provides a cheat sheet of essential Linux operations organized into various categories. It lists common commands for file and directory operations, file viewing and manipulation, permissions and ownership, process management, system information and performance monitoring, networking, package management, file compression and archiving, text processing, disk and file system management, user and group management, system services, system logs and monitoring, security, SSH, scripting and automation, disk and storage management, networking and firewalls, text processing and analysis, archive and compression, disk and partition management, process monitoring and control, remote management, system services and job scheduling, monitoring and performance, system information and hardware details, and logs and auditing. The cheat sheet serves as a quick
This document provides a cheat sheet of essential Linux operations organized into various categories. It lists common commands for file and directory operations, file viewing and manipulation, permissions and ownership, process management, system information and performance monitoring, networking, package management, file compression and archiving, text processing, disk and file system management, user and group management, system services, system logs and monitoring, security, SSH, scripting and automation, disk and storage management, networking and firewalls, text processing and analysis, archive and compression, disk and partition management, process monitoring and control, remote management, system services and job scheduling, monitoring and performance, system information and hardware details, and logs and auditing. The cheat sheet serves as a quick
● Change Directory: cd /path/to/directory ● Print Working Directory: pwd ● Create a New Directory: mkdir directory_name ● Remove a Directory: rmdir directory_name ● Create a New File: touch filename ● Copy Files or Directories: cp source destination ● Move or Rename Files or Directories: mv source destination ● Delete Files: rm filename ● Delete Directories and Their Contents: rm -r directory_name
2. File Viewing and Manipulation
● Display File Content: cat filename
● Display the Beginning of Files: head filename ● Display the End of Files: tail filename ● Page Through Text Files: less filename ● Edit Files (using nano editor): nano filename ● Edit Files (using vi/vim editor): vi/vim filename ● Search Text Within Files: grep 'search_string' filename ● Find and Replace Text in File (using sed): sed -i 's/original/replacement/g' filename ● Count Words, Lines, and Characters: wc filename ● awk for Pattern Scanning and Processing: awk '/pattern/ {action}' file ● sed for Stream Editing: sed 's/old/new/g' file ● join for Joining Lines on a Common Field: join file1 file2
● Change Group Ownership: chgrp group filename ● View File Permissions and Ownership: ls -l filename ● umask for Setting Default Permissions: umask 022 ● setfacl for Setting File ACLs: setfacl -m u:username:rwx filename
4. Process Management
● Display Active Processes: ps
● Display Active Processes (detailed): ps aux ● Kill a Process by PID: kill pid ● Kill a Process by Name: pkill process_name ● Start a Process in the Background: command & ● Bring a Background Process to Foreground: fg ● Stop a Process Temporarily: Ctrl + Z
5. System Information and Performance Monitoring
● Display Current Date and Time: date
● Display Disk Usage: df ● Display Disk Space Used by Directory: du /path/to/directory ● Display Memory Usage: free ● Monitor System Activity (real-time): top or htop ● Display System Information: uname -a ● Display Kernel Version: uname -r ● Display CPU Information: lscpu ● Display PCI Devices: lspci
6. Networking
● Display Network Configuration: ifconfig
● Ping a Host to Check Connectivity: ping hostname_or_ip ● Display Routing Table: route ● Network Scanning and Host Discovery: nmap ip_address ● Download Files from the Internet: wget url ● Transfer Files Over SSH: scp source user@host:destination
7. Package Management (Debian-based systems)
By: Waleed Mousa
● Update Package Index: sudo apt update ● Upgrade Packages: sudo apt upgrade ● Install a Package: sudo apt install package_name ● Remove a Package: sudo apt remove package_name ● Search for a Package: apt search keyword
8. Package Management (RPM-based systems)
● Update Package Index: sudo yum check-update
● Upgrade Packages: sudo yum update ● Install a Package: sudo yum install package_name ● Remove a Package: sudo yum remove package_name ● Search for a Package: yum search keyword
9. File Compression and Archiving
● Compress Files (tar): tar czvf archive_name.tar.gz
● Compare Two Files: diff file1 file2 ● Merge Lines of Two Files: paste file1 file2 ● Display Line Numbers: nl filename ● Cut Portions of Each Line: cut -d'delimiter' -f fields filename
11. Disk and File System Management
● Check Disk Space: df -h
● Check Inode Usage: df -i ● Display Mounted File Systems: mount | column -t ● Check File System Disk Space Usage: du -sh ● Format a File System: mkfs -t ext4 /dev/sdxn ● Check and Repair a File System: fsck /dev/sdxn
By: Waleed Mousa
12. User and Group Management
● Add a New User: useradd username
● Delete a User: userdel username ● Change User Password: passwd username ● Add a New Group: groupadd groupname ● Delete a Group: groupdel groupname ● Add User to Group: usermod -aG groupname username ● usermod for Modifying User Account: usermod -aG groupname username ● groupadd for Adding a New Group: groupadd groupname ● groupdel for Deleting a Group: groupdel groupname ● groups for Displaying User Groups: groups username ● id for User Identification: id username
13. System Services and Daemons
● Start a Service: systemctl start service_name
● Stop a Service: systemctl stop service_name ● Restart a Service: systemctl restart service_name ● Enable a Service to Start on Boot: systemctl enable service_name ● Disable a Service from Starting on Boot: systemctl disable service_name ● Check Service Status: systemctl status service_name
14. System Logs and Monitoring
● Display System Log Messages: dmesg
● Tail a Log File: tail -f /var/log/syslog ● Search Through Log Files: grep 'search_term' /var/log/filename ● Monitor System Logs in Real-time: journalctl -f
15. Security and Permissions
● Add User to sudoers: usermod -aG sudo username
● Generate SSH Keys: ssh-keygen -t rsa -b 4096 ● Set up a Firewall with UFW: ufw enable and ufw allow 22/tcp
By: Waleed Mousa
16. SSH and Remote Connection
● SSH to a Remote Server: ssh user@hostname
● Copy Files Over SSH: scp file user@hostname:/path ● SSH Port Forwarding: ssh -L local_port:remote_address:remote_port user@ssh_server ● Terminate an SSH Session: exit
17. Scripting and Automation
● Executing a Shell Script: bash script.sh
● Setting Up a Cron Job: crontab -e ● Running a Command at a Specific Time: at now + 5 minutes -f script.sh ● Writing Bash Scripts: #!/bin/bash at the start of scripts ● Making Scripts Executable: chmod +x script.sh ● Running Scripts at Specific Times with Cron: 0 * * * * /path/to/script.sh
18. Disk and Storage Management
● List Block Devices: lsblk
● Display Disk Usage: du -h ● Monitor Disk I/O: iotop ● Create a Swap File: fallocate -l 1G /swapfile ● Mount a File System: mount /dev/sdxn /mnt/directory
● awk for Text Processing: awk '{print $1}' filename
By: Waleed Mousa
● sed for Stream Editing: sed 's/old/new/g' filename ● tr for Character Transformation: tr '[:lower:]' '[:upper:]' < filename ● uniq for Uniqueness in Text Lines: sort filename | uniq ● diff for File Differences: diff file1 file2 ● patch for Applying Differences: patch < diff_file
21. Archive and Compression
● tar for Archiving Files: tar cvf archive_name.tar directory/
● gzip for Compression: gzip filename ● gunzip for Decompression: gunzip filename.gz ● zip for ZIP Archiving: zip archive_name.zip files ● unzip for Extracting ZIP Archives: unzip archive_name.zip
22. Disk and Partition Management
● fdisk for Disk Partitioning: fdisk /dev/sdx
● mkfs for Making File Systems: mkfs -t ext4 /dev/sdxn ● e2fsck for File System Checking: e2fsck /dev/sdxn ● mount for Mounting File Systems: mount /dev/sdxn /mnt/point ● umount for Unmounting File Systems: umount /mnt/point ● df for Disk Space of File Systems: df -h ● du for Disk Usage of Files and Directories: du -sh /path/to/dir
23. Process Monitoring and Control
● ps for Active Processes: ps aux
● top for Real-time Process Monitoring: top ● htop for Interactive Process Monitoring: htop ● kill for Killing Processes: kill pid ● killall for Killing Processes by Name: killall processname ● nohup for Running Commands Persistently: nohup command & ● nice for Setting Process Priority: nice -n 19 command ● renice for Changing Process Priority: renice 19 -p pid
24. SSH and Remote Management
By: Waleed Mousa
● ssh for Remote Login: ssh user@hostname ● scp for Secure Copy over SSH: scp local_file user@hostname:/remote/path ● sftp for Secure File Transfer: sftp user@hostname ● ssh-keygen for SSH Key Generation: ssh-keygen -t rsa ● ssh-copy-id for Copying SSH Key to Server: ssh-copy-id user@hostname
25. System Services and Job Scheduling
● service for Managing Services: service nginx start
● systemctl for Systemd Management: systemctl status nginx ● crontab for Scheduling Cron Jobs: crontab -e ● at for One-time Scheduled Jobs: echo "command" | at now + 2 hours
26. Monitoring and Performance
● vmstat for Virtual Memory Statistics: vmstat 1
● iostat for Input/Output Statistics: iostat ● lsof for Open Files and Ports: lsof -i ● strace for System Call Tracing: strace -p pid ● netstat for Network Statistics: netstat -tulnp ● ss for Socket Statistics: ss -tuln
27. System Information and Hardware Details
● uname for System Information: uname -a
● lscpu for CPU Architecture Information: lscpu ● lsblk for Block Devices Information: lsblk ● lsmem for Memory Information: lsmem ● lsusb for USB Devices Information: lsusb ● lspci for PCI Devices Information: lspci ● hwinfo for Detailed Hardware Information: hwinfo --short
28. Logs and Auditing
● tail for Viewing Log Files: tail -f /var/log/syslog
● journalctl for Systemd Logs: journalctl -u nginx
By: Waleed Mousa
● dmesg for Kernel Messages: dmesg | grep something ● auditd for Auditing System Events: auditctl -l
29. Backup and Restore
● rsync for File Transfer and Synchronization: rsync -av /source/
/destination/ ● dd for Disk Cloning and Backup: dd if=/dev/sdx of=/dev/sdy ● tar for Archiving and Backup: tar cvzf backup.tar.gz /important/data ● restore for Restoring Files from Backup: restore -if backup.tar.gz
30. Virtualization and Containers
● docker for Managing Containers: docker run image_name
● docker-compose for Multi-container Docker Applications: docker-compose up ● virsh for Managing KVM/QEMU Virtual Machines: virsh list --all ● virt-manager for Virtual Machine Management: virt-manager
31. Security and Encryption
● openssl for SSL/TLS Operations: openssl s_client -connect
example.com:443 ● gpg for Encryption and Signing: gpg --encrypt --recipient 'name' file ● fail2ban for Intrusion Prevention: fail2ban-client status sshd
32. Custom Commands and Aliases
● Creating Aliases for Commonly Used Commands: alias ll='ls -la'
● Creating Functions in .bashrc or .bash_profile: function extract() { tar xvf $1; }
33. Performance Tuning and Kernel Parameters
● sysctl for Runtime Kernel Parameters: sysctl -a
● tuned for System Tuning Profiles: tuned-adm active
By: Waleed Mousa
34. Networking and Troubleshooting
● ifconfig for Configuring Network Interfaces: ifconfig eth0
● iwconfig for Configuring Wireless Networks: iwconfig wlan0 ● dhclient for Obtaining IP Address via DHCP: dhclient eth0 ● traceroute for Tracing Network Path: traceroute url_to_website ● nslookup for DNS Querying: nslookup url_to_website ● host for DNS Lookup: host url_to_website ● dig for DNS Lookup and Diagnosis: dig url_to_website ● iptables for Firewall Configuration: iptables -L -n -v ● ip for Advanced IP Addressing and Routing: ip addr add 192.168.1.5 dev eth0 ● traceroute for Tracing Network Path: traceroute url_to_website ● curl for URL Transfer: curl -O url_to_website ● wget for Non-interactive Download: wget url_to_website