Linux Cheat Sheet

Here’s a Linux cheat sheet:

File System Navigation

Change Directory:

cd directory_path

List Files:

ls

List All Files (Including Hidden):

ls -a

Present Working Directory:

pwd

File and Directory Operations

Create Directory:

mkdir directory_name

Create Empty File:

touch filename

Copy File/Directory:

cp source destination

Move/Rename File or Directory:

mv old_name new_name

Remove/Delete File:

rm filename

Remove/Delete Directory:

rm -r directory_name

File Viewing and Editing

View File Content:

cat filename

View File with Pagination:

less filename

Edit File using Nano:

nano filename

Permissions

Change File Permissions:

chmod permissions filename

Here is a dedicated File Permissions Cheat Sheet.

Change Ownership of a File:

chown user:group filename

Process Management

List Running Processes:

ps

Kill a Process by PID:

kill PID

Kill a Process by Name:

pkill process_name

System Information

Display System Information:

uname -a

Display Free and Used Memory:

free -h

Display Disk Usage:

df -h

Networking

Show Network Interfaces:

ifconfig

Display Network Statistics:

netstat -a

Check Internet Connectivity:

ping google.com

Package Management

Update Package Lists:

sudo apt update

Upgrade Installed Packages:

sudo apt upgrade

Install a Package:

sudo apt install package_name

File Compression/Archiving

Create a Tar Archive:

tar -cvf archive.tar files_to_archive

Extract Tar Archive:

tar -xvf archive.tar

Here is a dedicated tar Cheat Sheet.

User Management

Add User:

sudo adduser username

Change User Password:

sudo passwd username

Switch User:

su - username

Miscellaneous

Search for Files:

find /path/to/search -name filename

View System Logs:

tail -f /var/log/syslog

This Linux cheat sheet covers basic commands for file system navigation, file and directory operations, file viewing and editing, permissions, process management, system information, networking, package management, file compression/archiving, user management, and miscellaneous commands. Adjust as needed based on your specific Linux distribution and requirements.