Config command in linux

How to Edit Config Files in Ubuntu

Configuration files contain the information required to control the operation of a program. Linux users, especially Linux administrators, must know how to edit configuration files to maintain an Ubuntu server or desktop. Configuration files on Ubuntu are stored in subdirectories of the /etc folder as a text file and can be edited using text editors. Some of the examples of config files are host.conf, hosts. resolv.conf, networks, syslog.conf etc. in Linux-based operating systems.

To make any configuration changes, you have to open and edit the file using a text editor. In this article, I will describe multiple ways to edit config files in Ubuntu. The steps described in this guide have been tested on Ubuntu 20.04, but they will work on other Ubuntu versions too.

  • Using Gedit Editor
  • Using Nano Editor
  • Using Vim Editor
  • Using Gvim Editor
  • Using Emacs Editor

Now let’s take a look at these text editors. By using these editors, you can easily edit files in terminal .

Using Gedit Editor

Gedit is the default text editor of the Gnome desktop environment. It supports tabs so you can open different files in multiple tabs. It is the simpler and easier text editor as compared to other available text editors.

To edit a config file in text editor, launch Terminal by pressing Ctrl+Alt+T key combinations. Then type the below command as sudo:

Replace /path/to/filename with the actual file path of the configuration file that you want to edit. When prompted for a password, enter sudo password.

Example: editing of the /etc/resolv.conf file

It is like the notepad editor in Windows OS. As soon as the editor window opens, you can start typing or editing without entering in any mode. Once you have done with the editing, press Ctrl+S to save the file.

Using Nano Editor

Nano is the simplest and the powerful built-in editor in the many Linux distributions. You do not have to learn the Nano editor before using it and also there is no need to remember the commands. They are displayed at the bottom and can be triggered with the Ctrl key. For instance to save a file, press Ctrl+O.

To edit any config file, simply open the Terminal window by pressing the Ctrl+Alt+T key combinations. Navigate to the directory where the file is placed. Then type nano followed by the filename that you want to edit.

Replace /path/to/filename with the actual file path of the configuration file that you want to edit. When prompted for a password, enter sudo password.

Читайте также:  Windows 10 x64 winpe

Now you can edit and make changes in the config file using Nano editor.

Once you have done editing, press Ctrl+O to save and Ctrl+X to exit the Editor.

Using Vim Editor

Vim or Vi editor also comes pre-installed with most Linux distributions. It has no visible prompts or control that can be a little harder for beginners. However, once you learned it, it is the more quick and powerful tool for editing. Using Vim, you can edit and view multiple files in one session.

To open a file in Vim editor, open the Terminal window by pressing the Ctrl+Alt+T key combinations. Then type vi as sudo followed by filename along with the file path like:

Replace /path/to/filename with the actual file path of the configuration file that you want to edit. When prompted for a password, enter sudo password.

Then edit the file using Vim editor. Note that when the editor opens, you enter command mode. Here are the few steps to edit a file in Vim editor:

  • To edit the file, Press I from keyboard to enter into insert mode, here you can do editing just like the normal editor.
  • When done with editing, get out of this mode by pressing Esc. It will return you to normal mode.
  • To save the file, type :w in command mode
  • To quit the editor, type :q in command mode
  • To combine the above actions type :wq to save and quit simultaneously.

Using Gvim Editor

Gvim is a Vim editor with a graphical user interface. To install Gvim, launch Terminal by pressing Ctrl+Alt+T. then type the below command in Terminal to start the installation.

Once done with the installation, you can open and edit any config file in it. Type the below command with sudo in Terminal to open any config file in Gvim:

Press I to enter in insert mode where you can edit the file.

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.

Using Emacs Editor

Emacs is also a text editor but it is not a built-in editor. You have to manually install it using the Ubuntu Terminal. It has so many features including a built-in web browser, calculator, calendar, Terminal, etc.

To install Emacs editor, launch Terminal by pressing Ctrl+Alt+T key combinations. Type the below command in Terminal as sudo:

Once done with the installation, you can open and edit any config file in it.

To open a config file using emacs editor, type emacs followed by filename along with the file path in the below syntax:

Replace /path/to/filename with the actual file path of the configuration file that you want to edit. When prompted for a password, enter sudo password.

Edit the file as normal and save it using the toolbar.

You can also open the config file in bash instead of a separate window.

Type the following command as sudo in Terminal:

Edit the file as a normal text file. Then press Ctrl+X and Ctrl+C to save the file. When it prompts for saving the file, press y to save and quit the editor.

So these were some simple editors you can use to easily and safely edit config files in your Ubuntu operating system.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Читайте также:  Не могу подключиться vpn windows 10

Источник

15 Useful “ifconfig” Commands to Configure Network Interface in Linux

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage and query network interface parameters via command-line interface or in a system configuration scripts.

