The gedit (GNOME Editor) is a flexible plugin for creating and editing files in Linux using the terminal. Other editor tools are available such as nano and vim, but gedit is preferred if the user wants to edit the file graphically. It is pre-installed by default in all the renowned Linux distributions.
This article will demonstrate the usage of the gedit command in Linux.
- Usage of the gedit Command
- Options and Detailed Usage
How to Use the gedit Command in Linux?
As mentioned earlier, it is the file text editor. The syntax for using gedit is given below:
$ gedit [OPTION...] [FILE...]
Use the “gedit” keyword, “options” along with the gedit command, and the filename which you want to edit.
Options and Detailed Usage:
To display the options for using the gedit command, run the help command in the terminal:
$ gedit --help
Example 1: Opening GNOME Text Editor With “w” Flag
Using the gedit command with the “w” option will block the processes until the user closed the file:
$ gedit -w
After running the above, the text editor will be opened:
Write the content in the editor and save it using the “save” button:
After clicking on the “save” button, give the file a name and the Linux will ask for the location of the file where you want to save it.
Example 2: Opening GNOME Text Editor For Specific Files with “s” Flag
The “s” flag will open the text editor in standalone mode. Use the file name or path with the gedit command and the “s” option. We have a C program file in our home directory with the name “file.c”, let’s open it in standalone mode:
$ gedit -s file.c
The file “file.c” has been opened and can be used for editing.
Example 3: Opening GNOME Text Editor For System Files
To open the system files in Linux, use the “sudo” privileges to edit them. Otherwise, it will open them in read-only mode. Let’s open the “services” file in the “/etc/services” directory:
$ sudo gedit /etc/services
The content of the services file has been listed.
To use the gedit (GNOME Text Editor) command in Linux, open the terminal and type gedit with options and file name to edit the files. It can be used for editing specific files or system files with the “sudo” privileges. This write-up has illustrated the usage of the “gedit” command in Linux.