61

I just installed Ubuntu a couple of days ago. As far as I can tell the terminal is a huge part of any Linux distro. My question at this point is why? When I look up anything about it, the commands put in the terminal are all easily done through the GUI. So, what are the advantages of using the terminal?

Edit: Thanks for the answers everyone. After a little poking around, and with the help of your answers, I can now understand its use. I can proudly say, that for the past 3 days, I've been using it for just about everything, and I hope to soon have a better grasp on scripting.

5
  • 21
    The fact that you asked that shows how far Linux as an OS has come from the days where everything was CLI based! :-) Feb 21, 2012 at 14:49
  • 1
    The definitive answer to this question is probably Eric S. Raymond's The Art of Unix Programming. For a more cynical (or, some might say, more pragmatic) take on the same ideas, see Joel Spolsky's article on Biculturalism. Feb 21, 2012 at 19:34
  • 1
    In a general sense, the advantage of using the terminal is expressiveness. It's as close to a Do What I Mean interface as we have, free of clutter and modality, and that counts for a lot in terms of time and practicality. -- This isn't comprehensive enough to be an answer per se, but the quick sound byte hopefully helps.
    – MrGomez
    Feb 22, 2012 at 20:42
  • In last 5 years that I've spent with Ubuntu, I fail to remember a single day when I haven't used terminal. It is the first application that I open after I login (I've of course automated it :-) ) and it closes only when my PC shuts down. Feb 23, 2012 at 12:03
  • 2
    This question is not a good fit to our Q&A format. We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion.
    – jrg
    Feb 24, 2012 at 21:05

16 Answers 16

79

The terminal in Unix is a wonderful, powerful tool. When transitioning from the world of Windows it is hard to appreciate this because the Windows (cmd.exe) shell is rather, how do I nicely say, lacking. Most *nix default shells (bash, zsh, etc) have several advantages:

  1. It is standardized through POSIX and the Single Unix Specification, so a script you write for one computer will likely work on all POSIX compliant machines (assuming you restrict yourself to standard commands, of which there are lots). Microsoft has a habit of including tools in some versions and not in others, making batch programming very hit or miss

  2. Because Unix was built from the terminal up, most everything is configurable from the command line. Windows was like this up to a point, but they opted to drop the 16-bit subsystem and DOS with it. Now the GUI is the only way to change some things in Windows.

  3. Because it is so flexible. Commands can be piped together (ls | grep filename), they can be captured (gcc program.c > ./standard_out 2> ./standard_error), and can be substituted (ls /home/`whoami` or ls /home/$(whoami))

  4. Because UNIX utilities are designed to do one thing, and do it well. Just look into awk,grep,sed, wget or a host of others. By themselves they achieve a single task, but given #3 and #2 they can be built into powerful expressions.

  5. Because of the ability to automate tasks. cron and bash scripts allow long, complicated, and/or repetitive tasks to either be simplified or automated completely.

  6. Because humans are prone to error. Relatively short shell scripts can be used to change settings in a consistent manner. Safety checks can be built into the scripts, rather than relying on users to know which commands are safe to run in different circumstances.

9
  • 10
    I'd call ` bad ticks... It's better to use ls /home/$(whoami) nowadays :-)
    – raphink
    Feb 21, 2012 at 13:58
  • 19
    I'd say there's a 5., namely, scripting possibilities. You can automate anything, I even have a script that launches a random episode of my favorite series when I wanna procrastinate... Get your PC a couple of wheels & you can probably write a script that gets you beer from the fridge, and if you put it in cron, it'll meet you at the door with it when you come back from work...
    – TC1
    Feb 21, 2012 at 14:01
  • 6
    To be fair, PowerShell has improved the Windows shell situation in terms of usability (though not standardization). Feb 21, 2012 at 14:54
  • 4
    I'd like to add another bit of balance and also mention PowerShell, and even before that it was perfectly possible to accomplish most tasks from the CMD prompt in Windows from Windows XP onwards. The difference as has been said is that the command line has always been, and continues to be, more central to day-to-day *nix use. This has good and bad implications.
    – Alan B
    Feb 21, 2012 at 16:07
  • 9
    What about 6 - It's often easier to issue a command than to follow step-by-step instructions telling you how to navigate the GUI. That's why many how-to instructions on the web use command line. And it's also generally true for users - as you gain more experience, it just becomes faster and easier to use the CLI.
    – Phil
    Feb 21, 2012 at 17:26
