LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Terminal Help (https://www.linuxquestions.org/questions/linux-newbie-8/terminal-help-620331/)

vwtech 02-11-2008 11:43 AM

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?

b0uncer 02-11-2008 12:38 PM

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.


All times are GMT -5. The time now is 09:18 AM.