The Linux Command Line Versus Graphical User Interfaces

Weighing the Pros and Cons

Businessman on computer
Comstock Images/Stockbyte/Getty Images

This article is all about deciding when you should use the Linux command line and when you should use a graphical application.

Some people are always more inclined to use a terminal window and others prefer the seemingly more simple visual tools.

There is no magic ball that states that you should use one tool over another and in my experience there are good reasons for using both in equal portions.

In some circumstances the graphical application is an obvious choice.

For instance if you are writing a letter to a friend then a tool such as LibreOffice Writer is much superior to trying to type the letter in a command line editor such as vi or emacs.

LibreOffice Writer has a good WYSIWYG interface, provides great layout functions, provides the ability to add tables, images and links and you can check the spelling of your document at the end.

With this in mind can you think of a reason why you should ever have to use the command line?

In fact many people get by without using the terminal at all as you can easily do most tasks without ever having to use one. Most average Windows users probably don't even know a command line option exists.

What the command line provides over a graphical user interface is flexibility and power and 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.

Within Ubuntu there is what seems on the surface a perfectly good tool for installing software installed as part of the operating system. Compared to the command line however the Software Manager is slow to load and cumbersome to search.

Using the Linux command line you can use the apt command to search for software, install software, remove software and add new repositories with relative ease.

You can guarantee when you are using the apt command that you are seeing all the applications available in the repositories whereas the software manager doesn't.

In general applications with graphical user interfaces are great for doing the basics but the command line tools provide the access to do that bit extra.

For example if you want to see which processes are running within 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 for the process. 

It is very easy to navigate the system monitor application and within a few clicks you can get detailed information about each process, you can kill a process and filter the list of processes to show different information.

On the surface this seems great. 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 all processes except session leaders and processes not associated with a terminal. 

The ps command can also show all processes associated with this terminal or indeed any other terminal, restrict the output to only running processes, show only the processes for a specific command, or for a specific group of users or indeed 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 command line tools are often more useful because they have so many switches available to them that it would be impossible or unwieldy to include all of them in a graphical application.

For this reason graphical tools tend to include the most commonly used features but to get all of the features the command line is better.

As another example where a command line tool is more useful than a graphical tool think of a large text file which is say 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 in the file and then either page down or use a keyboard shortcut or menu option to go to the end of the file. Within the terminal it is as easy as using the tail command and assuming that the graphical application is memory efficient and only loads a certain amount of the file at a time it will be considerably faster viewing the end of the file in the command line than via the graphical editor.

Thus far it seems that except for writing letters the command line is superior to using graphical user interfaces except of course this 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 within Linux you don't only have a hammer. Within Linux you have every tool you can conceivably imagine.

If you have no interest in learning about the command line then you can probably get by using the graphical tools available but if you do want to learn a little bit then a good place to start is with this guide which highlights 10 essential commands for navigating the file system.