Getting Started with Linux Commands on Your Raspberry Pi
Linux is like an iceberg — not so much because it’s big, cold, and it sinks ships (because it doesn’t), but because the desktop you usually see is a small part of a much bigger thing. And to use the rest of the big Linux thing, you have to know how to type commands.
When your Raspberry Pi is ready for commands it displays a prompt — a dollar sign ($) at the end of some gobbledeegook. When you power up your Pi, the first thing you see after it settles down is this dollar prompt.
Any time you type startx to make the desktop appear, you are using the command-line. You just didn’t know it!
Commands are so useful, you can use them on the desktop. A special application called LXTerminal shows the command line. The following figure shows LXTerminal doing the big Linux thing.
If you have an old-style desktop, launch LXTerminal by double-clicking the LXTerminal icon.
On the new desktop, click the LXTerminal icon once. It looks like a monitor with a black window in the icon bar at the top of your screen.
After it launches, you see a tab with the current prompt, like the one in the preceding figure. Type commands after the prompt, and your Pi does what you tell it to.
The prompt doesn’t just listen and wait. It tells you useful stuff. The first part shows you your username and the name of the computer, which is raspberrypi, in case you’ve forgotten. The rest shows you the current working directory/folder.
The figures in this article show Terminal set up with extra-big letters to make it easy for you to read commands. When you use Terminal on your Pi, the letters will be smaller. You can change them by choosing Edit→Preferences and selecting a different font size.
Understanding magic word commands
Linux includes hundreds of commands. No one remembers them all! And unfortunately, most of the commands don’t look like English. You can’t guess them, no matter how good you are with computers.
Some people think commands are like magic words. You have to know the right words to make a command work.
Because you can’t guess commands, you have to find them online or learn them from someone who already knows them. Be prepared to spend time online looking up commands and finding “magic word” examples that do what you want.
Don’t search online for “magic word commands” because you won’t find anything useful. Grown-up computer users don’t like calling them magic word commands — even though that’s what they are.
Using command switches
Many commands include options called switches. Switches change what a command does.
To include a switch, you usually type a minus sign – after a command, followed by one or more letters or numbers. (Some switches use two minus signs –, but that’s not so common.)
The following shows an example of using the ls command with different switches. ls lists the files in a folder. If you use it without switches, you get a list of the files and no other information.
Commands can have lots and lots of different switches. Only a few are really useful. The rest are there because someone decided it would be a good idea to include them — but they’re not used much.
If you add the -l switch (type ls –l and press Enter), the command shows the size, date, and time the file was created, and who created it, for every file.
If you add the -A switch (type ls –A and press Enter), you get a list of invisible files.
For some commands only, you can combine switches to save typing. So ls –Al works and shows you all the hidden files, with all their details.
Invisible files? Huh? Your operating system has been lying to you! But the files aren’t really invisible. They just don’t show up unless you look for them. They include settings for apps, settings that control what happens when you log in to your Pi, and other stuff you probably don’t want to look at all the time. Hiding them helps avoid clutter. So leaving them invisible makes sense. Sort of. . .