Linux commands cheat sheet

Linux & SBC 7 Th01 2022

In this tutorial, you will find commonly used Linux commands as well as a downloadable cheat sheet with syntax and examples.

Linux Commands Cheat Sheet: Definitive List With Examples
Linux command syntax may seem difficult to remember. Use our 2020 Linux Command Cheat Sheet with examples. All the important commands in one pdf.
Linux Command Line Cheat Sheet
A cheat sheet of the commands I use most for Linux, with popup links to man pages.
Linux Command Cheat Sheet
In this Linux/Unix command line cheat sheet, you will learn: Basic Linux commands File Permission commands Environment Variables command User management commands of linux Networking command Process co
CategoryRequirements, Conventions or Software Version Used
SystemAny Linux distro
SoftwareN/A
OtherPrivileged access to your Linux system as root or via the sudo command.
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

File System Navigation

CommandDescription
lsList all the files in a directory
ls -lList all files and their details (owner, mtime, size, etc)
ls -aList all the files in a directory (including hidden files)
pwdShow the present working directory
cdChange directory to some other location
fileView the type of any file

View, Create, Edit, and Delete Files and Directories

CommandDescription
mkdirCreate a new directory
touchCreate a new, empty file, or update the modified time of an existing one
cat > fileCreate a new file with the text you type after
cat fileView the contents of a file
grepView the contents of a file that match a pattern
nano fileOpen a file (or create new one) in nano text editor
vim fileOpen a file (or create new one) in vim text editor
rm or rmdirRemove a file or empty directory
rm -rRemove a directory that isn’t empty
mvMove or rename a file or directory
cpCopy a file or directory
rsyncSynchronize the changes of one directory to another

Search for Files and Directories

CommandDescription
locateQuickly find a file or directory that has been cached
findSeach for a file or directory based on name and other parameters

Basic Administration Commands

CommandDescription
whoamiSee which user you are currently logged in as
sudoExecute a command with root permissions
sudo apt installInstall a package on Debian based systems
sudo dnf installInstall a package on Red Hat based systems
sudo apt removeRemove a package on Debian based systems
sudo dnf removeRemove a package on Red Hat based systems
rebootReboot the system
poweroffShut down the system

Hard Drive and Storage Commands

CommandDescription
df or df -hSee the current storage usage of mounted partitions
sudo fdisk -lSee information for all attached storage devices
duSee disk usage of a directory’s contents
treeView the directory structure for a path
mount and umountMount and unmount a storage device or ISO file

Compression Commands

CommandDescription
tar cf my_dir.tar my_dirCreate an uncompressed tar archive
tar cfz my_dir.tar my_dirCreate a tar archive with gzip compression
gzip fileCompress a file with gzip compression
tar xf fileExtract the contents of any type of tar archive
gunzip file.gzDecompress a file that has gzip compression

Networking Commands

CommandDescription
ip aShow IP address and other information for all active interfaces
ip rShow IP address of default gateway
cat /etc/resolv.confSee what DNS servers your system is configured to use
pingSend a ping request to a network device
tracerouteTrace the network path taken to a device
sshLogin to a remote device with SSH

File Permissions and Ownership

CommandDescription
chmodChange the file permissions for a file or directory
chownChange the owner of a file or directory
chgrpChange the group of a file or directory

User Management Commands

CommandDescription
useraddLow level utility for adding new user accounts
adduserHigh level utility for adding new user accounts
deluserDelete a user account
usermodModify a user account
groupaddCreate a new group
delgroupDelete a group

System Resource Management Commands

CommandDescription
free -mSee how much memory is in use and free
topSee a list of processes and their resource usage
htopA more human readable and interactive version of top
niceStart a new process with a specified priority
reniceChange the nice value of a currently running process
ps aux OR ps -efView all of the currently running processes
kill or killallTerminate a process
kill -9 or killall -9Terminate a process with SIGKILL signal
bgSend a task to the background
fgBring a task to the foreground

Environment Variable Commands

CommandDescription
printenv or printenv variable_nameList all environment variables on a Linux system, or a specific one
whereis and whichFind where a command in PATH is located
export MY_SITE="linuxconfig.org"Set a temporary environment variable (just an example, but use the same syntax)
echo $VARIABLEDisplay the value of a variable
unsetRemove a variable

Kernel Information and Module Management

CommandDescription
uname -aOutput detailed information about your kernel version and architecture
lsmodFind what modules are currently loaded
modinfo module_nameGet information about any particular module
modprobe --remove module_nameRemove a module
modprobe module_nameLoad a module into the kernel

Hardware Information Commands

CommandDescription
lspciSee general information about host bridge, VGA controller, ethernet controller, USB controller, SATA controller, etc.
dmidecodeSee some information about BIOS, motherboard, chassis, etc.
cat /proc/cpuinfoRetrieve processor type, socket, speed, configured flags, etc.
x86info or x86info -aSee information about the CPU
cat /proc/meminfoSee detailed information about system RAM
lshwList all hardware components and see their configuration details
lshw -C memory -shortDetect number of RAM slots used, speed, and size
hwinfoList details for all hardware, including their device files and configuration options
biosdecodeGet some general information about your system’s BIOS
dmidecode -s bios-vendorRetrieve the name of your BIOS vendor with this simple command
lsusbGet a list of USB devices plugged into your system
ls -la /dev/disk/by-id/usb-*Retrieve a list of USB device files
hdparm -I /dev/sdxGet information about your hard drive’s make, model, serial number, firmware version, and configuration
hdparm -tT /dev/sdxShow the speed of an installed hard drive – including cached reads and buffered disk reads
wodim --devicesLocate CD or DVD device file

Tags

Tony Phạm

Là một người thích vọc vạch và tò mò với tất cả các lĩnh vực từ khoa học tự nhiên, lập trình, thiết kế đến ... triết học. Luôn mong muốn chia sẻ những điều thú vị mà bản thân khám phá được.