Share
VIDEOS 1 TO 50
rm Command In UNIX
rm Command In UNIX
Published: 2013/11/25
Channel: A-OneTutors
Linux Command Line Tutorial For Beginners 7 -  rm and rmdir commands for linux
Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux
Published: 2016/06/21
Channel: ProgrammingKnowledge
OS X Terminal Commands For Unix & Linux (ls | cd | mkdir | rm | cat | top | ps | find, etc.)
OS X Terminal Commands For Unix & Linux (ls | cd | mkdir | rm | cat | top | ps | find, etc.)
Published: 2014/12/18
Channel: Bit2Brain
How to Use RM Command in Unix
How to Use RM Command in Unix
Published: 2013/06/18
Channel: Windows and Linux Tutorials from Howtech
BASH Shell commands rm and rmdir ( commands for linux )
BASH Shell commands rm and rmdir ( commands for linux )
Published: 2012/02/01
Channel: Linux Leech
Unix touch, cp, mv Commands | UNIX Tutorial | Mr. Subba Raju
Unix touch, cp, mv Commands | UNIX Tutorial | Mr. Subba Raju
Published: 2016/09/10
Channel: Naresh i Technologies
11 - Unix | Linux Shell - Remove Files | Remove Non Empty Directory | RM Command
11 - Unix | Linux Shell - Remove Files | Remove Non Empty Directory | RM Command
Published: 2015/05/18
Channel: Mohammedi Computers
Unix for Neuroimagers 4: mkdir, rmdir, and rm
Unix for Neuroimagers 4: mkdir, rmdir, and rm
Published: 2012/08/18
Channel: Andrew Jahn
Creating and Deleting Files and Folders in Linux
Creating and Deleting Files and Folders in Linux
Published: 2013/08/28
Channel: Jason Wertz
Linux / Unix Commands for Beginners -  cp | rm | mv
Linux / Unix Commands for Beginners - cp | rm | mv
Published: 2016/03/09
Channel: T3SO Tutorials
Linux commands tutorials - What is "rm" command in linux ? How to use "rm" command ?
Linux commands tutorials - What is "rm" command in linux ? How to use "rm" command ?
Published: 2013/11/29
Channel: Being Skilled
The DANGEROUS Linux Command!! (rm -rf / --no-preserve-root)
The DANGEROUS Linux Command!! (rm -rf / --no-preserve-root)
Published: 2016/06/10
Channel: Dhanuhammer
Basic Unix Commands Part 1
Basic Unix Commands Part 1
Published: 2011/08/23
Channel: Ron Bass
Linux Commands 3.  Files : touch, gedit, cat, cp, mv, rm
Linux Commands 3. Files : touch, gedit, cat, cp, mv, rm
Published: 2016/04/23
Channel: Linux in 11 Minutes
How to Use Delete Command in Unix
How to Use Delete Command in Unix
Published: 2013/06/13
Channel: Windows and Linux Tutorials from Howtech
Unix touch, cp, mv Commands | UNIX Tutorial
Unix touch, cp, mv Commands | UNIX Tutorial
Published: 2017/01/03
Channel: Robert Wade
UNIX Copy command (cp) ,Remove command (rm)
UNIX Copy command (cp) ,Remove command (rm)
Published: 2013/06/06
Channel: vignan university
Unix Commands - 04 - Working with CAT and RM Command
Unix Commands - 04 - Working with CAT and RM Command
Published: 2013/05/03
Channel: ಬೀಬೈಟ್ಸ್ - BeeBytes
Purging Old Files in Linux
Purging Old Files in Linux
Published: 2013/12/01
Channel: LinuxTechShow
touch, rm, ls, and cp Files in the Linux/Unix Bash Shell Petting Zoo
touch, rm, ls, and cp Files in the Linux/Unix Bash Shell Petting Zoo
Published: 2015/12/10
Channel: Dototot
How to recover deleted file in your linux system
How to recover deleted file in your linux system
Published: 2016/01/31
Channel: shubham dubey
LINUX : Touch Rm - How To Create/Remove a File in Unix/Linux/Aix Terminal Tutorial
LINUX : Touch Rm - How To Create/Remove a File in Unix/Linux/Aix Terminal Tutorial
Published: 2014/04/20
Channel: LAST MINUTE REVISION
mkdir/ls/cd/cp/mv(basic commands) in linx[part 1]
mkdir/ls/cd/cp/mv(basic commands) in linx[part 1]
Published: 2017/04/16
Channel: kwl zerotwonine
Basic Unix Commands
Basic Unix Commands
Published: 2017/09/02
Channel: Goals InfoCloud Technologies
UNIX Basic Navigation
UNIX Basic Navigation
Published: 2013/04/17
Channel: Brian Matt
Basic Unix Commands
Basic Unix Commands
Published: 2010/07/14
Channel: Christina Bergey
UNIX Knowledge for Software Testers
UNIX Knowledge for Software Testers
Published: 2017/04/11
Channel: G C Reddy
Comandos UNIX-Date-RM-Finger.wmv
Comandos UNIX-Date-RM-Finger.wmv
Published: 2012/06/07
Channel: JOSE LUIS PEREZ HERNANDEZ
Directory Related Commands + Useful ls Variations + Removing File Forcibly - UNIX/LINUX Tutorials
Directory Related Commands + Useful ls Variations + Removing File Forcibly - UNIX/LINUX Tutorials
Published: 2016/06/04
Channel: thegenuinegourav
rm files & direcectories Linux UNIX command Easy Man Manual pages by UNIX Academy unixacademy.com
rm files & direcectories Linux UNIX command Easy Man Manual pages by UNIX Academy unixacademy.com
Published: 2010/03/10
Channel: DVDbyDVD
Unix Admin  -   Horror Story - rm -rf *
Unix Admin - Horror Story - rm -rf *
Published: 2016/12/23
Channel: Nir Vana
03 - Unix | Linux Shell - Create Remove Change Directory; Mkdir - Rmdir - Cd | Command - Hindi
03 - Unix | Linux Shell - Create Remove Change Directory; Mkdir - Rmdir - Cd | Command - Hindi
Published: 2015/03/04
Channel: Mohammedi Computers
UNIX/Linux Basic Commands | UNIX Tutorial
UNIX/Linux Basic Commands | UNIX Tutorial
Published: 2017/01/03
Channel: Robert Wade
unix-rm
unix-rm
Published: 2011/12/03
Channel: engalaa1987
How to use the touch and rm Commands
How to use the touch and rm Commands
Published: 2013/05/28
Channel: Ed Walsh
07 - Unix | Linux Shell - Copy | Move | Rename Files - cp | mv script commands - Hindi
07 - Unix | Linux Shell - Copy | Move | Rename Files - cp | mv script commands - Hindi
Published: 2015/03/14
Channel: Mohammedi Computers
Unix touch, cp, mv Commands | UNIX Tutorial
Unix touch, cp, mv Commands | UNIX Tutorial
Published: 2017/01/11
Channel: wayne womer
Hadoop DFS Command Line (mkdir, rm, copyFromLocal, copyToLocal)
Hadoop DFS Command Line (mkdir, rm, copyFromLocal, copyToLocal)
Published: 2016/09/22
Channel: Chris Dyck
OS Unix Torminal  top 10 command - mkdir rmdir rm pwd passwd ls cd cal date wc
OS Unix Torminal top 10 command - mkdir rmdir rm pwd passwd ls cd cal date wc
Published: 2015/07/03
Channel: Maulik Goyani
UNIX Lesson - mkdir rmdir touch rmdir rm.wmv
UNIX Lesson - mkdir rmdir touch rmdir rm.wmv
Published: 2010/01/21
Channel: Larry Meadors
rm and rmdir (for deleting in unix)
rm and rmdir (for deleting in unix)
Published: 2015/05/11
Channel: Sameh Labib
Unix commands | Linux command to delete file from directory using terminal | rm command
Unix commands | Linux command to delete file from directory using terminal | rm command
Published: 2017/02/12
Channel: SixForce Classrooms
Unix / Linux tutorial - command - learn FAST - fundamentals - touch, rm, rmdir - Tutorial - Lesson 5
Unix / Linux tutorial - command - learn FAST - fundamentals - touch, rm, rmdir - Tutorial - Lesson 5
Published: 2017/04/12
Channel: Tagmalogic Training
UNIX-1.3 UNIX Commands and Options
UNIX-1.3 UNIX Commands and Options
Published: 2012/05/24
Channel: fuzicast
Unix   Linux Shell Beginner " Tutorial File Related Command "  Cat , Mkdir , Rm & Rmdir
Unix Linux Shell Beginner " Tutorial File Related Command " Cat , Mkdir , Rm & Rmdir
Published: 2016/12/18
Channel: WebCode
Basic Linux/Unix File Manipluation (cmd line tutorial)
Basic Linux/Unix File Manipluation (cmd line tutorial)
Published: 2010/10/29
Channel: UMCoECAC
Unixでrm -rfしたら?Appleがリワード広告取締まり!月給11万円のPG求人?グレーゾーンなアフィリエイト
Unixでrm -rfしたら?Appleがリワード広告取締まり!月給11万円のPG求人?グレーゾーンなアフィリエイト
Published: 2014/06/22
Channel: やまろうTV
Unix Commands & Shell Scripting - 2
Unix Commands & Shell Scripting - 2
Published: 2017/08/27
Channel: OnlineTechGuru
Creating, Copying, Moving, Renaming, Deleting Files Commands - UNIX/LINUX Tutorials for beginners
Creating, Copying, Moving, Renaming, Deleting Files Commands - UNIX/LINUX Tutorials for beginners
Published: 2016/06/01
Channel: thegenuinegourav
UNIX/Linux Basic Commands | UNIX Tutorial
UNIX/Linux Basic Commands | UNIX Tutorial
Published: 2017/01/11
Channel: wayne womer
NEXT
GO TO RESULTS [51 .. 100]

