add networking and ufw to linux basics

This commit is contained in:
Lee 2023-06-27 09:05:58 +01:00
parent 18c94ad885
commit f859c5d8e5

@ -57,3 +57,24 @@ This guide provides a brief introduction to Linux, including basic commands and
- Extract a tar archive: `tar -xvf <archive.tar>`
- Create a zip archive: `zip <archive.zip> <file>`
- Extract a zip archive: `unzip <archive.zip>`
## Networking
- Get all interface ips: `ip a`
- Ping a host: `ping <host>`
- Get the public IP: `curl ifconfig.me`
- Get the public IP (alternative): `curl ipinfo.io/ip`
## Firewall (UFW)
Make sure to allow SSH before enabling the firewall, otherwise you will be locked out of your server. `sudo ufw allow ssh`
- Enable the firewall: `sudo ufw enable`
- Disable the firewall: `sudo ufw disable`
- List all rules: `sudo ufw status`
- List all rules (showing numbers): `sudo ufw status numbered`
- Delete a rule: `sudo ufw delete <rule>`
- Allow a port: `sudo ufw allow <port>`
- Deny a port: `sudo ufw deny <port>`
- Allow a service: `sudo ufw allow <service>`
- Deny a service: `sudo ufw deny <service>`