bash ifconfig command not found add net-tools package

If you enter “ifconfig” in the bash on modern Linux operating systems, you will see command not found, because missing the net-tools package.

bash ifconfig command not found add net-tools package

-bash: ifconfig: command not found

ifconfig is the utility for viewing and setting the network configuration on Red Hat, Fedora, CentOS, Debian, and Ubuntu Linux systems. The bash command includes the net-tools package, which has been replaced by the iproute2 package.

net-tools contains the bash ifconfig package

The ifconfig binary is supplied with the Debian net-tools package. Install the net-tools package with the following command in bash, which is available under the default repositories.

$ sudo apt install net-tools -y

Then ifconfig can be run to check the network configuration. The following command displays details for all interfaces configured on a Debian system.

$ ifconfig

For RHEL 8 and CentOS 8, the net-tools package is provided with the Manager YUM package.

$ sudo yum -y install net-tools

NOTE: The ifconfig program is deprecated! Replacement is given by the commands ip addr and ip link.

ifconfig shows the output of the network interfaces and their configuration, after installed the net net-tools package.

Now run ifconfig in the bash.

$ ifconfig
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 10.127.0.123 netmask 255.255.255.0 broadcast 10.127.0.255
        inet6 fe80::20b:25ff:fefb:28db prefixlen 64 scopeid 0x20 <link>
        ether 00:0b:25:fb:28:db txqueuelen 1000 (Ethernet)
        RX packets 103153 bytes 86175369 (82.1 MiB)
        RX errors 0 dropped 519 overruns 0 frame 0
        TX packets 47536 bytes 42444582 (40.4 MiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        inet6 ::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loop)
        RX packets 0 bytes 0 (0.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 0 bytes 0 (0.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0</host> </UP,LOOPBACK,RUNNING> </UP,BROADCAST,RUNNING,MULTICAST>

Run the new utility as follows.

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP>mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP>mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0b:25:fb:28:db brd ff:ff:ff:ff:ff:ff:ff
    inet 10.127.0.123/24 brd 10.127.0.255 scope global noprefixroute ens192
       valid_lft forever preferred_lft forever
    inet6 fe80::20b:25ff:fefb:28db/64 scope link
       valid_lft forever preferred_lft forever</BROADCAST,MULTICAST,UP,LOWER_UP> </LOOPBACK,UP,LOWER_UP>

The ifconfig eth0 command is replaced by ip link.

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP>mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00:00
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP>mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:0b:25:fb:28:db brd ff:ff:ff:ff:ff:ff:ff</BROADCAST,MULTICAST,UP,LOWER_UP> </LOOPBACK,UP,LOWER_UP>

To output the routing table, the ip route command is executed instead of route.

$ ip route
default via 10.127.0.1 dev ens192 proto static metric 100
10.127.0.0/24 dev ens192 proto kernel scope link src 10.127.0.123 metric 100

Change Computer Name or Hostname

Rename a Computer Name or the Hostname

Hostname is the unique name of a computer under which the systems can be recognized and identify each other in the network.

The Hostname is usually queried in the installation dialog and set during installation. This post shows how to change the Hostname on Linux and the Computer Name on Windows and macOS.

How to Rename Windows Computer Name

For Windows, the Computer Name can be assigned in the System Properties MMC-Console.

Windows Logo + R

Hit keyboard shortcut Win+R and type SYSTEMPROPERTIESCOMPUTERNAME
to open the MMC-Console.

Run SYSTEMPROPERTIESCOMPUTERNAME
Windows System Properties - Change Computer Name

Click on the Change button to rename the computer. After the change done, Windows must be restarted.

If you want to go through the Windows 10 settings, go to Start – Settings – System – About – Rename this PC.

In the Windows Command prompt there is the command hostname and ipconfig to output the computer name.

hostname
ipconfig /all | findstr hostname

This option is particularly suitable for batch processing. The query with output in the command prompt (cmd) shows below.

Command prompt to rename hostname
Illustration: command prompt run hostname, ipcconfig /all | findstr Hostname

View Windows Computer Name in PowerShell

$env:computername

The Windows Computer Name can also be renamed in PowerShell. To do this with open PowerShell as an administrator.

Rename-Computer -NewName NewComputerName

If the Computer is in a Windows domain, the following command can be used to rename it.

Rename-Computer -NewName NewComputerName -DomainCredential domain\Administrator -PassThru

Instead of NewComputerName, enter the actual computer name, with DomainCredential you authenticate as a domain administrator.

Change Linux hostname

Linux hostname can be queried by run hostname command.

$ hostname
$ zeus.simple.foo

Output Linux system status with hostnamectl status.

$ hostnamectl status
   Static hostname: zeus.simple.foo
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 94c14d79bb182e1aa3f0171a0eb05e79
           Boat ID: c28ea53f380c4e0eabe696f08128585c
    Virtualization: vmware
  Operating System: Debian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.0-13-amd64
      Architecture: x86-64

In the terminal run hostnamectl set-hostname to change it.

hostnamectl set-hostname NewHostname.domain.foo

With earlier versions like CentOS 5 or Debian 7 the query as well as the change takes place with the command hostname.

hostname NewHostname.domain.foo

To make hostname persistent save it in to the file /etc/hostname.

Edit macOS Computer Name

View and change the computer name on macOS. To do this, go via the Apple logo – System Preferences – Shares.

View and change your computer name on macOS

For Computer Name, this is set by clicking on Edit.

Alternatively, there is also the possibility to change the computer name in the macOS terminal.

sudo scutil --set HostName "NewHostname.domain.foo"

To check the change, the Mac Terminal must be closed, when reopened the new hostname appears in the prompt.