Copy a folder
1 |
cp -avr /home/cool_site_folder /var/www/cool_site_new_folder_name |
What port is used?
1 |
netstat -tulpn | grep php-fpm |
Find and delete files greater than a given size
1 |
find . -size +1M -exec rm -i {} \; |
Find out directories using disk space
1 |
du -cksh /var/* | sort -rn | head |
Find a file
1 |
sudo find / -name 'php.ini' |
Sorting ls command output by file size
1 |
ls -Slh |
to reverse order use -r option.
Archive directory
1 |
tar -zcvf my-dir.tar.gz /home/user/my-dir |
Copy files from remote to local with Rsync
1 |
rsync -razP user@remote-server.com:~/home/remote-user/file.cpp /home/local-user/ |
File permissions
1 |
chmod 755 nginx.conf |
Change permission of file.
4 – read (r)
2 – write (w)
1 – execute (x)
order: owner/group/world
eg:
755 – rwx for owner, rx for group and world
List directory files sorted by time
1 2 3 4 5 |
# Sort by newest files first ls -laht # Sort by oldest files first ls -lahtr |