LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-23-2004, 10:40 AM   #1
mcmanta
LQ Newbie
 
Registered: Apr 2004
Location: LI, New York
Distribution: Fedora Core 1
Posts: 7

Rep: Reputation: 0
useradd command not working in terminal


Hey all

Im trying to add a user with the useradd command.
I open a terminal and log in and do the following

[thomas@localhost thomas]$ su
Password:
[root@localhost thomas]# useradd tom
bash: useradd: command not found

what silly thing em I doing wrong?
 
Old 04-23-2004, 10:45 AM   #2
njbrain
Member
 
Registered: Jan 2004
Location: Rhinelander, WI, U.S.
Distribution: Slackware
Posts: 416

Rep: Reputation: 30
Try "adduser". Also, what disto are you running?
Noah.
 
Old 04-23-2004, 10:46 AM   #3
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
You could try
locate useradd or
which useradd
like so:
Code:
root@192:/home/devin]$which useradd
/usr/sbin/useradd
[root@192:/home/devin]$locate useradd
/etc/default/useradd
/usr/share/man/man8/useradd.8.bz2
/usr/sbin/useradd
/usr/sbin/luseradd
And then try running it with the full path
/usr/sbin/useradd

BTW, what distro are you using? That might help.

Later
 
Old 04-23-2004, 11:04 AM   #4
mcmanta
LQ Newbie
 
Registered: Apr 2004
Location: LI, New York
Distribution: Fedora Core 1
Posts: 7

Original Poster
Rep: Reputation: 0
Talking

I was able to get the command to work by locating it and running it from its directory.
how do i find what distro im running?

thanks again for the help !!
 
Old 04-23-2004, 11:41 AM   #5
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
Wink what distro

Hey,

This will tell you a lot about your system
uname -a

However, as for distro....well what one did you install? When you start up the computer it will usually tell you. By distro we are refereing to Mandrake, Red Hat, Debian...etc. To find out what you are running you can try

Code:
[root@192:/etc]$ls *-release
mandrake-release  redhat-release@

[root@192:/etc]$cat mandrake-release
Mandrake Linux release 10.0 (Community) for i586
for some reason I have both a redhat one and a mandrake one. This isn't fool-proof. Because this file could easily changed but I doubt anyone would do that

Hope this helps.

Later
 
Old 04-23-2004, 01:57 PM   #6
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
OK, the reason it didn't work is because useradd is only in the path for root and just doing 'su' does not change the environment variables, only the user. To be root with all root's environment set up you need to type:
Code:
su -
Notice the hyphen after su.
 
Old 04-23-2004, 05:11 PM   #7
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
actually you can just use su to become root....at least on my system
 
Old 04-23-2004, 06:52 PM   #8
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally posted by devinWhalen
actually you can just use su to become root....at least on my system
You didn't read what I wrote - su WITHOUT the hyphen will make you root, but it will not load root's environment (most importantly it won't give you root's PATH, just the normal user's path)

WITH the hyphen it gives you root's environment settings - his PATH, any other environment variables like DISPLAY that root might have set. Most importantly it puts /sbin in the path which it isn't usually for a normal user.

Obviously this all depends on what PATH you set for different users - if they have the same path as the root then nothing much will change apart from what you can load and change.

Read the su man page.
 
Old 04-24-2004, 10:40 AM   #9
devinWhalen
Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Red Hat, openBSD,Mandrake,freeBSD,SunOS
Posts: 168

Rep: Reputation: 30
sorry...didn't read you post carefully...just skimmed it. I guess my wife it correct when she says I don't listen =p

Later
 
Old 04-24-2004, 08:31 PM   #10
mcmanta
LQ Newbie
 
Registered: Apr 2004
Location: LI, New York
Distribution: Fedora Core 1
Posts: 7

Original Poster
Rep: Reputation: 0
Thumbs up

Thanks all everything works great!!!!!
 
Old 05-03-2004, 07:41 PM   #11
Swindle
LQ Newbie
 
Registered: May 2004
Posts: 1

Rep: Reputation: 0
The problem is when you type "su" you are not updating the environment variables.

You need to type "su -" to update this information, then your root user commands wills work.

Hope this helps!

-Swindled
 
Old 05-12-2004, 02:05 PM   #12
struberg
LQ Newbie
 
Registered: May 2004
Location: vienna
Distribution: FC3
Posts: 17

Rep: Reputation: 0
the "-" is only the short version for "-l" who gives you a real login shell.

If you do not use the "-" or "-l" option, you only change the user without getting a new login shell.
 
  


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
useradd command Wolvastur Linux - Newbie 9 01-25-2005 11:01 AM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-22-2003 12:47 AM
useradd command johnpayback Linux - General 4 08-13-2002 06:24 PM
useradd command johnpayback Linux - Newbie 5 08-13-2002 11:22 AM
useradd command allancondino Linux - General 5 04-27-2002 01:01 PM


All times are GMT -5. The time now is 10:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration