Rm command in Linux w/ examples

Read the full article: rm command in Linux w/ examples

The rm command, short for “remove,” is a powerful tool in the Linux command line toolkit. It is used for deleting files and directories. Understanding the rm command is important for any Linux user. As a system administrator, you’re likely to use it to delete unnecessary files and keep your file system organized. Even if… continue reading.
1 Like

Be careful with rm command guys. You can nuke entire directories and data wth a typo or error. :scream:

1 Like

In fact, you can nuke entire file systems…

2 Likes

Tbh. I try to avoid this command lately. Using Find command instead.

Or always use echo with rm first. Like:

echo rm -rf /path/to/target/*

Which prints a preview.

1 Like

I only recently found out that you can do {option1, option2, option3} to autocomplete strings with variations.

In this case, if I have a monorepo with multiple projects, and I want to clear node_modules, I could do:

rm -rfv ~/Documents/MonoRepo/{SubFolder1, SubFolder2, SubFolder3}/node_modules

I’ve been using linux for 6 years, and only found out now because I wanted to install multiple versions of dotnet with just one command (sudo rpm-ostree install dotnet-runtime-{10,9,8}.0.) It could have uses with more selective uses of both mkdir and rm.

… I am immensely disappointed in myself.

1 Like