Friday, October 24, 2014

Setting up default permissions to Files and Directories

Most of the Linux beginners / Linux - Level 1 administrator do this funny thing. Setting up 777 permission to files and folders.

With, chmod -R 777 folder_name

Some times it'll help to destroy the server easily by hackers.

Let's come to topic, How to setup default / basic level permission to files and folders.

chmod -R 777 folder_name will give you files and folders with read, write and execute permission, Mostly we no need of execute permission for files.

If we try to change it as chmod -R 666 folder_name, we are not able to open directory.

If we have 100s of sub directory with 1000 of files in each directory,... oh my god.... How do we fix it worst thing.... Here is command.

first open your parent directory, with
cd parent_directory_name

And run following commands,

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Working: On first command It'll check type of the object whether it is file or directory, if it is directory it'll change permission to 755, else leave. On second same condition, if it is file then change permission to 644 else leave with same,

No comments:

Copy all Incoming Outgoing Emails - Employee monitor

How can we monitor employee's email conversations ? If we are running company, It's too impotent to monitoring employee's ema...