Bash Cheat Sheet
COMMAND
DESCRIPTION
- |pwd|Print current working directory.
- |ls|List directory contents.
- |cd dir|Change directory.
- |mkdir dir|Create a directory.
- |touch file|Create an empty file.
- |cp src dst|Copy files or directories.
- |mv src dst|Move or rename files.
- |rm file|Remove files.
- |stat file|Show file metadata.
- |cat file|Print file contents.
- |less file|View file interactively.
- |head file|Show first lines.
- |tail file|Show last lines.
- |grep pattern file|Search text.
- |rg pattern|Fast recursive search.
- |sed 's/a/b/'|Edit text streams.
- |awk '{print $1}'|Column-based processing.
- |sort|Sort lines.
- |uniq|Filter duplicate lines.
- |wc|Count lines, words, bytes.
- |cut -d: -f1|Extract columns.
- |tr a b|Translate characters.
- |paste a b|Merge lines.
- |column -t|Align output in columns.
- |pr file|Pretty-print text.
- |find .|Search for files.
- |chmod +x file|Change permissions.
- |chown user file|Change ownership.
- |sudo cmd|Run as root.
- |ps aux|List processes.
- |top|Process monitor.
- |htop|Enhanced process viewer.
- |kill PID|Terminate process.
- |ss|Inspect sockets.
- |df|Filesystem usage.
- |du|Directory sizes.
- |lsblk|Block devices.
- |mount|Mount filesystem.
- |umount|Unmount filesystem.
- |tar -cf a.tar dir|Create tar archive.
- |tar -xf a.tar|Extract tar archive.
- |zip -r a.zip dir|Create zip archive.
- |unzip a.zip|Extract zip archive.
- |curl URL|Fetch URL.
- |wget URL|Download file.
- |rsync src dst|Sync files.
- |ssh user@host|Remote login.
- |scp file host:/path|Copy over SSH.
- |journalctl|Logs from systemd journal.
- |dmesg|Diagnostic messages from kernel.
- |nmcli device status|Network devices.
- |bluetoothctl|Bluetooth manager.
- |systemctl status svc|Service status.
- |systemctl start svc|Start service.
- |systemctl stop svc|Stop service.
- |apt install pkg|Install package.
- |man cmd|View manual.
- |apropos keyword|Search man pages.
- |uname -a|Kernel info.
- |uptime|System run time.
- |hostnamectl|Hostname config.
- |lshw|Hardware info.
- |modprobe module|Load kernel module.
- |env|Environment variables.
- |export VAR=value|Set variable.
- |set -o pipefail|Propagate error from any pipeline.
- |bash script.sh|Run script with Bash.
- |./script.sh|Run executable.