35

There are a multitude of advantages to using the terminal. Arguments range from convenience, productivity to nostalgia. Here are some :

  1. There are some things that you (rather me) simply cannot accomplish using a GUI. It is not because it isn't doable, it is simply because nobody bothered to write a GUI for these commands. For example if I wanted to use some command, say mdf2iso to convert a whole bunch of files in a folder. I can pipe the output using | operator and do it in a single stroke.

  2. For a lot of us, it is just the way things should be. Keep in mind that this has little to do with expertise. I am no linux expert, I am just a regular user, but I do prefer to use the command line wherever possible. This is not so much of an argument about why it should be used, as much as why it is used.

  3. Scripts are a powerful thing. You can use conditions if and loops for etc.. and do all sorts of things combining the power above. There is no limit to the power of scripting. You can automate complex tasks which are tailored to your requirements. For such things, it is often hard to find a GUI app that matches your requirement.

  4. You can perform tasks by remote login, even over very low bandwidth settings.

  5. Helping, writing tutorials etc are much easier if you can specify the commands to the other person. This way, you do not have to take screenshots. This has another advantage for the person who is being helped as well, which brings us to the next point.

  6. Using the command line usually gives you a better understanding of what you are doing and what is going on.

  7. And lastly, it is simply faster. It is much quicker to type a few letters and press TAB than to click though endless menu options. You can use !mo to invoke the last command you ran that started with mo (e.g. mount) and so on.

I am sure there are a thousand other reasons I failed mention.

2
  • It's 'advantegeous' in some tasks to use cli, but for 90% of day to day use nobody wants to use cli commands to miniscule things. All i ever see is that it's advantegeous because you can do "this" so efficently however that this only happens like once a month or when setting up computer. For example, just to copy a file you need to write paragraphs, set permissions, check, define options, give correct space, watchout for correct case, read through lists of 50 files, look up their permissions...whereas if you were doing it on windows gui, you would press ctl+a .. alt+tab ctl+c. And you are done Sep 13, 2014 at 19:11
  • There's something very satisfying about the commandline, commands are issued and are executed correctly with mute acceptance, with often only errors being shown. I nearly always prefer moving and copying files on the commandline to the often frustrating and ambiguous experience of drag and drop. Feb 28, 2016 at 16:45
17

Eventually? Because you start scripting, and the wonderful thing about scripting is this:

Instead of changing the way you do things, you can change the script that does them.

You can write scripts for the terminal, and you usually can't for graphical programs, so that's why people use the terminal.

But I sense a hint of "Why should I use the terminal?" in your question. I can't answer that for you, you being you and me being not-you, but this related question may offer you some insight:

How/why do people end up using being command-line users?