WIKIPEDIA ARTICLE

From Wikipedia, the free encyclopedia
Jump to: navigation, search

rm (short for remove) is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem. To be more precise, rm removes references to objects from the filesystem, where those objects might have had multiple references (for example, a file with two different names), and the objects themselves are discarded only when all references have been removed and no programs still have open handles to the objects.

This allows for scenarios where a program can open a file, immediately remove it from the filesystem, and then use it for temporary space, knowing that the file's space will be reclaimed after the program exits, even if it exits by crashing.

rm generally does not destroy file data, since its purpose is really merely to unlink references, and the filesystem space freed may still contain leftover data from the removed file. This can be a security concern in some cases, and hardened versions sometimes provide for wiping out the data as the last link is being cut, and programs such as shred are available which specifically provide data wiping capability.

Example[edit]

To remove a file named "foo" from a directory one could type:

% rm foo

Normally, no output is produced by rm, since it typically only generates messages in the event of an error. The -v option can be used to get rm to detail successful removal actions.

Users concerned about removing files unexpectedly - particularly when using wildcards - sometimes use the -i option to cause rm to verify each removal in advance, although this method may be inconvenient for use on large numbers of files.

% rm -i foo
remove foo? y

Context[edit]

rm is generally only seen on UNIX-derived operating systems, which typically do not provide for recovery of deleted files through a mechanism like the recycle bin,[1] hence the tendency for users to enclose rm in some kind of wrapper to limit accidental file deletion.

