LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-29-2004, 04:37 PM   #1
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Rep: Reputation: 15
chmod 755 won't change file permission.


I just made a new file that I want to make a shell script so as root I tried chmod 755 /etc/location/of file.

Unfortualnately the file remains a text file

I'm on mandrake 10 with kernel 2.6.3. Any Ideas????
 
Old 04-29-2004, 05:23 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Well all files in *nix are text files.. if your wanting it to be executable, well, the command you gave or this one: chmod +x <filename> will give it executable rights..

ls -al <filename>

And if it has rwxr-xr-x type rights.. then run the file by typing this:

./<filename>

And it should execute your script for you from there.
 
Old 04-29-2004, 05:36 PM   #3
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
when I do ls -al it says:-

-rwxr-xr-x 1 root root 150 Apr 29 21:56. It won't execute though...
 
Old 04-29-2004, 05:38 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by duffboygrim
when I do ls -al it says:-

-rwxr-xr-x 1 root root 150 Apr 29 21:56. It won't execute though...
Error messages please? And script contents please?
 
Old 04-29-2004, 05:42 PM   #5
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
No error messages. It seems to do what i want it too. On ls it appears as a shellscript, on the GUI (KDE) the icon still appears as a text file.

the contents of the file are:-
#! /sbin/sh

IPTABLES=/sbin/iptables
$IPTABLES -F -t nat
$IPTABLES -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv_4/ip_forward
 
Old 04-29-2004, 05:45 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
#! /sbin/sh
Is that my imagination or do you have a space after the !
 
Old 04-29-2004, 05:48 PM   #7
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
Would that cause a problem???
 
Old 04-29-2004, 05:57 PM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by duffboygrim
Would that cause a problem???
It can and also is sh located in /sbin? Usually by default it will be in /bin
 
Old 04-29-2004, 06:03 PM   #9
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
OK. I think I've sorted the problem...

I'll get back to you if it was right or wrong!
 
Old 04-29-2004, 06:12 PM   #10
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
Yep, I got the problem sorted and it the end of the day it was a stupid mistake on my part.

#!/bin/sh

IPTABLES=/sbin/iptables

#All The lines below are NAT routing

# flush any old rules
$IPTABLES -F -t nat

# turn on NAT (IP masquerading for outgoing packets)
$IPTABLES -A POSTROUTING -t nat -o eth0 -j MASQUERADE

# enable IP forwarding (of incoming packets)
echo 1 > /proc/sys/net/ipv4/ip_forward

was the script I should have entered which seemed to become executable on chmod 755 where as it originally didn't (can you tell me why?) and secondly I forgot to install iptables!

Well, at least I learnt what I did wrong!!!!

Thanks guys....
 
Old 04-29-2004, 06:14 PM   #11
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
It can and also is sh located in /sbin? Usually by default it will be in /bin
Funny how a person can be looking directly at that section and not see the sbin

I do think you hit that one on the head trickykid!
 
Old 04-29-2004, 06:17 PM   #12
duffboygrim
Member
 
Registered: Nov 2003
Location: Wales, UK
Distribution: Mandrake 10
Posts: 89

Original Poster
Rep: Reputation: 15
Don't I feel like the retard!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why chmod cannot change symbolic link permission? mikeshn Linux - General 17 03-22-2012 07:08 PM
would you recommend chmod -R 755 *? CodeFish Linux - Security 2 01-22-2005 10:49 PM
chmod permission change? tidasu Linux - Newbie 7 08-30-2004 06:02 PM
using chmod to change file permission kiwidoc Linux - Newbie 3 07-25-2004 06:39 AM
how to change exisitng files/directory permission from 755 to 770 mweil Linux - Newbie 3 07-01-2004 10:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration