• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

Adding new user in Linux - useradd and adduser not working

I'm trying to create a new user on my Web server.  I think it's running Ubuntu but I'm not sure.  I've tried useradd and adduser, while working as root, and it keeps telling me "bash: useradd: command not found"

I'm using putty to remote in to the server.

The man pages have information on the useradd command, even if the command doesn't seem to work.

What am I doing wrong?
0
GlennSimpson2
Asked:
GlennSimpson2
1 Solution
 
legolasthehansyCommented:
Are you root?
What is the output for command "id"?
0
 
GlennSimpson2Author Commented:
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
0
 
legolasthehansyCommented:
Great..
What about "which useradd" or "which adduser"
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
GlennSimpson2Author Commented:
which useradd

/usr/bin/which: no useradd in (/usr/kerberos/sbin:/usr/kerberos/bin:/user/local/bin:/bin:/usr/bin:/home/username/bin)

which adduser
/usr/bin/which: no adduser in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/usersname/bin)
0
 
legolasthehansyCommented:
Ok. It looks like you logged in without loading the environment variables and PATH for root.

CAn you open a new terminal.
login as user (whoever)
Do sudo su - (Dont forget the - or hyphen after su)
Now try which useradd and see if you are able to run useradd
0
 
farzanjCommented:
Did you do

sudo su -

To get to super user?  Make sure not to forget this hyphen at the end
Then issue command

useradd newuser

or
useradd -g group -s /bin/bash newuser
0
 
GlennSimpson2Author Commented:
Here's what's happening.

Log in as user (say jsmith)

sudo su -
[sudo] password for jsmith: (i enter correct password)
jsmith is not in the sudoers file. This incident will be reported.

In this case "jsmith" is the guy who usually manages this server, so I'm not sure what that means.
0
 
legolasthehansyCommented:
Ok. Try su - (provided you know the password for root)
0
 
woolmilkporcCommented:
Why not just

/usr/sbin/useradd ...

?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now