Linux Command
Linux Command
Hardware Information
Show bootup messages:
dmesg
cat /proc/cpuinfo
free -h
lshw
See information about block devices:
lsblk
lspci -tv
lsusb -tv
dmidecode
hdparm -i /dev/disk
badblocks -s /dev/[device]
Searching
Search for a specific pattern in a file with grep:
grep [pattern] [file_name]
locate [name]
File Commands
List files in the directory:
ls
ls -a
mkdir [directory]
Remove a file:
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]
Create a symbolic link to a file:
ln -s /path/to/[file_name] [link_name]
touch [file_name]
more [file_name]
cat [file_name]
head [file_name]
tail [file_name]
Encrypt a file:
gpg -c [file_name]
Decrypt a file:
gpg [file_name.gpg]
wc
Directory Navigation
Move up one level in the directory tree structure:
cd ..
cd
cd /chosen/directory
File Compression
Archive an existing file:
gzip [file_name]
File Transfer
Copy a file to a server directory securely:
Synchronize the contents of a directory with a backup directory using the rsync
command:
Users
See details about the active users:
id
last
Display who is currently logged into the system with the who command:
who
groupadd [group_name]
adduser [user_name]
Temporarily elevate user privileges to superuser or root using the sudo command:
sudo [command_to_be_executed_as_superuser]
Delete a user:
userdel [user_name]
usermod
Package Installation
List all installed packages with yum:
rpm -i [package_name.rpm]
Process Related
See a snapshot of active processes:
ps
pstree
pmap
top
kill [process_id]
Terminate a process under a specific name:
pkill [proc_name]
killall [proc_name]
bg
fg
fg [job]
lsof
System Information
Show system information:
uname -r
Display how long the system has been running, including load average:
uptime
hostname
hostname -i
last reboot
date
timedatectl
cal
List logged in users:
whoami
finger [username]
Disk Usage
See free and used space on mounted systems:
df -h
df -i
fdisk -l
du -ah
findmnt
Mount a device:
SSH Login
Connect to host as user:
ssh user@host
ssh host
telnet host
File Permission
Chown command in Linux changes file and directory ownership.
Assign read, write, and execute permission to everyone:
Give read, write, and execute permission to owner, and read and execute permission to
group and others:
Assign full permission to owner, and read and write permission to group and others:
Network
List IP addresses and network interfaces:
ip addr show
netstat -pnltu
netstat -nutlp
whois [domain]
dig [domain]
dig -x host
dig -x [ip_address]
host [domain]
Show the local IP address:
hostname -I
wget [file_name]
Ctrl + C
Ctrl + Z
The process can be resumed in the foreground with fg or in the background with bg.
Ctrl + W
Cut part of the line before the cursor and add it to clipboard:
Ctrl + U
Cut part of the line after the cursor and add it to clipboard:
Ctrl + K
Paste from clipboard:
Ctrl + Y
Ctrl + R
Ctrl + O
Ctrl + G
!!
exit