LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-30-2005, 02:20 PM   #1
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Rep: Reputation: 15
Default home directory permission


To all Linux experts out there,

hi... i am fairly new to linux world and trying to learn web administration using fedora core 3 as my OS and apache as my web server.

I am trying to setup default home directory permission for each new user created on the system (for the web purpose). After googling for a while, I learned that the default permission needs to be 755 for all the home directories created (so that the users can access the pages stored under public_html...yes, the I set the permission for public_html to be 755).

Now, I want to setup the default permission for each home directory created to be 755 automatically. can this be accomplished by editing the .bash_profile file under /etc/skel ?

I tried putting in the command chmod 755 $HOME in the .bash_profile (it was just a blind attempt...) and it didn't seem to work! (i am not surprised..hehe). Ofcourse, it got copied over to the newly created user but no effect in terms of what I want to accomplish...

Can anyone suggest me anything on how to establish this setup? Thank you very much in advance!
 
Old 06-30-2005, 02:27 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Try chmoding /etc/skel to be 755. This should be carried over when /etc/skel is copied for the new home directory.
 
Old 06-30-2005, 03:11 PM   #3
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
It didn't work:-( FYI: the default permission on /etc/skel is set to 755 (drwxr-xr-x). However, to be sure I did a chmod 755 on that directory and created a new user account and the new account's home dir has the default permission of drwx------


Any other suggestions??
 
Old 06-30-2005, 03:18 PM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
maybe umask wil help u
what do u get for running
umask

set that to

umask 0022

regards
 
Old 06-30-2005, 03:42 PM   #5
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
umask for /etc/skel is 0022

and it is same as above for the home directories created...

I tried adding 'umask 0022' at the end of .bash_profile file located under /etc/skel and it didn't do the trick... logged in and logged out as the newly created user and the home directory has the still the same old default permission

Thanks for the suggestion! Any more??
 
Old 06-30-2005, 03:47 PM   #6
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
how do u create new users??
and what do u get for
umask

regards
 
Old 06-30-2005, 03:55 PM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Yeah, you might need to run umask 0022 prior to creating the new user. My guess is your current umask is 0077.
 
Old 06-30-2005, 04:24 PM   #8
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
Masand...to answer your question, I create a new user by issuing the following command on shell:

useradd USERNAME -g www -s /sbin/nologin -p PASSWORD

and if you are asking what do I get for umask for the newly created home dir then the answer is 0022 . As I said before, it is 0022 for both newly created dir and for the /etc/skel directory. It is the permission that differs.... (Please read one of my previous posts)

Matir... what do you mean by I need to run umask 0022 prior to creating a new user? where do you suggest me to run that?? Can you eloborate a little more on that... Do I have to run that manually everytime I create a new user?? I just want to automate the whole process of setting the right permissions for each newly created home dir...

Thank you both of you!
 
Old 06-30-2005, 04:32 PM   #9
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
In a console, just like you would be about to add a new user, please run 'umask' by itself and post the output. You don't set umasks for directories, but for users.
 
Old 06-30-2005, 04:39 PM   #10
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
when I enter the command 'umask' I get 0022

I did that as a root for the /etc/skel directory... then I did the same as both root and the newly created user under the home directory of the new user and I get the same 0022
 
Old 06-30-2005, 04:40 PM   #11
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
how do u create new users???
 
Old 06-30-2005, 04:52 PM   #12
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
Masand.... Please 'scroll up' and read one of my previous posts where I clearly explained how I do it....

Thanks
 
Old 06-30-2005, 04:56 PM   #13
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
umask does not care about directories. Directories care about umask. According to http://lists.ssc.com/pipermail/linux...r/021773.html, which could be found by googling, you need to set the umask in /etc/logins.def.
 
Old 06-30-2005, 06:52 PM   #14
kumarsundaram
LQ Newbie
 
Registered: Jun 2005
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks for pointing me to that URL... it was helpful and I added UMASK 0022 to the file and created a new user.... Surprisingly enough the home dir got the permission I needed!

However, a new problem arised.... the permissions for 'public_html' or any other subdirs of /etc/skel/ is not carried over to the newly created user. The original permission for 'public_html' is set to 755 but for newly created user this directory has the permission of drwx------.

Just for fun, I changed the permission of 'public_html' to be 777, created a new user and the permission under the home dir is drwx------ for 'public_html'

I am confused to understand on what's going on now???
 
Old 06-30-2005, 07:33 PM   #15
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I wish I understood as well. I would've thought it performs a copy, preserving permissions, then chowns the files in question... or, for that matter, switches to the new user, and performs a copy, in which case the umask should take effect.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
permission denied to home directory ekdya Debian 3 11-08-2005 04:24 PM
Permission problems when removing user's home directory. davethegenius Linux - Software 3 08-11-2005 04:01 PM
Home Directory Permission dvishloff Linux - General 1 08-11-2005 04:07 AM
default permission for home in slack joma Slackware 7 06-20-2005 03:53 PM
Default home directory permission in SUSE 9.1 soldonz Linux - Security 1 05-26-2005 05:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration