Questions tagged [rm]

Questions relating to the Linux remove command (rm)

Filter by
Sorted by
Tagged with
6 votes
1 answer
2k views

Why can't I delete or move these files without sudo?

I had used file-roller to extract an ISO image to my Desktop earlier, but now I can not delete or move/rename those files any more "as myself", only with sudo. Changing permissions (chmod) or content ...
Byte Commander's user avatar
  • 107k
14 votes
6 answers
3k views

Remove all but every 12th file

I have a few thousand files in the format filename.12345.end . I only want to keep every 12th file, so file.00012.end, file.00024.end ... file.99996.end and delete everything else. The files may ...
Dorina's user avatar
  • 149
13 votes
3 answers
16k views

rm works on command line but not in script

When I do rm *.old.* on the command line it removes correctly, but when I do it in the following portion of my script, it does not rm all the *.old.* files. What is wrong in my bash script: for ...
Don's user avatar
  • 293
1 vote
1 answer
388 views

Cannot delete residual system files period, even after changing permissions as root user

Okay, so I'm having a weird issue where I've already done chown -R myuser:myuser folderName and chmod 777 -R folderName and upon attempting deletion of these files or the folder using rm -f, I get a ...
Nicholas Stommel's user avatar
13 votes
2 answers
2k views

Are there any disadvantages of using rm $(ls) to delete files?

I was wondering if using rm $(ls) to delete files(or rm -r $(ls) to delete directories as well) was safe? Because in all the websites, people give other ways to do this even though this command seems ...
posixKing's user avatar
  • 1,133
0 votes
1 answer
397 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 ...
dreamer1375's user avatar
16 votes
3 answers
12k 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/...
aneeshep's user avatar
  • 30.3k
5 votes
1 answer
6k views

How to prevent execution of "sudo rm -rf --no-preserve-root / " command?

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 ...
rohith's user avatar
  • 1,370
36 votes
5 answers
503k views

rm: cannot remove directory/: Permission denied

I made a directory called "shadi" and set this permission for it sinoosh@ubuntu:/home$ ls -ld shadi drwxr-xrwx 2 root root 4096 Jul 1 01:58 shadi In this situation I have "others" permissions, but ...
Sinoosh's user avatar
  • 2,031
4 votes
2 answers
4k 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.
musbach's user avatar
  • 1,445
0 votes
1 answer
91 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 ...
oscrx's user avatar
  • 1
3 votes
3 answers
1k 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.
juggernauthk108's user avatar
0 votes
1 answer
1k 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?
Kohjah Breese's user avatar
0 votes
1 answer
1k 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 ...
Anonymous Person's user avatar
7 votes
2 answers
3k 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.
kacpi2442's user avatar
5 votes
4 answers
11k 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 failure ...
Noki's user avatar
  • 932
1 vote
0 answers
112 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 ...
rainman's user avatar
  • 219
8 votes
1 answer
85k 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 ...
Duncan's user avatar
  • 1,053
4 votes
1 answer
4k 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 Would ...
SpeedCoder5's user avatar
2 votes
1 answer
271 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 ...
Ramy Farid's user avatar
0 votes
1 answer
5k views

How do I remove a MATLAB program running on Ubuntu 14.04 [duplicate]

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, ...
Moh Kha's user avatar
  • 81
6 votes
1 answer
823 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 ...
Yanick Nedderhoff's user avatar
1 vote
1 answer
2k 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 list ...
Leosar's user avatar
  • 113
3 votes
1 answer
62k 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?
Ali's user avatar
  • 536
2 votes
1 answer
2k 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 ...
mcocdawc's user avatar
  • 177
1 vote
2 answers
1k 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? ...
David's user avatar
  • 3,367
3 votes
3 answers
4k 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? ...
Hatshepsut's user avatar
0 votes
3 answers
11k 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 ...
NoWeDoR's user avatar
  • 35
0 votes
2 answers
5k 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: ...
Sun_Blood's user avatar
  • 123
35 votes
3 answers
45k 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 want to remove multiple files, e.g.: $ find . -name "*.txt" | xargs rm This will not delete ...
Ashley's user avatar
  • 497
6 votes
2 answers
24k 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 ...
Zurechtweiser's user avatar
4 votes
4 answers
6k 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 list ...
steve's user avatar
  • 331
13 votes
3 answers
51k 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: ...
Tal's user avatar
  • 394
2 votes
1 answer
112 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 ...
steve's user avatar
  • 331
2 votes
2 answers
17k 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?
It's Willem's user avatar
3 votes
3 answers
5k 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, ...
tito's user avatar
  • 33
2 votes
2 answers
385 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 '-...
whale_steward's user avatar
9 votes
2 answers
6k 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?
PAVAN KUMAR BHUKYA's user avatar
45 votes
7 answers
248k 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, when ...
DevinFrench's user avatar
1 vote
1 answer
63 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, ...
robert williams's user avatar
0 votes
2 answers
307 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’: ...
Christopher Gaspar's user avatar
93 votes
6 answers
98k 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 ...
Muye's user avatar
  • 1,033
8 votes
2 answers
63k views

how to restore data after running rm? [duplicate]

I accidently ran sudo rm * I thought I was in an unimportant subfolder. The result is that I deleted some very important files. Is there any way to get my data back?
user avatar
132 votes
2 answers
466k views

Removing files older than 7 days

I write below command to delete all files that are older than 7 days, but it doesn't work: find /media/bkfolder/ -mtime +7 -name'*.gz' -exec rm {} \; How can I remove these files?
Malihe Pakyari's user avatar
3 votes
2 answers
4k 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 /...
dot's user avatar
  • 535
2 votes
4 answers
2k views

how to remove image 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<...
Julio Sitges's user avatar
3 votes
2 answers
7k 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 ...
Brettetete's user avatar
0 votes
1 answer
827 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.
Rozane De Silva's user avatar
4 votes
1 answer
3k 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 ...
Rohith Madhavan's user avatar
4 votes
4 answers
17k 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 ...
Andrew Lynch's user avatar