After viewing the objectives for the new CompTIA Linux+ exam, I found it difficult to choose my favorite topics. From user management to permissions to service configuration, the content is great — modern, relevant and interesting.
Three topics, however, stand out to me: Git, Vim and Containers. This article provides my thoughts on Vim and file management within the larger context of CompTIA Linux+.
Be sure to read the whole series:
- My CompTIA Linux+ Favorites: Top 3 Favorite Topics From Linux+ (XK0-005)
- My CompTIA Linux+ Favorites: Git
- My CompTIA Linux+ Favorites: Containers
Vim? Again?
For those who have worked with Linux for some time (around one year of experience), Vim is a routine topic. Linux stores its configurations in text files, so administrators must edit these files to manage the servers they're responsible for. Recall that many Linux servers either don’t have a graphical user interface (GUI) installed, or the GUI is rarely launched. Linux administration defaults to the command line, and therefore command line tools are essential – tools like Vim.
Without a menu-driven and mouse-based interface, the features of text editors must be available solely via the keyboard. Vim accomplishes this by using modes and the keyboard responds differently depending on the current mode.
There are three primary modes in Vim:
- Command
- Execute
- Insert
Command and Execute modes cause the keyboard to execute commands against the file. These commands may be fairly simple, such as "Save this file" or "Quit Vim." Other features are far more involved. For example, Vim features a robust screen splitting feature. Insert mode causes the keyboard to respond normally in that it places text in the file. In other words, Insert mode is where you create the actual settings, comments and other values you want to be stored in the file. Command and Execute modes help you manage that content.
Knowing how to move from mode to mode and navigate within file contents is critical. When I cover Vim in training or in articles such as this one, I remind participants that there are four essential things any Linux user must be able to do in Vim:
- Create/open a file
- Edit the file
- Save the changes
- Exit Vim
Any additional tricks or shortcuts are helpful because Vim is common on most distributions and config files must often be edited.
The new CompTIA Linux+ (XK0-005) covers these minimal skills and provides several other useful tips and tricks.
Using Vim for File Management
Creating content with Vim is only part of the story, of course. Files need manipulation, from copying and moving to deleting, Linux relies on a series of file management commands. Understanding how to manage Vim text files is just as important as actually editing them. For example, before opening the SSH daemon file in Vim, it's a good idea to back it up first using the cp command. Or perhaps you used Vim to author some great scripts you're going to share with a colleague. In that case, bundle and compress those files using tar. Basic file management is an essential part of any sysadmin's job.
A Word About Nano
Vim isn't the only Linux text editor, and it's certainly not the simplest. Many users and distributions prefer using Nano. Nano is also a command line editor, but with no GUI menus or other features. However, instead of modes, it uses meta keys to alter how the keyboard responds to key presses. Nano defaults to the keyboard inserting text, but selecting Ctrl+O, for example, writes out or saves the content. Ctrl+X exits the program. Today's Linux users need at least a passing familiarity with both tools.
The Go-to Utility for Sysadmins
Vim is certainly not a new topic in CompTIA Linux+ (XK0-005), but it is a critical one. Many administrative tasks are managed from configuration files that must be edited and customized. From scripting to standing up an Apache webserver to securing SSH connections, Vim is the go-to utility for sysadmins. I was careful to place the Vim coverage near the front of the course because so many of the later topics rely on it, including network management, containers, Infrastructure as Code (IaC) and security settings.
I enjoy Vim enough to have added various plugins to it. As a writer, it's a tool I rely on regularly. In fact, do you want to guess what I used to draft this article?
Stay tuned for my final “favorites” article on containers.
See all the topics covered by CompTIA Linux+ (XK0-005) by downloading the exam objectives for free.