O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting Files in Linux

After experimenting with creating files and directories, you probably have odd bits of file and meaningless directories all over the place, so it’s time to tidy up.

warning_bomb.eps To delete files in Linux, you use the rm command, short for remove. Use it very carefully. There’s no trash can or recycle bin to recover your file from again, so when it’s gone, it’s gone. Actually, expert Linux users might be able to get it back using specialized software and huge amounts of time and patience, so it’s not a secure deletion. But for an average user without access to such software and expertise, when you tell Linux to remove a file, it acts fast and decisively.

The rm command has this format:

rm options filename

As with mkdir, the command doesn’t tell you what it’s doing unless you use the verbose option (-v). As an example, you could remove a file called letter.txt using

pi@raspberrypi ~ $ rm –v letter.txt

removed ‘letter.txt’

Like mkdir, running the rm command can take several arguments, which means it can remove several files at once if you list all their names, for example:

pi@raspberrypi ~ $ rm –v letter.txt letter2.txt

removed ‘letter.txt’

removed ‘letter2.txt’

This is where you need to be extremely careful. Imagine you have two files called old index.html and index.html. The latter is your new website home­page, which you’ve toiled over all weekend (you can see where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required