Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all when we add user using useradd command with -m option its home directory also gets created with bash_profile,bashrc ,bash_logout file this files gets copied from /etc/skel forlder the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Location
    India
    Posts
    45

    [SOLVED] useradd issue


    Hi all

    when we add user using useradd command with -m option its home directory also gets created with bash_profile,bashrc ,bash_logout file
    this files gets copied from /etc/skel forlder

    the default permission and ownership of /etc/skel
    by doing ls -lart
    -rw-r--r-- 1 root root 18 Dec 19 03:11 .bash_logout
    drwxr-xr-x 2 root root 100 Dec 27 20:27 .
    -rw-r--r-- 1 root root 132 Dec 28 06:40 .bashrc
    -r--r--r-- 1 root root 214 Dec 28 06:40 .bash_profile
    dr-xr-xr-x 64 root root 3240 Dec 28 18:03 ..
    and the ls -lart of /home/userC
    -rw-r--r-- 1 userC users 18 Dec 19 03:11 .bash_logout
    -rw-r--r-- 1 userC users 132 Dec 28 06:40 .bashrc
    drwx------ 2 userC users 4096 Dec 28 17:52 .ssh
    drwxr-xr-x 4 root root 4096 Dec 28 17:54 .
    -r--r--r-- 1 userC users 214 Dec 28 17:56 .bash_profile
    drwxr-xr-x 9 root root 4096 Dec 28 18:24 ..


    Now what I want is the default owner and group of bash_profile,bashrc and bash_logout to be root and not userC:users

    can anyone please help be out is there any way to have the owner of those file as root at the time of running useradd command

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,763
    *Nix Administration 101 - When you want to change what a command does, replace it with your own version.

    - Find the useradd command
    - Move it to another name
    - Replace it with your own useradd shell script that: 1) Calls the original useradd and then 2) runs a chgrp root on the completed home folder.

  3. #3
    Just Joined!
    Join Date
    Dec 2010
    Location
    India
    Posts
    45
    thank you frnd
    I did the same but wanted to confirm is tehre any option with useradd command

    thank you for ur valuable suggestion

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •