LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-06-2003, 01:38 PM   #1
roofy
Member
 
Registered: Apr 2003
Location: Florida
Distribution: Redhat 7.2
Posts: 222

Rep: Reputation: 30
useradd in slackware...


i really liked the useradd script in slackware 9 does anyone kno where i can find that script so i can put it in red hat
 
Old 05-06-2003, 02:39 PM   #2
rjethmal
LQ Newbie
 
Registered: May 2003
Location: Rep. of Panama
Posts: 1

Rep: Reputation: 0
rjc@jethmal:~# whereis adduser
adduser: /usr/sbin/adduser /usr/man/man8/adduser.8 /usr/share/man/man8/adduser.8
rjc@jethmal:~#
 
Old 05-06-2003, 02:45 PM   #3
roofy
Member
 
Registered: Apr 2003
Location: Florida
Distribution: Redhat 7.2
Posts: 222

Original Poster
Rep: Reputation: 30
is there anyway you can copy and paste the contents here? i kno its a shell script
 
Old 05-06-2003, 03:13 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
redhat has useradd.... probably as a bninary and not a script, but it's still there...
 
Old 05-06-2003, 04:37 PM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Code:
#!/bin/sh
# adduser script for use with shadow passwords and useradd command.
# by Hrvoje Dogan <hdogan@student.math.hr>, Dec 1995.
# Modified by Patrick Volkerding, Oct 1997, Mar 1999, May 2000.

echo
echo -n "Login name for new user []: "
read LOGIN
if [ -z "$LOGIN" ]; then
  echo "Come on, man, you can't leave the login field empty..."
  exit
fi
echo
echo -n "User id for $LOGIN [ defaults to next available]: "
read ID
GUID="-u $ID"
if [ -z "$ID" ]; then
  GUID=""
fi

echo
echo -n "Initial group for $LOGIN [users]: "
read GID

if [ -z "$GID" ]; then
  GID="users"
fi
GGID="-g $GID"

echo
echo "Additional groups for $LOGIN (seperated"
echo -n "with commas, no spaces) []: "
read AGID
GAGID="-G $AGID"
if [ -z "$AGID" ]; then
  GAGID=""
fi

echo
echo -n "$LOGIN's home directory [/home/$LOGIN]: "
read HME
if [ -z "$HME" ]; then
  HME="/home/$LOGIN"
fi
GHME="-d $HME"

echo
echo -n "$LOGIN's shell [/bin/bash]: "
read SHL
GSHL="-s $SHL"
if [ -z "$SHL" ]; then
  GSHL="-s /bin/bash"
  SHL="/bin/bash"
fi

echo
echo -n "$LOGIN's account expiry date (YYYY-MM-DD) []: "
read EXP
GEXP="-e $EXP"
if [ -z "$EXP" ]; then
  GEXP=""
fi
echo
echo "OK, I'm about to make a new account. Here's what you entered so far:"
echo
echo New login name: $LOGIN
if [ -z "$GUID" ]; then
  echo New UID: [Next available]
else
  echo New UID: $UID
fi
if [ -z "$GGID" ]; then
  echo Initial group: users
else
  echo Initial group: $GID
fi
if [ -z "$GAGID" ]; then
  echo Additional groups: [none]
else
  echo Additional groups: $AGID
fi
if [ -z "$GHME" ]; then
  echo Home directory: /home/$LOGIN
else
  echo Home directory: $HME
fi
if [ -z "$GSHL" ]; then
  echo Shell: /bin/bash
else
  echo Shell: $SHL
fi
if [ -z "$GEXP" ]; then
  echo Expiry date: [no expiration]
else
  echo Expiry date: $EXP
fi
echo
echo "This is it... if you want to bail out, hit Control-C.  Otherwise, press"
echo "ENTER to go ahead and make the account."
read FOO
echo
echo Making new account...
/usr/sbin/useradd $GHME -m $GEXP $GGID $GAGID $GSHL $GUID $LOGIN
if [ -d $HME ]; then
  chmod 711 $HME
fi
echo
/usr/bin/chfn $LOGIN
echo
/usr/bin/passwd $LOGIN
echo "Done..."
Should have copied before installing Redhat huh.. Just kidding.
 
Old 05-06-2003, 04:39 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
And its actually called adduser and not useradd in Slackware.
 
Old 05-06-2003, 05:53 PM   #7
roofy
Member
 
Registered: Apr 2003
Location: Florida
Distribution: Redhat 7.2
Posts: 222

Original Poster
Rep: Reputation: 30
always confuse em lol

there we go thanks guys

the beauty of open source
 
Old 05-06-2003, 05:56 PM   #8
roofy
Member
 
Registered: Apr 2003
Location: Florida
Distribution: Redhat 7.2
Posts: 222

Original Poster
Rep: Reputation: 30
ok now how do i integrate it into the shell i went to /bin/ and created a file and copied the contents...but it only works when i sh it? how do i make it a command like ls or mv
 
Old 05-06-2003, 06:30 PM   #9
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by roofy
ok now how do i integrate it into the shell i went to /bin/ and created a file and copied the contents...but it only works when i sh it? how do i make it a command like ls or mv
chmod +x /bin/<filename>
 
Old 05-06-2003, 06:38 PM   #10
roofy
Member
 
Registered: Apr 2003
Location: Florida
Distribution: Redhat 7.2
Posts: 222

Original Poster
Rep: Reputation: 30
aha! thanks u rock
 
Old 05-28-2003, 04:01 PM   #11
xcon
Member
 
Registered: Jan 2002
Location: Ohio
Distribution: Slackware 9.1 (and some 9.0)
Posts: 181

Rep: Reputation: 30
in DOS you make a script by changing the .TXT to .BAT... in *nix it's just a matter of giving it execute permission... i like it a lot!!

note: the #!/bin/sh at the beginning tells the system what to run it with, in this case /bin/sh is a symlink to /bin/bash. after all it's a bash script, yes? perl scripts start with #!/bin/perl or #!/usr/bin/perl or something and python is the same way... if you're in bash and you try to run a perl script that has no #!/bin/nnn, bash will probably try to run it (it's your shell!) and choke on the syntax, anyone want to confirm that?
 
  


Reply



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
useradd jerryluis Fedora 9 03-27-2005 07:37 PM
Using Useradd spud Linux - Newbie 6 03-10-2005 03:50 PM
slackware 10 useradd skeleton.. miguetoo Slackware 2 06-25-2004 01:50 AM
useradd cyrush Linux - Distributions 3 01-21-2003 09:40 PM
useradd qdickens Linux - General 4 11-02-2001 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:57 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