2022 Developer Survey is open! Take survey.

Questions tagged [rm]

Questions relating to the Linux remove command (rm)

Filter by
Sorted by
Tagged with
-2 votes
0 answers
22 views

accidental sudo rm -rf /* for 2 sec on a 32GB SanDisk 3.0 USB [closed]

I have just executed sudo rm -rf /* for 2 secs on my 32GB SanDisk 3.0 USB. I have Linux Mint 20.3 Una installed and I thought it would ask for sudo confirmation before executing the command but I ...
user avatar
0 votes
0 answers
23 views

How to change script for deleting files while names misses symbols?

I am trying remove files by names according this answer How to delete files listed in a text file But get following error: rm: cannot remove 'var/Resources/Images/fd29d33d.jpg'$'\r': No such file or ...
user avatar
  • 131
0 votes
1 answer
24 views

How to remove files in a directory with lots of subdirectories quickly?

I have a directory like this: my-app/ ├─ 1/ ├─ 2/ ├─ .... (a lot of subdirectories) ├─ N/ In each subdirectory, there are a LOT of PNG files, like: 1 ├─ 1.png ├─ 2.png ├─ .... ├─ 100000000.png (not ...
user avatar
0 votes
0 answers
19 views

Accidentally removed my sources.list file on Ubuntu 22.04 beta, need urgent help [duplicate]

Basically i accidentally rm -rfed my /etc/apt/sources.list I was trying to remove the wine jammy repo because it wasn't working If anyone could provide me a jammy sources.list, that would be great
user avatar
0 votes
1 answer
38 views

Undeletable "Icon" file

I have a strange problem with some files on my NAS that are not deletable, maybe remnants of some MacOS file copy. They appear with filename "Icon" in file manager but as 'Icon'$'\r' with ls....
user avatar
0 votes
0 answers
20 views

Keep bigger size image file and delete image files with smaller sizes of same name, using terminal command

Keep bigger size image file and delete image files with smaller sizes of same name, using terminal command My directory may contain a_500.jpg, a_1280.jpg BUT b_500.jpg, c_500.jpg, c_800.jpg. So, in ...
user avatar
3 votes
4 answers
3k views

What happens if we do rm -rf ../**? Can we restore the data?

I did something like: $ cd /A/B/ $ rm -rf ./* $ rm -rf ../** Due to network issues my system disconnected from Ubuntu. When I came back there were no files or folders in the /A folder.
user avatar
  • 39
0 votes
2 answers
44 views

How to delete a list of filenames without path that are matched in multiple subdirectories?

How to delete a list of filenames without path that are matched in multiple subdirectories? Delete_list.txt may contain (each filename is per line): a.jpg b.jpg c.jpg These files may exists in ...
user avatar
0 votes
1 answer
185 views

Not able to to delete file with drwx--S--- permission

We are not able to delete file because of special permission drwx--S---. I have tried command chmod g -s filenameion but we cant use root user. SO is there anyway to delete
user avatar
0 votes
1 answer
28 views

Entire system starts malfunctioning after empyting bin

So recently I wiped the trash bin folder with the sudo rm /bin command because it was getting filled up with a lot of junk that I didn't put there. Now I can't boot and get error messages. I don't get ...
user avatar
0 votes
1 answer
171 views

Why I can not remove neither folder nor its content?

Here is the folder and its content.I don't understand why I cannot remove these files and this folder. ls -ltr results in: total 16672704 -rwxrwxrwx 0 17064381527 Eyl 2 18:10 101737-31-HO-...
user avatar
0 votes
2 answers
143 views

In short i accidentally typed sudo rm /* and now my system doesnt boot as something is deleted in / [duplicate]

I am a beginner and hence did a child's mistake and now i cant enter my system and when I try to enter recovery shell it says "Kernel panic - not syncing attempted to kill init?" and i didn'...
user avatar
0 votes
0 answers
93 views

I accidentally removed everything from my base directory. Is there any way to recover these?

After opening terminal I typed sudo rm -rf * lampp from my base directory srj@srj. So now I have lost everything in my Desktop and Downloads folder. Can it be recovered in any way. I was trying to ...
user avatar
0 votes
0 answers
544 views

How to delete this WindowsApps folder (permission denied with rm even with sudo :( )?

I used to use windows on my laptop and then moved ubuntu. While I was using windows, I once moved microsoft store apps to a different partition to save space in C drive and I guess it was saved in &...
user avatar
0 votes
1 answer
69 views

How to delete a file named -something with rm [duplicate]

When I have a file named -19-5-20674., how can I delete that file? When I use sudo rm: $ sudo rm -19-5-20674. rm: invalid option -- '1' Try 'rm --help' for more information. What can I do?
user avatar
4 votes
2 answers
1k views

Protect folder from accidental deletion with `rm`

I have some folder ~/foo which I'd like to protect from accidental deletion, that is I'd like to protect it from deleting with rm -r ~/foo or rmdir ~/foo. I realized you can do that using chmod a-w ~/...
user avatar
  • 343
0 votes
2 answers
72 views

Safely remove directory with unknown contents

I have a directory /usr/local/foo, which I need to remove. This is going to be part of a script, which needs to be run as root. I'm mainly worried that the directory, which contains things that users ...
user avatar
  • 65
0 votes
1 answer
1k 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 ...
user avatar
  • 1
-2 votes
1 answer
5k 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 ...
user avatar
-5 votes
1 answer
84 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 ...
user avatar
  • 13
0 votes
1 answer
343 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 &...
user avatar
0 votes
1 answer
35 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 ...
user avatar
4 votes
0 answers
574 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 ...
user avatar
1 vote
0 answers
267 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 {...
user avatar
0 votes
1 answer
56 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?
user avatar
  • 1
0 votes
1 answer
321 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?
user avatar
-3 votes
1 answer
122 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 ...
user avatar
0 votes
0 answers
1k 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 ...
user avatar
0 votes
1 answer
69 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 ...
user avatar
0 votes
1 answer
317 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 ...
user avatar
  • 143
6 votes
2 answers
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 ...
user avatar
2 votes
2 answers
369 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 ...
user avatar
  • 677
0 votes
1 answer
140 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 ...
user avatar
3 votes
1 answer
505 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 ...
user avatar
1 vote
1 answer
55 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 ...
user avatar
1 vote
0 answers
103 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 ...
user avatar
1 vote
0 answers
174 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 ...
user avatar
1 vote
2 answers
4k 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 ...
user avatar
1 vote
1 answer
960 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 .. ...
user avatar
  • 768
4 votes
2 answers
5k 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 ...
user avatar
1 vote
2 answers
1k 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 ...
user avatar
  • 38.1k
4 votes
1 answer
292 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 ...
user avatar
1 vote
2 answers
252 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, ...
user avatar
  • 111
5 votes
2 answers
3k 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 ...
user avatar
  • 53
0 votes
2 answers
203 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 ...
user avatar
0 votes
0 answers
447 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 ...
user avatar
2 votes
3 answers
129 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 ...
user avatar
2 votes
1 answer
257 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 ...
user avatar
6 votes
1 answer
535 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. ...
user avatar
  • 203
4 votes
1 answer
2k 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. ...
user avatar

1
2 3 4 5 6