Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-09-2004, 06:48 AM   #1
Registered: Mar 2003
Location: New Zealand
Distribution: Red Hat Linux 8 & 9
Posts: 32

Rep: Reputation: 15
Using chmod on directories

If I FTP a complete website directory to my RH9 Linux server with subdirectories and files, the permissions are such that everyone gets an error when trying to view the pages.

I fixed this by using chmod as follows:

chmod -vR a=rx,u+w mynewdirectory

This works but it means that everything is executable. Ideally, I would like to just make the directories executable not the files. How? Anybody know?

I was also wondering if there was a way to set the default permissions for files and directories that are FTPed.
Old 07-09-2004, 07:34 AM   #2
Registered: Jul 2003
Location: Geneva, Switzerland
Distribution: Debian 3.1, SLC3 (based on RHEL)
Posts: 84

Rep: Reputation: 15

Unfortunately, there is no simple way to do that since chmod doesn't have a "directory only" option.

You may be interested to read this:

and the reply!

My idea would be to use the -p option in ls and then grep the / at the end of directories like that:
ls -p | grep /

to get a list of the directories, put this into a file and write a shell script to chmod the element in the list. There probably is a more efficient way to do it, but that's what I would do!

Hope this helps!
Old 07-09-2004, 07:06 PM   #3
Registered: Mar 2003
Location: New Zealand
Distribution: Red Hat Linux 8 & 9
Posts: 32

Original Poster
Rep: Reputation: 15
Thanks arobic,

I will give that a try. It makes sense to me in theory too but I thought there may have been a simple way.

I thought that umask would be the command I needed to set the default permissions but when I FTP files over it doesn't apply those settings. The settings in umask seem to only apply if the user creates new files on the server directly. Am I missing something with umask here? Incase setting default file permissions is dependant upon the FTP program, I am running vsftpd on the server (and I am very happy with it).
Old 07-09-2004, 08:45 PM   #4
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
suppose you downloaded the site into your /mirror directory. then, to give all directories under /mirror execute permissions, you would do
 find /mirror/ -type d -exec chmod a+x {} \;
Old 07-10-2004, 05:37 AM   #5
Registered: Mar 2003
Location: New Zealand
Distribution: Red Hat Linux 8 & 9
Posts: 32

Original Poster
Rep: Reputation: 15

That is a great fix. I can tidy up permissions with two simple lines now and only my directories are executable.

Pity nobody knows how to set default FTP permissions but I am not complaining.

Thanks again.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 04:22 PM
chmod to only change directories lluciano Linux - General 2 08-17-2005 03:14 PM
How to chmod -R on directories only? jdupre Linux - Newbie 3 11-13-2004 12:45 AM
chmod directories only vrillusions Linux - General 4 05-21-2003 09:02 PM
Cannot Chmod directories stelmed Slackware 4 05-19-2003 02:30 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration