hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : VPS Hosting : VPS Tutorials : Quickly change permissions per file/folder
Reply

VPS Tutorials Tutorials related to VPS.
Forum Jump

Quickly change permissions per file/folder

Reply Post New Thread In VPS Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-30-2012, 10:17 AM
kbeezie kbeezie is offline
Web Hosting Master
 
Join Date: Jun 2010
Location: Grand Rapids, Mi
Posts: 1,193

Quickly change permissions per file/folder


This is assuming you run a webserver and php as www-data (or the www equivalent) and that the owner of the files is one up from there (example /home/username/www/ is owned by username with the group of www-data).

Can quickly set all folders to 750 and all files to 740 with the following commands (or whatever octal numbers you need)

Code:
cd /home/username/www/
find . -type d -print0 |xargs -0 chmod 750
find . -type f -print0 |xargs -0 chmod 640
first find row will find from the current directory you're in all directories and then set their permissions to 750 (read/write/exec for owner/user, read/execute for group, nothing for 'other')

and the next find row would find all files recursively and set their permissions to 640 (read/write for user/owner, read for group, nothing for 'other')

Just something I thought of doing in light of securing WHMCS

for example if I moved the attachment, downloads, and template_c folder out of the WHMCS installation folder, and the configuration.php is already set, then all folders and files in the WHMCS installation path should be fine at 750/640 (or 755 and 644 depending on your server configuration).

My web services run as www-data (nginx and php), and the files are owned by a specific user as a part of that group, so technically there is no reason why any user/group outside of that should have access to those files, hence the zero for the 'other' octal.

Your milage may vary. But those commands will recursively set only-dirs and only-files to whatever octal value you choose as a starting point.

Reply With Quote


Sponsored Links
  #2  
Old 05-30-2012, 10:22 AM
cala2ar cala2ar is offline
Newbie
 
Join Date: Mar 2010
Location: Cyprus
Posts: 17
find /home//public_html/*/ -type d -exec chmod 750 {} \;

Reply With Quote
  #3  
Old 05-30-2012, 10:23 AM
kbeezie kbeezie is offline
Web Hosting Master
 
Join Date: Jun 2010
Location: Grand Rapids, Mi
Posts: 1,193
Quote:
Originally Posted by cala2ar View Post
find /home//public_html/*/ -type d -exec chmod 750 {} \;
If your webserver is setup that way (I assume directadmin from the look of it) and that's if you just want to reset every possible user (I think directadmin actually has a script in their script collection for resetting all the folder/file permissions).

By the way that method with the {} \ is a bit slower and sometimes snags on certain filenames.

Reply With Quote
Sponsored Links
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
System folder/file permissions? FLCLFan Hosting Security and Technology 2 08-28-2010 09:25 AM
Folder - File Permissions? ePlanetDesign Hosting Security and Technology 3 10-28-2007 02:06 PM
Can't install FP extensions and change folder permissions nogi Hosting Security and Technology 3 10-22-2003 06:16 PM
File and Folder Web Permissions?? Frotax Hosting Security and Technology 0 09-03-2003 10:29 AM
File/Folder security & permissions ... fantasmic0 Hosting Security and Technology 3 08-05-2002 09:59 PM

Related posts from TheWhir.com
Title Type Date Posted
Cloud File Sharing Software ownCloud Launches Beta of Updated Community Version Web Hosting News 2012-09-04 17:09:04
Pancake.io, DropPages Let Users Host Web Site Files on DropBox Blog 2011-12-08 17:03:11
Email Provider Atmail Releases One-Click iOS Provisioning with Atmail 6.3 Web Hosting News 2011-11-28 20:34:19
Cloud Management Software Firm Ensim Enhances Unify SharePoint Manager Web Hosting News 2011-09-06 17:57:22
Web Host WebHostingBuzz Partners with Cloud Platform SMEStorage Web Hosting News 2011-06-01 18:10:25


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?