Learning

Linux for Starters: Your Guide to Linux – Manipulating Files – Part 13

Last Updated on May 22, 2022

rm

The rm command removes files or directories. The command needs to be used with extreme caution. There’s no undelete command or wastebasket when removing files from the shell.

When you delete a file or directory with rm, you cannot get it back. Make sure you perform regular backups on all important data and test your backups.

We can remove files from specific locations. For example:

$ rm path/to/file path/to/another/file

We can also recursively remove a directory and all its subdirectories with the command:

$ rm -r path/to/directory

The next command forcibly removes a directory, without prompting for confirmation or showing error messages. Use this command with extreme caution.

$ rm -rf path/to/directory

You can also interactively remove multiple files, with a prompt before every removal:

$ rm -i file(s)

And there’s a verbose mode, printing a message for each removed file:

$ rm -v path/to/directory/*

Again wildcards can be used with the rm command. But we strongly recommend before running rm you sit on your hands and think what you are doing. And make sure you backup!

Page 4 – mkdir

Pages in this article:
Page 1 – cp
Page 2 – mv
Page 3 – rm
Page 4 – mkdir


All articles in this series:

Linux For Starters: Your Guide to Linux
1What is Linux? Why use Linux? What do I need?
2Choose a Linux distribution meeting your specific needs and requirements.
3Make a bootable Ubuntu USB stick in Windows.
4We show you how to install Ubuntu 21.04 on your hard disk.
5Things to do after installing Ubuntu.
6Navigating your way around the Desktop.
7Updating the system, install new software.
8Open source replacements for proprietary Windows desktop software.
9Get started with the power and flexibility of the terminal.
10We cover the basics of files and permissions.
11Getting help from your system.
12Learn all about the file system.
13Manipulating files from the shell.
14Maintain your system with these simple tips.
15Managing users on your system.
16Explore different desktops to GNOME 3.
17Gaming on Linux.
18Protect your privacy with this guide.
19Access the Windows desktop from Linux using a remote desktop client.
20Set up a virtual machine running Ubuntu as the host and openSUSE as the guest.
21Wine lets you run Windows programs on Linux without emulation.
22Extend your GNOME desktop with extensions and themes.
XUseful Linux commands.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our Comment FAQ before posting a comment.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
D Watson
D Watson
3 years ago

Thanks. How many parts will this guide be?