Sat. Dec 3rd, 2022

Hello Android

All android in one place

Linux Commands Cheat Sheet – JournalDev

4 min read

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

Command Description
uname -a Print all important system information like kernel release and version, hostname, processor type, operating system
uname -r Print Kernel Release
cat /etc/os-release Print information about the current Operating System
hostname show host name of your device over the network
hostname -i Show IP Addresses associated with the host name
uptime Display for how long the system has been running
last reboot Show reboot history
sensors Print sensor information like temperature, voltage and current
iostat -c Print CPU usage
free -m Print RAM and SWAP usage stats
acpi Print current Battery statistics
acpi -t Show thermal information
df -h List amount of hard disk space used
lsusb List all USB devices
cat /proc/cpuinfo Display CPU information like model name, cache size, etc
lshw List Hardware information
dmesg Display all messages from the kernel ring buffer

User information commands

Command Description
id Display real and effective user and group IDs
whoami Print current user you are logged-in as
echo $SHELL Check default shell
echo $0 Check current shell
echo $HOME Print the home directory of the current user
w Show all logged in users and what they are doing
sudo -l Check current user’s sudo privileges
who Show 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
passwd Change the current user’s password

Linux commands for working with files/directories

Command Description
pwd Print present working directory
ls Print the contents of the present working directory
ls -l Print the contents of a directory with detailed information about them like sizes, author, permissions granted, etc
ls -a Print 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 > File2 Over write contents of File2 with contents of File1
cat File1 >> File2 Append 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
updatedb Update 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

Command Description
ip a Show 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
iwconfig Show information related to wireless interfaces like mode, frequency, AP, etc
ping <ip> Send ICMP ping packets to the specified IP
traceroute Print 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 -pnltu Display 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

Command Description
ps Show 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
top Display information about running processes
htop View running processes using an Interactive environment
pstree Visualize processes in a tree model
bg Continue a process in the background
fg Bring a process to the foreground
lsof List 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.

www.hello-android.com

Leave a Reply

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

Hello android © All rights reserved. | Newsphere by AF themes.