x
1ssh user@127.127.127.1272ssh -i /path/private.key user@127.127.127.127Remove host from ssh known hosts (when server changes, but IP stays the same)
11ssh-keygen -R "hostname"Key must have read only rights
11chmod 600 /path/private.key
Exit any program in console using CTRL+C command
move to directory
11cd /path/to/some/dir
Tab button gives you auto-complete
Move back one dir
11cd ..
Your home directory
11cd ~/
Make directory
11mkdir ~/some_dir
Delete directory
11rm -rf ~/some_dir
Install programs in Debian/Ubuntu using apt / apt-get package manager (replace PACKAGE_NAME)
xxxxxxxxxx11sudo apt install PACKAGE_NAME
If program not available in package managers download using wget and install manually.
chmod gives execution rights, sudo means - execute as administrator
x1cd ~/downloads23wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh45sudo chomd +x ./Anaconda3-2021.11-Linux-x86_64.sh67sudo ./Anaconda3-2021.11-Linux-x86_64.sh
Rxecutable
xxxxxxxxxx11chmod +x ./file.sh
Readable by all users
xxxxxxxxxx11chomd a+wr ./file.sh
get chomd settings from file
xxxxxxxxxx11ls -l myfile.txt
htop - Activity monitor, also can kill programs with F9 , then 9
Which process use most CPU
xxxxxxxxxx11ps auxh --sort=-pcpu | head -n 10
Which processes use most Memory
xxxxxxxxxx11ps auxh --sort=-rss | head -n 10
Find parent Process ID (to find correct screen)
xxxxxxxxxx11ps -o ppid= -p 1289173
xxxxxxxxxx11sudo apt install lm-sensors
then
xxxxxxxxxx11sensors
xxxxxxxxxx31sudo apt-get install jnettop23sudo jnettop
nvidia-smi shows GPU usage and memory usage
xxxxxxxxxx151sudo apt install firewalld firewall-config ufw23sudo firewall-cmd --zone=public --add-port=10090/tcp --permanent4sudo firewall-cmd --zone=public --add-port=10090-10200/tcp --permanent5sudo firewall-cmd --reload678sudo firewall-cmd --zone=public --add-port=80/tcp --permanent9sudo firewall-cmd --reload10sudo firewall-cmd --zone=public --add-port=443/tcp --permanent11sudo firewall-cmd --reload1213sudo ufw allow 808014sudo ufw allow 44315sudo ufw allow from any to any proto tcp port 10090:10210
xxxxxxxxxx31sudo lsof -i -P -n23sudo lsof -i -P -n | grep LISTEN
xxxxxxxxxx21sudo apt install net-tools2netstat -nlt
xxxxxxxxxx11telnet ADDRESS PORT
xxxxxxxxxx11nc -l PORT
xxxxxxxxxx31sudo apt install speedtest-cli23speedtest-cli
Edit tasks
xxxxxxxxxx11crontab -e
Format
xxxxxxxxxx21@reboot /media/hdd/automation_cron/startup_automations_evalds_1.sh2*/5 * * * * /media/hdd/automation_cron/run_automations_evalds_1.sh
Log output to file
xxxxxxxxxx1159 23 * * * /home/john/bin/backup.sh > /media/hdd/automation_cron/run_automations_evalds_1.log 2>&1
Global crontab (with user names admin )
xxxxxxxxxx11sudo vim /etc/crontab
Restart
xxxxxxxxxx11sudo service cron restart
Logs
xxxxxxxxxx11sudo grep CRON /var/log/syslog
xxxxxxxxxx810: No permission21: Execute32: Write43: Write and execute54: Read65: Read and execute76: Read and write87: Read, write, and executexxxxxxxxxx31The owner can read, write, and execute the file.2The group can read, write, and execute the file.3Anyone else can read, write, and execute the file.xxxxxxxxxx11sudo chmod 660 /shome/fileAlternative way!
plus means add rights
minus means remove rights
Add folder write/read rights for all users
xxxxxxxxxx11sudo chmod -R a+wr /some/folderRemove folder write/read rights for all users
xxxxxxxxxx11sudo chmod -R a-wr /some/folderMake SH file executable
xxxxxxxxxx11sudo chmod +x /some/folder
xxxxxxxxxx31ls -ltr /path/dir2ls -ltr /path/dir | grep "filter-text"3
https://www.tecmint.com/sort-ls-output-by-last-modified-date-and-time/
xxxxxxxxxx11pwdxxxxxxxxxx11find /dir -name "*Something*"https://www.geeksforgeeks.org/find-command-in-linux-with-examples/
xxxxxxxxxx11grep -i -A 5 -B 5 "string" FILE_PATTERNhttps://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/
xxxxxxxxxx21kill -9 PROCES_ID2kill -9 $(ps aux | grep 'SOME TEXT IN PROCESS' | awk '{print $2}')
Compression level 0-9
xxxxxxxxxx11zip -X -9 -r <output_file> <folder_1>
xxxxxxxxxx11whereis app_name
xxxxxxxxxx31which docker23# gives /snap/bin/docker
Create
xxxxxxxxxx11ln -s /path/source/folder_or_file /path/destinationWill result in /path/destination/folder_or_file
Find source
xxxxxxxxxx21readlink -f /path/to/syslink2readlink -f which command
create with name
screen -S newname
List screens:
screen -ls
Attach to existing
screen -rd newname
Detach from screen ctrl+a => d
Kill screen ctrl+a => k
Rename screen
screen -S <session-id> -X sessionname <new-name>

Scroll mode

Screen shortcuts

Send commands to screen:
xxxxxxxxxx21screen -dmS server2screen -r server -X stuff "/media/hdd/Document/server.sh\n"
Alternative to Linux screens - tmux https://superuser.com/questions/236158/tmux-vs-screen
xxxxxxxxxx31sudo fdisk -l23sudo mkfs.ext4 /dev/sde1
xxxxxxxxxx31tar –xvzf file.tar.gz23unzip latest.zip
xxxxxxxxxx11zip -r <output_file> <folder_1>
xxxxxxxxxx21cd /dir/2ls -1 | wc -l
xxxxxxxxxx11systemctl list-units --type=service
xxxxxxxxxx11pwd
http://share.yellowrobot.xyz/quick/2022-9-5-DF70FF8D-C119-4746-BC69-17E78082B14F.html

ncdu
xxxxxxxxxx31cat /etc/os-release2
3lsb_release -a
ctrl+b then : activates commands
:kill-session
xxxxxxxxxx51sudo service postgresql status2sudo service postgresql start34sudo service nginx start5sudo service nginx status
Adding user with directory
x1sudo useradd -m -d /home/username -s /bin/bash username
Setting password
x1sudo passwd username
Adding to user group
x1sudo usermod -a -G www-data username
x1sudo chown -R username:username /home/username/.ssh2sudo chmod 770 /home/username/.ssh3sudo chmod 770 /home/username/.ssh/authorized_keys