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

1

The expression .* is expanded by bash to include the current and parent directories:

$ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep 10 15:34 .. -rw-r--r-- 1 terdon terdon 0 Sep 10 16:22 foo $ echo .* . ..

If I run rm -rf .* on my Debian using GNU bash, version 4.2.36(1)-release and rm from rm (GNU coreutils) 8.13, I get this message:

$ rm -rf .* rm: cannot remove directory: `.' rm: cannot remove directory: `..'

Is this a GNU thing or is it POSIX? Are there any *nix systems where the command above will silently delete . and ..?

Also, is this a safety feature of the shell or of the rm command itself?

The latest (as of 2017) version of the POSIX spec for the rm utility is here (and the previous one there) and forbids the deletion of . and ...

If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an...

0 0
2

Using Linux rm command on the bash shell command prompt to delete or remove file, hidden file, folder, hidden folder and meta character filename and folder name on Linux fedora core with example. This article show the step by step guide on delete file or delete folder on Linux system, make sure that the that you understand the rm command before you execute them.

Command description:

The Linux 'rm' command is used to remove or to delete file and directory.

Command type:

'file' disk file (external command) and alias to rm='rm -i'.

[root@fedora ~]# type -t rm

alias

[root@fedora ~]# alias

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

...

0 0
3

wikiHow's mission is to help people learn, and we really hope this article helped you. Now you are helping others, just by visiting wikiHow.

Direct Relief is a humanitarian nonprofit with a mission to improve the health and lives of people affected by poverty and emergencies. Recognized by Charity Navigator and Forbes for its efficiency, Direct Relief equips health professionals in the U.S. and throughout the world with essential medical resources to effectively treat and care for patients – without regard to politics, religion, or ability to pay.

Click below to let us know you read this article, and wikiHow will donate to Direct Relief on your behalf. Thanks for helping us achieve our mission of helping everyone learn how to do anything.


...
0 0
4

Hi!

I have a problem deleting some files of an already destroyed virtual machine. This is what I get when attempting to delete the folder:

########################

root@xxx yyy_zzz# rm -rf VM/

rm: cannot remove `VM//VM_2-flat.vmdk': Device or resource busy

rm: cannot remove `VM//VM-flat.vmdk': Device or resource busy

rm: cannot remove `VM//VM_1-flat.vmdk': Device or resource busy

rm: cannot remove `VM//VM-53afe79d.vswp': Device or resource busy

root@xxx yyy_zzz# cd VM/

root@xxx yyy_zzz# vmkfstools -U VM_1-flat.vmdk

Failed to delete virtual disk: Device or resource busy 1048585

#######################

The files are located on a LUN shared by seven ESX 3.02 Servers. What can I do to find out which process/system is locking those files? And how can I finally remove this folder?

Any help appreciated. Thanks!

Message was edited by:...

0 0
5

For expert users of Linux and other UNIX-like operating systems, the command line is where the action is. We (they) claim that stuff gets done faster and easier on the command line than pointing and clicking on a fancy graphical interface.

While that may, to a very large extend, be true, the command line can be a scary place for new users. What do you do at the command line if you do not know what command to type? That may account for why new users shy away from the command line.

Typing the wrong command can severely cripple your computer. A wrong switch or wrong option is all it takes. One command that I learned to avoid a long time ago, based on what experienced users told me, is rm -rf /. The rm command is what you use to remove or delete a file or directory. By itself, rm will delete a file. With the -r or -R option, it will recursively delete a directory. The -f option will force the action. So, you can imagine what rm -rf / could theoretically do to you your...

0 0
6

Boomerang's Boomerang is a third option as well.

But I would caution you this, do not boot directly into the machine's hard drive. Boot off the recovery tool's software CD if it provides a boot mode. Every write to the hard drive, including swap files etc... lessens the chances of recovery.

Use the startup manager to do the boot, as 'C' key doesn't always work right:

http://docs.info.apple.com/article.html?artnum=106178

In the future always backup your data*:

http://www.macmaps.com/backup.html

Whomever recommended rm -rf to you should be reprimanded. rm -ri (that's the letter I as in 'eye' after the r) is much, much safer, and gives you an interactive yes/no dialog on each file, and still gives you the recursiveness you want.

- * Links to my pages may give me...

0 0
7

Copying and Moving: Problems Copying and Moving Files

If you attempt to copy, move, or duplicate a file and are unsuccessful, consider the following causes and solutions.

Insufficient space

If you try to copy a large file to a volume that has less free space than the size of the file, you will be unable to do so. Not a surprise.

The solution is to delete unneeded files from the destination volume, so as to free more space. Or you can attempt to copy the file elsewhere, on a volume that has more free space.

Occasionally, a volume may seem to have less space than you expected, based on the files you installed. This situation usually happens because some OS-related file sometimes, an invisible file is taking up more than the usual amount of space. Examples include the Console log files. If these files are not updated periodically, or if a recurring error is filling them rapidly, they can become very large. Explorer cache files can also become...

0 0
8

This article describes different methods to delete files or folders that cannot be deleted normally.

After trying the following methods, please click here to let us all know your results.

Table of contents

for this article

Reboot, then delete.

Open a command line window (WindowsKey + R, enter: cmd). Move to the folder in question by means of CD commands like CD \ and CD foldername.

Delete the file or folder by using the DEL command to delete files or the RMDIR (remove directory) command to remove directories (folders).

If this, on its own, is still not enough, then leave the command line window on the desktop, open Task Manager (Ctrl + Shift + Esc), and kill all explorer.exe tasks. Your desktop will go blank, except for the windows already open.

Now try to delete the offending file by means of the DEL command, or folder by means of the RMDIR (remove directory) command, in the command line window, as described...

0 0
9
CVS--Concurrent Versions System - Adding, removing, and renaming files and directories Go to the first, previous, next, last section, table of contents.

In the course of a project, one will often add new files. Likewise with removing or renaming, or with directories. The general concept to keep in mind in all these cases is that instead of making an irreversible change you want CVS to record the fact that a change has taken place, just as with modifying an existing file. The exact mechanisms to do this in CVS vary depending on the situation.

To add a new file to a directory, follow these steps.

You must have a working copy of the directory. See section Getting the source. Create the new file inside your working copy of the directory. Use `cvs add filename' to tell CVS that you want to version control the file. If the file contains binary data, specify `-kb' (see section Handling binary files). Use `cvs commit filename' to actually check in the file into the...
0 0