Linux Commands Cheat Sheet
The commands used daily for filesystem navigation, permissions, processes, networking, storage, and service management on any Linux distribution.
Files & Directories
ls -lahList all files (incl. hidden) with sizes and permissionscd -Switch to the previous working directorycp -r src/ dest/Copy a directory recursivelymv old newRename or move a file/directoryrm -rf dir/Remove a directory and its contents (irreversible)find / -name '*.log' -mtime -1Find .log files modified in the last daydu -sh */Show the disk usage of each subdirectoryln -s target linknameCreate a symbolic linkPermissions & Ownership
chmod 755 file.shSet rwxr-xr-x (owner rwx, group/others r-x)chmod u+x file.shAdd execute permission for the owner onlychown user:group fileChange owner and group of a filechown -R user:group dir/Change ownership recursivelyumask 022Set default permission mask for new files/directoriesgetfacl fileShow extended ACLs on a fileProcesses & Services
ps aux | grep nginxFind running processes matching 'nginx'top / htopLive CPU/memory usage per processkill -9 PIDForce-kill a process by PIDsystemctl status sshdShow a service's current statussystemctl restart nginxRestart a systemd-managed servicesystemctl enable --now nginxEnable a service on boot and start it nowjournalctl -u nginx -fFollow live logs for a specific serviceNetworking
ip aShow all network interfaces and their IP addressesss -tulnpShow listening TCP/UDP ports and owning processescurl -I https://example.comFetch only the HTTP response headersping -c 4 hostSend 4 ICMP echo requests to a hosttraceroute hostTrace the network path to a hostscp file user@host:/pathCopy a file to a remote host over SSHDisk & Storage
df -hShow disk space usage for all mounted filesystemslsblkList block devices and their mount pointsmount /dev/sdb1 /mntMount a device to a directoryfdisk -lList partition tables on all disksvgs / lvs / pvsList LVM volume groups / logical volumes / physical volumesPackage Management
apt update && apt upgradeRefresh package lists and upgrade (Debian/Ubuntu)dnf install nginxInstall a package (RHEL/Rocky/Fedora)dpkg -l | grep nginxCheck if a package is installed (Debian/Ubuntu)rpm -qa | grep nginxCheck if a package is installed (RHEL family)