LinuxQuestions.org
Review your favorite Linux distribution.
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 02-11-2008, 12:43 PM   #1
vwtech
Member
 
Registered: Dec 2007
Distribution: Fedora, Oracle Linux & Centos
Posts: 187

Rep: Reputation: 25
Terminal Help


When running the "useradd" command in the terminal (within the GUI).

I get the following error:
bash: useradd: command not found.

When I run the same command from the CLI it executes with no problem.

How can I make is so it will run in the terminal?
 
Old 02-11-2008, 01:38 PM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Most probably it's "not found" because the directory where useradd executable resides is not included in the $PATH environment variable of the user you are trying to run the command as. If you use sudo the case is the same, or if you used 'su' and not 'su -' to become root (you need to run useradd with root privileges). To make it right, run
Code:
sudo /usr/sbin/useradd --etc--
or
Code:
su
/usr/sbin/useradd --etc--
or
Code:
su -
useradd --etc--
depending on your distribution (preferably use sudo if you can).

Shortly said, the $PATH variable contains directories from which an executable is looked for when you type in it's name. Some executables are in sbin directories that are in some distributions included in root's $PATH but not in users', because typically the executables in those directories need to be run with root privileges, and not regular users' (so it is intentional; less directories to look from means less time consumed). So as regular user you need to type in the full path too, or alter your environment variable to contain the other directories as well.

When you log in from the console, or become root trough "su -", the environment variables are set to include the sbin directories. When you just launch a terminal, or become root trough "su" or use sudo, the user's environment variables do not contain sbin directories (in some distributions, that is), and thus the executables can't be found unless you tell exactly where they are.

Last edited by b0uncer; 02-11-2008 at 01:41 PM.
 
  


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
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 11:34 AM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 03:45 PM
pressing 'x' in gnome terminal starts new terminal instance Drwfan54 Ubuntu 3 09-26-2006 04:09 PM
How to launch an app in terminal, & keep it running after I close terminal? kornerr Linux - General 7 06-24-2006 06:54 PM
Alternative terminal to konsole & gnome-terminal Adony Linux - Software 3 10-08-2004 04:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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