Questions tagged [rm]

rm is the command to remove files

Filter by
Sorted by
Tagged with
-1 votes
1 answer
51 views

sudo rm -rf /* is not working

Using an online Arch-linux emulator, I ran sudo rm -rf /* and this is what I got: root@localhost:~# sudo rm -rf /* _(blicking) And I got a lot of "rm: operation not permitted" The question ...
lk050807's user avatar
0 votes
1 answer
42 views

Delete all *mp3 files without confirmation and inside all folders /sub

I am now in the "upload" folder (centos 7) I want the files *mp3 which is inside this folder and the folders inside it without being constantly "y" Hit I use this code, but I have ...
amir salarr's user avatar
0 votes
2 answers
58 views

Is it possible to protect a directory from being deleted without it making read-only?

There are some directories that I want to have edit access to, but I don't want to accidentally rm it. I have accidentally ran rm -rf * in the wrong directories before and want to safe proof against ...
roulette01's user avatar
4 votes
4 answers
1k views

Delete all files without user permissions

I have a prompt that asks me to delete all the files in a directory that the owner (u) can't r, w, nor x, in one command. I tried this command: find data -type f ! -perm -u=rwx -exec rm -f {} \; ... ...
cow's user avatar
  • 81
0 votes
1 answer
63 views

Suggest a safe command to delete files after a script used it

I have this script where I would like to add a line that, after the concatenation, safely deletes the *.dump files, because they are big and I have no space for the concatenated files and the dump ...
Paulo Sergio Schlogl's user avatar
3 votes
3 answers
695 views

How can I remove everything except last n bytes from the file in Linux?

I've a Tomcat server where logs are stored as catalina.out. It's a pretty huge file and causes troubles a lot of times. Because of it taking too much space, other servers have to stop involunatarily. ...
achhainsan's user avatar
-4 votes
1 answer
104 views

Is there a way to know who executed a command?

we are using redhat and we would to know if there is a way to show the session id or username who executes a rm command line, recently, someone from other teams delete a .jar file and me and my team ...
Think Different's user avatar
0 votes
1 answer
99 views

Accidentally deleted /dev directory

I've accidentally performed sudo rm -fr /dev Will I suffer from data loss or any side effects? I've rebooted the system and my data seems ok, but I'm afraid there is hidden or non-obvious loss of ...
ibrahem's user avatar
  • 111
2 votes
1 answer
46 views

time difference of rm single tar file between large and small size

If I have a file data.tar and one is 1 MB in size versus one that is 10 GB in size versus one that is 10.0 TB in size (yes 10 terabytes is correct) why is there a time difference in doing a rm on ...
ron's user avatar
  • 6,132
0 votes
0 answers
241 views

can't delete folders on samba share

I am dealing with a really weird issue I can't identify the cause of. I have a samba share mounted using autofs in Rocky 9.2 with the flags -fstype=cifs,rw,nounix,file_mode=0700,dir_mode=0700,...
BumpySiren's user avatar
0 votes
1 answer
690 views

rm deleting files very slowly

I've written the below script in Bash to delete files given a specific numeric range: # *** Declare variables *** SRC="${1}" START="${2}" END="${3}" # *** Delete frame ...
Davide Correia's user avatar
0 votes
1 answer
303 views

Is it safe to remove a directory that has a mixture of symbolic links and subdirectories?

I have a directory, dir. Inside dir, there are symlinks and regular subdirectories. I want to remove dir and create a symlink for dir to point to another directory. If I simply do rm -rf dir, I ...
anonuser01's user avatar
1 vote
2 answers
159 views

rm command contradictory options -i and -f

I learned that -i option is interactive mode and -f option is force model in rm command. When I tried both options rm -if test.txt it did not ask me and just deleted it which means -f option overrode ...
user67275's user avatar
  • 223
0 votes
0 answers
192 views

Extremely slow file deletion on NFS drive

I have a linux machine (OpenSuse), and there is a mount point on a network drive (NFS). In a folder containing log files (frequently modified), the file deletions (just the rm command) is extremely ...
François Vds's user avatar
0 votes
0 answers
18 views

Is there a way to monitor the progress of removing files on Linux? [duplicate]

I have a directory with millions of files, and I'm deleting it by rm -rf diretory_with_millions_of_files. I can see the change in the usage of inode counts on the filesystem. But is there a more ...
beatak's user avatar
  • 101
1 vote
1 answer
72 views

Remove entire folder when grep find no files with a match inside the folder

I have thousands of folders with a single html file in each folder. I want to remove the entire folder if grep find no match to example.com in the html file. I know how to remove the non matching file....
xorghelpneed's user avatar
0 votes
0 answers
1k views

Can't delete folder: rm: cannot remove: Directory not empty

I'm trying to delete a folder I once created and nothing happens when you try to remove the file in the file explorer. I tried to remove the file per command line: rm -rf folder-path/ This is where i ...
Robbie Sumner's user avatar
3 votes
3 answers
1k views

How do I delete files with the same names in multiple sub-folders from the command line?

I have a folder called simulations, which contains 101 subfolders. These sub-folders are named posterior_predictive_sim_1 to posterior_predictive_sim_101. Each subfolder contains five files: seq.nex, ...
Namenlos's user avatar
  • 131
0 votes
0 answers
81 views

Delete parent folder while keeping contents

I have a structure that is as follow: parentdir/nesteddir/content/files within parentdir are hundreds of subdirectories with differnet names (I am just using an example of 'nesteddir' I will cd into ...
linuxuser24569's user avatar
3 votes
3 answers
230 views

Find files and delete x from total of the list

I want to delete all log files in some directory, but not the latest 3. I've done: DATA_PATH=$(gadmin config get System.DataRoot) ZK_PATH=${DATA_PATH}/zk/version-2 log_count=$(ls -ltrh ${ZK_PATH} | ...
Yudha Restu's user avatar
0 votes
0 answers
60 views

Why does removing a directory first remove its subdirectories recursively?

Why must deleting dir1, which contains dir2, which in turn contains dir3, be a "recursive" operation and not just "simple" (destroying dir1 as-is, regardless of its contents)?
hamza's user avatar
  • 1
1 vote
2 answers
68 views

How to remove similar folder from multiple locations in terminal

I have a folder 'reg_standard' nested within 68 different folders that I want to remove. The path to this folder looks something like: /Volumes/.../sub-???/run_?.feat/reg_standard where '?' is a ...
user556056's user avatar
1 vote
1 answer
358 views

Unable to delete root-owned file under /tmp

The file and folder are owned by root but I did sudo chmod ugo+rw on both, which I confirmed with ls -l. Still, I cannot remove the file as normal user. ❯ ls -ld /tmp /tmp/perm drwxrwxrwt 46 root root ...
xeruf's user avatar
  • 531
0 votes
0 answers
27 views

Trashed files still remain in .Trash/1000/files after trash-empty

I use trash-cli to put files on trashcan from command-line. According to the documentation the command trash-empty remove definitly all files from the trashcan. So, I did it, but I find the files ...
fauve's user avatar
  • 1,150
0 votes
2 answers
83 views

Control the way git prints file names so that they can be passed to rm?

When I print a file from git using the command, there are edge cases: git diff --no-renames --name-only Edge case 1: spaces (added --diff-filter=D for illustrative purposes) # format 1: unquoted $: ...
Chris's user avatar
  • 961
0 votes
0 answers
196 views

how to kill java process forcefully and remove directory which is used by that process

I have one use case where I am killing a java process with pkill java, and after that, I want to remove certain directories. I have used rm -rf /pathtofolder but it gives: rm: cannot remove '/...
Samurai's user avatar
  • 55
1 vote
1 answer
179 views

Does rm -rf /mnt/ delete files in subfolders if you do not have write access to /mnt/?

I accidentally ended up with rm -rf some-text-folder-I-had-already-deleted-previously.txt /mnt/ because of arrow up into bash history. My screen flashed with lots of subfolders that I actually do have ...
jmkane's user avatar
  • 111
1 vote
3 answers
175 views

Removing directories with spaces in their directory paths

I'm on macOS. I have many directories at paths that looks like this: ./FirstName SecondName/A Multi Word Title/Contents/Index/files I want to remove ALL the Index directories and their contents. I ...
rbpeirce's user avatar
1 vote
0 answers
134 views

What's the current status of the "sudo rm -rf /" UEFI-bricking bug?

There used to be a bug several years ago where rm -rf'ing your system, due to mounted efivars, actually bricked the motherboard due to shoddy uefi boards. What's the modern day status of that? Is that ...
Daffy's user avatar
  • 395
2 votes
1 answer
1k views

Error while removing file (Function not implemented)

I get the following error trying to remove a file: $ rm 22621.525.220925-0207.ni_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso ...
Matr1x-101's user avatar
10 votes
4 answers
2k views

In Bash, how can I rm files against a wildcard while supplying more than one exception?

I have the following list of files: main.acn main.acr main.alg main.aux main.glg main.glo main.gls main.ist main.lof main.log main.lot main.nlo main.out main.pdf main.tex main.toc I want to rm all ...
Sudoh's user avatar
  • 257
1 vote
1 answer
132 views

very strange dir/file, what is?

Today on backup rsync give me an error about a dir($HOME.cache/doc/by-app) I have checked it and I see this First I go to the dir cd $HOME.cache/doc$ cd by-app/ I do ls and.. ls /bin/ls: error while ...
elbarna's user avatar
  • 12.4k
-2 votes
2 answers
5k views

How to make "yes" the default of rm -i

I want to review a long list of files from being deleted, they are not very important so there is no problem if I accidentally delete some of them, but still I want to save some. How can I call rm -i ....
cabo's user avatar
  • 13
6 votes
3 answers
614 views

Delete huge directory that causes all commands to hang

How do I delete this large directory? stat session/ File: ‘session/’ Size: 321540096 Blocks: 628040 IO Block: 4096 directory Device: 903h/2307d Inode: 11149319 Links: 2 Access: ...
Bojan Hrnkas's user avatar
2 votes
0 answers
70 views

Why does `rm writeprotectedfile <<< ""` delete the file?

The default behaviour of the GNU rm command when asked to delete write-protected files is to interactively ask whether the user wants to delete each of the files. This is quite inconvenient in many ...
leftaroundabout's user avatar
0 votes
4 answers
186 views

`find` removed top-level directory as well as contents

I ran /bin/find /home/user/myfiles \! -name '.htaccess' -exec rm -r {} \; and it removed everything in myfiles and the myfiles directory itself if .htaccess doesn't exist. What I was expecting is ...
Mark Lane's user avatar
0 votes
0 answers
48 views

What is the correct way of moving home?

I am trying to move /home onto a dedicated partition. What I already did: created the partition created a filesystem mounted the partition into a temporary folder rsynched all files into the ...
flood's user avatar
  • 288
0 votes
1 answer
231 views

how to remove file 0= file which has srw permission

How can I remove below file? srwxrwxrwx 1 patroh root 0 Aug 8 16:11 0= The user patroh is myself. The rm command won't work - it doesn't give any error when I execute rm 0. I am not sure ...
Rocky's user avatar
  • 3
0 votes
2 answers
398 views

Will `rm -rf` continue deleting if it can't delete something in the middle?

Consider a dir garbage containing many files and directories. If I run rm -rf garbage, but some files or directories within garbage are busy by the OS/NFS/etc., so rm -rf will fail for them. Will it ...
Serge Rogatch's user avatar
1 vote
2 answers
294 views

How can I delete a directory called ";"(semicolon)? [duplicate]

On a shared machine somehow a directory ; (with a lot of stuff in it) was created. I only have shell access to this machine and so I can't use any GUI File explorer to delete that file. rm -rf ; ...
h0ch5tr4355's user avatar
-2 votes
2 answers
322 views

find + how to delete files that exists only on specific folder [closed]

to delete files on under folder we can use the following approach with find find /home -type f -delete but how to delete recursive only the files that exists under temp folder ? lets say we have the ...
yael's user avatar
  • 12.8k
2 votes
1 answer
819 views

Delete files with a particular string in the filename but not other strings

I have some directories with a very large number of files in them. I am looking to prune these directories by deleting files that have a particular string in them but don't have certain other strings ...
TimR75's user avatar
  • 133
0 votes
0 answers
40 views

Simple way to delete files absolutely [duplicate]

I want to actually delete files in linux, as opposed to just erasing the representation of a file, with the command rm, for example, actually deleting the file literally, and as a basic good security ...
Guest_name's user avatar
16 votes
4 answers
3k views

Delete a file called '.env'$'\r'

I have no idea what created this file - I guess a terrible shell script. It is called '.env'$'\r' I have tried various versions of rm, and the technique of opening the direcory with vim ./, selecting ...
DefenestrationDay's user avatar
0 votes
2 answers
433 views

Erasing the boot disk on an external hard drive

I recently had my original computer stolen so I bought a second hand one and created a boot disk for Bullseye using dd in a linux VM on the original windows OS. This worked perfectly fine and bullseye ...
Adam Ledger's user avatar
0 votes
3 answers
127 views

How to display a prompt and prevent execution against basic but dangerous commands like mv or rm

Objective Whenever I use mv (or commands of similar nature) I want my shell to prompt me something like "Hey, you used mv. Sorry but do it again using mv -i". I'd like to know the reasonable ...
dungarian's user avatar
  • 415
0 votes
1 answer
163 views

Deleting Files in a Directory that contain a single quote (') character

I Have files as such: "contrail's", hello , "larch's"...etc How could I delete files that contain a single quote (') character(ex: "kibosh's" ). I was thinking in using ...
Mike's user avatar
  • 53
1 vote
0 answers
423 views

Recovering deleted directory with rm -rf /* (no sudo)

I am (was) running a Minecraft server in my second computer (Debian). I was deleting some files in the server and i did rm -rf /* instead of rm -rf *, which deleted everything that did not require ...
Eloy Miguelez's user avatar
4 votes
2 answers
2k views

why rmdir can work well when delete cgroup directory but rm -rf can not?

Here is a cgroup tree. Root node is demo and it has only one child demo/ ├── cgroup.clone_children ├── cgroup.procs ├── cgroup.sane_behavior ├── child │   ├── cgroup.clone_children │   ├── cgroup....
Kramer Li's user avatar
19 votes
2 answers
2k views

I've copied a directory with `cp -as` and now I'm terrified to `rm -rf` the created directory as it might delete the original

I've copied a directory with cp -as /media/user/dir symlinks and now I'm terrified to rm -rf symlinks as it might delete files in /media/user/dir What is the safe way to only delete the directory ...
effbiae's user avatar
  • 309

1
2 3 4 5
17