Solved

Use CHMOD To Allow Read, Write and Execute Permissions Recursively

Posted on 2012-03-12
7
1,005 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 30

Accepted Solution

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

Assisted Solution

by:rowansmith
rowansmith earned 167 total points
ID: 37713176
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
ID: 37713251
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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37713824
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
ID: 37715256
@woolmilkporc - Is there any way to change the permissions to the  -owner userid when the user is untarring the tar ball?
0
 
LVL 30

Expert Comment

by:Randy Downs
ID: 37715322
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
ID: 37715353
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

738 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