Solved

Use CHMOD To Allow Read, Write and Execute Permissions Recursively

Posted on 2012-03-12
7
922 Views
Last Modified: 2012-03-28
Hello,

I'm going to tar up a few directories and scripts and I want to apply the chmod a+w+x to all files under the main directory and have those permissions apply recursively.  Is there a way to do that with chmod?  I know how to change and individual script file, but I tried chmod a+w+x and it didn't allow access to all users.  I want to do this and then tar it up so that the person who untars it can run everything.  Thanks for the help!  This is for Linux 32 bit OS.
0
Comment
Question by:cgray1223
7 Comments
 
LVL 29

Accepted Solution

by:
Randy Downs earned 167 total points
Comment Utility
Try
chmod -R 777 /maindirectory/*.ext
0
 
LVL 11

Assisted Solution

by:rowansmith
rowansmith earned 167 total points
Comment Utility
Use the number values instead

So chmod 777 = rwxrwxrwx
chmod 677 = rw-rwxrwx
chmod 477 = r--rwxrwx
chmod 177 = --xrwxrwx

In each case the 7 is made up of:

4 = r (read)
2 = w (write)
1 = x (execute)

So chmod 755 filename would result in rwxr-xr-x

Which is what you need if you want anyone to be able to execute a script (read and write)

Likewise chmod 700 filename will result in rwx------

See this link for further details.
0
 
LVL 1

Assisted Solution

by:ishanjrana
ishanjrana earned 166 total points
Comment Utility
4 = r (read)
2 = w (write)
1 = x (execute)

chmod 777 /abc/f1.txt       -----owner has read,write,execute permission on f1
                                                 -----group has read,write,execute permission on f1
                                                 ------others has read,write,execute permission on f1


chmod 753 /abc/f1.txt       -----owner has read,write,execute permission on f1
                                                 -----group has read,execute permission on f1
                                                 ------others has write,execute permission on f1


chmod 721 /abc/f1.txt       -----owner has read,write,execute permission on f1
                                                 -----group has write permission on f1
                                                 ------others has execute permission on f1


chmod 760 /abc/f1.txt       -----owner has read,write,execute permission on f1
                                                 -----group has read,write permission on f1
                                                 ------others has no permission on f1
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Don't modify your existing files, that's unnecessary and can even be dangerous from a security perspective.

Have tar modify the permissions during the archival process, so only the archived files will get the new settings.

tar --mode 777 -cvf archive.tar /source/spec

This works also using the symbolic notation:

tar --mode a=rwx -cvf archive.tar /source/spec

You can even change the owner of the files during archival ("--owner userid").

wmp
0
 

Author Comment

by:cgray1223
Comment Utility
@woolmilkporc - Is there any way to change the permissions to the  -owner userid when the user is untarring the tar ball?
0
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
Try this

http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/

For example following command will setup user and group ownership to root user only for /backup directory:
# chown root:root /backup
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
No, unfortunately there isn't, and even if it were possible - you must be root to change a file's owner anyway.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now