What Non-Techies Should Know About The Command Line

dcp's picture

So you have GNU/Linux installed, and your friends are congratulating you on being the king of your computing castle. But you quickly lose that majestic feeling when you find yourself needing a Bash prompt, and start feeling like this whole GNU/Linux thing is a royal pain. The Bash prompt need not give you the feeling of having to issue royal decrees in a foreign language you've never even heard of, let alone speak fluently.

I started with computers when you had to install DOS 6.22 and then install Windows 3.11 on top of that. So I quickly became fairly familiar with both the command line and the graphical shells. I once wrote a batch file menu in DOS, and I have compiled programs from source. I have used SSH extensively from the command-line, as well as in Konqueror and Nautilus. I am no expert, but neither am I afraid of it. And recently, I wrote about writing a shell script to automate a process that I normally do in the graphical shell.

When faced with a shell prompt, the only thing some people, especially non-technical users, feel prompted to do is close it and stay in the confines of their graphical castle walls. For many people, a command-line shell is an unfamiliar thing. It's foreign, and requires learning foreign languages to speak to it, as far as they are concerned. Well, it doesn't have to be that way; the command line can be kind of fun. Whether you need to open a Bash prompt to solve a driver problem, or compile a program, or just to automate a simple task, it's always good to at least be familiar with your command-line shell.

Why Bother?

Why should a non-techie bother learning anything about the command line? Good question. Consider the following situations:

  • Your graphical desktop crashes, but you can still access a virtual console. You might be able to fix the problem without having to completely shut down your computer.
  • You face a driver issue that requires you to load the driver as a kernel module. As far as I know, this can only be done from the command line.
  • You need to know some basic commands to write simple shell scripts, like I mentioned above.
  • You need to use some console applications, such as SSH, a database server, like MySQL or PostgreSQL, or some other program, like mp32ogg.

These situations frequently (but not always) require use of the command-line shell, as opposed to a graphical shell.

What Should I Learn?

What should a non-technical user learn? That's a good question. Most non-technical users rarely venture beyond the graphical desktop to the shell to begin with. But even then, you should at least understand a few basic things. What happens if your graphical desktop crashes on you, but your system is still up and running? Knowing certain commands can make it easier to write scripts to automate certain tasks. You don't have to become a Bash master, but becoming familiar with it will be useful when you find yourself needing it. Let's talk a little about what you should know and why.

How to access a shell (console windows and virtual consoles)

It's important to know the different ways to access a command prompt in GNU/Linux. WIndows offers a command prompt via the DOS window, but with GNU/Linux, you not only can open multiple graphical command consoles, but can also access full-screen virtual consoles using the [Ctrl]+[Alt]+Fn (F1-F8) key combination.

How to navigate their system using a shell

When you use your graphical file browser (Konqueror or Nautilus), you know you can just click a folder to open and see its contents. When using a console, however, you have to type a command, and the result is usually a list of directories (folders) and files. Knowing where you are can make a big difference when you enter a command. And you need to know how to change directories so you can enter the command where you need or want to.

How to get help for commands (man, --help)

Since it's near impossible to remember every detail about any given command, especially when you rarely enter the command-line realm anyway, you at least need to know how to find out what options are available and how to use them. Sometimes you can just use the command --help sequence, but sometimes, you need to use the manual system (man). You can even get help with man, itself: man man.

How to use the command history (very useful!)

Here's a jewel. Knowing how to use Bash's command history is great when you've been changing between the same directories or running the same command with different options, and so on. You can do like many people do and just use the Up and Down arrow keys to navigate through the history, or you can learn the more advanced history functions. Either way, you can save a lot of typing.

How to list and manipulate (move, copy, etc.) files and directories (folders)

Everyone needs to know how to copy, move and delete files and folders. It's that simple. You also need to know how to display a list of the files in a given folder.

How to set permissions on a file

You can change the permissions on a file to allow others to, or prevent them from, accessing or running a file. You need to know how to set the read, write and execute permissions for just you, your group, and everyone else who might access the system. There's more, of course, but I am just covering some bare basics.

How to redirect input and output

I almost ommitted this one, because, frankly, I consider it slightly advanced. The thing is, redirection really is pretty basic. I see it all the time in help discussions, frequently with the grep command, cat and others. So, seriously, learn a little about it.

How to automate simple tasks (shell scripting or shell programming)

Yeah, you can use my script from the link I gave earlier. You can modify it to suit your system. Try that and play with it. Seriously. And you might try a simple back-up script. Then build on it as you gain experience.

I hope you can see better why you should learn at least a little bit about Bash, and what you ought to learn. I have included some resources below to help you learn. Look, you're not going to learn it all overnight. But at least consider devoting just a brief 5 minutes each day to learning and practicing a new command, or at least practicing one you recently learned. Then, when you really do need it, you won't feel like a stranger in your own kingdom.

I'm not advocating that everyone should become a Bash guru, but neither should anyone waste perfectly good computing power. I also realize that Grandpa Jones just ain't gonna learn Bash. Fine. But I would encourage Gramps, and anyone else, to at least come out of their comfort zone for a little while, and try something new.

As always, I'm sure Blue GNU readers will point out other reasons to learn Bash, as well as other 'basics' you ought to know and why. Some will know of other great resources for learning Bash.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Two additions

Two more points

Another essential reason to learn Bash (or another Shell) is to understand what the hell this guru is making me do on my system to fix it (or to seek for the problem). Different graphical interfaces (for example on Gnome and on KDE) provide different ways to perform something. At least, the labels are different. As a consequence, it is difficult to help someone having a set of graphical tools different from yours. In the opposite, once you know how to do it with Bash, you can switch to any desktop/distribution without this feeling of a foreign kingdom you are talking about. Understanding what you are actually doing when a guru tells you to type a few commands is an excellent way to start learning Shell commands.

As you said it, the command line generally allows to perform things faster. However you have forgotten one of the main reason for this speed gain: the automatic completion of commands/file names/etc. through the tabulation key (which you usually press every two characters!).


Great post!

By my question "how should non-technical users begin" on your previous post about writing a shell script, this is exactly the type of thing I was trying to get at. A general guide to bash seems, to me, to daunting for the average computer user to just be willing to diving in and absorb. But the kinds of suggestions you mention in this post are, I think, exactly what the average user with an interest to learn more is looking for. That is, some specific, well-defined attainable tasks (e.g. Learning how to set permissions on a file) that can give the user some legs to stand on with respect to bash.

Great post!