SUMMARY: Problem in adding an host

From: Fiorella Sartori (fiorella@alpha.science.unitn.it)
Date: Thu Sep 19 1996 - 02:16:32 CDT


Hi all!

I received many replies to my question... and I concluded that it's better
writing the file /etc/hosts with ":wq!" (I'm using VI editor) rather than
changing permissions on this file and saving it normally (it could be
dangerous if you let write permission on it).

Many thanks to:
   jeffreyl@riskdevel.ml.com (Jeffrey Liu)
   rloftin@engsys.mc.xerox.com (Ron Loftin)
   fpardo@tisny.com (Frank Pardo)
   scott.swoboda@edwardjones.com (Scott Swoboda)
   zaitcev@lab.sun.mcst.ru (Pete A. Zaitcev)
   iv08480@issc02.mdc.com (Colin Melville)
   TrevorPaquette@aec.ca (Trevor Paquette)
   Daniel.Blander@ACSacs.Com (Daniel J Blander)
   diarra@ipno.in2p3.fr (Christophe DIARRA)
   jholt@pdc.com (Jay Holt)
   edgrimm@neptune.mtc.ti.com (Edward Grimm)
   jturner@zeus.aetc.af.mil (John M. Turner)
   fiori@crrel41.crrel.usace.army.mil (John Fiori)
   poffen@San-Jose.ate.slb.com (Russ Poffenberger)
   jasonn@nabaus.com.au (Jason Noorman)
   robert@scantec.scantech.nl (Robert van der Rijst)
   lemercie@dr.gdf.fr (LEMERCIER Laurent)

Thanks for your patience and sorry again for my stupid question!
Greetings,

Fiorella

--------------------------------------------------------------------------------
My original question was:
--------------------------------------------------------------------------------

Hi Sun Managers!

This could be a stupid question... sorry in advance!
On our SUN Ultra1 with Solaris 2.5 and SunOS 5.5, I would add a new host in
file /etc/hosts (I see this is a link...). With my account, from which I
call "su" and then I give root password, editing this file I get the message
"Read only" and so I cannot save it. With the same operations from another
account, I can save it regularly.
My files look like these:
  lrwxrwxrwx 1 root root 12 Feb 14 1996 hosts -> ./inet/hosts
  -r--r--r-- 1 root sys 292 Sep 18 11:42 inet/hosts
These two accounts are defined in the same way in /etc/passwd and in
/etc/group, both with root like secondary group.

Is there a workaround? Thanks, I'll summarize.

Fiorella

--------------------------------------------------------------------------------
jeffreyl@riskdevel.ml.com (Jeffrey Liu) wrote:
--------------------------------------------------------------------------------

First, as root, you need to 'chmod u+w' so that root has write access.
Secondly, if you ever get the message as root 'write permission
denied', you can try to use :w! to override the permission.

Hope this helps,
Jeff

--------------------------------------------------------------------------------
rloftin@engsys.mc.xerox.com (Ron Loftin) wrote:
--------------------------------------------------------------------------------

If you are using vi for an editor, you can use the command sequence ":w!" or
":wq!" to force a write of the file. As root, this will work. With any
other editor, you will have to do a chmod of the /etc/inet/hosts file to 644
to allow writes by root.

--------------------------------------------------------------------------------
fpardo@tisny.com (Frank Pardo) wrote:
--------------------------------------------------------------------------------

This happens to me all the time. The easiest workaround is to exit from
vi with ':wq!' -- The '!' at the end of the command tells vi to
overwrite the file even though it is marked as not writable.

But I don't understand how some other account can write to it... since
the permissions are set to '-r--r--r--'.

By the way, to write without exiting from vi, use ':w!'.

good luck

--------------------------------------------------------------------------------
scott.swoboda@edwardjones.com (Scott Swoboda) wrote:
--------------------------------------------------------------------------------

if you are using vi to edit the file use
:w! to force the write.
and then :q to quit

scott swoboda

--------------------------------------------------------------------------------
zaitcev@lab.sun.mcst.ru (Pete A. Zaitcev) wrote:
--------------------------------------------------------------------------------

>These two accounts are defined in the same way in /etc/passwd and in
>/etc/group, both with root like secondary group.

Issue "alias", "env", in both accounts and watch for a difference.
I usually do ":w!:q".

Pete

--------------------------------------------------------------------------------
iv08480@issc02.mdc.com (Colin Melville) wrote:
--------------------------------------------------------------------------------

Fiorella,

vi /etc/inet/hosts, make the changes, then :wq! from the vi command line. That'll override the read-only permissions.

TTFN,
Colin

--------------------------------------------------------------------------------
TrevorPaquette@aec.ca (Trevor Paquette) wrote:
--------------------------------------------------------------------------------

chmod 644 /etc/inet/hosts
Edit the file..

--------------------------------------------------------------------------------
Daniel.Blander@ACSacs.Com (Daniel J Blander) wrote:
--------------------------------------------------------------------------------

1) look at the permissions of the source file: /etc/inet/hosts
        those are the driving permissions....

