Questions tagged [rm]

Questions relating to the Linux remove command (rm)

Filter by
Sorted by
Tagged with
0
votes
1answer
69 views

Accidentally deleted home directory on Linux, how to recover?

I accidentally deleted my home directly from terminal with rm -rf. Later, I tried to recover the deleted contents using foremost and testdisk. I couldn't recover the content and there were some ...
-3
votes
1answer
65 views

rm: cannot remove 'test123': Permission denied [closed]

I use this command but it didn't work rm test123 note 1 : menna@ubuntu:/etc$ l -ltr total 1116 drwxr-xr-x 7 root root 4096 Mar 18 06:11 apparmor.d/ drwxr-xr-x 3 root root 4096 Mar 18 06:11 ...
-5
votes
1answer
72 views

how to write a command to remove a folder, name includes spaces.? [duplicate]

How can I delete a folder with whitespace in its name, but without quoting the folder name? I also need to be prompted to confirm the deletion. I know how to do it like this: rm -ri /home/user/'my ...
0
votes
1answer
310 views

i ran this command “ sudo rm -r -f /home/fille/Desktop/”

i ran this command " sudo rm -r -f /home/fille/Desktop/" desktop is gone including the trash bin and i get this error when i try to create a new folder from my desktop," see image 1 &...
0
votes
1answer
32 views

find command to search for logs

I need to search logs only in a, b ,c, d, e, f directories and not in the subdirectories The command I use: find . -name "*.log" | xargs rm which deletes important logs inside these ...
4
votes
0answers
187 views

Recovering deleted files with rm -rf [duplicate]

I accidentally deleted a directory with rm -rf /media/directory When using ls -lh /media the space appears to be free, but when I use df or open the file manager nautilus or pantheon, it shows that ...
1
vote
0answers
68 views

Trying to use extundelete for recovering a “rm -rf”ed directory. But receiving this: extundelete: No such file or directory /dev/sda5

