Skip to main content

Questions tagged [rm]

rm is the command to remove files

Filter by
Sorted by
Tagged with
1 vote
2 answers
59 views

rm on symlinks works different on Mac

The following commands behaves different between Linux and Mac: mkdir tmp ln -s tmp symlink rm -rf symlink/ On Linux, the content of tmp folder is deleted but the folder itself remains, while on Mac ...
Andrés Esguerra's user avatar
0 votes
1 answer
70 views

How to delete a directory whose name has special characters

My ./imap directory contains two folders with names containing special characters : ‘No’$‘\351’‘.sbd’ ‘S’$‘\351’‘gol’$‘\350’‘ne.sbd’ (these are the full names with no other characters added). The ...
Josef's user avatar
  • 1
1 vote
1 answer
54 views

Remove all files, but write protected [duplicate]

In the folder there are files with write permission and without it. I need to remove only files which have write permission. When I simply do rm * it prompts confirmation for every write-protected ...
Alex Anushat's user avatar
1 vote
2 answers
65 views

Removing a file does not increase available space?

OS is Debian. Output of df -h /: Filesystem Size Used Avail Use% Mounted on /dev/sda3 99G 97G 0 100% / lsof shows /var/log/syslog file handle is open, but nothing related to /var/log/...
cat pants's user avatar
  • 487
0 votes
0 answers
91 views

Ubuntu - trying to delete a file that has no inode

I try to delete a file that is left in a directory, but even an ls -i will not give me an inode to remove it. Deleting/removing the directory won't work even with the inode. $ ls -ila ls: cannot ...
merkc's user avatar
  • 1
0 votes
1 answer
91 views

How can I recover moved jpg files

On my ubuntu system I ran a command and moved all my jpg files to a single file by mistake src_dir=$1 echo "src_dir: $src_dir" for f in $src_dir/*; do if [ -f $f ]; then new_dir=...
Daemon's user avatar
  • 103
-1 votes
1 answer
247 views

sudo rm -rf /* is not working [duplicate]

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
182 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
211 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
69 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
887 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
546 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
267 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
53 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
  • 7,162
0 votes
0 answers
614 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
1k 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
2 votes
1 answer
1k 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
991 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
  • 243
1 vote
1 answer
83 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
2k 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
4 votes
3 answers
2k 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
  • 141
3 votes
3 answers
241 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
72 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
113 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
755 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
  • 571
0 votes
2 answers
107 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
  • 983
0 votes
0 answers
244 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
270 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
383 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
2 votes
1 answer
2k 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
  • 267
1 vote
2 answers
259 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.8k
-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
4 answers
986 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
83 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
393 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
  • 328
0 votes
1 answer
311 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
535 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
377 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
573 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
  • 13.4k
2 votes
1 answer
1k 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
695 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
139 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
  • 445
0 votes
1 answer
213 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
  • 63
1 vote
0 answers
527 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
5 votes
2 answers
3k 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
  • 101

1
2 3 4 5
17