LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-02-2007, 06:42 AM   #1
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Rep: Reputation: 15
adding users? + edditing files


Hi.

Just wondering if there is a way to set a uses passwords at the same time as creating the user. At the moment i do:

useradd testuser -p password

But this does not work! I still have to passwd testuser and set there password that way! Is there a way round this?

Also it there a way i can set a new users shell to be /sbin/nologin (no have to add -s each time?)

Lastly i was wondering is there as way i can add a line onto the end of a file without have to open it?

- Thanks
 
Old 01-02-2007, 07:06 AM   #2
namit
Member
 
Registered: Aug 2005
Distribution: Debian
Posts: 355

Rep: Reputation: 30
do you not just put the -p before the testuser?
 
Old 01-02-2007, 07:09 AM   #3
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Original Poster
Rep: Reputation: 15
Apparently not! Tried it both sides, but still does not work.
 
Old 01-02-2007, 07:10 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
If you look at the man page for 'useradd', you will see that the -p option wants the encrypted form of the password as generated by crypt.

Quote:
-p, --password password
Encrypted password as returned by crypt(3) for the new account. The default is to disable the account.
So, you might try passing the output of crypt to the useradd command:

useradd testuser -p `crypt password`

Note the back ticks around 'crypt password'.
 
Old 01-02-2007, 07:49 AM   #5
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
you might try passing the output of crypt to the useradd command:

useradd testuser -p `crypt password`
This looks like the way forwords!
. . . . I asume i need to run a seprate comand to get the crypt password first? I looked at the man page for crypt and it sugest it need a list of other options. How do i know which to use for this?

- Thanks
 
Old 01-02-2007, 08:09 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by just_me_then

Lastly i was wondering is there as way i can add a line onto the end of a file without have to open it?

- Thanks
To answer to your last question, a simple command is

Code:
printf "\n" >> filename
 
Old 01-02-2007, 08:33 AM   #7
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
I asume i need to run a seprate comand to get the crypt password first?
No. The reason for the backticks around 'crypt password' is the backticks will cause the command 'crypt' to be run with 'password' as input to crypt. The return from running that command (the encrypted password) is then passed to the -p option.
 
Old 01-02-2007, 08:40 AM   #8
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Original Poster
Rep: Reputation: 15
Ok, so i ran: useradd -p `crypt testpassword` testuser

and it just through an error back at me
-bash: crypt: command not found

Maybe i should just give it a good kick?!

(thank for all your help so far)
 
Old 01-02-2007, 08:42 AM   #9
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Original Poster
Rep: Reputation: 15
tabbing shows me cryptsetup but not crypt as an option? Does this help?
 
Old 01-02-2007, 08:51 AM   #10
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
crypt is a system call, not an user command. Note the manual section.

I have a post about this subject. read it:

http://www.linuxquestions.org/questi...ighlight=crypt

Last edited by marozsas; 01-02-2007 at 09:44 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding users Joe2003 Linux - Software 1 05-19-2005 10:20 AM
Adding users muppski Programming 5 04-08-2005 02:41 AM
adding users... Digital_Err0r Linux - General 1 03-31-2004 03:08 PM
Adding New Users guygriffiths Linux - General 4 10-13-2003 10:11 AM
Adding users... philfighter Linux - General 3 07-23-2001 10:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration