PDA

View Full Version : [ubuntu] Which CHMOD Number?



adamjkok
October 2nd, 2010, 08:12 PM
I want to create a public_html directory in a user's home folder for Apache2 to serve.


I'll do this as root by using sudo
Needs to be readable by everybody
Needs to be owned, readable, and writable by user

Which CHMOD number do I use? Is there something else that I need to run?

Lateralis
October 2nd, 2010, 08:35 PM
If you run the sudo command then the directory will be owned by root. If you want to set the user as the owner then you need to run the chown command.

This page (http://catcode.com/teachmod/) gives a good guide to the use of chmod.

gzarkadas
October 2nd, 2010, 08:42 PM
755 (rw for user r for group, others). You must also make sure that the user's home folder has the others' x bit activated. You can do all of this inside a terminal window by typing the following commands (substitute [account-name] with the account's login name):



sudo -i
cd /home
chmod g+x,o+x [account-name]
mkdir -p -m 755 /home/[account-name]/public_html
chown [account-name]:[account-name] /home/[account-name]/public_html
exit
See http://en.wikipedia.org/wiki/Filesystem_permissions, section "Notation of traditional Unix permissions" for a detailed presentation and mapping between permissions and chmod numbers.

sisco311
October 2nd, 2010, 08:43 PM
Assuming that you have a world-readable home directory, create it as your regular user:

mkdir ~/public_html

abohsin
October 2nd, 2010, 08:43 PM
I recommend you try '755', so owner has full permission, others have read and execute, without the ability to write. I have learned that with permissions, sometimes you need to use trial and error.