2) If in vi, then using :wq! (note the !) while su to root will
        force as save.....even if the file is read only.....

--------------------------------------------------------------------------------
diarra@ipno.in2p3.fr (Christophe DIARRA) wrote:
--------------------------------------------------------------------------------

Hello,

if you are using vi, save it with 'w!' (this is how I do).

Maybe the two accounts you are speeking about are not using the same text
editor ?

Christophe.

--------------------------------------------------------------------------------
jholt@pdc.com (Jay Holt) wrote:
--------------------------------------------------------------------------------

When you "vi" /etc/hosts, make your changes and then press the
escape key. Then, type the following:
        :w!
Then exit the file.

--------------------------------------------------------------------------------
edgrimm@neptune.mtc.ti.com (Edward Grimm) wrote:
--------------------------------------------------------------------------------

If you use vi, use a :w! to write it.

If this doesn't work, get a vi clone. (Possibly a good idea anyway if
you want more than a basic editor, many of the newer clones have a lot
of new features.)

I don't know other editors enough to say...

Ed

--------------------------------------------------------------------------------
jturner@zeus.aetc.af.mil (John M. Turner) wrote:
--------------------------------------------------------------------------------

As the root user, you can override the "read only" on any file
just by forcing a save. In VI, you make your changes then give the
command ":w!" This is not something you do normally, since you can
easily mess critical system files up if you are not careful.

Alternatively, you can use admintool from an openwindows display.

Good luck!

--------------------------------------------------------------------------------
fiori@crrel41.crrel.usace.army.mil (John Fiori) wrote:
--------------------------------------------------------------------------------

Fiorella
        If you are using the VI editor just quit using :wq!

--------------------------------------------------------------------------------
poffen@San-Jose.ate.slb.com (Russ Poffenberger) wrote:
--------------------------------------------------------------------------------

You can "chmod u+w inet/hosts" before editing, or if you are using vi, save
using ":w!". The "!" means to override the warning.

--------------------------------------------------------------------------------
jasonn@nabaus.com.au (Jason Noorman) wrote:
--------------------------------------------------------------------------------

Your right it was a stupid question.

To start with Solaris 2.5 and SunOS 5.5 are the acronyms for the same product
so you an't have one with out the other.

To edit the hosts file try using ":wq!" as because the link is rrr you have
to force it.

Thanks

Jason.

--------------------------------------------------------------------------------
robert@scantec.scantech.nl (Robert van der Rijst) wrote:
--------------------------------------------------------------------------------

Hi Fiorella,

I had the same problem (it isn't realy), the best is to use the admintool.
You can also work around it by use chmod on the /etc/inet/hosts file,
then edit the file and set the permissions back with chmod (this is what i do).

good luck
Robert

--------------------------------------------------------------------------------
lemercie@dr.gdf.fr (LEMERCIER Laurent) wrote:
--------------------------------------------------------------------------------

> This could be a stupid question... sorry in advance!

None is ...

using for example vi, confirm that you want to write the file after editing it using :w! command.

Laurent

--------------------------------------------------------------------------------

-- 

------------------------------------------------------------------------- | Fiorella Sartori | Phone : +39-461-881598 | | C.I.S.C.A. | Fax : +39-461-881668 | | University of Trento | E-Mail: fiorella@science.unitn.it | | Via Sommarive, 14 | | | I-38050 POVO (Trento), ITALY | | -------------------------------------------------------------------------



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:10 CDT