User
sudo adduser [newuser]
create a new usersudo usermod -aG [group] $USER
to add group into current usersudo usermod -aG sudo [user]
to add user to sudo
Filesystem
du -sh * | sort -h
tampilan directory berdasarkan urutan sizedu -sh * | sort -rh
untuk reverse
System
Port
sudo lsof -i :443 -sTCP:LISTEN
check siapa yang menggunakan port tertentusudo netstat -anv -p tcp | egrep 'Proto|(\*\.(80|443))'
sudo lsof -i -P -n | grep 80
- lalu gunakan
ps -p [pid]
untuk melihat detail proses-nya sudo kill <process id>
Process
ps
ps -p [pid]
melihat siapa yang menggunakandu -h | sort --key=2
menampilkan folder beserta ukurannya dan di sortir untuk koom 2 (filename). Defaultnya sortir terhadap filesilze di kolom 1
CHMOD & FACL
Chmod recursively
// recursively 755 and 664
chmod -R a=,a+rX,u+w,g+w /some/path/here
Step 1: Create Backup
First make a backup incase anything goes wrong someday:
mkdir ~/storage-changes
sudo getfacl -R /var/www > ~/storage-changes/default_www_facl
(Incase) To Restore
sudo setfacl --restore=~/storage-changes/default_www_facl
Apply ACL
Next, apply to a group:
# -R is recursive
# -m is modify
# -d applies to default ACL
sudo chgrp -R www-data /var/www
sudo setfacl -Rd g:www-data:rwX /var/www
sudo setfacl -Rdm g:www-data:rwX /var/www
ls -lta /var
sudo getfacl /var/www
The +
at the end of the file/dir listing only means it has additional ACLs.
MISC
Create New File via Right Click
- See if you have
~/Templates
folder. Create one if it is missing using command:
mkdir ~/Templates
- Now create an empty file from command prompt:
touch ~/Templates/Text\ File.txt
- History, clear history
history -cw
Diff
diff -cw [file1] [file2]
difference while ignoring whitespace in context viewdiff -yw [file1] [file2]
difference while ignoring whitespace and in 2 column view