• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

rm Command Examples in Linux

by admin

The rm command removes files and directories. You must use the -R option to recursively remove files, subdirectories, and the parent directory itself.

Syntax

The syntax of the rm command is:

# rm [options] {file/directory names}

For example, to remove the ~/myfiles directory and its contents:

# rm -R ~/myfiles

rm Command Examples

1. To remove a file:

# rm file 

2. To forcefully remove a file:

# rm -f file 

3. To prompt before removing any file:

# rm -i file 

4. To prompt before removing any file, if more than three files:

# rm -I file* 

5. To prmpt as specified:

# rm --interactive=WHEN file* 

6. To skip any directory that is on a file system different from specified:

# rm --one-file-system 

7. To do not treat “/” specially:

# rm --no-preserve-root 

8. To do not remove “/”:

# rm --preserve-root 

9. To remove directories and their contents recursively:

# rm -r
# rm -R
# rm --recursive 

10. To run in verbose mode:

# rm -v
# rm --version 

11. To get the help:

# rm --help 

12. To get the version:

# rm --version 

Filed Under: Linux

Some more articles you might also be interested in …

  1. dpkg-deb Command Examples in Linux
  2. How to delete unused kernels and keep only the running kernel in CentOS/RHEL
  3. How to uninstall neovim from Ubuntu
  4. pkill Command Examples in Linux
  5. nova Command Examples in Linux
  6. daemonize Command Examples in Linux
  7. lsof : Most commonly used examples
  8. CentOS / RHEL 7 : How to install and configure telnet
  9. How to tar, untar files and view contents of tar file under Linux
  10. How to grow/extend XFS filesytem in CentOS / RHEL using “xfs_growfs” command

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright