MySQL Backup and Compress – One Line command

Let’s consider a case where you have limited disk space available in your database server. In addition, you need a database backup quickly. However, you estimate that, the space available in the server for the backup is not enough.

Continue reading

Change permissions of files, folders and sub-folders in linux

Let’s assume we have a folder /opt/docs/ and we have to create bellow folder tree, which are used by Accounts, HR and Sales divisions. Each folder is accessible to respective devisions only and others must not have any access to it.

/opt/docs/
|-- Accounts
|       `-- Employee
|-- HR
|      `-- Employee
`-- Sales
`-- Customers

To make the folder strcuture,

mkdir -p /opt/docs/Accounts/Employee
mkdir -p /opt/docs/HR/Employee
mkdir -p /opt/docs/Sales/Customers

To change ownerships to respective divisions,

chown -R accounts:accounts /opt/docs/Accounts/Employee
chown -R hr:hr /opt/docs/HR/Employee
chown -R sales:sales /opt/docs/Sales/Customers

To set access permissions only to respective divisions,

find /opt/docs/ -type d -exec chmod -v 0770 ‘{}’ \; # directory permissions
find /opt/docs/ -type f -exec chmod -v 0660 ‘{}’ \; # file permissions