Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

0
votes
1answer
10 views

what is the accurate command_line for deleting a folder in /usr/local? [duplicate]

i was unsuccessful for installing jdk8 and i want to delete the java folder in my usr/local. cd /usr/local rm java error :rm: cannot remove ‘java’: Is a directory rmdir java error :rmdir: failed to ...
12
votes
3answers
2k views

What does [co] mean in the “rm -rf filename[co]” command?

Let's say I have two files in /tmp: root@ubuntu:~# touch /tmp/hello.{pyc,py} root@ubuntu:~# ls /tmp/ hello.py hello.pyc Now, lets run rm -rf command with [co] option root@ubuntu:~# rm -rf /tmp/...
1
vote
1answer
51 views

all my previous configurations and settings are gone by using the following command in ubuntu 14.04LTS

I used the command rm -rf ~/.Trash/* to empty the trash but when the command is executed, all my files in Download folder are deleted and all my Ubuntu settings are changed. Can anyone please help, ...
3
votes
5answers
371 views

rm: cannot remove directory/: Permission denied

I made a directory , the name is "shadi" and I set this permission for it In this situation I have others permissions but why I can not delete the
5
votes
1answer
3k views

Piping find -name to xargs results in filenames with spaces not being passed to the command

Normally to remove files with spaces in their filename you would have to run: $ rm "file name" but if I wanted to remove multiple files, i.e: $ find . -name "*.txt" | xargs rm This will not ...
1
vote
1answer
88 views

How to prevent execution of “sudo rm -rf --no-preserve-root / ” command? [duplicate]

After going through this question I'm quite scared! It's not that I don't want to use sudo rm command, but I want to inhibit the execution of the sudo rm -rf --no-preserve-root / command. If this ...
3
votes
2answers
360 views

Difference between rm executable >>dev/null and rm executable

What is the difference between rm executable and rm executable >>dev/null I had the later statement in a Makefile and changed it to the first one. I had the impression that nothing changed....
0
votes
1answer
68 views

Does anyone have some suggestions for me I deleted some important files

Is there a way to recover removed files in a situation such as described below? The command I executed was: root@system:/# rm -r /tmp/letsencrypt.sh-XXXXXX l* I tried to remove all the files in ...
184
votes
6answers
224k views

How can I recursively delete all files of a specific extension in the current directory?

How do I safely delete all files with a specific extension (e.g. .bak) from current directory and all subfolders using one command-line? Simply, I'm afraid to use rm since I used it wrong once and now ...
0
votes
1answer
1k views

Duplicate /media directory entries

I installed Ubuntu 64-bit 12.04 over Ubuntu 32-bit 32-bit on the same partitions. In my /media directory I have what appear to be duplicate entries. I had found a similar issue on an Ubuntu discussion ...
3
votes
3answers
67 views

how do i make shell ask for confimation for rm -rf command (even sudo)?

I want to make the command shell to prompt me for confirmation before execution of certain commands like dd , rm -rf etc.
0
votes
0answers
17 views

Removing the folder $Windows.BT

In my dual-boot system I have Windows 8.1 installed (next to Ubuntu 14.04.1). Now I want to remove the folder $Windows.BT in my Windows system (due to being too large, and I do not want to update to ...
0
votes
1answer
32 views

Deleted 16GB MySQL log file, no space freed

I deleted a 16GB MYSQL log file via the command line: sudo rm /var/log/mysql/slow.log but the space has not been freed. Is there some sort of flush I need to run?
0
votes
1answer
76 views

Accidentally deleted EVERYTHING in /usr/local

I performed sudo rm -rf newfolder, when I was in /usr/local/ directory. It has deleted everything inside that folder! I only wanted to delete newfolder inside that directory. How can I restore what ...
16
votes
6answers
11k views

Is there any faster way to remove a directory than “rm -rf”?

I have a folder that has many files and "rm -rf" takes a lot of time to complete. Is there any faster way to remove a directory and it's contents (subdirs, etc)?
8
votes
2answers
2k views

I have a file named “-t”. How to remove it? [duplicate]

Output of "ls -l": -rw-r--r-- 1 root root 0 Mar 4 08:22 -t When i try to do "rm '-t'": rm: invalid option -- 't' Try 'rm ./-t' to remove the file '-t'. Try 'rm --help' for more information.
1
vote
3answers
99 views

Can't delete a file with a '?' in the file name

Can't delete a file with a '?' in the file name, it fails to delete with the message 'the file does not exist'. I've tried through the terminal using rm -f ./pathtofile\?.mkv But despite no ...
2
votes
4answers
3k views

how to remove files in a list of paths easily?

I have a list of lines like /usr/lib/i386-linux-gnu/libavfilter.so /usr/lib/i386-linux-gnu/libavfilter.so.3 /usr/lib/i386-linux-gnu/libavfilter.so.3.42.103 /usr/lib/i386-linux-gnu/i686/cmov/...
35
votes
5answers
285k views

How do I remove a folder?

I'm a new user and Im trying to remove a specific folder. I am using sudo rm /path/ but its not working. What is the correct command to use? It is a file catolog I am attempting to remove but im ...
9
votes
4answers
14k views

How can I make rm stop asking me for permission?

On my server rm always asks me for permission (even though I'm root) when I run it, on my desktop it does not. Like so: $ rm mod_wsgi-3.3.tar.gz rm: remove regular file `mod_wsgi-3.3.tar.gz'? How ...
35
votes
5answers
70k views

Can files/directories deleted with rm be restored?

Is it possible to restore files/directories which are deleted from terminal using rm and rm -r?. If a file is deleted from graphical interface, it could be restored from trash, but how do you restore ...
1
vote
0answers
51 views

How can i remove home directory from download directory without deleting it

In my Downloads folder when I make ls I see the home directory, and I don't know why, I want to remove it but I am afraid to remove my home folder. Can anyone tell me how I can just remove the home ...
3
votes
2answers
7k views

how to download “rtsp” flow

I could download a conference from this link (rtsp://real2.infn.it/webcast/2012-esploratori-invisibile/esploratori-dell-invisibile.rm). How can I do it? Thank you previuosly..
3
votes
1answer
507 views

How do I delete / remove a file

I am a beginner with Linux / Ubuntu, and I'm trying to remove / delete a file. The specific is a wallet I created in Electrum to import a paper wallet; I can see the wallet in the file list but can't ...
1
vote
1answer
81 views

Given rm why does rmdir exist?

Is there any resultant difference on disk between using rm or rmdir to remove a directory? Or is it only different by usage preference, By example, given $ mkdir a $ mkdir a/b $ mkdir a/b/c ...
69
votes
9answers
316k views

How to remove all files from a directory?

The closest I've gotten is # rm /path/to/directory/*.* but that doesn't work for files that don't have an extension...
0
votes
1answer
1k views

How do I remove a MATLAB program running on Ubuntu 14.04

I have installed MATLAB 2012 on Ubuntu 14.04, and I want to uninstall it. According to the support instructions, I should type in a command as rm -rf matlabroot. Howeever, this does not help. In fact, ...
4
votes
0answers
131 views

Not allowed to delete a encfs-encrypted empty folder

I have an encfs-encrypted folder and just cut the content of a subfolder of it and pasted it into another folder outside the encfs-encrypted one. While doing that, I got an error message, saying that ...
1
vote
1answer
58 views

dpkg is confused since I manually removed installation files for spotify with sudo rm recursive

So I was reading to learn on how packages and package installation works in Ubuntu in general and where do the files responsible for the existence of any application (installation files) reside in my ...
0
votes
0answers
66 views

script bash to move file with multiple extension

#!/bin/bash # #Directory MOVETO=/DRIVE/new2/ SOURCE=/DRIVE/picture/ #files to find MOVEFILES=("*.m4v" "*.avi" "*.art" "*.3gp" "*.mpeg") find "$SOURCE" -iname "${MOVEFILES}" -type f -exec mv -v -...
1
vote
2answers
94 views

Can rm -rf use grep?

I am trying to use PlayOnLinux to install iTunes but my wine is clogged up, so I want to 100% delete the wine files, so is there any way to delete all files with the tag (or word) wine in them? ...
1
vote
1answer
42 views

How to delete all files that contains “ (2)” wildcards dont work

I would like to delete all files that contains " (2)" --whitout the quotes-- in the file names. I tried first with ls to test ls *(2)* and list all the files in the folder ls "*(2)*" don't ...
2
votes
4answers
3k views

How to delete all the files/folders from the folder except few folders?

Assume that I have a directory structure as follows: application │ ├── config │ ├── c1.conf │ └── c2.conf │ ├── logs │ ├── l1.txt │ └── l2.txt │ └── src ├── static ├── s1.py └── ...
0
votes
1answer
2k views

Restore Direcory/files after rm -rf [duplicate]

I've accidentally deleted a project directory from my Ubuntu with rm -rf. is it possible to restore them somehow?
2
votes
1answer
114 views

Remove except some files/directories in a script; need revision

I have the same problem as this question How to delete all the files/folders from the folder except few folders? several times. This is the reason why I wanted to write myself a script for a command ...
0
votes
1answer
115 views

trash: cannot trash regular file

I'm trying to avoid using rm so I don't delete anything permanently. I'm using the utility function trash, but it keeps telling me trash: cannot trash regular file. Why can't I delete these files? ...
-1
votes
4answers
700 views

How to remove a file from usr/share/applications on ubuntu 14.04

I have examined this page (How to remove single file from /usr directory?) and tried sudo rm /usr/share/applications/Eclipse Mars C/C++.desktop in the terminal, but it didn't work. I think the ...
0
votes
1answer
270 views

“rm: not found” by apt, cron and others

For some reason I get this error all the time in system scripts: rm: not found For example I wanted to update the system: Setting up install-info (5.2.0.dfsg.1-6) ... /usr/sbin/update-info-dir: 52:...
0
votes
0answers
17 views

Millions of files automatically created inside home/rPns20HPyX folder [duplicate]

In my HOME folder, a folder named rPns20HPyX was automatically created. Inside that millions of files are accumulated. 1. What is going wrong, how these files are created ? Below are some screen-...
0
votes
0answers
178 views

rm -rf command can't delete a file. Ubuntu 14.04.03

I was trying to copy some files and I saw that I had already backed up the data, so I pressed Ctrl+C to stop the process. When trying to remove the backed up files, I was not able to delete the folder ...
2
votes
2answers
506 views

Only delete files but not folders with rm

I have a directory like this: <folder1> <folder2> <folder3> file1 file2 file3 What is the rm command like that removes only file1, file2, file3 but leaves folder1, folder2 and ...
2
votes
4answers
354 views

Delete a list of directories stored in a file

I have a list of directories names in the following path /home/list/list.txt The directories are all in the following path /home/directory/ How can I delete the directories contained in the ...
6
votes
3answers
27k views

Syntax error near unexpected token `('

When I use below code in Ubuntu terminal, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run the shell script from terminal, it throws an error: ...
9
votes
3answers
5k views

How to find the pid of the process which has deleted a file?

I am working on a project related to VM migration. Sometimes the VM image will disappear and I just want to know who the culprit is. I tried strace on suspicious processes but to no avail.
2
votes
1answer
39 views

Remove list of files from different subfolders

I have a folder (call "folder"), composed of different subfolders ("subfolder1", "subfolder2",...). I would like to remove a list of files in all the subfolder of "folder", while some files are ...
0
votes
2answers
64 views

How to make a script delete a directory after checking for its existence?

How might one make a bash script which when run will check for the existence of a file/folder and if the file/folder is there remove it?
1
vote
3answers
181 views

remove pictures from folder

I want to remove all the photos from a folder and keep the remaining files. I searched in the web and I found a tons of solutions like: find . -type f -name "*.jpg" -delete All the photos are jpeg,...
0
votes
1answer
109 views

I removed /usr/lib/xorg by mistake, copying it from the live cd is enough?

The story(because it's kind of a funny fail): I have a remote target(ARM board) and I was testing one of my scripts that recreates the folder structure of my target but with local debug libraries for ...
2
votes
2answers
39 views

remove file with -h_some_file_name in shell [duplicate]

I have a problem when trying removing a file with name something like -h_some_file_name, this is because of generated script that I made and forget to check the prefix. If I run the command rm '-...
6
votes
1answer
803 views

How to recover accidentally removed /bin/ls binary

I have mistakenly deleted the ls executable from the /bin folder. Can I recover it or install it through the terminal?