LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How can I define permissions on a /home/user dir _before_ creating it with adduser (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-define-permissions-on-a-home-user-dir-_before_-creating-it-with-adduser-159068/)

skunkburner 03-17-2004 02:51 PM

How can I define permissions on a /home/user dir _before_ creating it with adduser
 
Hi

I am setting up an apache server with /~user access on RH9, and am trying to create the user directories with the appropriate permissions in place.

I have found the /etc/skel dir and found setting the public_html in there to 755(or whatever) makes the /home/user/public_html to 755 as well.

I would like to know how I can set the /home/user dir to have 711 permission when it is created with the adduser command. setting the /etc/skel to 711 doesn't work : (

Thanks in advance

Skunkburner

DoubleOTeC 03-17-2004 04:11 PM

Isn't it possible to make the directory and then set it add the user?

OR

I suppose it could be easily done afterwards....

cyberfunk 03-17-2004 05:14 PM

I guess one way of doing it would be

useradd <blahblahblah> -d <directory> <blahblahblah>;mkdir <directory>;chmod 711 <directory>

If you popped that into a shell script with some variables, it would happen almost instantly, but I think if you created the directory before you added the users with those perms, useradd might complain... well it would on hpux anyways...

Cyber

liamoboyle 03-17-2004 05:59 PM

Edit the adduser command so that it sets new user directories to what you want

liam@loki:~$ su -
Password:
loki:~# vi `which adduser`

There is a line like this -
$config{"dir_mode"} = "0755";

if you set it to
$config{"dir_mode"} = "0711";

Then you'll be sweet.

skunkburner 03-18-2004 05:35 AM

Hi Liam

OK I followed your explaination until just after vi 'which adduser'
adduser is an ELF executable and only shows up as garbage in vi.
I tried using the vi command :!xxd which converted it to hex,
but I still couldn't see anything like $config{"dir_mode"} = "0711";

what am I doing wrong?

skunkburner 03-18-2004 06:20 AM

Thanks for the help but I've just worked it out.

I needed to add the line 'umask 066' to /etc/login.defs and the /home/user dir was created with the appropriate permissions.

liamoboyle 03-18-2004 03:42 PM

Must be a distro drifference; adduser under debian is a perl script!


All times are GMT -5. The time now is 09:10 PM.