🐋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/null
find . -mount -type f -size +100M 2>/dev/null
sudo 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 ufw status
sudo ufw enable
sudo ufw disable
sudo ufw allow OpenSSH
sudo ufw allow 22
sudo ufw allow 22/tcp
sudo ufw allow 3306
sudo ufw allow 'Nginx HTTP'
sudo ufw app list
Remote connection
scp readme.txt user@192.168.0.1:/home/user/temp
scp -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_rsa
sudo lsof -i -P | grep LISTEN | grep :$PORT
- Check all ports
Last updated