πLinux
The Basics
Systemctl
sudo systemctl restart <systemd-process-name>sudo systemctl stop <systemd-process-name>sudo systemctl status <systemd-process-name>sudo journalctl -f -u <systemd-process-name>sudo systemctl enable /etc/systemd/system/<systemd-process-name>sudo systemctl disable /etc/systemd/system/<systemd-process-name>
Find, files
find . -mount -type f -size +1G 2>/dev/nullfind . -mount -type f -size +100M 2>/dev/nullsudo du -a / | sort -n -r | head -n 20
Important! When you enable Firewall and if you want to connect on your server by ssh, you must allow it in firewall 22 port
Firewall
sudo apt install ufw -ysudo ufw statussudo ufw enablesudo ufw disablesudo ufw allow OpenSSHsudo ufw allow 22/tcpsudo ufw allow 80/tcpsudo ufw allow 443/tcpsudo ufw allow 3306sudo ufw allow 'Nginx HTTP'sudo ufw app list
Remote connection
scp readme.txt user@192.168.0.1:/home/user/tempscp -r -i ~/.ssh/digitalocean readme.txt user@192.168.0.1:/home/user/temp
Configs
wget -qO- eth0.me- get ip server
ifconfig | grep "inet " | grep -v 127.0.0.1- To get access to your localhost you can via using same wifi networkifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'- Get your local IP
Crontab
Useful link
0 * * * *- Every hour
Ssh
Create ssh key and paste it in server:
ssh-keygen -t rsa- generate an ssh key (type file path and name if you want)Or
ssh-keygen -t rsa -f ~/.ssh/example- generate an ssh key (type file path and name if you want)pbcopy < ~/.ssh/id_rsa.pub- copy file contentsPaste .pub content to server
Connection to server:
ssh <username>@<ip_address> ssh <username>@<ip_address> -i ~/.ssh/id_rsasudo lsof -i -P | grep LISTEN | grep :$PORT- Check all ports
Last updated