This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: suggestion for cygutils - usermod (was Re: howto change home path in /etc/passwd)
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Sylvain dot Ferriol at imag dot fr
- Cc: cygwin at cygwin dot com
- Date: Mon, 12 May 2003 11:19:10 -0400 (EDT)
- Subject: Re: suggestion for cygutils - usermod (was Re: howto change home path in /etc/passwd)
- Reply-to: cygwin at cygwin dot com
On Mon, 12 May 2003 Sylvain.Ferriol@imag.fr wrote:
> Surlignage Igor Pechtchanski <pechtcha@cs.nyu.edu>:
>
> > On Mon, 12 May 2003 Sylvain.Ferriol@imag.fr wrote:
> >
> > > Surlignage Max Bowsher <maxb@ukf.net>:
> > >
> > > > Sylvain.Ferriol@imag.fr wrote:
> > > > > Yes , because i don't want to create a shell doing this:
> > > > > grep -v $USERNAME /etc/passwd > /etc/passwd
> > > >
> > > sorry
> > > but i don't know with sed how to delete a line starting with $USER
> >
> > For the record: "sed '/'$USER':/d". However, grep is perfectly adequate.
> > What Max was warning you about was the shell redirection mechanism. You'd
> > be safer using something like
> >
> > cp -p /etc/passwd /etc/passwd-bak-tmp && grep -v $USERNAME
> > /etc/passwd-bak-tmp > /etc/passwd && rm -f /etc/passwd-bak-tmp
> >
> is it better to use $USER or $USERNAME??
>
> sylvain
$USERNAME is set by Windows. $USER is set by /etc/profile to the output
of "id -un". They should be the same in most cases (they even seem to be
the same if "login" is used to switch user contexts from a SYSTEM-owned
shell -- go figure). Which would be better depends on the purpose, I
guess...
Igor
> > > > Care! That will leave you with an empty /etc/passwd.
> > > > The shell truncates /etc/passwd BEFORE grep reads it.
> > > >
> > > > > mkpasswd -l -u $USERNAME -p $HOME >> /etc/passwd
> > > >
> > > > Max.
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
Knowledge is an unending adventure at the edge of uncertainty.
-- Leto II
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/