There are undelete utilities that will attempt to reconstruct the index and can bring the file back if the parts were not reused.

Options[edit]

Common options that rm accepts include:

  • -r, which removes directories, removing the contents recursively beforehand (so as not to leave files without a directory to reside in) ("recursive")
  • -i, which asks for every deletion to be confirmed ("interactive")
  • -f, which ignores non-existent files and overrides any confirmation prompts ("force"), although it will not remove files from a directory if the directory is write-protected.

rm can be overlain by a C shell alias or Bourne shell function of "rm -i" so as to avoid accidental deletion of files. If a user still wishes to delete a large number of files without confirmation, they can manually cancel out the -i argument by adding the -f option (as the option specified later on the expanded command line "rm -i -f" takes precedence). Unfortunately this approach generates dangerous habits towards the use of wildcarding, leading to its own version of accidental removals.

rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Unix disasters.[2] The rm -rf variant of the command, if run by a superuser on the root directory, would cause the contents of nearly every writable mounted filesystem on the computer to be deleted, up to the point the system itself crashes from missing some crucial file, directory, or the like.[citation needed]

rm is often used in conjunction with xargs to supply a list of files to delete:

 xargs rm < filelist

Or, to remove all PNG images in all directories below the current one:

 find . -name '*.png' -exec rm {} +

Permissions[edit]

Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place). (Note that, confusingly for beginners, permissions on the file itself are irrelevant. However, GNU rm asks for confirmation if a write-protected file is to be deleted, unless the -f option is used.)

