- View system info:
uname -a
- Check memory usage:
free -h
- Check disk usage:
df -h
- Check CPU usage:
or
top
htop
- Check system uptime:
uptime
- List all users:
cut -d: -f1 /etc/passwd
- Switch user:
su - username
- Change user password:
sudo passwd username
- Add a user:
sudo adduser username
- List files in directory:
ls -l
- Change directory:
cd /path/to/directory
- Copy files:
cp source destination
- Move/rename files:
mv source destination
- Remove files:
rm filename
- Edit a file (with nano editor):
nano filename
- Check IP address:
ip a
- Check open ports:
sudo netstat -tuln
- Test connectivity to a host:
ping hostname_or_ip
- Check active network connections:
ss -tuln
- Update packages:
sudo apt update
- Upgrade packages:
sudo apt upgrade
- Install a package:
sudo apt install package_name
- Remove a package:
sudo apt remove package_name
- Check service status:
sudo systemctl status service_name
- Start a service:
sudo systemctl start service_name
- Stop a service:
sudo systemctl stop service_name
- Enable a service to start at boot:
sudo systemctl enable service_name
- Restart a service:
sudo systemctl restart service_name
- View system logs (most recent logs):
sudo journalctl -xe
- View specific service logs:
sudo journalctl -u service_name
- Check UFW status:
sudo ufw status
- Allow port (e.g., port 80 for HTTP):
sudo ufw allow 80/tcp
- Enable UFW:
sudo ufw enable
- Disable UFW:
sudo ufw disable
- Check firewall rules:
sudo ufw status verbose
-
Show running processes:
ps aux
-
Kill a process:
kill process_id
-
Kill a process by name:
pkill process_name
- SSH into server:
ssh username@hostname_or_ip
- SSH with a specific port:
ssh -p port_number username@hostname_or_ip
- Check disk usage:
sudo du -sh /path/to/folder
- Clean up apt cache:
sudo apt clean
- Create a tar backup:
tar -czvf backup.tar.gz /path/to/directory
- Extract a tar backup:
tar -xzvf backup.tar.gz