Linux Commands Cheat Sheet
1. File & Directory Management
`ls` → List files in a directory.
`pwd` → Show current directory path.
`cd /path/to/directory` → Change directory.
`mkdir directory_name` → Create a new directory.
`rm file_name` → Delete a file.
`rm -r directory_name` → Delete a directory and its contents.
`cp source destination` → Copy a file.
`cp -r source destination` → Copy a directory.
`mv old_name new_name` → Rename/move a file or directory.
2. File Permissions & Ownership
`chmod 755 file_name` → Change file permissions.
`chown user:group file_name` → Change file ownership.
`ls -l` → View file permissions.
3. Process & System Monitoring
`ps aux` → Show running processes.
`top` or `htop` → Display system resource usage.
`kill PID` → Kill a process by ID.
`df -h` → Show disk space usage.
`du -sh /path/to/directory` → Show directory size.
`free -m` → Show memory usage.
4. User Management
`whoami` → Show current user.
`who` → Show logged-in users.
`adduser username` → Create a new user.
`passwd username` → Change user password.
`usermod -aG group_name username` → Add a user to a group.
5. Networking Commands
`ip a` or `ifconfig` → Show network interfaces.
`ping google.com` → Check network connectivity.
`netstat -tulnp` → Show open ports.
`scp file user@remote:/path` → Secure copy a file to another server.
`ssh user@remote` → Connect to a remote server via SSH.
6. Package Management
**Ubuntu/Debian:**
`apt update && apt upgrade` → Update and upgrade packages.
`apt install package_name` → Install a package.
`apt remove package_name` → Remove a package.
**RHEL/CentOS:**
`yum update` → Update system packages.
`yum install package_name` → Install a package.
`yum remove package_name` → Remove a package.
7. Searching & Text Processing
`grep "text" file.txt` → Search for text in a file.
`find /path -name "file.txt"` → Search for a file by name.
`awk '{print $1}' file.txt` → Extract first column of a file.
`sed 's/old/new/g' file.txt` → Replace text in a file.
8. Archiving & Compression
`tar -cvf archive.tar /path/to/files` → Create a tar archive.
`tar -xvf archive.tar` → Extract a tar archive.
`gzip file.txt` → Compress a file.
`gunzip file.txt.gz` → Decompress a file.
9. System Control & Logs
`reboot` → Restart the system.
`shutdown -h now` → Shut down the system.
`systemctl start/stop/restart service_name` → Manage services.
`journalctl -xe` → View system logs.
`tail -f /var/log/syslog` → Monitor system logs in real-time.