Basic Linux command

Command Description Example
ls Lists file and directories ls-l
cd <directory> change current directory cd /var/log
pwd show current directory path pwd
mkdir <name> creates a new directory mkdir backups
rm <file> remove/delete file rm filename.txt
rm -r <directory> remove directory and its contents rm -r foldername
cp <source> <destination> copy files or directories cp file.txt /tmp/
mv <source> <destination> move or rename file or directories mv filename.txt newname.txt
sudo apt update Update package lists sudo apt update
sudo apt upgrade upgrade installed packages sudo apt upgrade -y
cat <file> Display contents of a file cat /etc/hostname
tail -f <file> view live long output tail -f /var/log/syslog
chmod change file/directory permissions chmod +x script.sh
chown Change file/directory owner sudo chown user:user file.txt
scp <file> user@host:path securely copy file between local and remote machines scp file.txt user@192.168.1.10:/home/user/
ssh user host Secure shell login to remote machine ssh user@192.168.1.10
rsync Sync files/directories locally or remotely rsync -avz /src/ user@host:/dest/
df -h show disk space usage in human-readable format df -h
du -sh <directory> show size of a directory or file du -sh /var/log
ps aux show running processes ps aux
kill <PID> Terminate a process by its process ID kill 1234
systemctl status <service> check status of a systemd service systemctl status nginx
systemctl start <service> starts a systemd service systemctl start nginx
systemctl stop <service> stops a systemd service systemctl stop nginx
journalctl -xe View system logs with extra details journalctl -xe
wget <url> Download files from the internet wget https://example.com/file.zip
curl <url> Transfer data from or to a server curl -O https://example.com/file.zip

Networking Commands

Command Description Example
ssh user@host Secure shell login to remote machine ssh user@192.168.1.10
ip addr or ifconfig Show network interfaces and IP addresses ip addr or ifconfig
netstat -tulnp Check active network connections and listening ports netstat -tulnp
curl -O <url> Download a file or test network speed curl -O <http://example.com/file.zip>
wget <url> Download a file wget <http://example.com/file.zip>
sudo ufw status View uncomplicated firewall (UFW) status sudo ufw status
sudo ufw status verbose View detailed UFW status sudo ufw status verbose
sudo ufw enable Enable uncomplicated firewall (UFW) sudo ufw enable
sudo ufw allow <port/service> Allow specific ports or services through firewall sudo ufw allow 22 (allow SSH)