Solved

Use CHMOD To Allow Read, Write and Execute Permissions Recursively

Posted on 2012-03-12
7
953 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
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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 29

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS - HAProxy- KeepAlived 5 41
Linux VM 6 86
centos linux 65 123
how to install java on RHEL image on EC2 4 26
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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…
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.

813 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

12 Experts available now in Live!

Get 1:1 Help Now