The Linux Command Line Versus Graphical User Interfaces

Weighing the pros and cons

Businessman on computer
Comstock Images/Stockbyte/Getty Images

Deciding when you should use the Linux command line interface (CLI) and when you should use a graphical user interface (GUI) instead isn't as difficult as you might think. Much comes down to personal preference: Some people are always more inclined to use a terminal window, and others prefer seemingly simpler visual tools. There is no Linus user maxim that states that you should use one tool over another, and in fact, you might find the most efficient, practical approach is to use both the GUI and CLI.

When using the GUI makes more sense

In some circumstances, the graphical application is an obvious choice. For instance, if you're writing a letter to a friend, using a tool such as LibreOffice Writer is much easier and faster than trying to type the letter in a command line editor such as vi or emacs. LibreOffice Writer provides a good WYSIWYG ("what you see is what you get") interface, layout functions, the ability to add tables, images and links, and spell-checking.

With this in mind, coming up with a reason to ever have to use the CLI might seem a fruitless exercise. In fact, many people get by without ever using the terminal at all; you can easily accomplish most tasks without ever having to see the CLI. Most average Windows users probably don't even know a command line option exists.

When using the CLI makes more sense

What the command line provides over a graphical user interface is flexibility and power; in many cases, it is actually quicker to use the command line than to use a graphical tool.

For example, take the act of installing software. Ubuntu has what at first glance seems to be a perfectly good tool for installing software that comes with the operating system. Compared to the command line, however, the software manager is slow to load and cumbersome to search with.

The CLI's apt command lets you search for, install, and remove software and add new repositories with relative ease. When you use the apt command, you can be sure that you're seeing all the applications available in the repositories, whereas the software manager doesn't necessarily catch them all.

In general, applications with GUIs are great for doing the basics, but the CLI tools provide the access to do a bit extra. For example, if you want to see which processes are running in Ubuntu, you can run the system monitor tool. The system monitor tool shows each process, the user the process is running under, how much CPU is used as a percentage, the process ID, memory, and priority. Navigating the system monitor application is very easy, and within a few clicks, you can get detailed information about each process, kill a process, and filter the list of processes to show different information.

What can the command line provide that the system monitor can't? Well, on its own, the ps command can show all processes; show all processes except session leaders; and show all processes except session leaders and those not associated with a terminal. The ps command can also show all processes associated with this terminal or, indeed, any other; restrict the output to only running processes; and show only the processes for a specific command, or for a specific group of users or user. In all, there are hundreds of different ways to format, view, and present the list of processes running on your system using the ps command — and that is just one command. 

Now add to this the fact that you can pipe the output of that command and use it alongside other commands. For instance, you can sort the output using the sort command, write the output to a file using the cat command or filter the output using the grep command.

In essence, CLI tools often are more useful because they have so many switches available to them that would be impossible or unwieldy to include in a graphical application. For this reason, GUIs tend to include the most commonly used features, but to get all of them, the command line is better.

As another example in which a CLI tool is more useful than a graphical tool, think of a large text file of perhaps hundreds of megabytes or even gigabytes in size. How would you view the last 100 lines of that file using a graphical application?

A graphical application would require you to load the file and then either page down or use a keyboard shortcut or menu option to go to the end of the file. In the terminal, you'd simply use the tail command and, assuming that the graphical application is memory-efficient and loads only a certain amount of the file at a time, you can view the end of the file in far less time than the GUI method takes.

The best of both worlds: Using the GUI and the CLI

Thus far, the CLI seems superior to the GUI for anything but letter-writing. This, of course, is untrue. You would never edit videos using the command line, and you are far more likely to use a graphical audio player to set up playlists and choose the music you wish to play. Image editing also clearly requires a graphical user interface.

When all you have is a hammer, everything looks like a nail; however, in Linux, you don't have only a hammer: You have every tool you can conceivably imagine when you use both the GUI and CLI.

If you have no interest in learning about the command line, you can probably get by using the GUI. If you do want to learn a bit to get the absolute most out of Linux, a good place to start is our guide to 10 essential commands for navigating the file system.