main_linux-commands-cheat-sheet
main_linux-commands-cheat-sheet
Sheet Searching
Hardware Information
File Commands Directory Navigation
grep [pattern] search for a specific pattern ls list files in cd .. move up one level in the
dmesg show [file_name] in a file directory directory tree structure
cat /proc/cpuinfo show CPU bootup ls -a list all files, including
information find [/folder/location] list names that begin with rm [file_name] remove
hidden a
grep -r [pattern] search recursively for a cd change directory to
lsblk list information about block -name [a] [a] in [/folder/location] file
free -h show free and used memory (- [directory_name] specific pattern in a pwd show the directory $HOME
devices rm -r remove a directory
m flag indicates memory in MB) directory currently working in cd /chosen/directory change to specified
[directory_name] recursively
locate [name] find all files and directories directory
lshw list information about by a specific name mkdir [directory] create a new
hardware configuration directory
lspci -tv show PCI devices in a tree-like find [/folder/location] list files larger than 100M
diagram -size [+100M] in a particular folder rm -rf [directory_name] remove a directory
Users
lsusb -tv show USB devices in a recursively without
tree-like diagram requiring confirmation
id show details of the active
cp [file_name1] [file_name2] copy the contents of the first file
user
dmidecode show hardware information to
the second file last show the last logins onto
from the BIOS
the system
cp -r [directory_name1] recursively copy the contents
hdparm -i /dev/[disk] show information about disk [directory_name2] of the first directory into the
data second directory who show who is logged into the
File Transfer system
hdparm -tT /dev/[disk] conduct a read speed test on
disk w show who is logged in and
mv [file_name1] rename file_name1 to
file_name2 their activity
badblocks -s /dev/[disk] test for unreadable blocks on scp [file_name.txt] securely copy a specific [file_name2]
disk [server/tmp] file to a server directory
groupadd add a new
ln -s /path/to/[file_name] create a symbolic link to
head [file_name] show the first 10 lines of [group_name] group
rsync -a synchronize the contents [link_name] a file
a file
[/your/directory] of a specific directory with
adduser [user_name] add new
[/backup/] a backup directory touch [file_name] create a new
Process Related file usermod
user
use for changing / modifying
tar xf [compressed_file. extract archived gpg -c [file_name] encrypt a usermod -aG add a user to a
more [file_name] show the contents of a user information
tar] File Compression
file file
file [group_name] group
ps show a snapshot of gpg [file_name.gpg] decrypt a [user_name]
active processes file
tar czf create a gzip compressed
tar cf [compressed_file. create
tar file an archived file from wc print the number of words, delete a
[compressed_file.tar.gz] userdel [user_name]
tar] [file_name] a file tail [file_name] show the last 10 lines of
show processes as a lines, and bytes in a file user
pstree a file
tree
Disk Usage
top show all running
processes
remove an rpm
package
File Permission whoami show user you are
using
rpm -e w show logged in users in the Ctrl + C kill current process running
chmod 755 [file_name] give full permission to owner, system in the terminal
[package_name.
rpm] and read and execute
permission to group and Ctrl + Z stop current process (can be
tar zxvf
others finger show information about a Keyboard resumed
Shortcuts
in the foreground
chmod 777 [file_name] give read, write, and
chmod 766 [file_name] give full permission to owner, [username] user with fg or in the background
[source_code.tar.gz] install software from source execute permission to
code and read and write with bg)
cd [source_code] everyone
permission to group and Network Ctrl + W cut one word before the cursor
./configure
others and add it to clipboard
make
make install chown [user] change the file ip addr show IP addresses and
SSH Login [file_name] ownership show network interfaces Ctrl + cut part of the line before
U the cursor and add it to
chown [user]: [group] change the owner and ip address add assign an IP address to clipboard
ssh user@host connect to host as [file_name] group ownership of a file [IP_address] interface eth0 Ctrl + K cut part of the line after the
user cursor and add it to clipboard
ssh host securely connect to host via ifconfig show IP addresses of all
SSH default port 22 network interfaces Ctrl + Y paste from
clipboard
recall last command that
matches the provided
netstat -nutlp show tcp and udp ports and characters
telnet host connect to host via telnet their programs Ctrl + O run the previously
default port 23 recalled command
whois [domain] show more information
connect to host using a about a domain Ctrl + G exit command history
ssh -p [port] user@host netstat -pnltu show active (listening) Ctrl + R
particular port ports without running a
dig [domain] show DNS information command
about a domain !! repeat the last
command