Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-05-2005, 10:49 AM
|
#1
|
|
Member
Registered: Jul 2003
Location: USA
Distribution: Slack 12.2 and Ubuntu 9.04
Posts: 61
Rep:
|
set file permissions for 100 directories & its files
I have a directory called /Data
It has many directories; probably 100. Inside those dir I have executable files - They shouldn't be executable.
For example lets just say /Data has 2 directories calles /folder1 and /folder2
I would like to be at /Data and issue one command to give the
subsequent directories rwxr xr x and its
subsequent files rw r r
Can this be done or do I have to go to each of the 100 directories and
chmod -x * ??
|
|
|
|
01-05-2005, 11:02 AM
|
#2
|
|
Member
Registered: Oct 2004
Location: Brooklyn
Distribution: Slackware 13.1,12.1,12.2; Debian Sqeeze; Centos 5,6
Posts: 249
Rep:
|
I have always found its easier dealing with numbers when modifying permissions. Read is 4, write 2, and execute 1. This means the rx is 5 and rw is 6. With that in mind, it would issue a chmod -R 644 * That would (recursively) from the attach point change permissions to rw,r,r.
|
|
|
|
01-05-2005, 11:18 AM
|
#3
|
|
Member
Registered: Jul 2003
Location: USA
Distribution: Slack 12.2 and Ubuntu 9.04
Posts: 61
Original Poster
Rep:
|
I've tried that already. It doesnt work becasue:
it takes away the x permission on all the directories, making it impossible for other users to read the file.
Directory
drw-r--r-- 2 Smith users 3208 Mar 13 2004 temp/
ITS CONTENTS
-rw-r--r-- 1 Smith users 153454 Aug 5 2002 sample
I need other users to be able to look into the directory and read the files.
|
|
|
|
01-05-2005, 05:31 PM
|
#4
|
|
Member
Registered: Dec 2003
Location: Vienna | Austria
Distribution: Gentoo
Posts: 52
Rep:
|
I have asked myself this question - but I still have not found a solution.
With you are able to list the files and (sub)directories in a directory.
With or you should
Quote:
|
list directory entries instead of contents
|
(from ls --help).
I think this means that you can see all (sub)directories in the choosen directory. Further I think if you can find this out, it's simple to write a short script doing what you want.
The problem is: ls -d shows me only the directory itself with one dot. nothing more.
|
|
|
|
01-06-2005, 03:11 AM
|
#5
|
|
Member
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799
Rep:
|
1) cd /Data
2) chmod -R 755 *
3) find ./ -type f | xargs chmod 644
Step 2 is just to be sure your directories are correct.
Step 3 will find any 'regular' files (see 'man find' for other types), and then make them non-executable.
Enjoy!
--- Cerbere
Last edited by Cerbere; 01-06-2005 at 03:12 AM.
|
|
|
|
01-06-2005, 07:56 AM
|
#6
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Another way of doing it is using the -exec option of the find command.
1) cd /Data
2) find ./ -type d -exec chmod 755 {} \;
3) find ./ -type f -exec chmod 644 {} \;
If only a handful of files and directories need changing, you can add the -perm test to return files with execute permissions for Groups and Others.
---
If this directory is truly a data directory, and its own partition, consider also using the -noexec option when mounting. You the owner won't be able to execute files from there either, but this is added insurance.
Last edited by jschiwal; 01-06-2005 at 08:11 AM.
|
|
|
|
01-06-2005, 10:23 AM
|
#7
|
|
Member
Registered: Jul 2003
Location: USA
Distribution: Slack 12.2 and Ubuntu 9.04
Posts: 61
Original Poster
Rep:
|
thanks for your replies.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|