1836380 Members
2594 Online
110100 Solutions
New Discussion

-rwsrwxr-x

 
SOLVED
Go to solution
panchpan
Regular Advisor

-rwsrwxr-x

Hello.
I see permissions for some of the executable files as mentioned in subject line. I wish to FTP these files and run on another server. After FTPing I see permissions are as -rwx------ , How can i make them -rws------

Thanks for your help!
12 REPLIES 12
Peter Godron
Honored Contributor
Solution

Re: -rwsrwxr-x

Hi,
see man chmod
chmod 700 filename
chmod u+s filename



H.Merijn Brand (procura
Honored Contributor

Re: -rwsrwxr-x

# chmod +s file
# chmod 4700 file

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Senthil Prabu.S_1
Trusted Contributor

Re: -rwsrwxr-x

Hi,
Here, setuid bit is set for the user, so that anyone can get the privilege of that particular user and execute them.

To set it on the new machine,
execute
#chmod u+s

Please refer this link for more info;

http://www.xav.com/scripts/help/setuid.html


HTH,
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.
panchpan
Regular Advisor

Re: -rwsrwxr-x

Can you please suggest - IF i want to replace e.g. 'hello' in many files under directory '/home/tmp/'. How can it be done using UX command?

Thanks for your help!
H.Merijn Brand (procura
Honored Contributor

Re: -rwsrwxr-x

In the file's content or in the file name?
Case insensitive?
Word anchored?
All occurances, or just the first? perl line?

Content, all, anchored, case insensitive:

# cd /home/tmp
# perl -pi -e's/\bhello\b/goodbye/gi' *

File names, unanchored, case sensitive, first occurance only:
# cd /home/tmp
# perl -MFile::Copy -e'for$f{<* >){($x=$f)=~s/hello/goodbye/;move$f,$x}'

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
spex
Honored Contributor

Re: -rwsrwxr-x

Hi,

#!/usr/bin/sh
FN1=$1
FN2=$2
for FILE in *${FN1}*
do
mv $FILE $(echo $FILE | sed "s/${FN1}/${FN2}/")
done
exit 0

PCS
panchpan
Regular Advisor

Re: -rwsrwxr-x

Hello,
I wish to replace actually -
'/opt/prog/' with '/dev/'
Please suggest what could be the command for replacement (having / in string) in many
files.

Thanks
H.Merijn Brand (procura
Honored Contributor

Re: -rwsrwxr-x

Again, inside the file, or in the file name?

/ is not mandatory as delimiter:

'/opt/prog/' with '/dev/'

Inline replace:
# perl -pi -e's{/opt/prog/}{/dev/}g' *

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
panchpan
Regular Advisor

Re: -rwsrwxr-x

Sorry - the string to be replaced is inside the files.
spex
Honored Contributor

Re: -rwsrwxr-x

This will replace all occurrences of "/opt/prog/" with "/dev/" within all files in /home/tmp:

#!/usr/bin/sh
DIRNAME=/home/tmp/
for FILE in ${DIRNAME}
do
sed 's/\/opt\/prog\//\/dev\//' < ${DIRNAME}/${FILE} > ${DIRNAME}/${FILE}.tmp
mv ${DIRNAME}/${FILE}.tmp ${DIRNAME}/${FILE}
rm ${DIRNAME}/${FILE}.tmp
done
exit 0
James R. Ferguson
Acclaimed Contributor

Re: -rwsrwxr-x

Hi:

> I wish to replace actually - '/opt/prog/' with '/dev/'

Using Perl, either escape the foward slash (which creates a hard-to-read "leaning toothpick") or change the substitution's delimiter (which Perl allows):

# cd /path && perl -pi -e 's/\/opt\/prog\//\/dev\//gi' *
or:

# cd /path && perl -pi -e 's%/opt/prog/%/dev/%gi' *

Regards!

...JRF...



panchpan
Regular Advisor

Re: -rwsrwxr-x

MANY THANKS FOR YOUR HELP!