PDA

View Full Version : Directory structure cliff notes



gnossos
12-22-2003, 07:49 AM
Hey all,
for those of use who are not as familiar with the hosting side of things, eg., directory structures, what directories and subdirectories do what, what are ok to kill, what should never be killed, etc., If those more knowledgeable on the topic could post what the directories and subdirectories are and what they do/are used for and what their subdirectories are for/used for, I think it would be very helpful for myself and potentially others. I am on westhost 2.0 and I'm talking about the directory structure one is presented with when logging in via ftp.
when I login via ftp I am presented with the following directories.

bin
dev -> pts
etc -> default, depend, ftpd, hd, httpd, logrotate.d, mail, smrsh, sysconfig
ftp -> bin, dev, etc, lib, pub, usr
home -> acct name, www
include
lib -> apace, gconv, i686, liibmycrypt, locale, mysql, php, sasl
proc -> whole lotta folders
tmp
usr -> bin, home, include, lib, libexec, local, mail, sbin, share
var -> adm, cache, lib, lock, log, mail, named, run, spool, tmp, www
www -> bin, cgi-bin, conf, acct name, htdocs, icons, include, libexec, logs,
modules

and the following files
.bash_history
.bashrc
.profile

now I've only listed the initial sub directories here and I realize that a number of these are symlinks but since I'm new to the apache based hosting, if people could contribute and explain what goes where, what folders are for what, what does what, etc., etc., I would very much appreciate it (and what is a symlink to what/why).

thanks much!

wildjokerdesign
12-22-2003, 09:03 AM
Well to show that each account can be a bit different I well post what one of my accounts looks like when I first log in via FTP:

.bash_history
.bashrc
.profile -> .bashrc
.spamassassin
bin
dev
etc
ftp
home -> usr/home
home2 -> home
home3 -> home
include
lib -> ftp/usr/lib
proc
.spamassassin
tmp -> var/tmp
usr
var
www -> usr/local/apache

The ones with the "->" are symlinks with where they are pointed. I'll start with the one on the bottom which should be the one most followed. When you follow the www symlink it takes you to usr/local/apache and there you find the following.

.htpasswd
Password file used when you log in via your browser on diffrent things. Do Not Delete.
bin
Not sure about this one but has symlinks in it.
cgi-bin -> ../../../var/www/cgi-bin/
Yet another symlink pointing to your cgi-bin. Do Not Delete.
conf -> ../../../etc/httpd/conf
Symlink to your config files. Do Not Delete.
htdocs -> ../../../var/www/html
Sylink to the directory where you upload you public html files. Do Not Delete.
icons -> ../../../var/www/icons
Symlink to a directory in your public www directory file that has images in it. There are a variety of images in this diretory and sub diretory called small. If you look at the readme file it says this at the top.

Public Domain Icons
These icons were originally made for Mosaic for X and have been
included in the NCSA httpd and Apache server distributions in the
past. They are in the public domain and may be freely included in any
application.
Not sure if any of the applications WestHost has uses these are not. If you do delete them you would need to check your applications to see if any have broken images. Since they are public domain you can use them on your pages and in your aplications.
include -> ../../include/apache
A symlink to I belive the programs used to run apache. I wouldn't delete them.
libexec -> ../../lib/apache
Symlink that again I think is similiar to the include symlink. Do No Delete.
logs -> ../../../var/log/httpd
Symlink to the directory that holds your log files. The content of the real directory depends on the logs you are keeping.
modules -> ../../lib/apache
If you notice this is a symlink to the same place as the libexec symlink. Do No Delete.
myusername -> htdocs
Symlink that takes you to your public directory where you upload your web pages. Do No Delete.


So there it is for at least a start. Like you I am not real familiar with apache and the file structure but that is what I understand of things from following the links and looking at files with in the different directories.

You might notice that I have home home2 and home3. I know others have these or at least versions of them in their setup. From what I understand these are symlinks to keep accounts working that where transferred from 1.0 to 2.0.

Duplicate cgi-bin
The one thing that I am curious about in my set up is that within my cgi-bin directory there is anouther cgi-bin directory that has duplicates of all the files in the first cgi-bin. That is all files that where on the 1.0 account. When I add an application that puts something in the base cgi-bin via the Site Manager it does not put it in the second cgi-bin. I keep thinking I well ask tech about this but haven't. Has anyone else asked them or have this in their setup?

torrin
12-22-2003, 01:26 PM
[rant mode]
I think one question you should ask yourself is why are you doing this? That is, why do you want to delete these directories? I'm not saying you don't have a good reason, just make sure you know why you're subjecting yourself to the hassle.
[/rant mode]

OK, now that I have said that let me get on with a response. :) I don't have access to my account at the moment, so I'm doing this from memory. I've been playing with linux systems since Red Hat 5.0.

