GO-V.ORG
As seen in

Rm (Unix)

rm , short for remove, is a shell command for removing files (which includes special files such as directories) from the file system. The command may not actually delete a file (release its storage for reuse) since it only unlinks it removes a hard link to a file via the unlink() system call. If a file has multiple links and less than all are removed, then the file remains in the file system; accessible via its other links. When a file's only link is removed, then the file is deleted releasing its storage space for other use. Generally, a deleted file's former storage space still contains the file's data until it is overwritten with another file's content. The data is not accessible via... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

rm , short for remove, is a shell command for removing files (which includes special files such as directories) from the file system. The command may not actually delete a file (release its storage for reuse) since it only unlinks it removes a hard link to a file via the unlink() system call. If a file has multiple links and less than all are removed, then the file remains in the file system; accessible via its other links. When a file's only link is removed, then the file is deleted releasing its storage space for other use. Generally, a deleted file's former storage space still contains the file's data until it is overwritten with another file's content. The data is not accessible via normal file operations but can be recovered via specialized tools. Since this is considered a security risk in some contexts, a hardened version of may wipe the file's storage area when the file is deleted. Commands such as shred and srm specifically provide data wiping. Since rm does not provide a fallback to recover a file such as a recycle bin, its use involves the risk of accidentally losing information. Users tend to wrap calls to rm in safety mechanisms to limit accidental deletion. There are undelete utilities that attempts to reconstruct the index and can bring the file back if its storage was not reused. Originally, developed for Unix, today it is also available on Unix-like and non Unix-like systems, KolibriOS, IBM i, EFI shell. and Windows (via UnxUtils). The del command provides a similar capability in MS-DOS, OS/2, and Command Prompt. Like , the unlink command also removes (unlinks) files, but only one file at a time. $ rm foo But that command fails if foo is a directory. To delete directory foo: $ rm -r foo The command is often used with xargs to supply a list of files: $ xargs rm To remove all PNG images in all directories below the current one: $ find . -name '*.png' -exec rm {} + alias rm="rm -i" or rm () { /bin/rm -i "$@" ; } Then, by default, requires the user to confirm removing each file by pressing or plus . To bypass confirmation, a user can include the -f option (as the option specified later on the expanded command line " rm -i -f " takes precedence). Unfortunately this can lead to other accidental removals since it trains users to be careless about the wildcards they hand to rm , as well as encouraging a tendency to mindlessly press and to confirm. Users have even been seen going as far as using yes | rm files , which automatically confirms the deletion of each file. 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 Arguably, 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. Other commands are designed to prevent accidental deletion, including and . ==Limitations== The GNU Core Utilities implementation has limits on command line arguments. Arguments are nominally limited to 32 times the kernel's allocated page size. Systems with 4KB page size would thus have an argument size limit of 128KB. For command-line arguments before kernel 2.6.23, the limits were defined at kernel compile time and can be modified by changing the variable MAX_ARG_PAGES in include/linux/binfmts.h file. Newer kernels limit the maximum argument length to 25% of the maximum stack limit (ulimit -s). Exceeding the limit results in an error.

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Rm (Unix)". 1791277299. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1378833507

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·