LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 02-16-2009, 09:43 AM   #1
bergman
Member
 
Registered: Jan 2009
Distribution: slackware 12.1 (kernel 2.6.24.5-smp)
Posts: 39

Rep: Reputation: 17
Thumbs down cannot remove contents of the /tmp folder


Hello,

Im trying to delete the contents of my /tmp folder, so from within /tmp I issue this command:

Code:
rm -r *
but it gives me the error message:

Quote:
rm: invalid option -- _
Ive tried the above command as root also.

The permissions on the /tmp folder are 'drwxrwxrwt', Im wondering what the 't' is ?

Is there a special command to delete the contents of the /tmp folder?
 
Old 02-16-2009, 10:01 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
You can try the following but you should be careful as it will probably delete files that are in use:

Code:
# rm -rf -- *
The '--' mans there are no more parameters.

Use at your own risk.
 
Old 02-16-2009, 03:59 PM   #3
bach-fiend
LQ Newbie
 
Registered: Feb 2009
Location: St Paul, Minnesota, USA
Distribution: Redhat Fedora 10; someday planet CCRMA
Posts: 11

Rep: Reputation: 0
deleting files that are in use

This is legal in unix, I'm pretty sure. a "rm" command will succeed but the file will stick around UNTIL IT IS NO LONGER OPEN. THEN it will be really removed.
 
Old 02-17-2009, 07:12 AM   #4
raj k yadav
LQ Newbie
 
Registered: Dec 2008
Posts: 21

Rep: Reputation: 2
't' is denoted for sticky bit. You cannot delete files which are not owned by you if sticky bit is applied on a directory.
 
Old 02-17-2009, 07:51 AM   #5
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 49
You can remove the stiky bit as root:
chmod -t /tmp
if /tmp is owned by root, then he shopuld be able to remove the files anyway
 
Old 02-17-2009, 09:00 AM   #6
rich_c
Member
 
Registered: Apr 2008
Location: UK
Distribution: Mepis; Maemo; openSUSE
Posts: 384
Blog Entries: 74

Rep: Reputation: 81
Just do a reboot. That should clear out /tmp. It seems to have done on my system. My last reboot was 8 Feb and there are no files older than that in /tmp.
 
Old 02-17-2009, 10:06 AM   #7
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,802

Rep: Reputation: Disabled
Yes, Rich_c is right. Just wait for your next reboot and /tmp gets cleared out automatically. I don't think it's a clever idea to remove everything from /tmp on a running system. Lots of apps put stuff there until they are closed down. Removing these /tmp file would probably bring your system down. You can certainly delete specific files that you know are no longer necessary (I use /tmp as my default download folder and delete installation files all the time). Why do you want to delete everything from /tmp anyway?
cheers,
jdk
 
Old 02-17-2009, 02:32 PM   #8
bergman
Member
 
Registered: Jan 2009
Distribution: slackware 12.1 (kernel 2.6.24.5-smp)
Posts: 39

Original Poster
Rep: Reputation: 17
Thumbs down

Thanks everyone.

Rebooting didnt remove the files in /tmp (slackware 12.1), but doing:

Code:
# rm -rf -- *
as suggested did remove all the files, and it doesnt seem to have created any problems (at least not yet!)

p.s jdkaye, I just wanted a clearout
 
Old 02-17-2009, 02:40 PM   #9
Ranguvar
Member
 
Registered: Oct 2008
Location: Upstate NY
Distribution: Arch Linux
Posts: 99

Rep: Reputation: 17
Don't remove the /tmp sticky bit evar. It's for security
 
Old 02-17-2009, 11:30 PM   #10
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,802

Rep: Reputation: Disabled
Quote:
Originally Posted by bergman View Post
Thanks everyone.

Rebooting didnt remove the files in /tmp (slackware 12.1), but doing:

Code:
# rm -rf -- *
as suggested did remove all the files, and it doesnt seem to have created any problems (at least not yet!)

p.s jdkaye, I just wanted a clearout
bergman,
There are always going to be files in /tmp for the reasons explained above. Are you sure the ones that you save in /tmp when you rebooted arent' fresh ones installed after your latest reboot? You can check the date/time of the files by doing
Code:
ls -l [filename]
cheers,
jdk
 
Old 02-18-2009, 02:17 AM   #11
bergman
Member
 
Registered: Jan 2009
Distribution: slackware 12.1 (kernel 2.6.24.5-smp)
Posts: 39

Original Poster
Rep: Reputation: 17
There are a few hidden files and directories which seem to have been created since the reboot (.xorg.conf, .X0-lock, etc), but alot fewer than there were.

I suppose Im trying to clean up a directory which by its nature is 'untidy'.

Last edited by bergman; 02-18-2009 at 02:18 AM.
 
Old 02-18-2009, 03:25 AM   #12
rich_c
Member
 
Registered: Apr 2008
Location: UK
Distribution: Mepis; Maemo; openSUSE
Posts: 384
Blog Entries: 74

Rep: Reputation: 81
Quote:
Originally Posted by bergman View Post
I suppose Im trying to clean up a directory which by its nature is 'untidy'.
And probably best left ignored, unless it's using an awful lot of space. Mine's got 5.2MB in the 10 days since last reboot.
 
Old 02-18-2009, 09:17 AM   #13
bernihard
LQ Newbie
 
Registered: Feb 2009
Location: Spain
Distribution: CentOS 5.2
Posts: 13

Rep: Reputation: 2
A useful command for know if some process is using any file inside /tmp folder do the following:

Code:
fuser /tmp
The output will be the PID of the processes using files under /tmp
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
want to 'tar' a folder without some contents of folder shipon_97 Linux - Newbie 5 10-13-2007 04:21 AM
deleted contents of /tmp dave`2005 Slackware 2 06-22-2007 10:45 PM
Is it safe to delete the contents of /tmp? tramni1980 Slackware 19 01-15-2007 02:39 PM
2 gigabyte /tmp directory..ok to delete contents pAn1k Linux - Newbie 3 09-02-2004 09:56 AM
file:/tmp - mysterious contents. Rm, or not rm? linuxfond Linux - Newbie 5 06-12-2004 02:00 PM


All times are GMT -5. The time now is 11:09 PM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration