how to change permissions only to files, not directories....?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to change permissions only to files, not directories....?
# 1  
Old 06-04-2007
how to change permissions only to files, not directories....?


I am really new to unix, any help is much appreciated.

I need to change permissions of all files under several subdirectories to 700 but keep directories readable (755). Why ? Because I need a FTP user to only list his files and can't read them. But to browse to subfolder, the directories must be readeable.

Something like:

"find . -type f" (list only files) >> then "chmod 700" (chmod the printed files)


"ls -l | grep -v "^d" " (list non directories) >> chmod 700

I don't know how to do it. Please any advice ?

Thank you!
# 2  
Old 06-04-2007
find . -type f -exec chmod 700 {} \;

# 3  
Old 12-13-2008
really find . -type f -exec chmod 700 {} \; good

but if i need to chmod 1 type only of files like *php

and if i need to find all files *php and delete them
# 4  
Old 12-13-2008
Yes i understood your problem ..
ill tell you the simple command to solve your problem
1> To delete only the specified files in a perticular directory and subdirectory use the below command
find <dir_path> -name <search_format> -delete
find /home/avi/examples/ -name "*.html" -delete
to just print all required files
find /home/avi/example/ -name "*.html" -print
2>To change the mode for each file type which you want
for eachFile in `find /home/avi/examples/ -name "*.sh" -print`
chmod 700 $eachFile

### ateya i thing all your problems solved... Smilie
Regards:Avinash... A Real Angry Man
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Command to change add permissions for a new user to all files in all subfolders and folders

Hi there! I'm new to Unix and haven't done command line stuff since MS-Dos and Turbo Pascal (hah!), I would love some help figuring out this basic command (what I assume is basic). I'd like to add a User to the permissions of all files in a folder and all files in all subfolders, as well... (9 Replies)
Discussion started by: Janjbrt
9 Replies

2. AIX

Permissions on directories and files

Hello, I have a main directory called /test123 /test123 has lot of sub-directories and files. drwxr-x--- 21 root system 4096 Jan 25 10:20 /test123 Here, "other" does not have any access to /test123 folder. How can we provide read-only access to others on /test123... (1 Reply)
Discussion started by: aaron8667
1 Replies

3. Solaris

Change permissions for files

Hi! I have a dir in a server, that receives files with the wrong permissions, so I decide to put on a cron entry that changes its permitions, but because of the time gap, not all of them get changed. What I did was the following: ... (14 Replies)
Discussion started by: fretagi
14 Replies

4. Shell Programming and Scripting

Script to change Permissions on files and directories

Hey, It's me again. Have a problem, that's not really a problem. I have the below script, that goes to the directory I want it to go to. lists out the directories available, lets you choose the directory you want, then it changes the permissions on said directory. using chmod -R and chown -R. ... (2 Replies)
Discussion started by: gkelly1117
2 Replies

5. Shell Programming and Scripting

Find only files/directories with different permissions/owners

My git post-update has the following lines in it to make sure the permissions are set right: find /usr/local/apache/htdocs -type d -print0 | xargs -0 chmod 755 find /usr/local/apache/htdocs -type f -print0 | xargs -0 chmod 644 chown -R apache:apache /usr/local/apache/htdocsThe only problem is... (5 Replies)
Discussion started by: dheian
5 Replies

6. Linux

Default user:group permissions while creating files and directories

Hi, I am working on setup a environment where only a specific user can upload the builds on htdocs of apache. Now i want that a specific user can copy the builds on htdocs folder. I created a group "deploy" and assign user1 and user2 to this group. On Apache side i mentioned User=deploy... (3 Replies)
Discussion started by: sunnysthakur
3 Replies

7. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

8. Shell Programming and Scripting

script to change the access permissions of the files

Hi, I want to change the access permissions of the files whose extension is same.For example *.c but these are inside a directory and inside that other directory is there and it contains the .c files..for example-- So my aim is to search the files under src and change the access permissions... (3 Replies)
Discussion started by: smartgupta
3 Replies

9. Shell Programming and Scripting

Need help in changing Permissions to 775 for files and directories

Hi All I need to create a script which would change Permissions to 775 All the Files and directories will be mentioned in the Paramter files Can anyone give a Hint how to proceed in this ?? THanks (1 Reply)
Discussion started by: ranga27
1 Replies

10. UNIX for Dummies Questions & Answers

How to change default permissions on new files

Hello, I would like to know if there was any way I can change the default permissions for new files being generated within a certain directory. Would I need to have the same permissions set at the directory level as for the files being generated in it. Regards, Rdgblues (1 Reply)
Discussion started by: rdgblues
1 Replies
Login or Register to Ask a Question

Featured Tech Videos