You are on page 1of 1

LINUXGUIDEHQ.

COM
Linux Commands Cheat Sheet
Hardware Information Searching File Commands Directory Navigation

dmesg show bootup messages grep [pattern] search for a specific pattern in a ls list files in directory cd .. move up one level in the directory
[file_name] file tree structure
cat /proc/cpuinfo show CPU information ls -a list all files, including hidden
grep -r [pattern] search recursively for a specific cd change directory to $HOME
free -h show free and used memory (-m flag [directory_name] pattern in a directory pwd show the directory currently
indicates memory in MB) working in cd /chosen/directory change to specified directory
locate [name] find all files and directories by a
lshw list information about hardware specific name mkdir [directory] create a new directory
configuration
find [/folder/location] list names that begin with [a] in rm [file_name] remove a file
lsblk list information about block devices -name [a] [/folder/location]
rm -r [directory_name] remove a directory recursively
lspci -tv show PCI devices in a tree-like diagram find [/folder/location] list files larger than 100M in a
-size [+100M] particular folder rm -rf [directory_name] remove a directory recursively Users
lsusb -tv show USB devices in a tree-like without requiring confirmation
diagram
id show details of the active user
cp [file_name1] [file_name2] copy the contents of the first file to
dmidecode show hardware information from the the second file
last show the last logins onto the
BIOS
system
cp -r [directory_name1] recursively copy the contents of the
hdparm -i /dev/[disk] show information about disk data [directory_name2] first directory into the second
who show who is logged into the system
File Transfer directory
hdparm -tT /dev/[disk] conduct a read speed test on disk
w show who is logged in and their
mv [file_name1] rename file_name1 to file_name2
activity
badblocks -s /dev/[disk] test for unreadable blocks on disk scp [file_name.txt] securely copy a specific file to a [file_name2]
[server/tmp] server directory
groupadd add a new group
ln -s /path/to/[file_name] create a symbolic link to a file
[group_name]
rsync -a synchronize the contents of a [link_name]
[/your/directory] specific directory with a backup
adduser [user_name] add new user
[/backup/] directory touch [file_name] create a new file

usermod -aG add a user to a group


more [file_name] show the contents of a file
File Compression [group_name]
[user_name]
head [file_name] show the first 10 lines of a file
tar cf [compressed_file. create an archived file from a file userdel [user_name] delete a user
tar] [file_name] tail [file_name] show the last 10 lines of a file
Process Related usermod use for changing / modifying user
tar xf [compressed_file. extract archived file gpg -c [file_name] encrypt a file
information
tar]
ps show a snapshot of active gpg [file_name.gpg] decrypt a file
tar czf create a gzip compressed tar file processes
[compressed_file.tar.gz] wc print the number of words, lines,
pstree show processes as a tree and bytes in a file
gzip [file_name] compress a file with the .gz
extension pmap shows a memory usage map of
processes Disk Usage
top show all running processes
df -h show free and used space on
kill [process_id] kill a process under a given ID System Information mounted systems

Package Installation pkill [proc_name] kill a process under the specified df -i show free inodes on mounted
uname -r show system information
name filesystems
yum search find a package by a related uname -a show kernel release information
killall [proc_name] kill all processes labelled proc fdisk -l show disk partitions, sizes, and
[keyword] keyword
uptime show how long the system has been types
bg list and resume stopped jobs in
yum info show package information and running, including load average
the background du -ah show disk usage for all files and
[package_name] summary
hostname show system hostname directory
fg bring the most recent suspended
yum install install a package using the YUM job to the foreground
hostname -i show the IP address of the system du -sh show disk usage of current
[package_name. package manager
directory
rpm] fg [job] bring a particular job to the
last reboot show system reboot history
foreground findmnt show target mount point for all
dnf install install a package using the DNF
date show current time and date filesystems
[package_name. package manager lsof list files opened by processes
rpm]
timedatectl query and change the system clock mount [device_path] mount a device
[mount_point]
rpm -i install an rpm package from a local
[package_name. file cal show current calender month and
rpm] day

rpm -e w show logged in users in the system


[package_name. remove an rpm package File Permission whoami show user you are using
rpm]

finger show information about a user


Keyboard Shortcuts
tar zxvf chmod 777 [file_name] give read, write, and execute
[source_code.tar.gz] install software from source code [username]
permission to everyone
cd [source_code] Ctrl + C kill current process running in the
./configure chmod 755 [file_name] give full permission to owner, and terminal
make read and execute permission to
make install group and others Ctrl + Z stop current process (can be
resumed in the foreground with fg
chmod 766 [file_name] give full permission to owner, and or in the background with bg)
read and write permission to
group and others
Network
Ctrl + W cut one word before the cursor and
add it to clipboard
chown [user] change the file ownership ip addr show show IP addresses and network
SSH Login [file_name] interfaces Ctrl + U cut part of the line before the
cursor and add it to clipboard
chown [user]: [group] change the owner and group ip address add assign an IP address to interface
ssh user@host connect to host as user [file_name] ownership of a file [IP_address] eth0 Ctrl + K cut part of the line after the cursor
and add it to clipboard
ssh host securely connect to host via SSH ifconfig show IP addresses of all network
default port 22 interfaces Ctrl + Y paste from clipboard

ssh -p [port] user@host connect to host using a particular netstat -pnltu show active (listening) ports Ctrl + R recall last command that matches
port the provided characters
netstat -nutlp show tcp and udp ports and their
telnet host connect to host via telnet default programs Ctrl + O run the previously recalled
port 23 command
whois [domain] show more information about a
domain Ctrl + G exit command history without
running a command
dig [domain] show DNS information about a
domain !! repeat the last command

dig -x host reverse lookup on domain exit log out of current session

dig -x reverse lookup of an IP address


[ip_address]

host [domain] do an IP lookup for a domain

hostname -I show the local IP address

wget [file_name] download a file from a domain

You might also like