LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I got a few noob questions... (https://www.linuxquestions.org/questions/linux-newbie-8/i-got-a-few-noob-questions-707878/)

trist007 02-26-2009 11:46 PM

I got a few noob questions...
 
I am running Slackware 12.0

1. Why is it that I cannot change permissions on /proc/sys/net/ipv4/ip_forward as root?

I ran ls -l ip_forward and root is the owner. So I want to be able to give other groups permission to write to the file. So as root, I run

chmod o+w ip_forward

but I get

chmod: changing permissions of `ip_forward': Operation not permitted

Why is this so? I mean, I'm running it as root. Do I need to run it with kernel privileges? If so, how do I do that?

2. I want to make 120 files like file1, file2, file3, file4, etc
What command would I use? I guess I'd need some sort of bash script.

while i!=120; export i=1; touch file[i]; i++;

How would I script that? Or what command would I use?

trist007 02-27-2009 01:44 AM

I solved question 2.

#!/bin/bash
i=0
while [ $i -lt 21 ]; do
touch file$i
let i=i+1
done

easy as pie, Linux Rulez!!

Any of you guys know the answer to question 1?

comprookie2000 02-27-2009 07:39 AM

Why did you want to write to /proc/sys/net/ipv4/ip_forward?

trist007 02-27-2009 07:41 AM

so i can turn my nic into a router, so why can't i change the permissions as root?

comprookie2000 02-27-2009 07:44 AM

So you want echo 1 > /proc/sys/net/ipv4/ip_forward
What guide are you using?

trist007 02-27-2009 07:56 AM

I want to understand why even if the file ip_forward has root as its owner, why I can't change permissions as root giving o+x to others, or maybe even adding a suid flag to it, which also returns the same error.

I'm experimenting with some pentesting tools. I want the nic to simply forward the packets, but I want to be able to write to ip_forward as a normal user.

comprookie2000 02-27-2009 08:07 AM

This should help;
http://www.google.com/search?hl=en&q...q=%2Fproc+file

trist007 02-27-2009 08:32 AM

Thank you, sudo -i fixed the problem.

archtoad6 03-02-2009 08:08 PM

Back to problem 2,
Code:

touch file{1..120}
will do the trick. If you want to pad the #'s, then try:
Code:

touch file`seq -ws " file" 120`
Suggested reading:
1) man bash, search (case sensitive) for "Brace Expansion"
2) man seq


All times are GMT -5. The time now is 06:51 AM.