Questions tagged [rm]

Questions relating to the Linux remove command (rm)

Filter by
Sorted by
Tagged with
0
votes
1answer
26 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
165 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 ...
0
votes
0answers
25 views

E: No priority (or zero) specified for pin

Hi can you help me fix this error? Error: Opening the cache (E:No priority (or zero) specified for pin) Im using ubuntu 16.04 i just updated it from ver 14.04 I tried removing it using rm but i always ...
1
vote
1answer
26 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
32 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
40 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 ...
0
votes
0answers
184 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 ...
0
votes
0answers
32 views

rm -rf gives could not delete file location

I have a file on my external HDD that was created during a failed copy. The jpeg file is getting opened in a viewer and on the terminal also it is showing the date and size. The permissions on the ...
1
vote
1answer
76 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
312 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
197 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
135 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
140 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
1k 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
129 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
113 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 ...
0
votes
0answers
51 views

Deleted folders with lock icon reaper

I've tried several things, and they keep coming back to the Desktop folder, for example: sudo rm -r -f /path/ deletes it, I check with ls and see it disappear in the Desktop folder, however when I ...
2
votes
1answer
83 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
334 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. ...
0
votes
0answers
205 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
567 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
1k 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
27 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
45 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
1k 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 ...
24
votes
7answers
9k 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
44 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
207 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
28 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
5k 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
94 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
197 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" ...
34
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
582 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
2k 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
vote
2answers
320 views

Delete directory

Sometimes I want to bang my head when it concerns understanding file permissions. I want to delete a dir called Test_Dir. andy is the owner. andy is in group. No files in directory have immutable ...
7
votes
3answers
5k views

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

Given: I have a tree structure with folders EmptyMe on different levels EmptyMe directories contain sub-directories and files Required: Empty contents of EmptyMe directories (including their sub-...
6
votes
2answers
986 views

How do I delete files of certain extension that don't have a given string in their filename?

I have a directory with files of many extensions in it. I would like to recursively delete *.srt files (and *.srt files only) which don't end with -en.srt (where srt is an extension). I've come up ...
0
votes
0answers
67 views

Automate Deletion of File from terminal

I want to write a Python script that will automate my commands without waiting for user input. My python script will delete the least played video. When I execute the command: rm video_123.mp4 it ...
0
votes
2answers
54 views

Delete 3 oldest files based on filename

I want to delete the 3 oldest files based on their filename. Here is an example of what is in my backup directory. There will be multiple copies with different times. Ubuntu_Scripts.zip_2018-08-09-...
-1
votes
1answer
66 views

Recovering the relative path option

Managed to delete the relative path option in linux by typing in rm .*, now I can't change or add files to any directory. How can these be recovered? Running a ls -a and the standard . and .. ...
3
votes
1answer
887 views

Is it possible to exclude some files from rm -rf? [duplicate]

I have a directory that I is filled by another user, and I'm tasked with maintaining it. I want to delete all its content except a 2 files with a specific name. Is it possible with rm or should I do ...
1
vote
1answer
4k views

Cannot delete .git directory

I try to run sudo rm -rf .git/ but the terminal return the following message: rm: cannot remove ‘.git/objects/pack/pack-3818f69fa7bd64ef22c94c0bf630c18333cd5da9.idx’: Operation not permitted rm: ...
3
votes
2answers
10k views

Deleting many files results in “argument list too long” [duplicate]

I have 280 thousand photos to delete in a folder, but some videos to keep. In the folder, I gave the command: #rm *.jpg, but I get "argument list too long". When I create an argument to delete some of ...
-3
votes
1answer
149 views

how to re-create the .Trash file in ubuntu server

I recently deleted the .Trash file in Ubuntu server using the command alias rm="mv -t ~/.Trash" and now I am unable to delete any file using rm command, and when I use it I get: mv: accessing `/...
5
votes
1answer
61 views

How to remove bad entry in home directory

My home directory looks like this: # ls -lt total 417656 drwxrwxr-x 2 ljohnson ljohnson 427577344 May 9 08:48 2z9TnVLzmf drwxr-xr-x 4 ljohnson ljohnson 4096 May 9 07:42 transmission drwxr-xr-x ...
2
votes
1answer
1k views

Folder recovery with rm command

I deleted /bin folder from computer in Ubuntu with rm command. How can recover it ?
1
vote
1answer
4k views

How to remove only files created before a specific date and time

l would like to remove from my directory files which have been created before 04/29/2018 at 4:00 pm. Thank you
6
votes
2answers
12k views

How do I set Cron to send emails?

I have the following cron job command running once daily on my NAS device: find /nfs/rpiggott/complete -mtime +45 -exec rm {} \; I am wondering if there is a way to pipe a list that will result in ...

1
2 3 4 5