Skip to content
Back
Linux Commands

Command Library

Linux Commands

Core Linux commands for navigation, files, networking, and system tasks.

Navigation

Print working directory

pwd

Shows the current directory path.

List all files including hidden ones

ls -la

Useful for viewing file metadata and dotfiles.

Change directory

cd /path/to/folder

Moves to a target folder.

Files & Directories

Create nested directories

mkdir -p project/src

Creates folder structure without failing on existing parents.

Copy directory recursively

cp -r src backup/

Copies files and subdirectories.

Rename or move a file

mv old.txt new.txt

Moves a file or renames it.

Delete a directory

rm -rf build

Removes a folder and its contents recursively.

Permissions

Set file permissions

chmod 755 script.sh

Makes the script executable by the owner.

Change file owner

chown user:user file.txt

Transfers ownership to a specific user and group.

Edit system files as admin

sudo nano /etc/hosts

Opens a privileged file using sudo.

Processes

List running processes

ps aux

Displays active processes and resource usage.

Monitor system activity

top

Shows live CPU, memory, and process metrics.

Force stop a process

kill -9 1234

Kills a process by PID.

Networking

Show network interfaces

ip a

Displays IP addresses and interface details.

Check connectivity

ping google.com

Sends ICMP requests to test network reachability.

List listening ports

ss -tulpn

Shows active TCP/UDP sockets and services.

Package Management

Update package lists and packages

apt update && apt upgrade

Refreshes and upgrades Debian/Ubuntu packages.

Install a package

apt install curl

Installs software from the configured repositories.

List installed packages

dpkg -l

Shows installed Debian packages.

SSH

Connect to a remote server

ssh user@host

Logs into another machine securely using SSH.

Copy file over SSH

scp file.txt user@host:/tmp/

Transfers a file to a remote system.

Generate SSH keys

ssh-keygen -t ed25519

Creates a secure key pair for passwordless authentication.

Archives

Create a compressed archive

tar -czvf backup.tar.gz folder/

Creates a .tar.gz archive.

Extract an archive

tar -xzvf backup.tar.gz

Extracts archived content.

Create a ZIP file

zip -r archive.zip folder/

Compresses files and folders into a ZIP archive.