I think you could identify three stages: (1) reluctant use; (2) knowing the minimum needed for comfort; (3) finding one enjoys scripting. One can get use out of the terminal at all three of these levels; find out for yourself where your curiousity stops. Also, one can pass through these stages very quickly indeed if one simply decides one wants to learn shell scripting.

  1. “I need this program, so I guess I'll use the command-line.”

    It starts, usually, because people find that they need something specialist or tricky, and the program that Google/a forum/a friend recommends for the turns out to be a command-line program. So, they open a terminal, and type what the instructions tell them to type, and this is how they come to use the terminal. Examples of such programs that make you use the command-line:

    • LaTeX/TeX/ConTeXt (different flavours of the same system) takes a text file, and turns it into a beautiful PDF document. See this showcase for examples; I rather like ‘pp’ and ‘LM-Volume-manuscript’.
    • rename is a lovely little program that lets you rename tons of files according to a pattern. A simple example: rename s/myfile([0-9]+).txt/$1-myfile.txt/ turns all files named like 'bond007.txt' into '007-bond.txt', no matter what the number is. Perhaps you want to rename some music album files, you see.
    • Perhaps you want to run a website from your computer, and you discover that if you want to tell the webserver to run/halt/refresh its configuration, you have to issue a terminal command.

    Note that there are graphical front-ends for many of these systems, but that's beside the point: command-line invocation is common and traditional, many HOWTOs assume this, and this is how it starts. Because:

  2. “Okay, I'm a bit more comfortable now.”

    Once inside the command line, people start thinking: Wouldn't it be easy if I could just ..

    • ... change directories to look inside another one? (cd mydir, for 'change directory')
    • ... get a quick reminder of the text files in this directory? (ls *.txt, for 'list')
    • ... move/rename a file? copy a file? delete a file? (mv myfile newname, cp myfile mycopy, and rm myfile, for 'move', 'copy', and 'remove')
    • ... open this file for editing/viewing? (gedit myfile, or leafpad, or nano, or vim, or whatever.)

    Once people have learned these five commands, they are essentially comfortable in the command line: they can move, look, and interact. It's even a bit powerful: you can operate on whole groups of files at once with commands like mv iceland-*.jpg My_Iceland_Pics/, and isn't that cool?

    Now, a lot of people happily stop here. They know how to use the terminal, they'll use it when they need it, and that's all. This is the "the terminal is useful" level. People who prefer the terminal, however, usually do so because they need/want/feel they can't do without the spectacular power that scripting offers. And that usually starts like this:

  3. “Hey, a script is just some commands in a file!”

    This realisation may lead to several further changes, depending on the person. Many just go 'meh', of course; there's no point in learning what you don't need. Anyway, things like this may happen:

    • You start using little scripts to automate boring stuff. Some you write yourself; some you get from someone else; and eventually, you start modifying other people's scripts.
    • You discover that a huge category of things that you used to do by hand, because it required thinking-in-between, can be automated using these two constructs:
      • if something_is_true; then step1a; step2; else step1b; fi, and
      • for file in list_of_files; do process1 $file; process2 $file; step3; done
    • Faced with a boring or complex task, you find that you would rather write a script for it than do it by hand. This is not even for time savings or reuseability, necessarily, but simply because it's more fun.
    • You start using the 'use script on source file' workflow a lot, because it fits the way you think.

You may not experience all, or even any, of these things. The more apply to you, however, the better the terminal will be for you. You'll find out for yourself how much you end up using it. Have fun!

Post scriptum. In programming the script -> run -> result and input -> process -> output workflows are hugely common, and the terminal is spectacularly suitable for these workflows. Add to this the fact that the shell really is nothing but another programming language, and you'll see why there is such a huge overlap between command-line users and programmers.

2
  • 2
    I am guessing you used vim to write this post.
    – jokerdino
    Feb 21, 2012 at 18:22
  • 5
    @jokerdino: No, but I should have. :-)
    – Esteis
    Feb 21, 2012 at 19:19
15

Another point to add: It's fun to use the command line! ;)

