29

I installed CentOS 5.5 on my VMWare 8 recently and I am trying to add a new user on the system. I am unable to add the user unless I use su - option. I believe it has to do something with path not set properly.

I updated the path and here is what it looks like /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/uone/bin:/sbin

I believe the command is in /sbin dir which is already a part of path. Can anyone suggest me what else I might be missing?

4 Answers 4

41

Try adding /usr/sbin to your path.

For example to add it to the end of the path you would do something like this:

export PATH=$PATH:/the/file/path

4
  • Yep! That did the trick, Added it as priority location in path. Thanks mdpc :)
    – Atul
    Commented Aug 3, 2014 at 6:54
  • 1
    How would I do that? There is already a PATH = something in my .bash_profile? How do i add another one?
    – xiaodai
    Commented Dec 17, 2014 at 7:05
  • @xiaodai unix.stackexchange.com/a/26059/24354 Commented Oct 20, 2015 at 18:41
  • 5
    Want to provide an example of that for this to be a complete answer?
    – Henry F
    Commented Feb 28, 2017 at 4:01
23

I know the OP answer was solved, however for those who are running CentOS from within the docker container, which appears to be missing both adduser and useradd, the solution is to install shadow-utils (under root obviously):

yum install shadow-utils
1
  • I am on Rocky Linux 8. I used to be able to use "addgroup" and "adduser" then after a few automatic updates addgroup is missing, and i checked /usr/sbin/adduser, it's linked to 'useradd'. My understanding was that useradd is different than adduser, adduser is more advanced and do more things for you.
    – fchen
    Commented Apr 2 at 22:27
8
/usr/sbin/useradd username -g groupname -d homedirectory
3
  • Its giving me error -bash: /usr/sbin/useradd: No such file or directory
    – Nishad Up
    Commented Feb 20, 2018 at 7:51
  • same here @NishadUp
    – Stanley
    Commented May 19, 2020 at 17:43
  • you first need to install shadow-utils package and then use the /usr/sbin/useradd command. It should work this way. Maybe you did not install the shadow-utils in the first place. Commented Apr 7, 2023 at 6:27
-3
whereis useradd

this is used to solve that problem

2
  • That only tries to find useradd, not install it.
    – Amint
    Commented Mar 3, 2021 at 21:50
  • whereis: command not found
    – s3c
    Commented Apr 20, 2022 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .