When prompted for a password, enter the sudo password.Įdit the file as normal and save it using the toolbar. Replace /path/to/filename with the actual file path of the configuration file that you want to edit. To open a config file using the emacs editor, type emacs followed by filename along with the file path in the below syntax: $ sudo emacs /path/to/filename Once done with the installation, you can open and edit any config file in it.
Type the below command in Terminal as sudo: $ apt-get install emacs To install Emacs editor, launch Terminal by pressing Ctrl+Alt+T key combinations. It has so many features including a built-in web browser, calculator, calendar, Terminal, etc. You have to manually install it using the Ubuntu Terminal. Using Emacs EditorĮmacs is also a text editor but it is not a built-in editor. In Gvim editor, you can do various functions using the toolbar just like any normal GUI application like saving the file, undo, redo, finding a keyword, etc. Press I to enter in insert mode where you can edit the file. Type the below command with sudo in Terminal to open any config file in Gvim: $ sudo gvim /path/to/filename then type the below command in Terminal to start the installation. To install Gvim, launch Terminal by pressing Ctrl+Alt+T. Gvim is a Vim editor with a graphical user interface. To combine the above actions type :wq to save and quit simultaneously.To quit the editor, type : q in command mode.To save the file, type : w in command mode.When done with editing, get out of this mode by pressing Esc.To edit the file, Press I from the keyboard to enter into insert mode, here you can do editing just like the normal editor.Here are the few steps to edit a file in Vim editor: Note that when the editor opens, you enter command mode. Then type vi as sudo followed by filename along with the file path like: $ sudo vi /path/to/filename To open a file in Vim editor, open the Terminal window by pressing the Ctrl+Alt+T key combinations. Using Vim, you can edit and view multiple files in one session. However, once you learned it, it is a more quick and powerful tool for editing. It has no visible prompts or control that can be a little harder for beginners.
Vim or Vi editor also comes pre-installed with most Linux distributions. Once you have done editing, press Ctrl+O to save and Ctrl+X to exit the Editor. Now you can edit and make changes in the config file using nano editor. Advertisement $ sudo nano /path/to/filename Then type nano followed by the filename that you want to edit. Navigate to the directory where the file is placed. To edit any config file, simply open the Terminal window by pressing the Ctrl+Alt+T key combinations. For instance to save a file, press Ctrl+O. They are displayed at the bottom and can be triggered with the Ctrl key. You do not have to learn the Nano editor before using it and also there is no need to remember the commands. Nano is the simplest and the most powerful built-in editor in the many Linux distributions. Once you have done with the editing, press Ctrl+S to save the file. As soon as the editor window opens, you can start typing or editing without entering in any mode.
It is like the notepad editor in Windows OS. When prompted for a password, enter sudo password.Įxample: editing of the /etc/nf file Then type the below command as sudo: $ sudo gedit /path/to/filename To edit a config file in the text editor, launch Terminal by pressing Ctrl+Alt+T key combinations. It is a simpler and easier text editor as compared to other available text editors. It supports tabs so you can open different files in multiple tabs. Gedit is the default text editor of the Gnome desktop environment.
By using these editors, you can easily edit files in the terminal. Now let’s take a look at these text editors. The steps described in this guide have been tested on Ubuntu 22.04, but will work on other Ubuntu versions as well. In this article, I describe several ways to edit configuration files in Ubuntu.
To make configuration changes, you need to open the file with a text editor and edit it. Some examples of configuration files are /etc/hosts, nf, hosts. Configuration files on Ubuntu are stored in subdirectories of the /etc folder as text files and can be edited with text editors.
Linux users, especially Linux administrators, need to know how to edit configuration files to maintain an Ubuntu server or desktop. Configuration files contain the information needed to control the operation of a program.