Now it’s time to discuss one of the most mysterious and confusing parts of Linux to a Windows user: the command line.
To most Windows users the prospect of typing in what you want your computer to do is completely foreign and thus intimidating. It’s so intimidating in fact that Linux developers have poured countless hours into designing GUIs (graphical user interfaces) to imitate and/or replace text-based commands. But sometimes the command line is still the fastest, easiest, or only way to get something done.
What is this “Linux Command Line”?
A command line is a method of interacting with your computer that involves typing commands (that is, words and phrases that have meaning to the computer) to make it do things. Command line interfaces replaced punch card systems back in the 1950′s and subsequently made room for GUIs. Today all three major operating systems –Windows, Mac OS X, and Linux– have command line interfaces to go along with their GUIs, although Linux tends to rely on the command line more than the other two. (That being said, you can still do plenty with your system without ever touching the command line.)
Why Should I Use it?
Everyone will agree that the command line was a great invention and it served many early PC users well. But with our constant rush for the latest technology, many regard the command line as archaic and useless as a steam powered automobile. I disagree and I’m certainly not alone. Here are a few reasons it may come in handy:
- 1. It’s fast – “productivity” is a word that gets tossed around a lot by so-called power users, but the command line can really streamline your computer use, assuming you learn to use it right.
2. It’s easier to get help – The command line may not be the easiest thing to use, but it makes life a whole lot easier for people trying to help you and for yourself when looking for help, especially over the internet. Many times it’s as simple as the helper posting a few commands and some instructions and the recipient copying and pasting those commands. Anyone who has spent hours listening to someone from tech support say something like, “OK, now click this” knows how frustrating the GUI alternative can be.
3. It’s nearly universal – There are hundreds of Linux distros out there, each with a slightly different graphical environment. Thankfully, the various distros do have one common element: the command line. There are distro-specific commands, but the bulk of commands will work on any Linux system.
4. It’s powerful – The companies behind those other operating systems try their best to stop a user from accidentally screwing up their computer. Doing this involves hiding a lot of the components and tools that could harm a computer away from novices. Linux is more of an open book, which is due in part to its prominent use of the command line.
OK, so what do I need to know?
Truly mastering the command line, like anything, takes plenty of time and practice. Entire books and websites have been written on the subject, but we can at least cover the basics here.
Navigate the file system – Like Windows, Linux uses a system of folders and files to organize data. When you first open a terminal you will be, by default, in the home folder. Enter the pwd (print working directory) command to make sure and it should output something like /home/user_name. Enter ls to list all the files and folders in your home folder. If you’ve been using your OS for a while your home folder is likely full of files and folders.
Rummage through the debris and you should find the Desktop folder. Let’s take a look at that. Type cd (change directory) and the directory name to go to any place on your computer. In this case we want to go to the Desktop directory, but there are three ways of writing its “address”: The long way, /home/user_name/Desktop, and the two shorthand ways, ~/Desktop, ./Desktop. The tilde (~) is shorthand for “/home/user_name,” while the period is shorthand for the current directory. Sound confusing? If so then I suggest just using the longhand way for now.
A few simple tasks – Using the ls command in my Desktop directory returns that I have a couple of cute cat pictures there that I just downloaded. Well, I want to get them off my desktop and into their own folder. So first I’ll enter “mkdir ~/cats” to make a directory called “cats” in my home directory. Now to move the two pictures to the new cat directory I enter “mv ./Fluffy.jpg ./mr-jingles.jpg ~/cats”. It may seem confusing, but it simply tells the computer to move the two pictures (the .jpg files) from the desktop to the “cat” folder in the home folder. You can also use the cp command instead of mv to copy the pictures without changing the originals on the desktop. Should I ever feel the need, I can use the “rm /path/to/files/” command to remove them. Please note, however, that using this command does not put the file in the trash bin, but instead deletes it forever.
A little miscellaneous info – Most commands (if not all) have a variety of options you can use to change the way the command works. Enter “[command] -[option letter]” to use options. Enter “man [command]” to open a command’s manual page and learn a bit about what a specific command does as well as its particular options. Lastly is the concept of root user. Some commands (particularly ones that could harm your computer if used recklessly or with malice) require you to become root user beforehand, using either the su or sudo commands.
A warning – The command line is great, but as Uncle Ben from Spider-Man says, “With great power, comes great responsibility.” So please do not enter any commands that you know absolutely nothing about. Be wary of copying and pasting questionable commands off the internet. Be especially wary of the rm command since you may cause irrevocable damage to your system and data. I hope this doesn’t discourage you, but instead prompts you to use a bit of caution when dealing with the Linux command line.
Where do I go from here?
Those are the absolute basics, but there is still so much to learn. There are plenty of articles both on and off the internet that go much deeper into the subject and even reference guides that list every single command. I suggest you don’t look at them just yet. Instead, I suggest you spend a few weeks or even months getting used to the command line and picking up things as you go along. Gradually you will learn what is useful and what is not so useful, what works better on the command line than the GUI and what doesn’t. This in turn will help you get the most out of your Linux system and maybe even fall in love with computing all over again.
(By) Abraham Kurp was introduced to open source software a few years ago and it was love at first site. When not preaching the virtues of open source he enjoys reading classic science fiction, playing obscure video games, dabbling in programming, and of course writing.