1820057 Members
3056 Online
109608 Solutions
New Discussion юеВ

Re: Unix Command

 
Rahim Makhani
Advisor

Unix Command

Can someone tell me the command to give execute permission to a directory and to all the sub-directories and files within that directory

Thanx
Rahim...
8 REPLIES 8
RAC_1
Honored Contributor

Re: Unix Command

chmod -R 755 /dir
gives rwx ro owner and rx to group and others.
There is no substitute to HARDWORK
Cheryl Griffin
Honored Contributor

Re: Unix Command

chmod is the command
http://docs.hp.com/en/B2355-90689/chmod.1.html
"Downtime is a Crime."
Peter Godron
Honored Contributor

Re: Unix Command

Rahim,
see man chmod

Grant execute to all users (dangerous!)
chmod -R a+x
Sivakumar TS
Honored Contributor

Re: Unix Command


Hi,

The chmod command with -R ( recursive ) applies the permission to all files and subdirectories too.

Regards,

Siva.
Nothing is Impossible !
Vipulinux
Respected Contributor

Re: Unix Command

Hello

do the following:

chmod -R 755 /yourdir

Cheers
Raj D.
Honored Contributor

Re: Unix Command

Rahim,

Here it is :

# chmod -R ugo+x dirname


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
SUDHEER M S
Advisor

Re: Unix Command

Do the following.

chmod -R 755 /
Changes all Directories, Sub-Dir and Files to RWX for Owner, r_x for Group and r_x for others.
Note:- Hope you realize seriousness of 755 -R.

This will not apply for the Newly created files and folder. (your umask will matter there).

Cheers
MS
Bill Hassell
Honored Contributor

Re: Unix Command

Actually, all of the answers are slightly incorrect. chmod -R wil change EVERYTHING in every directory which you defeinitely do NOT want to do. Directories must be executable to be searched, but data files should not be excutable to avoid problems. The correct command would be:

find /specific_directory -type d -print -exec chmod a+x {} \;

The find command locates only the specific_directory and all sub-directories, but ignores any files.

NOTE: chmod -R is an extremely dangerous command as it can make unwanted changes to all directories and files in a directory tree. Be very cautious about using the -R option. Also make note that an absolute numeric value (such as 755 or 666 or 7777) will destroy sticky bits and set UID and GID bits, rendering certain programs inoperable. Adding +x to a bunch of directories is genrally safe as it allows all users to search through (execute) the directory. Adding +w to all users for a set of directories in inherently unsafe as it allows all users to delete or rename the files (and directories) in the directory.


Bill Hassell, sysadmin