(http://vladdolezal.com/blog/2008/the-real-reason-we-use-linux/)

2
  • +1 nice article. I do feel like I'm a part of a special "clique."
    – Aaron
    Feb 21, 2012 at 1:15
  • I would modify it to say it's fun once you've learned a few of the many tricks and techniques, especially editing commands. The biggest improvement for me was learning enough to begin to understand the stuff in "man bash". Feb 21, 2012 at 22:41
12

I was just answering a similar question like this the other day. It turned out this person never used keyboard shortcuts to do anything, so it turned out to be a long discussion. I hope you have some familiarity with those...it would make my points more understandable.

Consider using a word processor. If you save a file, you might use a keyboard shortcut like ctrl-s. Someone might say, "I prefer to use the menu. It doesn't save me much time to use the shortcut. And if you have to save a new file you have to navigate through the file system to the directory, and then type the name anyway." So this objector is correct that each keyboard shortcut by itself does not save a significant amount of time. The true savings is in chaining shortcuts together, e.g. select all, cut, paste. Even the word processor makers have realized this and made it more convenient to access the file structure using the keyboard, e.g. being able to access recent folders/locations using tab and arrow keys.

Of course selecting pieces of text requires the mouse oftentimes... this is why programmers and people that do a lot of editing prefer to use a text editor that supports full keyboard use so you never have to use a mouse. Not only is the mouse slow, but it is prone to errors -- it is particularly easy to select or delete the wrong text.

Now what does this have to do with the command line? An advantage of the command line is that it avoids using the slow, error-prone mouse. Instead, you type and you do it from one location; you don't have to be looking around for another menu or clicking over there and then over here. It's the same reason people like using web browser keyboard shortcuts (to open new tabs/windows, to use Gmail, etc.); they're going to have to type the URL (or email or whatever) in anyway...why move your hand away from the keys?

But most importantly, just like keyboard shortcuts are the most powerful when you start using them all together (rather than just one or two), you can chain commands together to do more powerful things that would either take forever through the GUI or you couldn't even imagine doing at all. For example, from the command line, you can tell your web browser, I want to keep refreshing this webpage every 30 seconds, look for a certain text and when that happens, send me and a group of contacts an email saying that text has appeared on the webpage. As another example, you can tell your computer, I want to look through ALL the emails I ever wrote, look for a reference to this particular book, produce a list of dates I've mentioned this and who to, order the list according to frequency, and put it into this email I'm typing now.

3
  • using screen in a console, I rarely ever use a mouse unless it is to navigate a website anymore. (No one had better mention lynx...)
    – Huckle
    Feb 21, 2012 at 4:26
  • 1
    +1 for the keyboard shortcuts. It's ridiculous how many people claim Linux is faster to use because of the CLI (and hence the keyboard), and yet they don't know how to use the keyboard to accomplish anything in Windows. It's like claiming a tricycle is more advanced/easier to use than a bicycle that has training wheels.
    – user541686
    Feb 21, 2012 at 8:14
  • I'll be the first to say that I know Windows keyboard shortcuts better than Gnome ones, but that's because I spend most of my *nix time on servers. But ALT+Space+N, ALT+TAB, ALT+SPACE+M+(Arrow) all have Gnome equivalents (I believe).
    – Huckle
    Feb 21, 2012 at 16:27
11

The CLI is fast to use when you know exactly what you want to do and how to do it. It can be much more efficient than using a gui. Also, if you want to connect remotely to your machine the CLI is far easier on a slow link. If you are comfortable with the CLI you can take advantage of scripting too.

If you google cli vs gui you will get tonnes of hits eg:

http://www.computerhope.com/issues/ch000619.htm

Your question is not really specific to Ubuntu, linux or even pc's - you get a debate on this subject from any system that supports gui and cli, e.g. configuring Cisco routers.

1
  • With configuration files, one advantage of just editing them from the command line is knowing what's happening to the file. If you append a certain command, you now know the file has that extra line. With the GUI, sometimes it's actually unclear what you did or what effect your checking/unchecking the box will do. I suppose the disadvantage is that config files can be hard to read. Feb 28, 2012 at 20:57
10

There are a number of good points made in the answers but I still have an additional point to make. Sometimes after an install or or update a GUI application won't start and leaves you without any error messages. In these cases it can be very helpful to open a terminal window and start the ap from the command line. There's almost always more information provided on the terminal than presented when starting from the GUI.

8

My favourite is less typing. How can this be I hear you ask. Well I login, reverse search or up arrow) for a command I typed last week and hit carriage return. The alternative is far more mouse clicks (and trying to remember).

My second favourite is it makes it easier to answer questions on stack-overflow; No screen shots needed, just text.

2
  • 5
    +1 for less typing. The obvious question is how a keyboard interface can result in less typing, but it does. You don't always realize how often you repeat the same tasks over and over again until you look at your bash history. Feb 23, 2012 at 12:04
  • I did a small study of button presses, comparing mouse and keyboard. This ignores all sliding of the mouse, just the clicks, and every keyboard key press (This methodology under-estimates mouse effort). I counted up the score/effort for doing some everyday tasks using each method. The only keyboard short-cuts used were reverse search(ctrl-r), arrow-keys and tab. Lower score is better. In conclusion, Using the keyboard with Reverse search(ctrl-r), arrow-keys and tab, is less effort that using mouse, for most everyday tasks. Jan 16, 2016 at 22:47
5

