LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash: Command Not Found (https://www.linuxquestions.org/questions/linux-newbie-8/bash-command-not-found-4175428434/)

kohshan99 09-21-2012 03:28 PM

Bash: Command Not Found
 
I installed Red Hat Enterprises 5
when I try to issue the commands useradd, usermod, or userdel
it gives me the following error message:

bash: useradd: command not found
bash: usermod: command not found
bash: userdel: command not found

I checked these commands in the following path and I found them
/usr/sbin/useradd
/usr/sbin/usermod
/usr/sbin/userdel

what does that mean ????

pleassssss help meeee

colucix 09-21-2012 03:59 PM

Hi and welcome to LinuxQuestions!

Most likely you are trying these commands as a normal user, whereas they are system commands reserved to the system administrator (that is the Linux super-user, named root). As you can see they are in the /usr/sbin directory, that according to the Filesystem Hierarchy Standard contains commands for which root's privileges are required.

Indeed, if you check your PATH environment variable:
Code:

echo $PATH
you cannot see /sbin nor /usr/sbin in the (colon separated) list of directories, hence the command not found error. On the contrary, if you gain root's privileges you will see them listed and you'll have these commands at your disposal.

In addition to the official Red Hat documentation, I suggest the more friendly "The Linux Command Line" book, that explains these basic concepts in a plain and clear way.

kohshan99 09-23-2012 07:55 AM

when im using Level 5 then its works. but in GUI mode (level 7) didn't work....

pixellany 09-23-2012 09:16 AM

I don't know what level 5 and level 7 are----it sounds like level 5 might have a root environment (different $PATH)

Check the PATH in both levels---but also try to simply enter "su" in a terminal to switch to root user.

kohshan99 09-24-2012 12:40 AM

its called RUN Level's.

Alt+Ctrl+F5 or Alt+Ctrl (F1 to F7)

F7 is full GUI mode.

konsolebox 09-24-2012 02:44 AM

As a normal user, PATH does not include everything /sbin. Also, executables in /sbin are normally only executable by an EUID 0 user or root.

pan64 09-24-2012 03:08 AM

no, that is not run level (I think). Alt+Ctrl+F5 will give you a command window where you can log in as root, Alt+Ctrl F7 will give you a GUI where usually normal users are logged in.
/usr/sbin is available only for root, normal users are not allowed to use those tools (as it was mentioned before)

chrism01 09-24-2012 05:01 AM

Indeed, runlevels are not the same as different login screens https://en.wikipedia.org/wiki/Runlev...nux_and_Fedora

mandyapenguin 09-24-2012 01:02 PM

Quote:

Originally Posted by kohshan99 (Post 4787109)
when im using Level 5 then its works. but in GUI mode (level 7) didn't work....

The reason of "command not found" is already said in colucix post itself.
run
Code:

whereis useradd
whereis userdel
whereis usermod

As a root or super user check whether or not the path is set to environment variables using
Code:

env | grep PATH
or
echo $PATH

If not, then set path variable using
Code:

export PATH=/sbin/:$PATH
or
export PATH=/usr/sbin/:$PATH

or whereever you find the path from whereis command. And then excecute useradd, userdel, usermod commands as root/super user, or simply use full path whichever you have found from whereis command like
Code:

/usr/sbin/useradd username
And dont get confuse with runlevels and terminals

kohshan99 09-25-2012 01:11 AM

Thank u friends... Problem is solved... & once again thanks for help...


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