Klaus Zimmermann's Corner

Living in the Linux terminal - is it possible in 2021?

Perhaps one of the starkest differences you feel when switching from Windows to Linux for the first time is that sooner or later, invariably you have to do some form of work in the terminal. That is a scary prospect for the sheltered beginner indeed, since typing esoteric commands with mysterious --flags and values in a black screen with nothing but a prompt is the absolute opposite that someone born and raised in a graphical environment is used to doing.

It's not surprising that Linux has its fame for "not being as user-friendly" and beginner distributions are labelled so for abstracting away as much as possible the terminal work. However, like any other tool, once you learn how to use it, you get to know how powerful and convenient the terminal and the shell are, and eventually you get to the point where it's so integrated into your workflow that you can't live without it anymore. When this happens, you may need to shave off some of that Unix beard that may have grown on you.

Jokes apart, the terminal is an integral part of Linux, and using it without touching the terminal is simply incomplete. And the best part is that, despite its 80s appearance, the terminal is by no means a piece of old technology anymore. The terminal evolved together with the GNU/Linux system not alongside, but rather as an integral part of it, and to this day remains the only practical way to do systems administration. The modern-day Linux command-line environment is a robust and practical tool, especially if you use integrate it to a modern graphical environment through a terminal emulator.

However, what if you were to take a step further into the text-only environment and ditched the graphical desktop completely? Yes, I mean pressing Ctrl+Alt+F1 and going back to the Linux Console (or TTY) completely - no use for a mouse. Would it still be possible to "survive" for long enough using only the console in 2021?

To try this proposal out, I set myself a challenge and use nothing more than the console for one week. Every application that I used had to be usable from the console alone, without the use of the X server. I was still allowed to use my phone along the day, but anything involving the computer in my time off work had to be done in the terminal.

Doing this has forced me to learn more how you can solve something without resorting to full-blown graphical programs, and how eclectic the command-line can be. It also, unsurprisingly, didn't prove to be a more efficient way to do work - after all, scrolling, selecting and copying and pasting things with a mouse is pretty fast and convenient. Still, I had other interesting insights, which I'm sharing in this post. Read on!

The Linux Console is not your Grandpa's Command Line Interface

For starters, if you think that the Console is an old-fashioned piece of software just because there isn't any graphical interface or fancy menus to click, you should definitely think again. As stated before, the command-line remains the preferred way to perform administration work in Linux, and for much of the more "complex" tasks, might as well be the fastest - or only - way.

The console has also greatly benefitted from the fact that so many other applications were developed specifically for the text-only environment, processing and facilitating the way data is presented there so that you would not need to open a graphical program to interact with it.

Perhaps unlike some decades ago, today there are browsers, file managers, IM programs, spreadsheet editors, music players, and many, many other text-based programs that work just as well as their graphical counterparts. Not to mention that you can usually "mimic" individual functionalities of programs by chaining around a few commands in a script.

Furthermore, the console nowadays is by itself a modern environment: it fully supports localization, setting and using different keyboard layouts, you can set up the screen brightness, lock and suspend the session, and with a bit of training it feels just like using a graphical desktop environment.

The drawback is that, upon first use, the Console looks and feels rather harsh and unfriendly. Here's a few tips to make it more usable to work on it.

Give the console a fresh look

The standard console that greets you upon boot looks rather dull in comparison even with the terminal emulators you can use in a graphical environment, which is not very encouraging. Thankfully, like everything in Linux, you can also customize how it looks.

My first recommendation is to set a new display font. The default font is sort of ugly and usually very small for screens with modern resolutions, almost unreadable depending on your screen size. There are better selections of fonts available in your system already, usually available under /usr/share/console/ or /usr/share/kbd/, with the .psf.gz or .psfu.gz extensions (psfu for unicode fonts). You can set a new console font with the following command:

sudo setfont /path/to/font/file.psf.gz 

sudo is necessary because unlike graphical terminal emulators, the console is owned by the kernel. To reset to the default font, run setfont without arguments:

sudo setfont # set the default font back 

You can usually read off the size in pixels of these fonts directly from the file name: they are available in a HxW format. I set a font size of at least 20px height, and 22px is the optimal size for me. Very large fonts look ugly to me, and also limit how much stuff can be displayed at a time in the screen. Try a few sizes and find out what works best for you.

There are also many different character sets. The Uni or Lat charsets fit my needs, but you might have to try out a few to find the best. This is the font I use in case you're wondering, which I in turn got from Debian.

The next peeve with a default console is that the colors may not be as attractive as in some graphical terminals. Once again, though, this is customizable, though you need an extra piece of software to do so.

This tiny C program is able to change the colors that are used in the console according to a color scheme file, very similar to how the .Xresources file works. Once you build and install it (just run make), you can use it to change the colors like this:

