Find the answer to your Linux question:
Results 1 to 6 of 6
Hello...I am a beginner I want to write a script name myuseradd I want to add user without useing useradd command 1- Check if user is root. If not the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11

    Useradd....without useradd comman......


    Hello...I am a beginner
    I want to write a script name myuseradd
    I want to add user without useing useradd command

    1- Check if user is root. If not the script cannot be run and it exits.
    2- Check the number of arguments. If none the script exits.

    Can someone give me a clue ???
    thanks Loooot

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    hint:
    Code:
    if [[ $EUID -ne 0 ]]; then
       echo "This script must be run as root" 1>&2
       exit 1
    fi
    linux user # 503963

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11
    Quote Originally Posted by scathefire View Post
    hint:
    Code:
    if [[ $EUID -ne 0 ]]; then
       echo "This script must be run as root" 1>&2
       exit 1
    fi
    Ok good....but how to add user without using useradd command
    ????

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    In puppet, it would look like this:
    Code:
    user { 'abdelellah':
      ensure  => 'present',
      comment => 'Abdelellah',
      uid     => '1000',
      gid     => '10',
      home    => '/home/abdelellah',
      shell   => '/bin/bash',
      password => '<Abdelellah_HASH>',
      managehome => 'true',
    }
    See? No useradd

    But I assume, what you are looking for is directly editing the files containing the account information.
    And as this looks like a homework question to me, I suggest
    - you read the man page of useradd to figure out, which files contain the account informations
    - then look at the files
    - then decide how you would implement your own useradd

    Code:
    man useradd
    You must always face the curtain with a bow.

  5. #5
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    linux user # 503963

  6. #6
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    This sounds like a homework question, which are not allowed on this forum. I am closing this thread.

Posting Permissions

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