[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debian 8 system is not fully functional





On Thu, Dec 24, 2020, 8:08 AM Greg Wooledge <wooledg@eeg.ccf.org> wrote:
On Thu, Dec 24, 2020 at 12:49:30PM +0800, zhang yang wrote:
> IP_ dynaddr
> To modify and save the prompt: "IP"_ dynaddr" E212: Can't open file for
> writing“.
> So I used Chmod 777 ip_ dynaddr authority, display error: Chmod: changing
> permissions of 'IP_ dynaddr': Operation not permitted.
> I use chaddr - i ip_dynaddr command to removes attributes and displays an
> error: chattr: Inappropriate ioctl for device while reading flags on
> ip_dynaddr.  How to set dynaddr?

For the benefit of others, the file in question is

/proc/sys/net/ipv4/ip_dynaddr

/proc is not a regular file system.  It's an interface to pieces of the
kernel.  Some of these pieces can be read by everyone.  Almost none of
them can be *written* by everyone -- you usually have to be root to
write to them.

chmod 777 is almost always a *huge* mistake.  If the permissions on a
file are stopping you from doing someting, there's usually a reason
for that.  Destroying the permissions on the file is not the right answer.
Elevating yourself to a higher power level is.

Now, the next thing you'll want to know is that while root can probably
write to this file, it can't necessary *edit* the file with a text
editor.  You're expected to use a much lower level of access to open
the file, write to it, and close it.  Typically that's done with

echo something > /proc/whatever

Of course this redirection means that it's your shell who needs
privileges to open the file for writing.  If you try it as your
regular user, you'll encounter the "permission denied" error that
you already saw.

The expected course of action is for you to do it from a root shell,
which you obtain by using su or sudo.

$ su
Password:
# echo something > /proc/whatever
# exit
$

If you're not a fan of su, or if you're one of those people who has
decided not to have a root password (a bad idea!), then you can get
a root shell with sudo -s:

$ sudo -s
# echo something >/proc/whatever
# exit
$

(sudo may prompt you for your password if you haven't used sudo in that
terminal in the last few minutes.)

Some people will try to be clever and do this:

sudo echo something > /proc/whatever

That will not work, for the reasons explained at
<https://mywiki.wooledge.org/BashPitfalls#pf53>. 

+10

That is an Awesome page you have there, Greg!  I have Bookmarked it. 


You may use one of
the quoted forms on that page if you prefer.  But the original design
of the files in /proc was for users with a root shell to perform shell
redirections.  Not for sudo.

Also, while I'm here talking about su, bear in mind that Debian decided
to become more like Red Hat and replaced their version of su with the
one used by Red Hat, and didn't bother configuring it to maintain backward
compatibility with the previous version.  See
<https://wiki.debian.org/NewInBuster#Changes> for workarounds... 

Also good.  I was never affected by the change, because I always use "su -". 

Kenneth Parker 

Reply to: