Docsity

Linux Commands Cheat Sheet: Essential Linux Commands and Usage, Slides of Engineering Science and Technology

Toggle sidebar
bg1
Linux Commands Cheat Sheet
show bootup messages
show CPU information
show free and used memory (-m flag
indicates memory in MB)
list information about hardware
configuration
list information about block devices
show PCI devices in a tree-like diagram
show USB devices in a tree-like
diagram
show hardware information from the
BIOS
show information about disk data
conduct a read speed test on disk
test for unreadable blocks on disk
dmesg
cat /proc/cpuinfo
free -h
lshw
lsblk
lspci -tv
lsusb -tv
dmidecode
hdparm -i /dev/[disk]
hdparm -tT /dev/[disk]
badblocks -s /dev/[disk]
Hardware Information
File Transfer
Searching File Commands Directory Navigation
Users
grep [pattern]
[file_name]
grep -r [pattern]
[directory_name]
locate [name]
find [/folder/location]
-name [a]
find [/folder/location]
-size [+100M]
search for a specific pattern in a
file
search recursively for a specific
pattern in a directory
find all files and directories by a
specific name
list names that begin with [a] in
[/folder/location]
list files larger than 100M in a
particular folder
ls
ls -a
pwd
mkdir [directory]
rm [file_name]
rm -r [directory_name]
rm -rf [directory_name]
cp [file_name1] [file_name2]
cp -r [directory_name1]
[directory_name2]
mv [file_name1]
[file_name2]
ln -s /path/to/[file_name]
[link_name]
touch [file_name]
more [file_name]
head [file_name]
tail [file_name]
gpg -c [file_name]
gpg [file_name.gpg]
wc
list files in directory
list all files, including hidden
show the directory currently
working in
create a new directory
remove a file
remove a directory recursively
remove a directory recursively
without requiring confirmation
copy the contents of the first file to
the second file
recursively copy the contents of the
first directory into the second
directory
rename file_name1 to file_name2
create a symbolic link to a file
create a new file
show the contents of a file
show the first 10 lines of a file
show the last 10 lines of a file
encrypt a file
decrypt a file
print the number of words, lines,
and bytes in a file
cd ..
cd
cd /chosen/directory
move up one level in the directory
tree structure
change directory to $HOME
change to specified directory
SSH Login
Disk Usage
Keyboard Shortcuts
System Information
Network
Process Related
File Permission
Package Installation
File Compression
scp [file_name.txt]
[server/tmp]
rsync -a
[/your/directory]
[/backup/]
securely copy a specific file to a
server directory
synchronize the contents of a
specific directory with a backup
directory
ssh user@host
ssh host
ssh -p [port] user@host
telnet host
id
last
who
w
groupadd
[group_name]
adduser [user_name]
usermod -aG
[group_name]
[user_name]
userdel [user_name]
usermod
show details of the active user
show the last logins onto the
system
show who is logged into the system
show who is logged in and their
activity
add a new group
add new user
add a user to a group
delete a user
use for changing / modifying user
information
show free and used space on
mounted systems
show free inodes on mounted
filesystems
show disk partitions, sizes, and
types
show disk usage for all files and
directory
show disk usage of current
directory
show target mount point for all
filesystems
mount a device
df -h
df -i
fdisk -l
du -ah
du -sh
findmnt
mount [device_path]
[mount_point]
tar cf [compressed_file.
tar] [file_name]
tar xf [compressed_file.
tar]
tar czf
[compressed_file.tar.gz]
gzip [file_name]
uname -r
uname -a
uptime
hostname
hostname -i
last reboot
date
timedatectl
cal
w
whoami
finger
[username]
show system information
show kernel release information
show how long the system has been
running, including load average
show system hostname
show the IP address of the system
show system reboot history
show current time and date
query and change the system clock
show current calender month and
day
show logged in users in the system
show user you are using
show information about a user
Ctrl + C
Ctrl + Z
Ctrl + W
Ctrl + U
Ctrl + K
Ctrl + Y
Ctrl + R
Ctrl + O
Ctrl + G
!!
exit
kill current process running in the
terminal
stop current process (can be
resumed in the foreground with fg
or in the background with bg)
cut one word before the cursor and
add it to clipboard
cut part of the line before the
cursor and add it to clipboard
cut part of the line after the cursor
and add it to clipboard
paste from clipboard
recall last command that matches
the provided characters
run the previously recalled
command
exit command history without
running a command
repeat the last command
log out of current session
ps
pstree
pmap
top
kill [process_id]
pkill [proc_name]
killall [proc_name]
bg
fg
fg [job]
lsof
show a snapshot of active
processes
show processes as a tree
shows a memory usage map of
processes
show all running processes
kill a process under a given ID
kill a process under the specified
name
kill all processes labelled proc
list and resume stopped jobs in
the background
bring the most recent suspended
job to the foreground
bring a particular job to the
foreground
list files opened by processes
create an archived file from a file
extract archived file
create a gzip compressed tar file
compress a file with the .gz
extension
find a package by a related
keyword
show package information and
summary
install a package using the YUM
package manager
install a package using the DNF
package manager
install an rpm package from a local
file
remove an rpm package
install software from source code
yum search
[keyword]
yum info
[package_name]
yum install
[package_name.
rpm]
dnf install
[package_name.
rpm]
rpm -i
[package_name.
rpm]
rpm -e
[package_name.
rpm]
tar zxvf
[source_code.tar.gz]
cd [source_code]
./configure
make
make install
ip addr show
ip address add
[IP_address]
ifconfig
netstat -pnltu
netstat -nutlp
whois [domain]
dig [domain]
dig -x host
dig -x
[ip_address]
host [domain]
hostname -I
wget [file_name]
show IP addresses and network
interfaces
assign an IP address to interface
eth0
show IP addresses of all network
interfaces
show active (listening) ports
show tcp and udp ports and their
programs
show more information about a
domain
show DNS information about a
domain
reverse lookup on domain
reverse lookup of an IP address
do an IP lookup for a domain
show the local IP address
download a file from a domain
chmod 777 [file_name]
chmod 755 [file_name]
chmod 766 [file_name]
chown [user]
[file_name]
chown [user]: [group]
[file_name]
give read, write, and execute
permission to everyone
give full permission to owner, and
read and execute permission to
group and others
give full permission to owner, and
read and write permission to
group and others
change the file ownership
change the owner and group
ownership of a file
connect to host as user
securely connect to host via SSH
default port 22
connect to host using a particular
port
connect to host via telnet default
port 23

