| UNIX/Linux Forum Archives · Rules and Guidelines · Disclaimer |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| mm1409 |
Posted: Apr 25 2005, 09:30 AM
|
|
Newbie ![]() Group: Members Posts: 2 Member No.: 941 Joined: 22-April 05 |
hello,
i have the following problem. i create a new user with useradd in a shell by the following command: useradd -c "$3" -d /home/ftp/$1 -g ftp -m -k /home/ftp/vorlage -s /bin/sh -p $(perl -e "print crypt('$2','UM');") $1 chmod 770 /home/ftp/$1/* after that i have to correct entries in the passwd and the shadow file because the username contain only numeric and this wouldn`t work. so i create the user with an leading 'B'. here is an example B47600:x:1000:500:Muster, Test:/home/ftp/47600:/bin/sh now i have to change directly the entry in both files (passwd and shadow). so it looks like: 47600:x:1000:500:Muster, Test:/home/ftp/47600:/bin/sh how can i fix these entries? michael |
| andyb1ack |
Posted: Apr 26 2005, 03:55 PM
|
|
User Level: 4 ![]() ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 513 Joined: 9-September 04 |
Not recommended to change these files by hand, but if you really have to:
sed is the command to script files edits. For example sed '/^B47600:/47600:/' file1 > file2 mv file2 file1 Make sure you backup the passwd and shadow files before running the script! |
| mm1409 |
Posted: Apr 28 2005, 03:45 PM
|
|
Newbie ![]() Group: Members Posts: 2 Member No.: 941 Joined: 22-April 05 |
hello,
i think i found a better solution. here it is ... useradd -c "$3" -d /home/ftp/$1 -g ftp -m -k /home/ftp/vorlage -s /bin/sh -p $(perl -e "print crypt('$2','UM');") $1 chmod 770 /home/ftp/$1/* vi passwd << EOD :%s/B47600/47600/g :wq EOD vi shadow << EOD :%s/B47600/47600/g :wq EOD ... when i change the entry as i have shown, i donīt need a second file and move it back to the original file. thanks for your help |
![]() |
![]() ![]() ![]() |