• 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 not found

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. To remove a file, you must have write permission in the directory that contains the file, but you need not have permission on the file itself. If you do not have write permissions on the file, you will be prompted (y or n) to override. rm is often aliased to rm -i, especially for the root user, to protect against inadvertently deleting files.

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

The rm (remove) command can delete files:

# rm file1 file2 file3

or recursively delete directories:

$ rm -r dir1 dir2

If you encounter the below error while running the rm command:

rm: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

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. lvextend command examples in Linux
  2. CentOS / RHEL : How to Disable and Blacklist Linux Kernel Module to prevent it from loading automatically
  3. lscpu Command Examples in Linux
  4. How to configure resource groups for MySQL Server running on Linux
  5. How to Change the Default Shell In Linux
  6. strace: command not found
  7. iperf Command Examples in Linux
  8. brightnessctl Command Examples in Linux
  9. awk Command Examples in Linux
  10. How to Configure a Fiber-Channel Over Ethernet (FCoE) Interface in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright