cancel
Showing results for 
Search instead for 
Did you mean: 

add user using ksh

 
Highlighted
Regular Advisor

add user using ksh

Hi All,

I m using RHEL5. I got a interesting query from an expert. Query was as follow...

# rm -rf `Type useradd`
and also newusers command

Now add user using ksh shell ?

How can we do it? Pls suggest. Is there any command or i have to put that user entry in every file like /etc/passwd, /etc/group, and other related files

Thanks in advance
MKS
5 REPLIES 5
Highlighted
Honored Contributor

Re: add user using ksh

Given that 'useradd' is just a nice way to:

- modify /etc/passwd
- modify /etc/shadow
- modify /etc/group (maybe)
- make a new home directory
- cp /etc/skel/* to new home directory

Sure, it's easy to do with a plain shell, but 'useradd' exists to make it easier.

If you've removed it, re-install it from it's package. There's *NO GOOD REASON* to remove it.
One long-haired git at your service...
Highlighted
Honored Contributor

Re: add user using ksh

you can reinstall " shadow-utils" package.
Highlighted
Honored Contributor

Re: add user using ksh

MKS,

Did u execute the above mentioned command?
Highlighted
Regular Advisor

Re: add user using ksh

Hello Santosh!

Yes i have go through above suggetion. But i was looking for any command or other stuf

Thanks
MKS
Highlighted
Honored Contributor

Re: add user using ksh

Why did the "expert" make you remove the useradd command?
Did he give a compelling reason like a discovered and unpatched exploit?
Or is this part of an excercise in a Linux sysadmin class?
Of course, you can add, remove and modify user accounts manually at the shell if you know which files all to edit and care for file locking.
But, if it isn't for an excercise, it is better to use commands like useradd, which can well be used in scripts, if you have to manipulate a 1000 accounts.
Think about how important files /etc/passwd and /etc/shadow are.
You don't want to lock out your users because of format errors or unsynched states.
Though I haven't got an RHES5 box I assume the package the useradd command belongs to hasn't changed.
On my RHES4 it is in the shadow-utils package, which you can reinstall:

# uname -srv;cat /etc/redhat-release; rpm -qf /usr/sbin/useradd
Linux 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005
Red Hat Enterprise Linux WS release 4 (Nahant)
shadow-utils-4.0.3-41.1

Madness, thy name is system administration