0% found this document useful (0 votes)
10 views

Linux-Essential-Commands-Cheat-Sheet

This document is a comprehensive cheat sheet for essential Linux commands, covering various topics such as file management, system monitoring, networking, and user management. It provides a quick reference for command-line operations, including syntax and usage examples. Additionally, it includes links to social media platforms for further learning and updates.

Uploaded by

Sai Charan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Linux-Essential-Commands-Cheat-Sheet

This document is a comprehensive cheat sheet for essential Linux commands, covering various topics such as file management, system monitoring, networking, and user management. It provides a quick reference for command-line operations, including syntax and usage examples. Additionally, it includes links to social media platforms for further learning and updates.

Uploaded by

Sai Charan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Linux Essential

Commands (Cheat
Sheet)
By : Tech Fusionist

A comprehensive Essential resource for Covers fundamental


reference guide for Linux system administration everyday terminal usage
command-line operations tasks commands
Table of contents

File and Directory Management

File Viewing and Editing

System Information and Monitoring

Process Management

Networking

Package Management

Text Processing and Searching

User and Permission Management

File Compression and Archiving

System Administration

Disk and Filesystem Management

Miscellaneous Utilities

Advanced File Operations

Scripting and Automation

Networking and Diagnostics

Security and Auditing

System and Hardware Tools

Process and Resource Management

Miscellaneous Utilities

Follow me on the below platforms to learn with quick content & get updates for new resources. Twitter (X) :&
File and Directory Management

1 ls -l 2 ls -la 3 cd /path/to/dir
Lists directory contents in long Lists all files (including hidden) Changes the current directory to
format (permissions, owner, in long format. the specified path.
size, etc.).

4 pwd 5 mkdir dir_name 6 rmdir dir_name


Prints the current working Creates a new directory named Removes an empty directory.
directory. dir_name.

7 touch file_name 8 cp source target 9 mv source target


Creates an empty file or Copies a file or directory from Moves or renames a file or
updates the timestamp of an source to target. directory.
existing file.

10 rm -rf dir_or_file 11 find /path -name 12 locate file_name


Recursively deletes a file or "pattern" Quickly finds files by name
directory (use with caution!). Searches for files matching (requires updated database).
pattern in the specified path.

13 tree -L 2 14 chmod 755 file_name 15 chown user:group


Displays directory structure up Changes file permissions (e.g., file_name
to 2 levels deep. rwxr-xr-x). Changes file ownership to user
and group.
File Viewing and Editing

1 cat file_name 2 less file_name


Displays the contents of a file. Views a file page by page (scrollable).

3 more file_name 4 head -n 10 file_name


Similar to less, but less interactive. Shows the first 10 lines of a file.

5 tail -n 10 file_name 6 nano file_name


Shows the last 10 lines of a file. Opens a file in the Nano text editor.

7 vim file_name 8 sed 's/old/new/g' file_name


Opens a file in the Vim text editor. Replaces old with new globally in a file.

9 awk '{print 1}' file_name 10 cut -d',' -f1 file_name


Prints the first column of a file (space-separated). Extracts the first field from a comma-separated file.
System Information and Monitoring

1 uname -a 2 df -h
Displays all system information (kernel, hostname, Shows disk space usage in human-readable format.
etc.).

3 du -sh /path 4 top


Estimates the size of a directory in human-readable Displays real-time system processes (CPU, memory
format. usage).

5 htop 6 free -h
A more user-friendly version of top (if installed). Shows memory usage in human-readable format.

7 whoami 8 uptime
Prints the current user's username. Shows how long the system has been running.

9 lscpu 10 lsblk
Displays CPU information. Lists block devices (e.g., disks and partitions).
Process Management

1 ps aux 2 kill -9 PID 3 killall process_name


Lists all running processes with Forcefully terminates a process Kills all processes with the
details. by its PID. given name.

4 jobs 5 bg %job_number 6 fg %job_number


Lists background jobs in the Resumes a suspended job in Brings a background job to the
current session. the background. foreground.

7 nohup command &


Runs a command immune to hangups (e.g., after logout).
Networking

1 ping hostname 2 curl url


Checks connectivity to hostname. Fetches content from a URL.

3 wget url 4 ifconfig


Downloads a file from a URL. Displays network interface configuration (older
systems).

5 ip addr 6 netstat -tuln


Modern alternative to ifconfig for network info. Lists listening ports and services.

7 ss -tuln 8 ssh user@hostname


Modern replacement for netstat. Connects to a remote machine via SSH.
Package Management

1 apt update 2 apt install package_name


Updates package lists for upgrades Installs a specified package (Debian/Ubuntu).
(Debian/Ubuntu).

3 apt remove package_name 4 yum install package_name


Uninstalls a package, leaving config files Installs a package (CentOS/RHEL, older systems).
(Debian/Ubuntu).

5 dnf install package_name 6 pacman -S package_name


Installs a package (modern CentOS/Fedora). Installs a package (Arch Linux).

7 apt upgrade 8 dpkg -i package.deb


Upgrades all installed packages (Debian/Ubuntu). Installs a .deb package file manually.
Text Processing and Searching

1 grep "pattern" file_name 2 grep -r "pattern" /path 3 sort file_name


Searches for pattern in a file. Recursively searches for pattern Sorts lines in a file
in a directory. alphabetically.

4 uniq file_name 5 wc -l file_name 6 tr 'a-z' 'A-Z' < file_name


Removes duplicate consecutive Counts lines in a file (-w for Converts text to uppercase
lines (use with sort). words, -c for characters). (lowercase with A-Z a-z).

7 tee file_name
Writes command output to both a file and the screen.
User and Permission Management

1 useradd username 2 passwd username


