How To Edit Files In Linux?

Linux provides different ways and tools in order to edit files. These methods can be called command-line editors and GUI editors. As a text-based operating system and most of the configuration is stored as a text file the configuration changes generally require editing files.

Why Edit Files In Linux?

As stated Linux is a command line and text based operating system the files can be edited for different reasons.

  • Change a text file
  • Change network and system configuration
  • Add and remove data into text-based database
  • Change apache web server configuration
  • Open log files

Linux File Editing Tools

Linux is free and open source operating system which provides a lot of different file or text editor in order to edit files. Some of the are command line which can be work over SSH connection, console and some of them are GUI based which requires desktop environment.

TEXT EDITOR NAMETYPEDESCRIPTION
vicommand line
vimcommand line
GvimGUI
KwriteGUI
GeditGUI
Notepad++GUI

Edit Files with Vim/Vi

Vim or Vi is one of the most popular command-line text editors which can be used to edit files in Linux. Vim is the next generation of the vi file editor which is managed with commands and keys. In order to edit a file with Vim/Vi, we should open the file from the command line.

$ vim /home/ismail/file.txt

Now we should change into the edit mode with the i key like below. But before we will sure the command mode is enabled.

ESC+i

Now we can edit our file. After the edit is completed we will save the changes with the ESC and then :w keys.

READ  Linux ldconfig Command Tutorial

Edit Files with Nano

Nano is a command line text editor too but it is more traditional then vim. Nano uses keys in order to edit and save a file. We will open the file with the nano command like below.

$ nano /home/ismail/file.txt

Move the cursor to the position you want to change and make changes. After you have completed your changed press CTRL+x in order to exit by saving changes.

Leave a Comment