bin - is a directory with general user tools in it. (don't delete)
dev - these are the files that represent the devices connected to your computer. (Hard drives, RAM, etc.) I'd be very surprised if you have access to delete them. They are generally root owned. (don't delete)
etc - This is where most configuration files for the system live. You'll also find start up scripts. (don't delete)
home - This is generally where all home directories for users of the computer live. I'm not sure this is the case with Westhost 2.0. Deleting this probably won't have much impact on the system itself, but will have impact on the users so I wouldn't delete it. (don't delete)
lib - These are libraries files (or dlls in the windows world). If you delete this, the only programs that will run are those that are statically linked. In other words, almost none. (don't delete)
proc - This directory contains information about the running system. What programs are running, how they were started, etc. Deleting this directory will save no hard drive space because it's virtual. Also, certain programs (ps for example) will not function correctly because it uses the info in proc. (don't delete)
tmp - This is a directory that programs use when them need to create temporary files. Everything under this directory is fair game for deletion, but don't delete the directory. (don't delete)
usr - Like bin this is a directory with general user tools. The difference is bin is base tools, usr is everything else. Try looking under /usr/bin, /usr/local/bin, /usr/sbin. (don't delete)
var - Usually there is a lot of misc. stuff under this directory. Mail, logs, databases, web directories, etc. (don't delete)
www - Not important unless you actually have a website. :P (don't delete)

OK, I said don't delete them, but you can probably get away with deleting /home and /www. I guess my advice is to not delete any of the above directories though because, they are important to the functioning of a linux system. You may get away with deleting some of the programs under those directories (/usr/bin, /usr/local/bin, /bin), but since we don't have access to rpm (The correct way to manage a Red Hat system), I don't think you should bother.

As for the directories I didn't mention, I don't know what's in them.

Good luck!

P.S. Like I said before, i'd be very surprised if you had access to delete any of those directories. They are generally root owned and managed. If someone would be so kind as the list the permissions on those directories that I have mentioned above we can tell.

wildjokerdesign
12-22-2003, 01:47 PM
bin dr-xr-xr-x root
dev drwxr-xr-x root
ect drwxr-xr-x vuser (user owned)
home lrwxrwxrwx root
lib lrwxrwxrwx root
proc dr-xr-xr-x root
tmp lrwxrwxrwx root
var drwxr-xr-x vuser (user owned)
www lrwxrwxrwx root

So there we have the user only has control of two of them. Aside from the fact of the cg-bin within the cgi-bin I see not reason to have to delete any thing on the server. I think the second cgi-bin may have been a "glitch" in the first upgrades to 2.0. As you can tell with the added diskspace I am not too concerned about it since I have not contacted WestHost to see if I need it. :)

For me all this is more of a learning tool to understand where things are and what is needed. I do think that there may be some stuff like the icons that if you don't use are just taking up space and I do know that many times manuals or help docs are installed that you may not need on each account if you have more then one and keep the docs on your local computer for refrence.

gnossos
12-22-2003, 02:14 PM
thanks to both of you, I really wasn't too interested in deleting things, rather more curious as to what everything does and what goes where, what does what, etc. I want to make sure that I have all of this straight before I upload the dinosaur of our old site which has tons and tons of directories in it (b/c I want to get rid of the horrid old site soon so I will want to delete all of it at some point w/o damaging the necessary directories, etc., etc.,)

thanks again to the both of you.

torrin
12-22-2003, 02:29 PM
thanks to both of you, I really wasn't too interested in deleting things, rather more curious as to what everything does and what goes where, what does what, etc.

No problem. Here are some links to some more information.

http://www.pathname.com/fhs/
http://www.pathname.com/fhs/2.2/

The information presented is how things should work, but some distros do things differently.

jalal
12-22-2003, 02:39 PM
As Torrin says, why delete stuff? You may save a megabyte, maybe, but if all you are deleting is symlinks then you save nothing.

The symlinks are there
a) to make it easier to provide scripts that will work straight off. e.g. on my site I have perl installed as /usr/local/perl/bin/perl. I also have symlinks at /bin/perl, /usr/bin/perl, /usr/local/bin/perl, all pointing to the main Perl binary. This means that I can install a script with any of those possibilites on the hash bang line and they will work.
b) it seems, as part of the site upgrade process. Upgraded sites have a lot of directory symlinks and I guess Westhost have done it this way as they may have had a bunch of different servers and file layouts and just wanted things to upgrade without to much trouble. So, symlink everything and you cut down on the problems.

Unless you really understand what you are doing and you have a good reason for doing it (I can't think of one), then leave it all alone.
8)

You can find more on the directory structure here:
http://www.pathname.com/fhs/2.2/
(altho a Westhost site doesn't comply with the standard, it gives an explanation of what the directories are for).

jalal
12-22-2003, 02:44 PM
bin dr-xr-xr-x root
dev drwxr-xr-x root
ect drwxr-xr-x vuser (user owned)
home lrwxrwxrwx root
lib lrwxrwxrwx root
proc dr-xr-xr-x root
tmp lrwxrwxrwx root
var drwxr-xr-x vuser (user owned)
www lrwxrwxrwx root

So there we have the user only has control of two of them.
...

Just to clarify, the user has access to all of them except /dev/ and /proc/, as the others have read, write and execute privileges granted to all. (thats the last 'rwx' on the line).

:shock: