Solved

Use CHMOD To Allow Read, Write and Execute Permissions Recursively

Posted on 2012-03-12
7
991 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

713 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