Linux commands


General

Check exit code of previous command (0 = success, 1 = error)

echo $?

File & Directory Management

List files with details

ls -la

Show current directory

pwd

Create directory

mkdir foldername

Remove file

rm filename

Remove directory recursively

rm -r folder

Search & Filtering

Search for text inside files

grep -R "text" .

Search for files by name

find . -name "*.js"

Search command history

history | grep keyword

Permissions & Ownership

Change file permissions

chmod 755 file

Change owner and group

chown user:group file

Networking

Test connectivity

ping google.com

Check open ports

ss -tulpn

Download file

curl -O https://example.com/file

Compression

Extract .tar.gz archive

tar -xzvf archive.tar.gz

Create .tar.gz archive

tar -czvf archive.tar.gz folder/

Process Management

List running processes

ps aux

Kill a process

kill PID

Force kill a process

kill -9 PID