I'm using OpenSuSE and my computer has only 2 accounts: root and me.I have a directory /srv/www/htdocs/abc.I just want to set it up so that when new folders or files are created in this directory they will have the permissions set to 777.When new files are created in this directory, I have to set them to 777 again to gain write access.I use root and type:chmod me /srv/www/htdocsBut I doesn't work.  How can I do that?
Set default permisson for newly folders and files in Linux
permissions;chmod
The use of chmod is for changing permissions, the command chown is for changing ownership of files & directories.ownershipTo change a directory's ownership you can use the following command: $ sudo chown -R me /srv/www/htdocsNOTE: we're using the sudo facility to elevate our privileges to the same level as root for these commands, without having to become root.permissionsTo change the permissions on this directory:$ sudo chmod -R 777 /srv/www/htdocsumaskUsing the command umask sets up your terminal so that when files & directories are created their permissions can be influenced a bit. Caution should be used when using umask since there are situations where it won't give you permissions exactly the way you think.For a directory it seems fine:$ for i in `seq 1 7`;do echo umask: 00$i; umask 00$i; rm -fr blah; mkdir blah;ls -l|grep blah;doneumask: 001drwxrwxrw-   2 saml saml     4096 Jul 29 14:39 blahumask: 002drwxrwxr-x   2 saml saml     4096 Jul 29 14:39 blahumask: 003drwxrwxr--   2 saml saml     4096 Jul 29 14:39 blahumask: 004drwxrwx-wx   2 saml saml     4096 Jul 29 14:39 blahumask: 005drwxrwx-w-   2 saml saml     4096 Jul 29 14:39 blahumask: 006drwxrwx--x   2 saml saml     4096 Jul 29 14:39 blahumask: 007drwxrwx---   2 saml saml     4096 Jul 29 14:39 blahHowever it won't let you have files exactly the way you might intend them to be with particular umasks. See umask 006 for example below:$ for i in `seq 1 7`;do echo umask: 00$i; umask 00$i; rm -fr blah; touch blah;ls -l|grep blah;doneumask: 001-rw-rw-rw-   1 saml saml        0 Jul 29 14:40 blahumask: 002-rw-rw-r--   1 saml saml        0 Jul 29 14:40 blahumask: 003-rw-rw-r--   1 saml saml        0 Jul 29 14:40 blahumask: 004-rw-rw--w-   1 saml saml        0 Jul 29 14:40 blahumask: 005-rw-rw--w-   1 saml saml        0 Jul 29 14:40 blahumask: 006-rw-rw----   1 saml saml        0 Jul 29 14:40 blahumask: 007-rw-rw----   1 saml saml        0 Jul 29 14:40 blahThere are others, this is just to highlight an example!So what should you do?Given you're dealing with a Apache directory (based on the path /srv/www/htdocs) I'd look for a Unix group that your user me and the user that Apache is running as are both members of. You can use the groups command to determine this:$ groups samlsaml : saml vboxusers jupiter newgrp$ groups apacheapache : apacheYou can also use the id command:$ id samluid=500(saml) gid=501(saml) groups=501(saml),502(vboxusers),503(jupiter),10000(newgrp)$ id apacheuid=48(apache) gid=48(apache) groups=48(apache)On my system Apache is run by a user apache. Looking at this user you can see that it's in a single group apache as well. So one approach would be to add the user me to this group.For example, add me to the apache groups:$ sudo usermod -a -G apache meThe other approach would be to create another group and add both apache and me to this secondary group (for example, apacheplus), and then run this command on /srv/www/htdocs:$ sudo chgrp -R apacheplus /srv/www/htdocs