Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

10
votes
2answers
1k 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
86 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
5answers
364 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
3
votes
2answers
359 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
67 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 ...
0
votes
0answers
15 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 ...
3
votes
3answers
65 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
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
74 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 ...
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
96 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 ...
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
1answer
502 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
80 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 ...
1
vote
1answer
57 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
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, ...
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 -...
4
votes
0answers
129 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
41 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 ...
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
110 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 ...
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? ...
0
votes
1answer
114 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
688 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
267 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
174 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 ...
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 ...
2
votes
2answers
484 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: ...
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
178 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
106 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
38 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
797 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?
8
votes
4answers
15k views

“No such file or directory” when trying to remove a file, but the file exists?

I am trying to remove a png image that was uploaded to my server via a PHP script. Whenever I try to delete it both through ftp and terminal, I get the error No such file or directory However, ...
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, ...
0
votes
2answers
40 views

I just want to remove the file from directory

I am trying to remove a file with: ubuntu64@ubuntu:/usr/local/mongodb$ rm /usr/local/mongodb/* But every time it just outputs: rm: cannot remove ‘/usr/local/mongodb/mongodb-linix-x86_64-2.6.4’: ...
66
votes
6answers
22k views

How is 'rm -rf /' able to delete all files in the system?

I haven't tried this command on Ubuntu (for obvious reasons) so I am not sure if Ubuntu will allow its execution. But it's famous for deleting everything. Just out of curiosity, what happens when the ...
1
vote
1answer
4k views

how to restore data after running rm?

I accidently run sudo rm * I thought I was in an unimportant subfolder. The result is that I deleted some very important files, unfortunately. Is there any hope to get my data back ?
2
votes
1answer
272 views

Accidentally removed /var folder

I did something real dumb. I was creating tarballs of files in my /var/ folder. The tarball i created was put into /tmp/test.tar In the process of testing the extraction process, I meant to delete /...
0
votes
0answers
18 views

VLC cannot be installed , [duplicate]

I installed KDE desktop before and am not able to login to kde so , i removed it using sudo remove kde* Then there was audio not working, so i re installed drivers. it is working fine, but for some ...
1
vote
2answers
71 views

how to remove files that are smaller than certain dimensions

I have already found an answer that lists pretty much everything. Except I cannot get it to work. I use: find . -iname "*.jpg" -type f | xargs -I{} identify -format '%w %h %i' {} | awk '$1<...
2
votes
2answers
899 views

Find folders of size lesser than x and delete them

I want to find all folders (within a folder) which are less than 100mb large and delete them. I actually don't want to use a bash script. But probably there is some neat one-line-loop possibility to ...
0
votes
1answer
415 views

Can't create files on desktop in Ubuntu 14.04

I accidentally created a desktop shortcut in my home directory. To remove it, I did sudo rm -rf Desktop Now I can't create files and folders on my desktop.
4
votes
1answer
837 views

Difference between commands for removing empty directories

What is the difference between rm --dir <directory> and rmdir <directory> with respect to removing empty directories? Also, if they are similar, is there any advantage of having an rmdir ...
1
vote
4answers
3k views

Undo sudo rm -R /*

I stupidly ran sudo rm /* followed by sudo rm -R /* My sites still run, although the vast majority of commands like ls are now broken. Is there a simple way to get data off the server or reverse ...
1
vote
1answer
522 views

Can a directory's mtime be older than that of file inside?

I have this very silly and very basic question but I thought better to ask before I start pruning my NAS. I want to delete all directories in which all files are older than 30 days. For files I ...