Linux Commands Cheat Sheet :)
Grep
grep "pattern" filename // search for the particular pattern
grep -n "pattern" filename // show along with page number
grep -e "pattern1" -e "pattern2" filename //Search for multiple patterns
Killall
It is used to stop all processes that match a given name
killall process_name
ps
It is used to list all the active processes in the current terminal
ps
ps aux
(a - show all processes)
(u - display user)
(x - show processes not attached to the terminal)
Top
This command provides a real-time, interactive view of system processes, including CPU and memory usage.
top
Ping utility
It is a basic tool used to test network connectivity. It helps to check if your computer can reach another computer over the internet.
Round-trip time: Time it takes for data to travel from source to the destination and back
When you use the ping command, your computer sends a small data packet called an "ICMP echo request" to the target address. The target then sends back a response called an "ICMP echo reply."
ping [url]
Third party ping applications: fping
What is the Default Gateway?
It is the IP address of a router or network device that your computer uses to communicate with other devices outside your local network. In other words, it's the address that your computer sends traffic to when it needs to access resources beyond its own subnet.
This means that any network traffic that needs to go beyond your local subnet (e.g., to the internet) will be sent to 172.22.8.1, which is likely the IP address of your router or gateway device.
If your computer wants to access a website, it sends the request to the default gateway (172.22.8.1), which then forwards the request to the internet. The gateway also handles incoming traffic from the internet and directs it back to your computer.
File Transfer Protocol
- Connect to FTP server It is used to connect to the FTP server from a terminal or command prompt.
ftp [url]
FTP Client
Ex. FileZilla
Network Mapper (nmap)
It is a network scanning tool used for discovering hosts and services on a computer network. It’s widely used for security auditing, network inventory, and identifying network issues.
nmap -sT target_ip //scan open TCP ports
nmap -sU target_ip //scan open UDP ports
nmap -A target_ip //agressive scan
// Report
Lists all open ports
PORT STATE SERVICE
21/tcp open ftp
80/tcp open http
110/tcp open pop3
135/tcp open msrpc
143/tcp open imap
443/tcp open https
ifconfig(Similar to ipconfig of windows)
This command gives you the details about network interface cards(NIC)
ifconfig
Symbolic Link (Symlink)
A symbolic link (or symlink) is a type of file that serves as a reference to another file or directory. It's essentially a shortcut or alias that points to the target file or directory.
ln -s [TARGET] [LINK_NAME]
Remove orca
sudo apt remove orca
Directory management
mkdir directory //create a folder
rmdir directory //delete a folder
Package management
apt-get install package-name
apt-get remove package-name
apt-get purge package-name
apt-get update
apt-get upgrade //upgrades all installed packages to the latest versions
Single Dash (-): Used for single-letter options. Example: -h for help. Double Dash (--): Used for word options. Example: --help for detailed help.
Create a New File:
cat > filename
Type your content and Press Ctrl + D to save and exit.
Granting Permissions
Each file and directory must be allocated a particular level of permission for the different identities using it. The three levels of permission are listed hereunder: r - (Read permission) This grants permission only to open and view a file. w - (Write permission) This allows users to view and edit a file. x - (Execute permission) This will enable users to execute a file (This does not guarantee viewing or editing it).
Changing Permissions We can use the Linux command chmod to change the permissions.
rwxrwxrwx
rwx for the owner: 7 (rwx)
rwx for the group: 7 (rwx)
rwx for others: 7 (rwx)
Read (r) = 4 (binary 100) Write (w) = 2 (binary 010) Execute (x) = 1 (binary 001)
Stay Connected! If you enjoyed this post, don’t forget to follow me on social media for more updates and insights:
Twitter: madhavganesan
Instagram: madhavganesan
LinkedIn: madhavganesan
Subscribe to my newsletter
Read articles from Madhav Ganesan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Madhav Ganesan
Madhav Ganesan
I am a computer science student passionate about web development and any other technologies that amazes me