Questions tagged [rm]
Questions relating to the Linux remove command (rm)
274
questions
0
votes
0
answers
26
views
Accidentally removed /var folder then turned off
I did something even dumber than this post, which accidentally removed the /var folder. I then turned off the computer. Now, I can't turn back in. When booting, it stays blocked at
/var/lib/snaps/...
0
votes
0
answers
62
views
Ubuntu 22.04 after "rm /*" symlink /bin is gone, bash complain: /bin/bash: bad interpreter
Mistakenly ran rm /* as root.
In result, it did remove all files from linux root dir, but preserved folders. (which is good news)
lrwxrwxrwx 1 root root 7 Aug 5 2020 bin -> usr/bin
...
0
votes
0
answers
87
views
I cannot rm -rf this directory Permission denied even though I have perm WSL2 ubuntu
So there is this location ~/.local/share/nvim/mason/.packages
for mason to properly install packages it apparently needs to be able to remove stuff within this folder
however my user doesn't have perm ...
1
vote
1
answer
32
views
How can I delete non-mp3 files recursively using fish shell?
The tree list is like this:
/Music
|--- folder1
|--- folder2
|--- folder3
| |---- folder3.1
| |---- folder3.2
| \---- folder3.3
|--- folder4
I had tried the command rm | ls -R | grep -v &...
14
votes
2
answers
8k
views
How do I repair Ubuntu after running the command: sudo rm /*
While I was trying to remove files from a SD card from the same directory, I ran sudo rm /* and now Ubuntu isn't working.
When I restarted I get the error: kernel panic attempted to kill init.
I'm new ...
0
votes
1
answer
142
views
Is it possible to recover a deleted directory? [duplicate]
I deleted a directory using the command rm -drf file_dev as root. Is it possible to recover this directory with its content somehow?
1
vote
1
answer
325
views
Anyway to undo overwriting file by mv or recover replaced file?
I accidentally mv a new file to an existing file and overwrote it. Is there anyway to undo mv or recover the replaced file?
0
votes
0
answers
83
views
How do you figure out what rm -rf deleted
I've accidentally executed rm -rf ~ because I failed to autocomplete a directory and it stayed with my home directory.
I was quick enough to kill the command in time, so no real damage (I think) was ...
0
votes
1
answer
47
views
Cannot delete or restore files from Trash
When I try to delete a file from Trash I get the message Error while deleting There was an error getting information about "file.txt". Timeout was reached
If I remove the file using the rm ...
1
vote
2
answers
2k
views
Cannot delete directories as sudo: Permission Denied
I am trying to remove directories with files and getting a permission denied error on Ubuntu 22.04.1.
I've changed permissions to 777 for the directory and the parent directory but I still get the ...
1
vote
2
answers
182
views
How to delete directory/file named "-f", "-r" or other in terminal [duplicate]
Just wondering how to delete directory/file named "-f", "-r" or other using terminal.
2
votes
1
answer
1k
views
Home folder contents lost: wrong use of rm?
I am using Ubuntu-Mate 20.04 and I have lost most of the contents of my home folder. I think it could be due to using wrongly the “rm” command with sudo, but not sure if it might be something else.
I ...
0
votes
1
answer
71
views
How do I get rid of these files?
I installed a program, decided I don't want to use it anymore so I got rid of it with:
sudo apt purge "target_program"
The program got uninstalled but left behind some leftover files and ...
0
votes
1
answer
47
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 ...
0
votes
1
answer
374
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 ...
0
votes
1
answer
71
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....
0
votes
0
answers
42
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 ...
3
votes
4
answers
4k
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.
0
votes
2
answers
51
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 ...
0
votes
1
answer
647
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
0
votes
1
answer
30
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 ...
0
votes
1
answer
1k
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-...
0
votes
2
answers
303
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'...
0
votes
0
answers
936
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 &...
0
votes
1
answer
350
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?
4
votes
2
answers
3k
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 ~/...
0
votes
2
answers
231
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 ...
0
votes
1
answer
3k
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 ...
-2
votes
1
answer
10k
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
1
answer
380
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
1
answer
385
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
1
answer
73
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
0
answers
909
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
0
answers
593
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
1
answer
108
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
1
answer
671
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
1
answer
170
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
0
answers
2k
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
1
answer
108
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
1
answer
397
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
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 ...
2
votes
2
answers
452
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
1
answer
184
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
1
answer
762
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
1
answer
82
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
0
answers
116
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
0
answers
276
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
2
answers
7k
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
1
answer
1k
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 ..
...
5
votes
2
answers
10k
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 ...