|
|
|
|
|
|
| Author |
Message |
Ertugrul Soeylemez *nix forums Guru Wannabe
Joined: 28 Oct 2005
Posts: 126
|
Posted: Tue Jun 20, 2006 9:20 pm Post subject:
Re: How to create /etc/passwd file?
|
|
|
"Chris F.A. Johnson" <cfajohnson@gmail.com> (06-06-20 13:47:12):
| Quote: | But why the hassle? You can script useradd to do the job more
easily for you. As usual the fine manual 'man useradd' has the
info.
Yes, and it's also more portable
It is not portable; there are different versions, with different
syntax, even among Linux distros. Other *nixen may not have it at
all.
|
I didn't say it's portable. I said, it's _more_ portable. Editing
/etc/passwd directly may even be unportable on the same distribution
with a different version.
Regards,
E.S. |
|
| Back to top |
|
 |
Ertugrul Soeylemez *nix forums Guru Wannabe
Joined: 28 Oct 2005
Posts: 126
|
Posted: Tue Jun 20, 2006 10:07 pm Post subject:
Re: How to create /etc/passwd file?
|
|
|
Michael Heiming <michael+USENET@www.heiming.de> (06-06-20 02:08:25):
| Quote: | There is nothing improper about a Windows text file; the standard
allows CR/LF line endings.
|
Most programs don't handle them properly. Even some text editors (like
GNU nano) fail there. One reason is that functions like fgets() do
return the CR character as part of the line.
| Quote: | Just that it sucks if you edit/transfer text on one and copy to
the other. Strange enough there's zero problem between any kind
of unix system. Just M$ has this problem, perhaps because it
isn't an OS but a fine?
|
Same with delimiter characters. Where Unix uses ':', Windows uses ';',
and where Unix uses '/', Windows uses '\'. Even basic system functions
names are totally incompatible, like poll() on Unix
vs. MsgWaitForMultipleObjectsEx() on Windows. Microsoft has
sufficiently reached the goal of making Windows programs as unportable
as possible. Wouldn't it be bad, if Photoshop ran equally well on Unix?
Ten screenfuls of source code just to create an empty OpenGL- or
D3D-enabled window via DirectX under Windows. A few more pages of code,
to make it closable. And you couldn't remember all those COM+ calls
needed, without having a browser to MSDN open. You couldn't even
remember their argument list. Even if you do for a single function;
what kind of argument is it? LPARAM, or DOWRD? Or even WINDOWCLASSEX?
Or CREATESTRUCT? Oh, please don't forget, you have to use LPCTSTR
instead of char *.
And (writing this in an own paragraph because of identifier length)
please remember that the FrontEndUploadMemoryUtilizedPercent component
of the D3DDEVINFO_D3D9BANDWIDTHTIMINGS structure is of type FLOAT, not
float!
Same program in Unix via SDL uses just about thirty lines, and can be
done mostly with standard types. Poor Windows coders ...
Regards,
E.S. |
|
| Back to top |
|
 |
Unruh *nix forums Guru
Joined: 22 Mar 2005
Posts: 1166
|
Posted: Wed Jun 21, 2006 8:32 am Post subject:
Re: How to create /etc/passwd file?
|
|
|
"Ross" <nospam@ross.com> writes:
| Quote: | Hi there,
I am going to create 9000 users.
I have all the user names in a txt file userlist.txt like this:
user_1
user_2
:
user_9000
|
Do your user names actually have the numbers int he names or are there just
9000 different names?
i=1000
for n in `cat nameoffile`
do
echo "$n :$i:1000::/home/$n:/bin/bash">>/etc/passwd
i=$(($i+1))
done
| Quote: | I want the passwd file to be created like this:
user_1:x:1001:1000::/home/user_1:/bin/bash
user_2:x:1002:1000::/home/user_2:/bin/bash
:
user_1000:x:1001::/home/user_2000:/bin/bash
:
user_9000:x:1009::/home/user_9000:/bin/bash
How could I use bash with something like awk to create the passwd file?
And also the group, shadow files (all passwords can be the same)?
Thanks,
Ross |
|
|
| Back to top |
|
 |
KernelPanic *nix forums beginner
Joined: 24 Jun 2006
Posts: 1
|
Posted: Sat Jun 24, 2006 2:01 pm Post subject:
Re: How to create /etc/passwd file?
|
|
|
Finally someone with the reasonable answer. If he's working from a text
file with "^M" imbedded, he could A) vi the file and perform a global search
and replace, or B) pipe the output to sed using '/s[CTRL][v][CTRL][M]//g' to
remove the "^M" before using the useradd command.
"Ertugrul Soeylemez" <never@drwxr-xr-x.org> wrote in message
news:e77be1$gmq$03$1@news.t-online.com...
| Quote: | Michael Heiming <michael+USENET@www.heiming.de> (06-06-19 23:24:09):
But why the hassle? You can script useradd to do the job more easily
for you. As usual the fine manual 'man useradd' has the info.
Yes, and it's also more portable and optionally allows automatic home
directory creation based on a template, and so on. You shouldn't tamper
with /etc/passwd, /etc/group and /etc/shadow, unless you have a good
reason to do so. Use system tools instead.
To get you started:
for n in `seq 0 8999`; do
useradd -u $((1000 + $n)) -g $((1001 + $n / 1000)) user_$((1000 + $n))
done
Regards,
E.S. |
|
|
| Back to top |
|
 |
