Cheat Sheets Help

Unix

Basic Commands

List files in a directory

ls

List all files, including hidden ones

ls -a

Change directory

cd <directory_path>

Print the current working directory

pwd

Create a new directory

mkdir <directory_name>

Remove a directory

rmdir <directory_name>

Remove a file

rm <file_name>

Copy files or directories

cp <source> <destination>

Move or rename files or directories

mv <source> <destination>

File & Directory Permissions

View file permissions

ls -l

Change file permissions

chmod <permissions> <file_name>

Change file owner

chown <owner> <file_name>

File Viewing & Editing

View the contents of a file

cat <file_name>

View file with paging

less <file_name>

Display the first 10 lines of a file

head <file_name>

Display the last 10 lines of a file

tail <file_name>

Edit a file with nano editor

nano <file_name>

Process Management

Display currently running processes

ps

Kill a process by PID

kill <pid>

Force kill a process

kill -9 <pid>

Check system resource usage

top

Networking

Check network configuration

ifconfig

Ping a server to check connectivity

ping <hostname_or_ip>

Check open ports

netstat -tuln

Miscellaneous

Check system uptime

uptime

View disk usage

df -h

Search for files

find <directory> -name <file_name>

Search for text in a file

grep "<text>" <file_name>
Last modified: 08 September 2024