Difference between revisions of "Rm (command)"

From wikieduonline
Jump to navigation Jump to search
 
(30 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Draft}}
+
{{lowercase}}
 +
[[wikipedia:rm (Unix)]] included in <code>[[coreutils]] package</code> is used to remove different type objects such as computer [[files]], [[directories]] and [[symbolic links]] from file systems and also [[special files]] such as [[device nodes]], [[pipes]] and [[sockets]].
  
 +
The <code>rm</code> command removes references to objects from the filesystem using the <code>[[unlink]]</code> [[system call]].
  
 +
Man page: https://man7.org/linux/man-pages/man1/rm.1.html
 +
 +
== Examples ==
 +
rm /path/to/your/file
  
 
  rm -rf
 
  rm -rf
  
  echo "" > /path/to/the/file.log
+
  [[echo]] "" > /path/to/the/file.log
  
 
  If it was already deleted, on Linux, you can still truncate it by doing:
 
  If it was already deleted, on Linux, you can still truncate it by doing:
  echo "" > "/proc/$pid/fd/$fd"
+
  echo "" > "[[/proc/]]$pid/fd/$fd"
  
 
  rm: cannot remove 'XXXX': [[Read-only file system]]
 
  rm: cannot remove 'XXXX': [[Read-only file system]]
 
  
 
== Related terms ==
 
== Related terms ==
 +
* <code>find /path/to/directory/ -mindepth 1 -mtime +5 [[-delete]]</code>
 
* <code>[[truncate]]</code>
 
* <code>[[truncate]]</code>
 
* <code>[[lsof]] -a +L1 /path/to/fs</code>
 
* <code>[[lsof]] -a +L1 /path/to/fs</code>
 +
* Files open but deleted: <code>[[lsof -nP]] | grep deleted</code>
 
* Set file to zero: <code>[[truncate]] -s 0 /path/to/filename</code>
 
* Set file to zero: <code>[[truncate]] -s 0 /path/to/filename</code>
 
* <code>[[unlink]]</code>
 
* <code>[[unlink]]</code>
 
* <code>[[echo]]</code>
 
* <code>[[echo]]</code>
 
* <code>[[inode]]</code>
 
* <code>[[inode]]</code>
 +
* <code>[[touch]]</code>
 +
* <code>[[scrub]]</code>
 +
* <code>[[shred]]</code>
 
* <code>[[mtime]]</code>
 
* <code>[[mtime]]</code>
* <code>[[scrub]]</code>
+
* [[coreutils]]
* <code>[[touch]]</code>
+
* [[block]]
 +
* [[virsh undefine]]
 +
* [[vgremove]]
 +
* [[podman machine rm]]
 +
* [[docker rm]]
 +
* [[docker-compose rm]]
 +
* [[docker buildx rm]]
 +
 
 +
== Activities ==
 +
* Read about [[rm performance information|rm performance]]
 +
* Read about [[ZFS]] <code>rm</code> "expensive" operations: https://serverfault.com/a/801080
 +
* https://unix.stackexchange.com/questions/tagged/rm?tab=Votes
  
 
== See also ==
 
== See also ==

Latest revision as of 10:13, 28 July 2023

wikipedia:rm (Unix) included in coreutils package is used to remove different type objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets.

The rm command removes references to objects from the filesystem using the unlink system call.

Man page: https://man7.org/linux/man-pages/man1/rm.1.html

Examples[edit]

rm /path/to/your/file
rm -rf
echo "" > /path/to/the/file.log
If it was already deleted, on Linux, you can still truncate it by doing:
echo "" > "/proc/$pid/fd/$fd"
rm: cannot remove 'XXXX': Read-only file system

Related terms[edit]

Activities[edit]

See also[edit]

Advertising: