TurnKey Linux Virtual Appliance Library


hamm3lvm's picture

Is there any way I can automatically Chmod the directory where I serve my websites.

This would make it easier to work with files.

This might seem a daft question, but I am still on a Linux learming curve.

Don Sanderson's picture

chmod -R XXX /var/www will

chmod -R XXX /var/www will change the permissions on the /www directory and all files/directories within it to XXX.


The SGID bit can be set on the /www directory to automagically set the group ID (GID) on all files created in, or copied to, that directory. And inherit that groups permissions.

See here:


Note: SGID does not work when files are MV'd so always use CP when transferring files to SGID'd folder.

Jeremy Davis's picture

Another way to go

May be to just add the Linux users who you want to be able to edit /var/www to the www-data (webserver) user group.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)