810: No permission21: Execute32: Write43: Write and execute54: Read65: Read and execute76: Read and write87: Read, write, and execute31The 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/fileMake folder write/read for all users
11sudo chmod -R a+wr /some/folderMake 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/dir2ls -ltr /path/dir | grep "filter-text"3ls -a # shows also hidden fileshttps://www.tecmint.com/sort-ls-output-by-last-modified-date-and-time/
Count files
31cd ~/documents/api_asya_ai/requests_files/unprocessed2ls | wc -l#3
Available HDDs
xxxxxxxxxx11sudo fdisk -l
Disk UUIDs
xxxxxxxxxx11sudo lsblk -f
Mounting disk
xxxxxxxxxx11sudo mount /dev/sdX /media/hdd
Automatic mounting
xxxxxxxxxx71sudo vim /etc/fstab23LABEL=cloudimg-rootfs / ext4 defaults 0 14LABEL=UEFI /boot/efi vfat umask=0077 0 156UUID="69d4002e-a45a-483e-a13b-a3a1ffb255fb" /media/hdd1 ext4 defaults,noatime,_netdev 0 27/swapfile swap swap defaults 0 0
Mount points to these HDDs
xxxxxxxxxx11cat /proc/mounts
xxxxxxxxxx11pwdxxxxxxxxxx21find /dir -name "*Something*2 find /dir -iname "*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}')
xxxxxxxxxx21zip -r <output_file> <folder_1>2unzip <zip_file>
xxxxxxxxxx11whereis app_name
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
Move betwween folders:
xxxxxxxxxx31cd.. (move directory up)2cd- (move to previous directory)3cd ...(exact path)... (move to some concrete folder)
xxxxxxxxxx11nc -l PORT
Test if port is accepting something
xxxxxxxxxx11netstat -a | grep PORT
x1sudo apt install firewalld firewall-config2sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent3sudo firewall-cmd --reload4sudo ufw allow 5432567sudo firewall-cmd --zone=public --add-port=80/tcp --permanent8sudo firewall-cmd --reload
xxxxxxxxxx111grep -i -A 5 -B 5 "error" ./var/log/dmesg2sudo tail ./var/log/syslog3sudo tail ./var/log/kern.log45grep -i -A 5 -B 5 "error" ./var/log/kern.log67cat ./etc/ssh/sshd_config89cat ./etc/iptables/rules.v410sudo cat ./etc/ufw/user.rules11sudo rm -rf ./etc/firewalld/zones/
HPC:
Started tasks:
xxxxxxxxxx21showq -r2qstat
Videocard memory usage:
xxxxxxxxxx41ssh wn56 (choose wn... from showq -r)2logout (iziet no wn)3watch nvidia-smi (ctrl+C lai izietu)4htop
Starting/killing tasks:
xxxxxxxxxx21qsub -N reinis_freibergs -A ditf_ldi start_hpc.sh (Example for start)2qdel ...(task name from qstat)... (Kill a task)
Screens:
xxxxxxxxxx31screen -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:
xxxxxxxxxx21Ctrl+A D (exit screen, program will continue to run)2Ctrl+A K (kill a screen)
https://github.com/nodesource/distributions#debinstall
xxxxxxxxxx21curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\2sudo apt-get install -y nodejs
xxxxxxxxxx21echo "user_allow_other" | sudo tee -a /etc/fuse.conf2
Set and store
xxxxxxxxxx11sudo hostnamectl set-hostname www.something.com
Stored here
xxxxxxxxxx11vim /etc/hostname