4 hard to remember useful linux commands

It may be a list of unrelated linux commands, but I wanted to write them somewhere in case I need them later and I though I might as well share them with you!

suPHP file and directory permission fix

suPHP require a specific set of permission on files and directory in order to allow Apache to access them. These commands change the permissions of all files and directories under the specified path to the required ones.

find /home/<user>/public_html -type d -exec chmod 755 {} \;
find /home/<user>/public_html -type f -exec chmod 644 {} \;

Synchronize local directory with remote (ftp)

This will synchronize a local directory base on a remote FTP directory. After the command has been run, the local directory will be exactly like the remote one, this is better than downloading every files, because it won’t download existing files and will delete files that are not on the remote.

rsync -chavzP –stats user@domain.com:<remote_path><local_path>

Find the largest files

This command will find the 20 largest files under the current directory and save their paths to “largest.txt”.

find . -type f -print0 | xargs -0 du -h | sort -hr | head -20 >largest.txt

Self-Signed Certificate

This command will create a 2048 bit self-signed certificate (and it’s private key) valid for 10 years (requires OpenSSL).

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout cert/server.key -out cert/server.crt -sha256

 

Add a Comment

Your email address will not be published. Required fields are marked *