TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Linux commands

rm Linux Command with Examples

Overview

In this tutorial, we will learn rm Linux command with examples. This command is used to remove directories or files.

Environment

  • Ubuntu Linux
  • JBoss Application Server directories and files.

rm Linux Command

rm Linux command is used to remove files and directories on the system. The general syntax for the command is:

$ rm <filename>

$ rm <directory name>

$ rm <path to filename/directory to be removed>

The man page for the command can be launched using the following command:

$ man rm 

Examples

Alice is a DevOps Engineer. She does manual application deployments on the QA server. She wants to clean the Wildfly/JBoss application server files and directories to deploy the next QA build on the server. Look at the examples, of how she uses the rm command for this purpose.

#Remove file

To remove a single file we can use the following command. For example, to remove a server log archive file, we can use the rm command.

$ rm server.log.2016-09-3

Remove file rm command

The above would remove the server log file. We can notice the output of the ls command before and after the rm command.

#Remove Directory

rm command is also used to remove the directory and all its contents recursively.

For example, to delete server tmp directory, its subdirectories, and file contents, we can use the following command:

$ rm -rf tmp

Remove Directory rm command

The -r  or –recursive command-line switch is to denote recursive. This flag removes directories and their contents in a recursive manner. By default, rm doesn’t remove directories. We can use this switch to override this behavior.

The -f or –force command-line switch is to force the remove operation without any prompts to the user.

The rm -rf option is generally used in shell scripts to remove files and directories. Issue this command with caution, as it would delete the entire directory and subdirectories with their contents as well.

–

Linux Basic Commands Tutorial page:

https://www.testingdocs.com/linux-basic-commands-tutorial/

More Information on Ubuntu Linux:
https://ubuntu.com/

Related Posts

sudo auth log entry

Linux commands /

sudo Linux Command with Examples

Common File Commands in Linux

Linux commands /

Common File Commands in Linux

su linux command

Linux commands /

su Linux Command

ls linux command

Linux commands /

ls Linux Command with Examples

touch create file

Linux commands /

touch Linux Command

‹ mv Linux Command› cd(Change Directory) Linux Command with Examples

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version