Questions tagged [rm]

rm is a basic UNIX command used to remove files, directories, and other items from the filesystem.

rm is a basic UNIX command used to remove files, directories, and other items from the filesystem.

Options:

-f force
-r, -R or --recursive

Examples

rm -rf /some/dir #removes all files and dirs recursively from this point

References

534 questions
5
votes
1 answer

What to do after a "rm -R /*"

I was working on my website under root and I commit the worst thing that a linux user can do : rm -R /* instead of rm -R ./*. I've stopped the process when I saw that it was taking too long... I manage to reinstall lubuntu with an usb key, is this a…
storca
  • 61
  • 1
  • 1
  • 4
5
votes
2 answers

rm all files under a directory using python subprocess.call

I'm writing a script that will move files into a .trash directory in a user's home folder. I want to add the ability to empty the trash directory by calling rm -rf /home/user/.trash/* using python's subprocess.call() ~$ touch file1 ~$ trash…
rodneyxr
  • 55
  • 1
  • 1
  • 4
5
votes
1 answer

/dev/simfs: No such file or directory while opening filesystem

I accidentally removed a wrong folder using rm -rf, every tool I've tried tell me either I have no hard disk or that the filesystem is not found. When I type df I get : Filesystem Size Used Avail Use% Mounted on /dev/simfs 25G 7.6G …
user3803848
  • 179
  • 1
  • 13
5
votes
3 answers

How to prevent user from deleting a file which is being used by JVM

I have a piece of JAVA code which reads a few files and keeps them loaded into memory for sometime. The file handles are preserved after reading. My problem here is that I want to restrict user from deleting these files using "DEL" key or rm…
5
votes
3 answers

rm cannot delete files starting with "--"

I have a script that creates files, and sometimes they end up having two dashes at the beginning. Is there any way to delete them? mv doesn't work either. Here is the error I am getting: $ ls --1355509766.jpg $ rm --1355509766.jpg rm: illegal…
frazras
  • 5,928
  • 4
  • 30
  • 40
5
votes
2 answers

In linux shell, How to cp/rm files by time?

In linux shell, When I run ls -al -t that show the time of files. How to cp/rm files by time? just like copy all the files that created today or yesterday. Thanks a lot.
herbertD
  • 10,657
  • 13
  • 50
  • 77
5
votes
3 answers

Unix command deleted every directory even though not specified

I am very new to the unix. I ran the following command. ls -l | xargs rm -rf bark.* and above command removed every directory in the folder. Can any one explained me why ?
arpanoid
  • 2,123
  • 4
  • 17
  • 15
4
votes
4 answers

can't delete directory under linux due to broken files

kt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al ls: cannot access post-commit: No such file or directory ls: cannot access update: No such file or directory ls: cannot access post-update: No such file or directory ls:…
russellkt
  • 311
  • 3
  • 10
4
votes
2 answers

Why does `rm -rf` behave differently when used in a git post-receive hook as opposed to shell?

I'm using this example on publishing a website w/ git post receive hooks. The hook pretty much clones the bare repo into a temporary directory, and after generating the site, removes that temporary git clone. #!/bin/sh # clone a repo, generate site…
Derrick
  • 2,356
  • 5
  • 32
  • 43
4
votes
1 answer

Catch "rm: fts_read: No such file or directory" error and continue

I goofed my Macbook real good. I moved some Time Machine backups from my external drive into Trash and quickly realized that was a horrible mistake. I can't put them back and I can't delete them. So far I've been running rm with a helper function…
Frank
  • 735
  • 1
  • 12
  • 33
4
votes
1 answer

rm -rf always exiting with 0, even if dir does not exist

I have this command: rm -rf ~/.quicklock; echo $? rm -rf ~/.quicklock; echo $? rm -rf ~/.quicklock; echo $? rm -rf ~/.quicklock; echo $? always exits with 0, even if directory does not exist. I am on a Mac. I thought it would exit with 1 if the…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
4
votes
1 answer

Why is find -delete faster than rm -rf?

Why is find ... -delete so much faster than rm -rf ? Specifically, To clarify: I'm specifically asking: Why is find ./x -type d -delete && rm -rf x so much faster than rm -rf x/? Background There have been a few people who use similar mechanisms,…
jayunit100
  • 17,388
  • 22
  • 92
  • 167
4
votes
3 answers

Deleting multiple files in Linux?

How can I delete multiple files in Linux created at same date and time? How can I manage this without using date? The file have different names. I have these .txt files: -rw-r--r-- 1 root root 54 Jan 6 17:28 file1.txt -rw-r--r-- 1 root root …
Bhushan Ahire
  • 79
  • 1
  • 6
4
votes
1 answer

remove all files with some extension from directories and subdirectories

Why does command: rm **/*.pyc removes nothing? What is the proper way to achieve expected behavior?
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
4
votes
4 answers

rm -rf doesnt work with home tilde in java runtime

This is my code to delete a folder , this below code wont delete the Downloads directory under home folder. import java.io.IOException; public class tester1{ public static void main(String[] args) throws IOException { …
stupidosaur
  • 97
  • 11