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

Customizing Your Shell with Your Own Linux Commands

If you want to stamp your identity on your Raspberry Pi, you can make up your own Linux commands for it. You can have fun inventing a command that shows a special message if someone enters your name (use the echo command for this), but it’s genuinely useful for making more memorable shortcuts so you don’t have to remember all the different options you might want to use. We show you how to make a command for deleting files that uses the recommended options to confirm each file that will be deleted, and to report on what’s been removed. We’ll call it pidel, a mashup of Pi and delete.

The first step is to test whether your preferred command name is already in use. If the type command tells you anything other than not found, you need to think up another command name, or risk upsetting an existing command. Here’s my test:

pi@raspberrypi ~ $ type pidel

-bash: type: pidel: not found

Now that you know that the command pidel is not yet taken, you can create your command. To do that, make an alias, like this:

alias pidel=’rm –vi’

Between the quote marks, put the Linux command you want to execute when you enter the pidel command. As you can see from this alias instruction, when you use pidel, it behaves like rm -vi, but you won’t have to remember the letters for those options any more. For example:

pi@raspberrypi ~ $ pidel *.txt

rm: remove regular file ‘fm.txt’? y

removed ‘fm.txt’

rm: remove regular file ‘toc.txt’? n

pi@raspberrypi ...

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