The “ifconfig” command is used for displaying current network configuration information, setting up an ip address, netmask, or broadcast address to a network interface, creating an alias for the network interface, setting up hardware address, and enable or disable network interfaces.

15 Useful ifconfig Commands

This article covers “15 Useful “ifconfig” Commands” with their practical examples, which might be very helpful to you in managing and configuring network interfaces in Linux systems.

Update: The networking command ifconfig is deprecated and replaced by the ip command (Learn 10 Examples of IP Command) in most Linux distributions.

1. View All Network Interface Settings

The “ifconfig” command with no arguments will display all the active interfaces details. The ifconfig command is also used to check the assigned IP address of a server.

2. Display Information of All Network Interfaces

The following ifconfig command with the -a argument will display information of all active or inactive network interfaces on the server. It displays the results for eth0, lo, sit0 and tun0.

3. View Network Settings of Specific Interface

Using interface name (eth0) as an argument with the “ifconfig” command will display details of the specific network interface.

4. How to Enable a Network Interface

The “up” or “ifup” flag with interface name (eth0) activates a network interface if it is not inactive state and allowing to send and receive information. For example, “ifconfig eth0 up” or “ifup eth0” will activate the eth0 interface.

5. How to Disable a Network Interface

The “down” or “ifdown” flag with interface name (eth0) deactivates the specified network interface. For example, the “ifconfig eth0 down” or “ifdown eth0” command deactivates the eth0 interface if it is in an inactive state.

6. How to Assign an IP Address to Network Interface

To assign an IP address to a specific interface, use the following command with an interface name (eth0) and ip address that you want to set. For example, “ifconfig eth0 172.16.25.125” will set the IP address to interface eth0.

7. How to Assign a Netmask to Network Interface

Using the “ifconfig” command with the “netmask” argument and interface name as (eth0) allows you to define a netmask to a given interface. For example, “ifconfig eth0 netmask 255.255.255.224” will set the network mask to a given interface eth0.

8. How to Assign a Broadcast to Network Interface

Using the “broadcast” argument with an interface name will set the broadcast address for the given interface. For example, the “ifconfig eth0 broadcast 172.16.25.63” command sets the broadcast address to an interface eth0.

9. How to Assign an IP, Netmask, and Broadcast to Network Interface

To assign an IP address, Netmask address, and Broadcast address all at once using the “ifconfig” command with all arguments as given below.

10. How to Change MTU for a Network Interface

The “mtu” argument sets the maximum transmission unit to an interface. The MTU allows you to set the limit size of packets that are transmitted on an interface. The MTU is able to handle a maximum number of octets to an interface in one single transaction.

Читайте также:  Mac os big sur icons png

For example, “ifconfig eth0 mtu 1000” will set the maximum transmission unit to a given set (i.e. 1000). Not all network interfaces support MTU settings.

11. How to Enable Promiscuous Mode

What happens in normal mode, when a packet is received by a network card, it verifies that it belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flow through the network card.

Today’s network tools use the promiscuous mode to capture and analyze the packets that flow through the network interface. To set the promiscuous mode, use the following command.

12. How to Disable Promiscuous Mode

To disable promiscuous mode, use the “-promisc” switch that drops back the network interface in normal mode.

13. How to Add New Alias to Network Interface

The ifconfig utility allows you to configure additional network interfaces using the alias feature. To add the alias network interface of eth0, use the following command. Please note that the alias network address is in the same subnet mask. For example, if your eth0 network ip address is 172.16.25.125, then the alias ip address must be 172.16.25.127.

Next, verify the newly created alias network interface address, by using the “ifconfig eth0:0” command.

14. How to Remove Alias to Network Interface

If you no longer required an alias network interface or you incorrectly configured it, you can remove it by using the following command.

15. How to Change the MAC address of Network Interface

To change the MAC (Media Access Control) address of an eth0 network interface, use the following command with the argument “hw ether“. For example, see below.

These are the most useful commands for configuring network interfaces in Linux, for more information and usage of the ifconfig command use the manpages like “man ifconfig” at the terminal. Check out some other networking utilities below.

Other Networking Utilities

  • nmcli – a command-line client that is used to control NetworkManager and report network information.
  • Tcmpdump – is a command-line packet capture and analyzer tool for monitoring network traffic.
  • Netstat – is an open-source command-line network monitoring tool that monitors incoming and outgoing network packets traffic.
  • ss (socket statistics) – a tool that prints network socket-related information on a Linux system.
  • Wireshark – is an open-source network protocol analyzer that is used to troubleshoot network-related issues.
  • Munin – is a web-based network and system monitoring application that is used to display results in graphs using rrdtool.
  • Cacti – is a complete web-based monitoring and graphing application for network monitoring.

To get more information and options for any of the above tools, see the man pages by entering “man toolname” at the command prompt. For example, to get the information for the “netstat” tool, use the command “man netstat“.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Оцените статью