LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 11-20-2004, 08:41 PM   #1
ninmonkeys
LQ Newbie
 
Registered: Nov 2004
Distribution: Slackware 10
Posts: 28

Rep: Reputation: 15
Root directories /tmp, /var, /etc


I'm confused about some of the basic root directories. I'm posting what I think they do, please correct me where I am wrong. (Using slack10)

/etc

Some config files are found here

/usr

I think this is where you install user wide programs. For example, I compile programs into /usr/local/src/app and then install to /usr/local/bin /usr/local/lib etc...

/var

What is this directories purpose?

/opt

What is this directories purpose? It only KDE uses this dir.

/sys

This is empty, does/did it have some purpose?

/tmp

I'm assuming it's a temperary dir, that it's contents eventually get deleted, but I don't know how it works.

1) What's sticky for? I do
Code:
$ file /tmp/
/tmp/: sticky directory
Reading man chmod, I think this is so everyone can write to /tmp, but can't overwrite/delete other user's files?

2) Does the /tmp dir get cleaned up itself, or should I write a script to delete it every once in a while?

3) Do you ever use the /tmp dir? For example if I did "$ find / -name foo 2>/dev/null 1>results", would you perhaps save the results on /tmp because it will get erased automatically?

thanks
 
Old 11-20-2004, 11:17 PM   #2
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
re sticky bits: http://www.hackinglinuxexposed.com/a.../20030424.html

and re filesystem use:
http://tldp.org/HOWTO/HighQuality-Apps-HOWTO/fhs.html
 
Old 11-21-2004, 12:48 AM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: At home: Arch, OpenBSD, Solaris. At work: CentOS, Debian, Ubuntu
Posts: 3,558

Rep: Reputation: 80
1) You got the purpose of the sticky bit exactly right (it's called the sticky bit because in the days of yore, it was used on commonly-accessed executables to keep their text segments in memory, making them "sticky". When Unix got proper demand paging of memory back in the '70s, this was no longer needed, so the bit was re-used to provide an extra level of acces permissions to directories).

2) Depends on the distro -- some have scripts that clean up /tmp on reboot, and some don't. Writing a script to clean out files from /tmp that haven't been accessed in 3 days or more is a good newbie shell scripting project.

3) Yes, I use /tmp quite a bit. Mozilla and Firefox also download stuff to /tmp (like when you open a PDF from a Web page, the PDF is actually saved in /tmp).
 
Old 11-21-2004, 04:45 AM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: FreeBSD, NetBSD
Posts: 1,446

Rep: Reputation: 46
I use /tmp frequently when I know I am going to create a mess of files that I will never miss. Basically, if I am testing a script... I will usually testbed it in a directory I make in /tmp (this is techically rude on multi-user systems as filling up /tmp with your junk might cause it to become full if it is on a seperate partition... but this is my personal computer so bah). I do that because I do have a cron script which removes all files which haven't been touched in three days. So, I can safely forget about it after I am done.

It is like being a kid again. I never have to clean up after myself... I just leave my toys laying about and my mother (the OS) cleans them up for me.

 
Old 11-21-2004, 04:47 AM   #5
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: FreeBSD, NetBSD
Posts: 1,446

Rep: Reputation: 46
Oh, and

/opt usually holds optional software packages. Which stuff ends up here and not elsewhere is distro dependant.

/sys should be a link into the kernel sources. If it is empty then you might not have installed the source.
 
Old 11-21-2004, 04:50 AM   #6
n0xvb
Member
 
Registered: Sep 2004
Location: 127.0.0.1
Distribution: Slackware 13; openSUSE 11.2
Posts: 255

Rep: Reputation: 31
The /var directory is traditionally for things that change size dynamically. For example print spool files, mysql db files, apache, lock files and log files, etc etc ad nauseum :-)
 
Old 11-21-2004, 01:39 PM   #7
ninmonkeys
LQ Newbie
 
Registered: Nov 2004
Distribution: Slackware 10
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks for all the help!

1) The only part I was confused on was:
Quote:
Originally posted by frob23 /sys should be a link into the kernel sources. If it is empty then you might not have installed the source. [/B]
I haven't compiled a new kernel yet, so maybe it changes, but for me /usr/src/linux is a symbolic link to /usr/src/linux-2.4.26/ which is my kernel source. /sys is a regular directory. (That's empty)

2) When writing a shell script to remove files older than X days, what should I do to special files? I noticed at least a socket, and a symbolic link files. Would I just "rm /tmp/oldFile" regardless if they are normal files? Or should I test for that and only remove files/dirs that are normal?
 
Old 11-21-2004, 02:49 PM   #8
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: At home: Arch, OpenBSD, Solaris. At work: CentOS, Debian, Ubuntu
Posts: 3,558

Rep: Reputation: 80
You probably ought to test for it. I notice things like MySQL sockets don't get their atime updated.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/tmp folder hardeep_ubhi Linux - General 4 10-02-2006 08:10 AM
/var/ and /tmp/ directories puishor Linux - General 5 06-25-2005 09:36 AM
kde, /tmp, /var/tmp and all that garba Linux - Software 4 06-17-2005 01:31 PM
/tmp /var/tmp Manuel-H Linux - General 3 04-23-2005 06:30 AM
Newbie question - /tmp /var/tmp Mr happy Linux - Security 3 01-27-2003 02:03 PM


All times are GMT -5. The time now is 01:39 AM.

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