using ufw firewall (Uncomplicated Firewall)
sudo apt-get install ufw
sudo ufw status
sudo ufw status verbose
sudo ufw status
sudo ufw status verbose
sudo ufw deny from {ip-address-here} to any port {port-number-here}
sudo ufw enable/disable
sudo ufw allow ssh #allow ssh
sudo ufw allow 25 #allow port
sudo ufw default deny incoming #set default to deny
sudo ufw default allow outgoing #set default to allow
sudo ufw delete allow ssh #delete allow port/service
sudo ufw reset #ufw reset rules
sudo ufw status numbered
sudo ufw delete {number}
sudo apt install openssh-server
systemctl status ssh
systemctl stop/start ssh
systemctl enable/disable ssh
nano /etc/ssh/sshd_config
service ssh reload
Load balancing & Routing
apt-get install haproxy
sudo nano /etc/haproxy/haproxy.cfg
systemctl restart haproxy.service
sudo fuser -k -n tcp 8000
Use the service command (Requires sudo)
service ssh status (service status)
service --status-all (all services status)
Almost every service has the following commands, some may have more like apache graceful-restart
:
service servicename start
service servicename stop
service servicename restart
service servicename status
service servicename force-reload
Add Service links:
sudo update-rc.d servicename defaults
Whether you get a warning if they already exist or not, enable it now:
sudo update-rc.d servicename enable
Pass the Force flag
sudo update-rc.d -f servicename remove
There is are several startup popular daemons:
- CentOS uses SystemV
- Ubuntu 14 uses Upstart
- Ubuntu 14.10+ uses SystemD (15, 16, 17..)
Focus on SystemD.
This would only apply to Ubuntu 14.10+, otherwise you would use Upstart.
systemctl <-- You'll use this more often
journalctl <-- You'll use this more often
update-rc.d <-- You'll use this more often
--------------------------
Installs/Removes System-V style init script links
Note: System-V Style, but it's really SystemD. (Confusing huh?)
"NNname" is the runlevel, lower means startup sooner
----------------------------------------------------
The Location is: /etc/rcrunlevel.d/NNname
The Target is: /etc/init.d/name.
notify
analyze
cgis
cgtop
loginctl
nspawn
shutdown
reboot
shutdown -h now
shutdown -h +10 (shutdown 10 mins)
shutdown -r now (reboot now)
gzip -dvk file.txt.gz
bzip2 -d file.txt.bz2
tar -xvf file.tar
tar -zxvf file.tar.gz
unzip test.zip
gzip -vk file.txt (Creates file.txt.gz)
bzip2 file.txt (Creates file.txt.bz2)
tar -cvf file.tar file.txt (Creates tar)
tar -czvf file.tar.gz file.txt (Creates tar.gz)
zip filename.zip file.txt (Creates filename.zip)
zip -r folder.zip path/to/folder (Creates folder.txt.bz2)
tmux #start this on SSH Terminal
tmux attach #open tmux session
exit #close tmux
1. /proc/cpuinfo
2. lscpu
3. hardinfo
whoami
su -u [username]
ex:
su -u User2 zsh
ifconfig
sudo ip route add IP_VPN via "Current Gateway" dev wlan0
sudo ip route del default via "Current Gateway" dev wlan0
sudo ip route add default via "Gateway VPN" dev vpn
ip route show