LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-20-2008, 12:26 AM   #1
Paris Heng
Member
 
Registered: Jul 2007
Location: Kuala Lumpur, Malaysia
Distribution: Ubuntu 8.04, Solaris 10
Posts: 198

Rep: Reputation: 30
Removing File and Directory


Dear,

1. When I issued a command

rm file

Where the file going? Into the trash? But it did not seen in the trash. What different if I issued?

rm file > /dev/null

2. Did Linux got some kind of tools like in Windows like "Disk Cleanup"?

Reagrds
 
Old 02-20-2008, 12:58 AM   #2
vedang
Member
 
Registered: May 2006
Posts: 89

Rep: Reputation: 15
Removing file and directory

1. rm file command removes the file named "file" and it doesn't store that
file in the trash, because you are deleting that file through command
prompt. But if you delete anything on command prompt it doesn't go to
trash.
If you try to delete same file in graphics mode it will be sent to
trash.

2. Normally > is used to save the output of the command to a file.
rm file > /dev/null will not save the output to any file as you
specify /dev/null, because /dev/null is a null pointer.
if you use
rm file > file1 then it will delete the file "file" and just create
an empty file named file1, because rm file doesn't give any output.

Normally redirection is used to to store output of some ls dir like
commands or with customized scripts.
for example
ls -l > file2

3. There is no such tool like Disk cleanup in linux. Normally it is not
required. Because of multiple advantages of ext3 filesystem is is not
required. But as size of your data increases OS stores data in
fragements. So in such cases you may need to run fsck to improve read
performance.
But in case of filesystem related problem fsck command is used to check
and repair filesystem. But fsck command is used in runlevel1 or unmount
partitions and then run fsck command.

Last edited by vedang; 02-20-2008 at 01:16 AM.
 
Old 02-20-2008, 01:42 AM   #3
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Excellent post, but just a couple of points:

Quote:
Originally Posted by vedang View Post
If you try to delete same file in graphics mode it will be sent to trash.
Deletion and trash has nothing to do with graphics or text mode. It has to do with whether the tool doing the deleting understands 'deletion' or 'movement to trash'. There are several graphical file managers which delete files and, while I can't think of one, I'm sure a console file manager with a trash command would be trivial.

Quote:
Originally Posted by vedang View Post
Because of multiple advantages of ext3 filesystem is is not required. But as size of your data increases OS stores data in fragements. So in such cases you may need to run fsck to improve read performance.
Ext3 isn't the only filesystem available for Linux. Though it is true that there are a variety of them that are good and few or none do defragmentation. But, I think what Paris Heng is asking is more for a decrapulator than a defragger. Basically, no, there isn't a disk cleanup tool, but Linux tends to generate nowhere near as much crap as Windows and tends to concentrate it in the various tmp directories (which can generally be safely emptied) and in /var, where things like logrotate and whatnot are generally set up by your distro to keep the crap to a reasonable and reasonably steady level. As far as your dotfiles in $HOME, it'd basically be up to you to police that how you wanted.
 
Old 02-20-2008, 01:46 AM   #4
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Well, there are a few applications that do secure file deletion, if that is what you had in mind. Apply them and you can rest assured that no-one will be able to retrieve them behind your back. The number of file systems they can handle is very limited, though, ext2 in most cases and perhaps also ext3 but that is about it.

Linux does not have a registry unlike Windows, which is precisely the part that tends to need most cleaning. There is little point in using windows-like cleaners on Linux.

Last edited by jay73; 02-20-2008 at 01:49 AM.
 
Old 02-20-2008, 05:55 AM   #5
Paris Heng
Member
 
Registered: Jul 2007
Location: Kuala Lumpur, Malaysia
Distribution: Ubuntu 8.04, Solaris 10
Posts: 198

Original Poster
Rep: Reputation: 30
Thanks for the information. But i still wonder, if i using rm file, like you mentioned it did not go to trash. It is remove to somewhere else? Or it just vanish after the removal?
 
Old 02-20-2008, 06:19 AM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Basically, this bit from unlink(2) should explain it pretty clearly:
Quote:
unlink() deletes a name from the filesystem. If that name was the last link to a file and no processes have the file open the file is deleted and the space it was using is made available for reuse.

If the name was the last link to a file but any processes still have the file open the file will remain in existence until the last file descriptor referring to it is closed.
Basically, IOW, it is rendered inaccessible to most tools and, when nothing's using it anymore and the space is needed, it will be overwritten.

I don't much trust any of these new-fangled .biz domains, but you might like

http://www.cyberciti.biz/tips/unders...em-part-i.html
http://www.cyberciti.biz/tips/linux-...-securely.html
 
  


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
Perl, Removing file from path to get directory only xemous Programming 8 04-11-2012 11:13 AM
Removing a Directory from the Terminal without deleting each file or folder lennysokol Linux - General 4 05-30-2005 11:30 PM
removing a directory swatward Linux - Newbie 5 05-19-2005 08:22 AM
Removing a directory snowmonkey Linux - Software 3 11-06-2003 08:43 AM
Removing a directory WorldBuilder Linux - General 2 03-29-2003 07:04 AM


All times are GMT -5. The time now is 12:20 PM.

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