sudo setcolors colorscheme_file 

Where colorscheme_file is a file in the right format for setcolors. The Github repo contains a few examples and premade colorschemes that you can use right away, or you can make your own through tools like terminal.sexy.

Multitasking just like in a GUI

The next step to making the console fully usable on par with graphical environments is to add to it multitasking capabilities. These are best done via software known as terminal multiplexers.

A multiplexer splits one large terminal screen into multiple subpanes that are independent of each other, resulting in an environment that feels like a tiling window manager. When you don't have a graphical environment available to spawn more terminals or tabs, the multiplexer is the only way to achieve multitasking.

Two of the most popular text-only multiplexers are tmux and GNU screen. I prefer tmux due to the fact that it behaves truly like client-server, with the possibility to detach from sections and back without terminating the session, even from remote machines. Although it might take some time to learn the keys involved in using it, tmux is fast and efficient, and allows you to set up a fully working environment very fast.

tmux also adds a very important feature to working across multiple programs: a clipboard. This not only allows you to select, copy and paste text from the terminal panes manually just like in a GUI, but also allows you to copy the output of commands directly to the paste buffer, much like it's done with xsel or xclip, like this:

command | tmux loadb - # hyphen required. 

And then pasting it with <prefix>+]. It's a useful way to copy passwords from encrypted files without risking printing them to the terminal output.

Another rather new project, the Kitty Terminal Multiplexer adds other modern stuff to the multiplexer world, like highlighting urls for easy opening by a browser. I haven't tried it myself, but hear lots of good things about this new project. There's even a multiplexer that includes visual effects and a screensaver built-in, called neercs (screen backwards).

Regardless of which one you choose, a multiplexer will help make your console work sessions persist consistently, even in the event of suspending the machine. To simulate a "lock on suspend" feature in the command-line only, for example, you could run:

tmux detach # from within the tmux session, return to bare terminal 

And then:

loginctl suspend; logout # order a suspend and immediately logout 

You'll find the username prompt upon awaking, and to resume work, just reconnect to your session via:

tmux attach 

Weapons of choice

Here's a short list of the programs I use in my console-only sessions, that sometimes even fare better than their GUI counterparts:

Media without a GUI?

Finally, to address a growing and pressing question about living only on the console: is it possible, after all, to view images or video without the X server?

The answer, surprisingly, is yes! It's possible to view images and video without starting X by using the computer's framebuffer device. It's a very primitive way to render images and graphical media, but works very well, and it was how early DOS games, for example, were able to run in graphical mode.

For images, the fim (Framebuffer IMproved) program can display images straight from the console via fim image.jpg. For video, the swiss-army knife of mpv can also handle it surprisingly well even on the console by specifying "drm" as the video output mode:

mpv -vo drm video.mp4 

You can even watch YouTube straight from the console if you also happen to have youtube-dl installed, through the following command, which is nothing short from mind-blowing when you think of it:

mpv -vo drm https://youtube.com/watch?v=YOUR_VID_ID 

As weird as it sounds, "drm" here most likely means direct-rendering mode or something, not Digital Restrictions Management.

Conclusion: still possible, but not without caveats

It's possible to live in a Linux terminal even in 2021 for your daily tasks as long as you don't need to do very graphic-heavy work in your routine. Even as powerful as the console is, there are still some things like usage of javascript-intensive webapps, image-heavy work or quick handling of copy and paste that you simply cannot beat having a GUI and a mouse to work. Plus, if you a GUI you can always open a fullscreen terminal and mimic the workflow whereas the opposite is not possible.

The console still is, however, king on things like productivity (stripping out flashy interfaces and colorful images and buttons everywhere reduces distraction enormously), and resource efficiency (512 MB of RAM is more than enough to fit a full-blown work session). It also breeds a learning mentality, as you have to hack your way into commands and options, and how your computer really actually works.

If this describes how you like to use your computer, then I definitely recommend that you try out going console-only for just a bit, and see what you can learn.

Addendum: additional resources

There are many, many other programs and resources out there to enhance your experience with the terminal. Most source and present information from the web so you don't have to open a web browser, others add a little more features and convenience, and some work on data in an equivalent manner as GUI applications, so you don't have to leave the terminal. At any rate, checking them out is strongly recommended.

The awesome-cli-apps Github repo contains a huge list of terminal-based applications for several categories.

This thread on the Arch Linux Subreddit also has some neat tips and tricks, including the aforementioned mpv trick to watch video. Definitely worth checking out.

Have you ever used only the console or the command-line in your computer before? How was the experience? What did you learn? Share with me your thoughts at Mastodon!

This post is number #5 of my #100DaysToOffload project. Follow my progress through Mastodon!

Last updated on 02/15/21