Solved

Use CHMOD To Allow Read, Write and Execute Permissions Recursively

Posted on 2012-03-12
7
1,017 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
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 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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

717 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