so I accidentally deleted a dirrectory using "rm -rf". I am trying to recover is using extundelete. So far I have done these: $ sudo umount -l /dev/sda5 $ extundelete --restore-directory {...
0
votes
1answer
47 views

Move all files with a certain extension from different subdirectories

Is there any Linux command to move all files with a certain extension (let's say .txt) from all different subdirectory (which has subsubdirectories, subsubsubdirectories...) to another directory?
0
votes
1answer
50 views

What will the following command delete? rm -r * /mnt/folder

I just want to make sure: rm -r * /mnt/folder1 This deletes folder1 and all files and folders in the directory that I am actually in?
-3
votes
1answer
73 views

Understanding the windows equivalent of braces [closed]

I am following a manual written for ubuntu, however I am in a windows environment. I understand the rm -rfv, but I have no idea what the braces do in the line below, I want to run the equivalent in ...
0
votes
0answers
581 views

rm no such file or directory terminal

I have tried --force, it doesn't work. When I put in sudo rm -d /someplace/wanttodelete it says: rm: cannot remove '/someplace/wanttodelete': No such file or directory There is a directory, I can cd ...
0
votes
1answer
57 views

Repair root following “rm -r ~” error

I was running a terminal as root and following installing a package noticed I had created a new directory in error. I used rm -r and began typing the directory when my cat jumped up onto my desk. I ...
0
votes
0answers
641 views

How to find, change attr -i and delete files

I need a command to find, chattr -i and rm -rf (delete) files I have a long list of files which I'm trying to delete using sudo find / | grep nginx | sudo xargs rm -rf and getting the following error:...
0
votes
0answers
74 views

I can't install software manager after `rm -rf`

I ran the rm -rf command, and deleted some of my directories and my software manager by error. Now when I am trying to install the software manager again, I face an error code 1: Below is the content: ...
0
votes
1answer
225 views

Cannot remove “empty directories” from my external hard drive after rsync fail

It seems like I have 4 empty directories on my external hard drive (NTFS). But I can't remove them with nautilus or a terminal. I think this happened just after my attempt to synchronize 2 directories ...
6
votes
2answers
1k views

Accidentally copied files to wrong directory

Years ago I copied all the files from /usr/local/bin into /bin. Now my /bin directory is littered with unneeded files. How do I remove them using the find command without having to install third party ...
2
votes
2answers
246 views

Accidentally moved `/tmp` - replacements won't persist

I did sudo mv /tmp /var/lib/apt/lists not realizing that it would move the whole folder and not just the contents. I since do (as suggested in Accidentally deleted tmp folder) sudo mkdir -m 1777 /tmp ...
0
votes
1answer
74 views

What happens with /media if you run “rm -rf /”?

rm -rf / rm -rf /* rm -rf --no-preserve-root / We know those commands will delete all possible files in /, but what would happen to the files of the disks mounted on /media? Likewise, what would ...
3
votes
1answer
199 views

How to delete only archives with a script

I would like to remove all of the archives (.tar, .zip, etc) on my system. I know how to delete files using rm but I'm wondering if there is a command just for deleting the archives on my system (and ...
1
vote
1answer
41 views

Finding directories inside a folder and deleting folder + parent if subdirectory is smaller than a certain size?

I use gmusic to order and organise my folder structure. However this means I am left with some folders that do not have any files other then normally, a image cover. I would like to sort through all ...
1
vote
0answers
65 views

Order of File Deletion in Bash

I'm surprised that I was not able to find this question posted already, but is there an definitive order in which files are deleted when using rm -r? For context, I accidentally began deleting a large ...
1
vote
0answers
85 views

how to automatically delete the folders of more than one day in the crontab

I would like to delete all of the directories that are more than one day old, knowing that these directories can be empty or not. this command must be executed from the crontab every day. I tried ...
1
vote
1answer
2k views

How can I delete a corrupted directory? (`rm: cannot remove 'directory': Bad message`)

I am in a mounted VeraCrypt volume and have a corrupted directory that I wish to delete. When I attempt to rm the directory, I get a message like the following: rm: cannot remove 'directory': Bad ...
1
vote
1answer
748 views

rm: cannot remove '0': Operation not permitted

Issue Impossible to remove folder as root. root@local:/home/hosek/app/firefox.bak/updates# ls -la total 12 drwxr-xr-x 3 hosek hosek 4096 pro 9 14:55 . drwxr-xr-x 3 hosek hosek 4096 pro 10 11:06 .. ...
4
votes
2answers
1k views

How to remove all files without deleting the directory? [duplicate]

I have a sample dir as follows: /path/to/dir/ - f1.txt - f2.txt - f3.txt I want to clear or remove all the files under /path/to/dir without actually deleting the directory /path/to/dir itself. How ...
0
votes
2answers
639 views

glob expansion suddenly not working properly in loops

I am trying to run: for i in *; do sudo rm $i; done The problem is that there is something wrong with glob expansion and I get the error: rm: cannot remove '*': No such file or directory I get ...
4
votes
1answer
175 views

Remove folder if it has another folder with the same started numbers

I have some folders that have been created in error. I would like remove these folders. ¬ 636 ¬ 636.empty ¬ 637 ¬ 638.empty ¬ 639 ¬ 639.empty In this situation I would like to remove 636.empty and ...
1
vote
2answers
162 views

Invisible space when trying to remove file (but exclude all files in a list)?

I'm trying to accomplish a simple task using the excellent post here: I would like to remove all files from a folder except those listed in a .txt file contained in the folder. The syntax works fine, ...
5
votes
2answers
2k views

how would i use rm to delete all files without certain wildcard? [duplicate]

using rm *text* you can delete all files which have a certain string in them. How would I make it so that it removes every file except for the ones with the specific wildcard? I have attempted to use ...
0
votes
2answers
170 views

Which file has basic commands features such as rm, cd etc.? [duplicate]

I am having problem to find a file has basic commands like rm, ls, cd, etc. I need the file path in Ubuntu to edit them. I checked on web but just found UNIX file locations (/usr/bin). So, here it is ...
0
votes
0answers
443 views

I accidentally deleted root using sudo rm * [duplicate]

I accidentally used sudo rm * while I was in the root directory. Now, I am not able to open terminal and my computer does not shut down, only a single _ is flicking on the black screen. How can I ...
2
votes
3answers
118 views

how do delete file called \\.\pipe\FC_{6D57D5C3-9CEA-4497-BE57-9E544137A437}_1

I somehow got this file \.\pipe\FC_{6D57D5C3-9CEA-4497-BE57-9E544137A437}_1 on my home dir. Tried deleting with rm and tab completion using the following prefixes: ./\ ./\. ./\.\p but it seems to ...
2
votes
1answer
130 views

When moving a directory to another file system, and it runs out of space, are files removed?

Given /mnt/source/ and /mnt/target/ which are two different places / filesystems. mv /mnt/source/dir /mnt/target/ It runs out of space part-way (and stops) Imagining that /mnt/source/dir is full ...
6
votes
1answer
396 views

'rm' (delete) thousands of files selectively

I created a cache system in my web server which stores the HTML files of each webpage, instead of dynamic producing them. As a consequence, I have 50,000+ files within a directory in a Linux server. ...
3
votes
1answer
1k views

Deleting folder completely, but it comes back

I have this folder in Ubuntu 18.04 that I completely removed. sudo rm -rf folder_name It has been deleted, but after a while, the folder comes back, but only with the .cache directory in the folder. ...
-1
votes
2answers
1k views

What does “rm -rf” do with “/*” in it? [duplicate]

Warning: To avoid catastrophic data loss, readers should NOT run this, nor any variations on it! I would like to understand what does this command do: sudo rm -rf/*
0
votes
0answers
2k views

Cannot remove read only file system

I have some videos recorded using gopro. The videos are in the SD card. Now i want to delete them. But rm gives me this command. How do I delete them? rm: cannot remove 'GOPR0002.JPG': Read-only file ...
0
votes
2answers
29 views

when deleting multiple files or folders what do you recommend to be safe? [duplicate]

When it comes to removing files. Instead of rm some_file.txt or rm -rf some_folder we do del some_file.txt or del some_folder where you can define your bash alias for del in ~/.custom_aliases ...
1
vote
0answers
46 views

Restore Folder (rm -r disaster) [duplicate]

I've just eliminated the /Desktop/ folder through rm -r that i shouldn't. I know there is no way to restore it but I would like to know if there is some automatic back up that I can use to restore my ...
2
votes
2answers
3k views

remove software from /opt

The software installed in that folder is not shown in Ubuntu Software Center in installed section. So I cannot remove it from GUI. How can I do it with terminal? How do I get the exact name of the ...
25
votes
7answers
11k views

Why is it possible to delete the entire file system?

After committing the infamous mistake of deleting my entire file system via sudo rm -rf /*, recovering from the horrendous damage that I had done and coping with the fact that I just lost 6 years off ...
0
votes
1answer
45 views

Can I use a list of file names that I saved to file to have each file on the list copied/moved/deleted?

How can I use cp rm or mv commands to manipulate files saved to a list, for example one made like so: ls Downloads/ | grep example > example.tmp The point is to be able to view/edit the file list ...
2
votes
2answers
454 views

How to delete /dev folder that is accidentaly copied to external hdd?

I have accidentally copied the entire contents of root to my external hard drive because of using wrong syntax of cp. I have deleted the rest leaving /dev folder. Using rm results to "device busy" and ...
1
vote
0answers
31 views

Delete file with a likely name [duplicate]

I have a folder which contain .srt and .txt files inside /var/www/myvideo folder with filename like this: /var/www/myvideo/course1/module1/dasa22.en.srt /var/www/myvideo/course1/module1/dasa22.en....
1
vote
2answers
7k views

rm -rf does not work: 'Device or resource busy'

I'm using OpenVZ to create containers and it creates a folder for each container to store its files. I stopped the creation of a container before it gets completed, so it created a folder for that ...
0
votes
1answer
138 views

Bash delete file with two variable path not working

I have a bash script containing this code: path=/apps/files/ ext=*.csv rm -f $path$ext This is not working. When I set -o to echo each command I see this in the output... rm -f '*.csv' So it's ...
0
votes
2answers
719 views

delete all sub-directories recursively except several ones [duplicate]

The main_directory includes 0001 0102 0203 ... sub-directories. The sub-directories include lots of directories. I need to delete all sub-directories except several ones whose names are "abc", "bcd" ...
35
votes
10answers
7k views

Will ls always list the files that rm will remove?

Something I feel I ought to know for sure: if I ls <something>, will rm <something> remove exactly the same files that ls displayed? Are there any circumstances where rm could remove files ...
10
votes
2answers
751 views

Is quoting filenames enough security for running `xargs sudo rm -rf`?

I wrote a script that deletes all except the last two files in a folder: #!/bin/bash ls -1 --quoting-style=shell-always /path/to/some/folder \ | head -n -2 \ | xargs printf -- "'/path/to/some/...
0
votes
1answer
3k views

Unable to delete files and folders

I am trying to delete some regular files in my machine (external hard-disk). It will throw the below errors, rm: cannot remove 'Personal/Mobile': Input/output error rm: cannot remove 'Personal/...

1
2 3 4 5