What about when you need to do something as "root"? Logging-in via the GUI as root is a bad idea (and I don't even think Ubuntu will allow you to do so, by default).

Also, consider that the Linux GUI (X11) is simply a running program just like everything else. If X11 should crash, you'll be glad you know your command-line.

5

I just want to contribute with an example, that I find very useful, from the instructions for adding the PPA for VirtualBox. When you add a PPA, you should also register the public key, so GUI method:

  • download the key with Firefox (or other browser)
  • open Synaptic (or other APT gui)
  • search for right menu item
  • browse for the downloaded file
  • finally confirm

Explaining this in a user guide can be expensive! Instead, it can be done with a single & simple command line:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
1
  • 1
    Except that downloading keys does not require human consciousness, therefore it is unnecessary burden to do it manually. Feb 22, 2012 at 7:08
3

The command line works pretty well as it does in windows -remember that text entry msdos box with the black background?

It gives the user a means of issuing commands directly to the computer without the drain on the computer's resources that a GUI brings. It is also a way of issuing powerful commands in order to do things which can not be done via a GUI.

I'm not knocking the usefulness of the GUI way of working but in the hands of a skilled op, the command line way can be extremely fast and efficient. In the hands of a real wizard the command line works miracles. I've barely scratched the surface of the possibilities, learn something new every day. I'll never be a wizard -too old- but I'd like to be an average op one day...

Welcome to Ubuntu and to Ask Ubuntu. This is a great place!!

3

For a beginner, the terminal is a chore to use, but if you start learning how to use it, it becomes easier. Once you feel comfortable with it, it gives you a feeling of confidence that you can handle things when they go wrong.

For example, when a gui program refuses to launch, and you have no clue as to what is wrong, you can run the command in a terminal, and often see the reason for the problem in the terminal output. Then, you can copy some of that into a search, and find the answer, if needed.

You can enter a command with "--help", and get a list of command line options that might be useful for some special cases.

If something goes wrong, and the GUI won't even run at all, you can often open a virtual terminal or possibly just a command line from bootup, and fix the problem by editing a config file, or running a commandline program.

2

Simply put, you have more than hundred keys that can control/talk/order the computer rather than one single mouse with two or three buttons. The more the controls you have, the faster you can be.

For anyone who does not know typing, an on-screen keyboard might look great. However faster you can use the mouse, you cannot type faster than you can using keyboard.

If you are using mouse/windows, its like the computer controlling you and dictating what you can do. When you get used to the command line world, you can feel the whole system under your control waiting for your order. You need to experience it to understand the difference.

1

I don't even see the point of checking off an answer lol. Anyhow. Terminal is like your CMD on Windows. Back in the days, before GUI appeared, people program and work under DOS mode, pretty much plain Terminal. GUI is made to make task simpler and easier, but sometimes using GUI actually requires more work.

For example, as a developer, if I just want to compile a C++ program, I don't have to use sophisticated IDE. IDE is a GUI interface which has many advanced features that a simple text editor does not offer. So instead of downloading a really huge IDE for a simple task, I can just write the following and it will execute my C++ program, whose executable file is called main.

g++ -o main main.cpp
chmod 777 main
./main

If you do interpreter language like Python, you can enter the Python interactive shell. Yes. There are interactive shells that are wrapped in nice GUI, but it's slower and buggy (oh think of IDLE...)

Sometimes when GUI is broken, you can try to use Terminal to open it. Sometimes, some softwares in Linux don't offer good GUI or it is very difficult to find where the GUI launcher is, you just go to Terminal and type, for example:

xpdf homework.pdf

This will open the homework.pdf for you.

In another situations, GUI doesn't offer enough power and magic to do your task. Some search functions are very basic, and you can't apply depth-search, or complicated search pattern. But through terminal, a command can be issued with really really complicated and long pattern.

GUI is nice, but sometimes through commands you can make things simpler too. Sometimes you just don't have a choice: you have to use commands through terminals.

1

I would add a side point that seems to not be mentioned, even if it's not a true advantage.

Think about the fact that the GUI is like a "panel" that gives access to the functions that the real program has. Many software, especially if in an early version, doesn't have a GUI, and you can run them only from the terminal. And, as others pointed out, even the applications which have a GUI, sometimes don't have interfaces for all functions; for those functions, you have to use the terminal.

0

Everyone has described the advantages well, I would just like to add that apart from transparency where you get to see all the dependencies listed, its speed. After demise of synaptic from Ubuntu, the software center is just too laggy especially on slower machines, here install from terminal is way faster.

1
  • 3
    Although Synaptic isn't part of the default install it's still available for install from the Software Center.
    – fragos
    Feb 21, 2012 at 21:22

Not the answer you're looking for? Browse other questions tagged .