To delete a directory (with rm -r), one must delete all of its contents recursively. This requires that one must have read and write and execute permission to that directory (if it's not empty) and all non-empty subdirectories recursively (if there are any). The read permissions are needed to list the contents of the directory in order to delete them. This sometimes leads to an odd situation where a non-empty directory cannot be deleted because one doesn't have write permission to it and so cannot delete its contents; but if the same directory were empty, one would be able to delete it.

If a file resides in a directory with the sticky bit set, then deleting the file requires one to be the owner of the file.

Protection of the filesystem root[edit]

Sun Microsystems introduced "rm -rf /" protection in Solaris 10, first released in 2005. Upon executing the command, the system now reports that the removal of / is not allowed.[3] Shortly after, the same functionality was introduced into FreeBSD version of rm utility.[4] GNU rm refuses to execute rm -rf / if the --preserve-root option is given,[5] which has been the default since version 6.4 of GNU Core Utilities was released in 2006.

User-proofing[edit]

Systems administrators, designers, and even users often attempt to defend themselves against accidentally deleting files by creating an alias or function along the lines of:

alias rm="rm -i"
rm () { /bin/rm -i "$@" ; }

This results in rm asking the user to confirm on a file-by-file basis whether it should be deleted, by pressing the Y or N key. Unfortunately, this tends to train users to be careless about the wildcards they hand into their rm commands, as well as encouraging a tendency to alternately pound y and the return key to affirm removes - until just past the one file they needed to keep.[citation needed] Users have even been seen going as far as "yes | rm files", which automatically inserts "yes" for each file.[citation needed]

A compromise that allows users to confirm just once, encourages proper wildcarding, and makes verification of the list easier can be achieved with something like:

if [ -n "$PS1" ] ; then
  rm () 
  { 
      ls -FCsd "$@"
      echo 'remove[ny]? ' | tr -d '\012' ; read
      if [ "_$REPLY" = "_y" ]; then
          /bin/rm -rf "$@"
      else
          echo '(cancelled)'
      fi
  }
fi

It's important to note that this function should not be made into a shell script, which would run a risk of it being found ahead of the system rm in the search path, nor should it be allowed in non-interactive shells where it could break batch jobs. Enclosing the definition in the if [ -n "$PS1" ] ; then ....  ; fi construct protects against the latter.

There exist third-party alternatives which prevent accidental deletion of important files, such as "safe-rm"[6] or "trash".[7]

History[edit]

On some old versions of Unix, the rm command would delete directories if they were empty.[8] This behaviour can still be obtained in some versions of rm with the -d flag, e.g., the BSDs (such as FreeBSD,[9] NetBSD,[10] OpenBSD[11] and OSX[12]) derived from 4.4BSD-Lite2.[13] The GNU coreutils version also provides this option, to help with compatibility.[14] The same functionality is provided by the standard rmdir command.

The -i option in Version 7 replaced dsw, or "delete from switches", which debuted in Version 1. Doug McIlroy wrote that dsw "was a desperation tool designed to clean up files with unutterable names".[15]

See also[edit]

References[edit]

  1. ^ http://www.faqs.org/faqs/unix-faq/faq/part3/section-6.html
  2. ^ Gite, Vivek. "Linux/UNIX: Delete a file". Nixcraft. Retrieved 24 November 2011. 
  3. ^ Meddling in the Affairs of Wizards
  4. ^ FreeBSD rm.c commit message
  5. ^ rm invocation - GNU Coreutils
  6. ^ https://launchpad.net/safe-rm
  7. ^ https://github.com/andreafrancia/trash-cli
  8. ^ Unix 8th ed. rm man page
  9. ^ "RM(1)", FreeBSD-5.4-RELEASE, retrieved February 5, 2015 
  10. ^ "RM(1)", NetBSD-2.0, retrieved February 5, 2015 
  11. ^ "RM(1)", OpenBSD-3.6, retrieved February 5, 2015 
  12. ^ "RM(1)", Darwin-7.0.1-ppc, retrieved February 5, 2015 
  13. ^ "RM(1)", 4.4BSD-Lite2, retrieved February 5, 2015 
  14. ^ Krzysztof Goj (January 22, 2012). "rm: new option --dir (-d) to remove empty directories". coreutils.git. 
  15. ^ McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139. 

External links[edit]


Disclaimer

None of the audio/visual content is hosted on this site. All media is embedded from other sites such as GoogleVideo, Wikipedia, YouTube etc. Therefore, this site has no control over the copyright issues of the streaming media.

All issues concerning copyright violations should be aimed at the sites hosting the material. This site does not host any of the streaming media and the owner has not uploaded any of the material to the video hosting servers. Anyone can find the same content on Google Video or YouTube by themselves.

The owner of this site cannot know which documentaries are in public domain, which has been uploaded to e.g. YouTube by the owner and which has been uploaded without permission. The copyright owner must contact the source if he wants his material off the Internet completely.

Powered by YouTube
Wikipedia content is licensed under the GFDL and (CC) license