Chapter 5

Working with Text Files

In This Chapter
Using vim and vi to edit text files
Searching for files
Searching in files

When the UNIX system, on which Linux was based, was created, almost all information was managed on the system in plain-text files. Thus, it was critical for users to know how to use tools for searching for and within plaintext files and to be able to change and configure those files.

Today, most configuration of Linux systems is still done by editing plaintext files. Even when a graphical tool is available for working with a configuration file, the graphical tool doesn't provide a way to do everything you might want to do in that file. As a result, you need to use a text editor to configure the file. Likewise, some document file types, such as HTML and XML, are also plaintext files that can be edited manually.

Before you can become a full-fledged system administrator, you need to be able to use a plain-text editor. The fact that most professional Linux servers don't even have a graphical interface available makes manual editing of plaintext configuration files necessary.

Once you know how to edit text files, you still might find it tough to figure out where the files are located that you need to edit. With commands such as find, you can search for files based on various attributes (filename, size, modification date, and ownership, to name a few). With the grep command, you can search inside of text files to find specific search terms.

Editing Files with ...

Get Linux Bible, 8th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.