Linux Commands Cheat Sheet

Filed Under: UNIX/Linux
Linux Commands Cheat Sheet

This article is a quick Linux Commands cheat sheet designed to give you most of the common commands at a glance. The list is divided into sections that can help you find the command that you’re looking for.

Linux Commands Cheat Sheet

Linux commands for system/hardware information

CommandDescription
uname -aPrint all important system information like kernel release and version, hostname, processor type, operating system
uname -rPrint Kernel Release
cat /etc/os-releasePrint information about the current Operating System
hostnameshow host name of your device over the network
hostname -iShow IP Addresses associated with the host name
uptimeDisplay for how long the system has been running
last rebootShow reboot history
sensorsPrint sensor information like temperature, voltage and current
iostat -cPrint CPU usage
free -mPrint RAM and SWAP usage stats
acpiPrint current Battery statistics
acpi -tShow thermal information
df -hList amount of hard disk space used
lsusbList all USB devices
cat /proc/cpuinfoDisplay CPU information like model name, cache size, etc
lshwList Hardware information
dmesgDisplay all messages from the kernel ring buffer

User information commands

CommandDescription
idDisplay real and effective user and group IDs
whoamiPrint current user you are logged-in as
echo $SHELLCheck default shell
echo $0Check current shell
echo $HOMEPrint the home directory of the current user
wShow all logged in users and what they are doing
sudo -lCheck current user’s sudo privileges
whoShow all logged in users
groupadd <name>Create a new group with the specified name
adduser <name>Add a user with the specified name
userdel <name>Delete an user
passwdChange the current user’s password

Linux commands for working with files/directories

CommandDescription
pwdPrint present working directory
lsPrint the contents of the present working directory
ls -lPrint the contents of a directory with detailed information about them like sizes, author, permissions granted, etc
ls -aPrint the contents of a directory including hidden files/folders
touch <name>Create an empty file
mkdir <name>Create a directory
rm <name>Delete a file
rm -rf <name>Delete a directory
rmdir <name>Delete a directory
chmod +x <name>Make a file executable
chmod +r <name>Make a file/folder read-able
chmod +w <name>Make a file/folder write-able
chown USER:GROUP <name>Change ownership of a file/directory
cat <name>Print the contents of a file
cat File1 > File2Over write contents of File2 with contents of File1
cat File1 >> File2Append contents of File1 to File2
cp <file> <copy>Make a copy of a file
cp -r <dir> <copy>Make a copy of a directory
mv <name> <path>Move a file to a specified path
mv <name> <new-name>Rename a file to a new filename
cd <path>Change directory to the specified location
cd ../Move one directory up
cd ~Go to home directory
ln <link> <name>Create a Hardlink to a file
ln -s <link> <name>Create a Softlink to a file
locate <name>Locate all file/directory instances having a particular string
updatedbUpdate database used by locate
file <name>Determine File type
grep <str> <name>Look for a string/pattern in a file
diff <file1> <file2>Compare differences between two files line by line

Networking commands for Linux

CommandDescription
ip aShow network information like available interfaces, IP Address, Netmask, and other such information associated with the interface
ip address add
<ip>/<cidr> dev
<interface>
Assign the specified IP along with the give CIDR to the mentioned interface
iwconfigShow information related to wireless interfaces like mode, frequency, AP, etc
ping <ip>Send ICMP ping packets to the specified IP
traceroutePrint the route packets trace to network host
whois <domain/ip>Retrieves information about a Domain/IP from a RFC 3912 database
dig <domain>Perform a DNS lookup
host <domain>Perform an IP lookup on the given domain name
wget <url>Fetch a file from the given URL
curl <url>Make a request to a URL
netstat -pnltuDisplay all active listening ports
nc <ip> <port>Connect to an IP at a specified port
tcpdump -i <interface>Capture all the packets across a particular interface

Process management commands

CommandDescription
psShow current running processes
ps aux | grep <name>Find process information pertaining to a particular application/program
kill <pid>Terminate a process with a given PID
killall <name>Kill all the processes associated with a particular name
topDisplay information about running processes
htopView running processes using an Interactive environment
pstreeVisualize processes in a tree model
bgContinue a process in the background
fgBring a process to the foreground
lsofList all files opened by a process

Linux Commands Cheat Sheet – Conclusion

And this brings us to the end of the Linux Commands Cheat Sheet. The commands may seem far and few, but these are some of the most commonly used ones and will help you get what you need, right away.

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content