We help IT Professionals succeed at work.

how to edit files Linux (Ubuntu Distr.)

Medium Priority
1,273 Views
Last Modified: 2012-05-12
Hello,
In my Linux Server some file not editable or when i edit them after reboot it's back to it previous version.

for example for /etc/ufw/ufw.conf I edit "enable=no" to "enable=yes" and saved it, but after reboot when I print ufw.conf's contents it's back to previous version.
I found a way for this, i change file permission to 755 and edit with root permission and it's not back to previous version.

after it new problem occur for me. I want to edit "/proc/sys/net/ipv4/ip_forward" but it's back to previous version after each reboot. i trying to set permission and receive following error:
root@testserver:/proc/sys/net/ipv4# chmod 755 ip_forward
chmod: changing permissions of `ip_forward': Operation not permitted

Open in new window


using chattr but it's not work and i received following error:
root@testserver:/proc/sys/net/ipv4# chattr +a ip_forward
chattr: Inappropriate ioctl for device while reading flags on ip_forward

Open in new window


Whould you mind help me?!
Comment
Watch Question

Commented:
you must run command as administrator user. example in linux ubuntu "sudo chmod 755 ip_forward". That will run as administrator user can modify system.

I Hope solved your problem
Top Expert 2011

Commented:
I'm glad Ubuntu prevents you from doing those things :)

Edit /etc/sysctl.conf, and add the following
net.ipv4.ip_forward = 0

Open in new window

then
sudo sysctl -p

Open in new window


If you want to enable forwarding, change the value to 1.
Top Expert 2011

Commented:
Doing so will make the change persistent across reboots.
Top Expert 2011

Commented:
To clarify on my answer,

Edit sysctl.conf to make sysctl changes persistent.
'sysctl -p' reads in /etc/sysctl.conf and makes your edit live on the system before a reboot.

If there is already a value present for the token you want to change, edit that instead of creating a new entry.

Author

Commented:
# kerimit
I run those commands with root privillage, first i run "sudo bash" and then run command you can see root username before @

# Papertrip
Thank, but i don't want to set ip_forwarding from /etc/sysctl.conf
I know this way, I just wanna know how it's possible we edit "/proc/sys/net/ipv4/ip_forward" in one of war games i saw it.

and my next question is  I run "ufw enable" command and enable UFW for run at boot, but after reboot i checked "ufw status" and received "inactive" why?
Top Expert 2011

Commented:
I know this way, I just wanna know how it's possible we edit "/proc/sys/net/ipv4/ip_forward" in one of war games i saw it.
[root@broken tmp]# cat /proc/sys/net/ipv4/ip_forward
0
[root@broken tmp]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@broken tmp]# cat /proc/sys/net/ipv4/ip_forward
1

Open in new window


Author

Commented:
# Papertrip

I do it before, but as I said in my question, after reboot ip_forward's content back to previous version (from 1 to 0)
Top Expert 2011

Commented:
I do it before, but as I said in my question, after reboot ip_forward's content back to previous version (from 1 to 0)
As I said in my previous answers, edit sysctl.conf to make it persistent across reboots.
Top Expert 2011

Commented:
and my next question is  I run "ufw enable" command and enable UFW for run at boot, but after reboot i checked "ufw status" and received "inactive" why?
Is iptables running?

Author

Commented:
# Papertrip
Is iptables running?

I read in Ubuntu which ufw is back-end of iptables and will make iptables management easier.

currently my problem is I create PPTP Server and everythings ok, i could connect to server and i can ping myself (192.168.1.2) from server and server( 192.168.1.1) from client.
but i can browser internet after connection established.
Top Expert 2011

Commented:
I don't think ufw is supposed to be "started" at boot... it's not a service, it's just a frontend tool to configure iptables.  When you need to use ufw, just enable it first and go about your business.
Top Expert 2011

Commented:
currently my problem is I create PPTP Server and everythings ok, i could connect to server and i can ping myself (192.168.1.2) from server and server( 192.168.1.1) from client.
but i can browser internet after connection established.

Ok well that is quite a different issue than your original question :)

Author

Commented:
My Server is Ubuntu which I install eBox Zentyal on That.

I do as you said on post #37074819
but after i reboot server sysctl -p return ipforwarding = 1 and /proc/sys/net/ipv4/ip_forwarding is zero 0

Author

Commented:
Ok well that is quite a different issue than your original question :)

I will Open new post after my ipv4_forwarding proble solved.
Would you mind help me on pptp routing?
Top Expert 2011

Commented:
but after i reboot server sysctl -p return ipforwarding = 1 and /proc/sys/net/ipv4/ip_forwarding is zero 0
Paste the output of the following command:
grep ip_forward /etc/sysctl.conf

Open in new window

Top Expert 2011

Commented:
I will Open new post after my ipv4_forwarding proble solved.
Sounds good.

Would you mind help me on pptp routing?
I'm I'm still awake :p
Top Expert 2011

Commented:
I'm I'm still awake :p

Err that should be "If I'm still awake" ... can you tell I'm already half asleep?

Author

Commented:
Paste the output of the following command:
root@testserver:~# grep ip_forward /etc/sysctl.conf
net.ipv4.ip_forward=1

Open in new window

Top Expert 2011

Commented:
Something isn't right here...

Paste the following as well please to make sure we are on the same page.
cat /proc/sys/net/ipv4/ip_forward
sysctl net.ipv4.ip_forward
cat /etc/network/options
grep forward /etc/rc.local

Open in new window

Author

Commented:
root@testserver:/etc# cd /proc/sys/net/ipv4/
root@testserver:/proc/sys/net/ipv4# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
root@testserver:/proc/sys/net/ipv4# cat /etc/network/options
cat: /etc/network/options: No such file or directory
root@testserver:/proc/sys/net/ipv4# grep forward /etc/rc.local
root@testserver:/proc/sys/net/ipv4# 

Open in new window

Top Expert 2011
Commented:
Couple things here.

For line #1, I asked for "cat /proc/sys/net/ipv4/ip_forward", not "cd /proc/sys/net/ipv4/"
For line #2, that says that forwarding is not enabled, which matches what you said /proc/sys/net/ipv4/ip_forwarding has (this is what I wanted to confirm with #1)

Paste the output of the following:
sysctl -p

Open in new window

Then
sysctl -w net.ipv4.ip_forward=1
sysctl net.ipv4.ip_forward
cat proc/sys/net/ipv4/ip_forwarding

Open in new window


Author

Commented:
#Papertrip

Thanks, I do like this and reboot server and /proc/sys/net/ipv4/ip_forwarding is set to 1


for other values i should do like this?


would you mind explain what sysctl -w do?
Top Expert 2011

Commented:
That is weird that it didn't work before.

-w takes a sysctl setting and changes the value to what you specify.

       sysctl [-n] [-e] [-q] -w variable=value ...
       -w     Use this option when you want to change a sysctl setting.

Open in new window


So the change works now across reboots?  Are you all set?
Top Expert 2011

Commented:
for other values i should do like this?

Whatever you did to make it work this time, do it for your future changes :)

Author

Commented:
#/proc/sys/net/ipv4/ip_forward
0

Open in new window


sorry Papertrip it's return back to 0 again.
but i read some where else /proc/* will return back on each reboot

http://www.experts-exchange.com/OS/Linux/Q_27429200.html#a37075092

Explore More ContentExplore courses, solutions, and other research materials related to this topic.