810: No permission
21: Execute
32: Write
43: Write and execute
54: Read
65: Read and execute
76: Read and write
87: Read, write, and execute
31The 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.
11sudo chmod 660 /shome/file
Make folder write/read for all users
11sudo chmod -R a+wr /some/folder
Make SH file executable
11sudo chmod +x /some/folder
older than 30 days
21find /opt/backup -type f -mtime +30 -delete
2find /var/log -name "*.log" -type f -mtime +30 -delete
31ls -ltr /path/dir
2ls -ltr /path/dir | grep "filter-text"
3ls -a # shows also hidden files
https://www.tecmint.com/sort-ls-output-by-last-modified-date-and-time/
Count files
31cd ~/documents/api_asya_ai/requests_files/unprocessed
2ls | wc -l#
3
Available HDDs
xxxxxxxxxx
11sudo fdisk -l
Disk UUIDs
xxxxxxxxxx
11sudo lsblk -f
Mounting disk
xxxxxxxxxx
11sudo mount /dev/sdX /media/hdd
Automatic mounting
xxxxxxxxxx
71sudo vim /etc/fstab
2
3LABEL=cloudimg-rootfs / ext4 defaults 0 1
4LABEL=UEFI /boot/efi vfat umask=0077 0 1
5
6UUID="69d4002e-a45a-483e-a13b-a3a1ffb255fb" /media/hdd1 ext4 defaults,noatime,_netdev 0 2
7/swapfile swap swap defaults 0 0
Mount points to these HDDs
xxxxxxxxxx
11cat /proc/mounts
xxxxxxxxxx
11pwd
xxxxxxxxxx
21find /dir -name "*Something*
2 find /dir -iname "*Something*
https://www.geeksforgeeks.org/find-command-in-linux-with-examples/
xxxxxxxxxx
11grep -i -A 5 -B 5 "string" FILE_PATTERN
https://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/
xxxxxxxxxx
21kill -9 PROCES_ID
2kill -9 $(ps aux | grep 'SOME TEXT IN PROCESS' | awk '{print $2}')
xxxxxxxxxx
21zip -r <output_file> <folder_1>
2unzip <zip_file>
xxxxxxxxxx
11whereis app_name
Create
xxxxxxxxxx
11ln -s /path/source/folder_or_file /path/destination
Will result in /path/destination/folder_or_file
Find source
xxxxxxxxxx
21readlink -f /path/to/syslink
2readlink -f which command
Move betwween folders:
xxxxxxxxxx
31cd.. (move directory up)
2cd- (move to previous directory)
3cd ...(exact path)... (move to some concrete folder)
xxxxxxxxxx
11nc -l PORT
Test if port is accepting something
xxxxxxxxxx
11netstat -a | grep PORT
x1sudo apt install firewalld firewall-config
2sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent
3sudo firewall-cmd --reload
4sudo ufw allow 5432
5
6
7sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
8sudo firewall-cmd --reload
xxxxxxxxxx
111grep -i -A 5 -B 5 "error" ./var/log/dmesg
2sudo tail ./var/log/syslog
3sudo tail ./var/log/kern.log
4
5grep -i -A 5 -B 5 "error" ./var/log/kern.log
6
7cat ./etc/ssh/sshd_config
8
9cat ./etc/iptables/rules.v4
10sudo cat ./etc/ufw/user.rules
11sudo rm -rf ./etc/firewalld/zones/
HPC:
Started tasks:
xxxxxxxxxx
21showq -r
2qstat
Videocard memory usage:
xxxxxxxxxx
41ssh wn56 (choose wn... from showq -r)
2logout (iziet no wn)
3watch nvidia-smi (ctrl+C lai izietu)
4htop
Starting/killing tasks:
xxxxxxxxxx
21qsub -N reinis_freibergs -A ditf_ldi start_hpc.sh (Example for start)
2qdel ...(task name from qstat)... (Kill a task)
Screens:
xxxxxxxxxx
31screen -ls (List all of the screen sessions for a user)
2screen -rd ...(name of screen to log into)...
3screen -S ...(new screen name)...
Console management:
xxxxxxxxxx
21Ctrl+A D (exit screen, program will continue to run)
2Ctrl+A K (kill a screen)
https://github.com/nodesource/distributions#debinstall
xxxxxxxxxx
21curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
2sudo apt-get install -y nodejs
xxxxxxxxxx
21echo "user_allow_other" | sudo tee -a /etc/fuse.conf
2
Set and store
xxxxxxxxxx
11sudo hostnamectl set-hostname www.something.com
Stored here
xxxxxxxxxx
11vim /etc/hostname