Partial preview of the text

Download Linux Commands Cheat Sheet: Essential Linux Commands and Usage and more Slides Engineering Science and Technology in PDF only on Docsity!

Linux Commands Cheat Sheet

show bootup messages show CPU information show free and used memory (-m flagindicates memory in MB) list information about hardwareconfiguration list information about block devices show PCI devices in a tree-like diagram show USB devices in a tree-like diagram show hardware information from the BIOS show information about disk data conduct a read speed test on disk test for unreadable blocks on disk

dmesg cat /proc/cpuinfo free -h

lshw

lsblk lspci -tv lsusb -tv

dmidecode

hdparm -i /dev/[disk] hdparm -tT /dev/[disk] badblocks -s /dev/[disk]

Hardware Information

File Transfer

Searching File Commands Directory Navigation

Users

grep [pattern][file_name] grep -r [pattern][directory_name] locate [name] find [/folder/location]-name [a] find [/folder/location]-size [+100M]

search for a specific pattern in afile search recursively for a specificpattern in a directory find all files and directories by aspecific name list names that begin with [a] in[/folder/location] list files larger than 100M in aparticular folder

ls ls -a pwd mkdir [directory] rm [file_name] rm -r [directory_name] rm -rf [directory_name] cp [file_name1] [file_name2] cp -r [directory_name1][directory_name2]

mv [file_name1] [file_name2] ln -s /path/to/[file_name] [link_name] touch [file_name] more [file_name] head [file_name] tail [file_name] gpg -c [file_name] gpg [file_name.gpg] wc

list files in directory list all files, including hidden show the directory currentlyworking in create a new directory remove a file remove a directory recursively remove a directory recursivelywithout requiring confirmation copy the contents of the first file tothe second file recursively copy the contents of thefirst directory into the second directory rename file_name1 to file_name create a symbolic link to a file

