Delete Linux Files and Directories
How Do I Delete Files and Directories?
Deleting FilesReady to do a little damage? The rm command removes a file (assuming you have permission to do so) without even saying hasta la vista. Be sure you really want to delete your files before you use rm, because once the files are gone, they're not coming back. For example, $ rm wallet
immediately deletes the file named wallet in the current directory without prompting. If you want to be prompted before the deletion, use the -i flag.
Note: There is one little safety feature in rm--it won't delete a directory (unless you use the -r flag).
One other rm flag is -f, which translates roughly to "Don't ask me any questions--just delete the files." While rm normally asks for confirmation before deleting a write-protected file, the -f (force) flag overrides this prompt.
Be careful with the rm command, since the multiuser nature of Linux does not allow for undelete as in DOS. As soon as you let go of the space occupied by a file, the operating system is likely to use it for something else.
Deleting Directories
If you created a directory named spelunking six months ago, and now you're not so keen on crawling through slimy caves, the rmdir command may be able to help:
$ rmdir spelunking
This command removes the specified directory, but only if it's empty. If the directory contains files or subdirectories, you'll have to delete them using rm first.
One alternative to painstakingly removing all the contents of a directory that you just want to make disappear is to use the rm -r command. The -r flag gives rm license to kill directories, their files, and even their subdirectories. Be very sure you understand what's about to happen before using a command like this:
$ rm -r spelunking
Let's just say that careless use of the -r flag might end your spelunking hobby prematurely.
Previous Lesson: Creating Files and Directories
Next Lesson: Linux Files - Wildcards
Comments - most recent first
(Please feel free to answer questions posted by others!)
I want to delete File but getting bash, or file not exist
Question is what should i put in terminals aster $?
-$ rm (File Name).txt
Or should i put address -directory also?
thanks
example file
am leaning linux from last 15days so still am persuing linux and i hav a doubt it may b silly for you all but i would like to know all your opinion on my doubt.....
my doubt is that ............ in oracle it is possible to delete particular records from the table and in the same way is it possible to remove particular data from the specified file..........thanks in advance................
regards,
thanmathpradeep@gmail.com
Could any one help me in deleting a file with sapces in the name Eg: abc dec.text
i am not able to delete more than 25000 xml files at a time using rm -f command in unix so can any help me out to delete the 50000 files at a time in unix .
In properties it says that the file type some kind of application (octet/streaming). I did run some iso mounting and after i unmount it the file does not wanna goes away. restart my pc a few times, still it were there. At first i run command rm -fr filename, it says access denied.Then i run chmod -R 775 filename, it still says access denied. so how do i delete this file .. cause when it says streaming .. scared it will streams something else. :)
aruna (01 Dec 2010, 02:18)
I am unable to delete this file 'Valvoline fluid analysis(2).pdf' kindly help me
if the title of your file enclose by apostrophies 'val..etc' in the first place then simple put rm 'the file name' in apostrophies. The command line can't read files with spaces
In your case it was looking for file valvoline
How to remove symentac update file (20110213-003-unix.sh) from linux11 & linux10.3 please help me
If this find command does return the desired list of icon files then run this command: "find / -name Icon\* -exec rm -f '{}' \;" Note that all spaces and punctuation are significant. To be sure you get it right copy all the text between double quote marks and paste them into a Non-Proportional font text editor to see just where the spaces lie.
Good Luck.
The ls output for the file is -rwxrwx---@
2nd. I would like a unix command to remove these files in all folders recursively. I haven't been very successful in finding one, or at least not being able to understand the syntax properly. Any help given would be nice on this.
Thanks in advance.
I have a problem with my server space becoming to full and I need to delete files from
/var/lib/psa/dumps in order to get it back online, in I am totally new to unix so a bit of an explantion will be really helpful, thank you all very much
rm -rf Valvoline\ fluid\ analysis\(2\).pdf
I have one file with permission stating as ??? and time stamp also ???
how can i remove this file.
I tried numerous steps including force remove etc.,
Any suggestion would be appreciated.
Regards,
Shameem.
very good.......
you done a great help....
I love the way you have designed the course material!
I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But
don't ask me to send what you already have. :-) NO SPAM! If you post garbage, it will be deleted, and you will be banned.
Copyright © by -
All rights reserved - Redistribution is allowed only with permission.