Floyd Davidson *nix forums Guru Wannabe
Joined: 02 Nov 2005
Posts: 124
|
Posted: Sat Jun 24, 2006 5:04 pm Post subject:
Re: How to create /etc/passwd file?
|
|
|
"KernelPanic" <myngreader@verizon.net> wrote:
| Quote: | Finally someone with the reasonable answer. If he's working from a text
file with "^M" imbedded, he could A) vi the file and perform a global search
and replace, or B) pipe the output to sed using '/s[CTRL][v][CTRL][M]//g' to
remove the "^M" before using the useradd command.
|
That is exactly what /col/ was designed to do. Pipe the file
through /col/, using -x and perhaps -b options.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com |
|
| Back to top |
|
 |
Ertugrul Soeylemez *nix forums Guru Wannabe
Joined: 28 Oct 2005
Posts: 126
|
Posted: Sun Jun 25, 2006 7:36 am Post subject:
Re: How to create /etc/passwd file?
|
|
|
floyd@apaflo.com (Floyd L. Davidson) (06-06-24 09:04:21):
| Quote: | Finally someone with the reasonable answer. If he's working from a
text file with "^M" imbedded, he could A) vi the file and perform a
global search and replace, or B) pipe the output to sed using
'/s[CTRL][v][CTRL][M]//g' to remove the "^M" before using the useradd
command.
That is exactly what /col/ was designed to do. Pipe the file
through /col/, using -x and perhaps -b options.
|
Even easier:
tr -d "\r" < SRCFILE > DESTFILE
Regards. |
|
| Back to top |
|
 |
Floyd Davidson *nix forums Guru Wannabe
Joined: 02 Nov 2005
Posts: 124
|
Posted: Sun Jun 25, 2006 9:53 am Post subject:
Re: How to create /etc/passwd file?
|
|
|
Ertugrul Soeylemez <never@drwxr-xr-x.org> wrote:
| Quote: | floyd@apaflo.com (Floyd L. Davidson) (06-06-24 09:04:21):
Finally someone with the reasonable answer. If he's working from a
text file with "^M" imbedded, he could A) vi the file and perform a
global search and replace, or B) pipe the output to sed using
'/s[CTRL][v][CTRL][M]//g' to remove the "^M" before using the useradd
command.
That is exactly what /col/ was designed to do. Pipe the file
through /col/, using -x and perhaps -b options.
Even easier:
tr -d "\r" < SRCFILE > DESTFILE
|
col -xb < SRCFILE > DESTFILE
Hmmm... that looks to be 3 characters shorter! :-)
I don't /tr/ as being easier, plus it is not as functional.
/tr/ only translates exactly what you tell it to, while /col/
was specifically designed to remove unknown control sequences.
For example, with the -b option it removes all but that last of
any series of "<BS>c", where c is any character, and with -x it
will replace tabs with spaces. There is no way to get /tr/ to
do those too, plus remove any other non-effective carriage
control sequences.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com |
|
| Back to top |
|
 |
Ertugrul Soeylemez *nix forums Guru Wannabe
Joined: 28 Oct 2005
Posts: 126
|
Posted: Sun Jun 25, 2006 10:48 am Post subject:
Re: How to create /etc/passwd file?
|
|
|
floyd@apaflo.com (Floyd L. Davidson) (06-06-25 01:53:33):
| Quote: | Even easier:
tr -d "\r" < SRCFILE > DESTFILE
col -xb < SRCFILE > DESTFILE
Hmmm... that looks to be 3 characters shorter! :-)
I don't /tr/ as being easier, plus it is not as functional.
/tr/ only translates exactly what you tell it to, while /col/ was
specifically designed to remove unknown control sequences. For
example, with the -b option it removes all but that last of any series
of "<BS>c", where c is any character, and with -x it will replace tabs
with spaces. There is no way to get /tr/ to do those too, plus remove
any other non-effective carriage control sequences.
|
Well, 'col' is more intelligent than 'tr', and processes its input. In
some situations, you don't want that, and instead just remove (or
translate) a selected set of characters. 'tr' is better in that case.
Regards,
E.S. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Tue Dec 02, 2008 12:31 pm | All times are GMT
|
|
Mortgages | Internet Advertising | Charity | Internet Advertising | PHP Photo Gallery
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|