create a new file show the contents of a file show the first 10 lines of a file show the last 10 lines of a file encrypt a file decrypt a file print the number of words, lines,and bytes in a file

cd .. cd cd /chosen/directory

move up one level in the directorytree structure change directory to $HOME change to specified directory

SSH Login

Disk Usage

Keyboard Shortcuts

System Information

Network

Process Related

File Permission

Package Installation

File Compression

scp [file_name.txt][server/tmp] rsync -a[/your/directory] [/backup/]

securely copy a specific file to aserver directory synchronize the contents of aspecific directory with a backup directory

ssh user@host ssh host ssh -p [port] user@host telnet host

id last who w groupadd[group_name] adduser [user_name] usermod -aG [group_name][user_name] userdel [user_name] usermod

show details of the active user show the last logins onto thesystem show who is logged into the system show who is logged in and theiractivity add a new group add new user add a user to a group

delete a user use for changing / modifying userinformation

show free and used space onmounted systems show free inodes on mountedfilesystems show disk partitions, sizes, andtypes show disk usage for all files anddirectory show disk usage of currentdirectory show target mount point for allfilesystems mount a device

df -h df -i fdisk -l du -ah du -sh findmnt mount [device_path][mount_point]

tar cf [compressed_file. tar] [file_name] tar xf [compressed_file. tar] tar czf [compressed_file.tar.gz] gzip [file_name]

uname -r uname -a uptime hostname hostname -i last reboot date timedatectl cal w whoami finger[username]

show system information show kernel release information show how long the system has beenrunning, including load average show system hostname show the IP address of the system show system reboot history show current time and date query and change the system clock show current calender month and day show logged in users in the system show user you are using show information about a user Ctrl + C Ctrl + Z

Ctrl + W Ctrl + U Ctrl + K Ctrl + Y Ctrl + R Ctrl + O Ctrl + G !! exit

kill current process running in theterminal stop current process (can beresumed in the foreground with fg or in the background with bg) cut one word before the cursor and add it to clipboard cut part of the line before the cursor and add it to clipboard cut part of the line after the cursor and add it to clipboard paste from clipboard recall last command that matchesthe provided characters run the previously recalledcommand exit command history withoutrunning a command repeat the last command log out of current session

ps pstree pmap top kill [process_id] pkill [proc_name] killall [proc_name] bg fg fg [job] lsof

show a snapshot of activeprocesses show processes as a tree shows a memory usage map of processes show all running processes kill a process under a given ID kill a process under the specifiedname kill all processes labelled proc list and resume stopped jobs in the background bring the most recent suspended job to the foreground bring a particular job to the foreground list files opened by processes

create an archived file from a file extract archived file create a gzip compressed tar file compress a file with the .gzextension

find a package by a relatedkeyword show package information andsummary install a package using the YUMpackage manager

install a package using the DNFpackage manager

install an rpm package from a local file

remove an rpm package

install software from source code

yum search[keyword] yum info[package_name] yum install[package_name. rpm] dnf install[package_name. rpm] rpm -i [package_name.rpm] rpm -e[package_name. rpm] tar zxvf[source_code.tar.gz] cd [source_code]./configure make make install

ip addr show ip address add [IP_address] ifconfig netstat -pnltu netstat -nutlp whois [domain] dig [domain] dig -x host dig -x[ip_address] host [domain] hostname -I wget [file_name]

show IP addresses and network interfaces assign an IP address to interface eth show IP addresses of all network interfaces show active (listening) ports show tcp and udp ports and theirprograms show more information about adomain show DNS information about adomain reverse lookup on domain reverse lookup of an IP address do an IP lookup for a domain show the local IP address download a file from a domain

chmod 777 [file_name] chmod 755 [file_name]

chmod 766 [file_name]

chown [user] [file_name] chown [user]: [group] [file_name]

give read, write, and execute permission to everyone give full permission to owner, and read and execute permission togroup and others give full permission to owner, andread and write permission to group and others change the file ownership change the owner and group connect to host as user ownership of a file securely connect to host via SSHdefault port 22 connect to host using a particularport connect to host via telnet defaultport 23