This trivial guide is a small introduction to CentOS and then a brief discussion on how we can get the server IP address in CentOS using the command-line interface (CLI).
This article will discuss some of the commands for the said purpose and their usage. Let’s begin with the introduction of CentOS.
Introduction to CentOS
CentOS, the shorthand for Community Enterprise Operating System, is a Linux distribution founded by Gregory Kurtzer that offers a free enterprise class and is an open-source operating system.
It is suited to Red Hat Enterprise Linux (RHEL), its upward source. RHEL is an enterprise-class operating system but is not free of cost and generally requires a payment for its subscription.
CentOS developers use the RHEL source code to develop a product that is substantially relatable to RHEL. Only community and web portals provide technical support for this.
CentOS is one of the most stable and trustworthy Linux distributions available. It is the preferred server operating system.
CentOS is a free version of Red Hat Linux that includes some of its features. Unlike Red Hat, it is an open-source operating system.
Its underlying architecture is similar to all the other Linux distros. Similar to other distributions, it also supports only the -86 and x64 bit architecture, which means it can only run on 32-bit and 64-bit platforms.
- The lowest layer comprises physical and hardware devices such as computers, networking and storage devices.
- On top of this, the kernel is placed. The kernel is the most fundamental part of OS because it directly interacts with the hardware.
- The next layer is the shell, which acts as an interface between the user and the kernel.
- On the top layer is the application layer, which is used for interaction between shell and kernel to perform user-defined tasks such as File Explorers, media players, text editing software, etc.
Pros of Using CentOS
- It is light, efficient, and speedy.
- It’s open-source and free, and it’s enterprise-ready.
- Some open-source server software is also packaged with Apache Web, CUPS, MySQL, and version control tools like Git, which are pre-installed.
- Best community support, including the ability to submit defects to
- It contains nearly the same functionalities as the commercial Red Hat Enterprise Linux. This is also accessible for no cost!
- CentOS is frequently favored (even above Ubuntu) over other open-source and free Linux distributions because of its stability and less frequent package upgrades.
Get IP Address in CentOS
Within a local network, private IP addresses are used for communication. Because private IP addresses cannot be routed, no traffic from the outside network may be transmitted to them.
You may need to know your system’s private IP address for various reasons, including setting up a network-related application, enabling remote administration, or troubleshooting.
Below are some methods to find the IP address using the command-line interface (CLI).
ifconfig is the acronym for
Interface Configuration. This is the most widely used command in the Linux world.
Along with the local IP address, it gives us many other network details, so to get the IP address, we will pipe it with
grep to get the IP address exactly. This is depicted in the image below.
ip a Command
This is the simplest and the shortest command to find the IP address. Write three characters only,
ip a, and get the local IP address as demonstrated in the image below.
This command is used to find the status of different networks and thus shows the IP address of that network too. So this can also be used to find the IP address.
ip addr Command
This works the same as the
ip a command, or we can say
ip a is the shorthand of
ip addr. The output of both commands is the same and can be used interchangeably.
hostname command is typically used to determine the system’s hostname. Using the
hostname command with the
-l option, on the other hand, gives you IP address information.
ip route Command
In Linux OS, the
ip route command is used to configure and displays static routes. This command also displays a system’s private IP address.
To find your private IP address, run the following command in