Creates a new user (use with passwd). Sets or changes a user's password.

3 userdel -r username 4 usermod -aG groupname username


Deletes a user and their home directory. Adds a user to a group.

5 groupadd groupname 6 id username


Creates a new group. Displays user and group IDs for username.

7 su - username 8 sudo command


Switches to another user account. Runs a command as a superuser (if authorized).
File Compression and Archiving

1 tar -cvf archive.tar /path 2 tar -xvf archive.tar


Creates a .tar archive from a path. Extracts a .tar archive.

3 tar -czvf archive.tar.gz /path 4 tar -xzvf archive.tar.gz


Creates a compressed .tar.gz archive. Extracts a .tar.gz archive.

5 zip archive.zip file1 file2 6 unzip archive.zip


Creates a .zip archive from files. Extracts a .zip archive.

7 gzip file_name 8 gunzip file_name.gz


Compresses a file into .gz. Decompresses a .gz file.
System Administration

1 reboot 2 shutdown -h now


Restarts the system (requires root). Shuts down the system immediately.

3 hostname 4 hostnamectl set-hostname new_name


Displays the system's hostname. Changes the system's hostname.

5 date 6 timedatectl set-time "YYYY-MM-DD


Displays the current date and time. HH:MM:SS"
Sets the system date and time.

7 crontab -e 8 systemctl start service_name


Edits cron jobs for scheduled tasks. Starts a system service (e.g., nginx).
Disk and Filesystem Management

1 fdisk -l 2 mkfs.ext4 /dev/sdX


Lists all disk partitions (requires root). Formats a partition as ext4 (replace sdX with your
device).

3 mount /dev/sdX /mnt 4 umount /mnt


Mounts a device to a directory. Unmounts a mounted filesystem.

5 fsck /dev/sdX 6 dd if=/dev/zero of=file bs=1M count=10


Checks and repairs a filesystem. Creates a 10MB file filled with zeros (useful for
testing).
Miscellaneous Utilities

1 echo "text" > file_name 2 echo "text" >> file_name 3 which command_name
Writes text to a file, overwriting Appends text to a file. Shows the full path of a
it. command.

4 history 5 watch -n 2 "command"


Displays the command history. Runs command every 2 seconds and displays
output.
Advanced File Operations

1 ln -s target link_name 2 readlink link_name


Creates a symbolic link to target named link_name. Displays the target of a symbolic link.

3 file file_name 4 stat file_name


Identifies the type of a file (e.g., text, binary). Shows detailed file metadata (timestamps,
permissions).

5 split -b 1M file_name prefix 6 join file1 file2


Splits a file into 1MB chunks with prefix (e.g., Joins two sorted files based on a common field.
prefixaa, prefixab).

7 paste file1 file2 8 diff file1 file2


Merges lines of files side by side. Compares two files and shows differences.
Scripting and Automation

1 bash script.sh 2 sh script.sh 3 chmod +x script.sh


Executes a Bash script. Runs a shell script (compatible Makes a script executable.
with POSIX shells).

4 sleep 10 5 time command 6 at now + 1 hour -f


Pauses execution for 10 Measures the execution time of script.sh
seconds. a command. Schedules script.sh to run in 1
hour.

7 watch -n 5 "date"
Runs date every 5 seconds (similar to previous watch, but different use case).
Networking and Diagnostics

1 traceroute hostname 2 nslookup hostname


Traces the route packets take to hostname. Queries DNS for hostname information.

3 dig hostname 4 who


Provides detailed DNS lookup for hostname. Lists currently logged-in users.

5 w 6 arp -a
Shows who is logged in and what they're doing. Displays the ARP cache (IP-to-MAC mappings).

7 route 8 iptables -L
Shows the kernel routing table. Lists current firewall rules (requires root).
Security and Auditing

1 last 2 who -b 3 chgrp groupname


Displays the last logins of Shows the time of the last file_name
users. system boot. Changes the group ownership
of a file.

4 setfacl -m 5 getfacl file_name 6 passwd -l username


u:username:rwx Displays ACL permissions for a Locks a user's account
file_name file. (requires root).
Sets access control list (ACL)
permissions for a user.

7 sha256sum file_name
Computes the SHA-256 checksum of a file.
System and Hardware Tools

1 dmesg 2 lspci 3 lsusb


Displays kernel ring buffer Lists PCI devices (e.g., graphics Lists connected USB devices.
messages (boot logs, errors). cards, network adapters).

4 dmidecode 5 swapoff -a 6 swapon -a


Displays hardware info from the Disables all swap space Enables all swap space defined
BIOS (requires root). (requires root). in /etc/fstab.

7 ulimit -n 1024
Sets the maximum number of open files to 1024.
Process and Resource Management

1 nice -n 10 command 2 renice 10 -p PID 3 pmap PID


Runs a command with adjusted Changes the priority of a Displays memory map of a
priority (lower priority here). running process by PID. process.

4 lsof -p PID 5 strace -p PID


Lists files opened by a process. Traces system calls made by a process (debugging).
Miscellaneous Utilities

1 clear 2 reset
Clears the terminal screen. Resets the terminal to default settings (useful if
corrupted).

3 env 4 export VAR=value


Lists all environment variables. Sets an environment variable for the session.

5 alias ll='ls -l' 6 unalias ll


Creates a shortcut (ll) for ls -l. Removes the ll alias.

7 cal 8 bc <<< "5 + 3"


Displays a calendar of the current month. Performs calculations (basic calculator).
Follow me on the below platforms to learn with quick content & get updates
for new resources.

Twitter (X) : https://twitter.com/techyoutbe

Telegram: https://t.me/LearnDevOpsForFree

Youtube: https://www.youtube.com/@T3Ptech

You might also like