How to get IP address in CentOS
This short article is a brief introduction to CentOS followed by 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 and their usage for the above purposes. Let's start with an introduction to CentOS.
Introduction to CentOS
CentOS is the abbreviation of Community Enterprise Operating System. It is a Linux distribution created by Gregory Kurtzer. It provides free enterprise-level and is an open source operating system.
It works with Red Hat Enterprise Linux (RHEL), from which it is derived. RHEL is an enterprise-class operating system, but is not free and usually requires a paid subscription.
CentOS developers use RHEL source code to develop products that are closely related to RHEL. Only the community and portal provide technical support for this.
CentOS is one of the most stable and trusted 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.
CentOS Architecture
Its underlying architecture is similar to all other Linux distributions. Similar to other distributions, it also supports only -86 and x64 bit architectures, which means it can run only on 32-bit and 64-bit platforms.
- The lowest layer includes physical and hardware devices such as computers, networks, and storage devices.
- On top of this, the kernel is placed. The kernel is the most fundamental part of the operating system as it interacts directly with the hardware.
- The next layer is the shell, which acts as an interface between the user and the kernel.
- The top layer is the application layer, which is used for interaction between the shell and the kernel to perform user-defined tasks such as file browsers, media players, text editing software, etc.
Advantages of using CentOS
- It's light, efficient and fast.
- It's open source and free, and is enterprise-ready.
- Some open source server software also comes pre-installed with version control tools such as Apache Web, CUPS, MySQL, and Git.
- Best possible community support, including the ability to submit bugs to bugs.centos.org.
- It contains almost the same features as the commercial Red Hat Enterprise Linux. It's also free!
- CentOS is often preferred over other open source and free Linux distributions (even over Ubuntu) due to its stability and less frequent package upgrades.
Get IP Address in CentOS
In a local network, private IP addresses are used for communication. Since private IP addresses cannot be routed, traffic from the external network cannot be transmitted to them.
You may need to know the private IP address of a system for a variety of reasons, including setting up network-related applications, enabling remote management, or troubleshooting.
Here are some ways to find your IP address using the command line interface (CLI).
Using ifconfig command
ifconfig
It is the abbreviation of Interface Configuration. This is the most widely used command in the Linux world.
Apart from the local IP address, it also provides us with many other network details, so to get the IP address, we will pipe it with grep to get the IP address accurately. This is depicted in the following image.
Use ip a command
This is the simplest and shortest command to find the IP address. Just write three characters, ip a
, and you will get the local IP address, as shown below.
Using nmcli command
The nmcli command is used to find out the status of different networks and therefore also displays the IP address of that network. So this can also be used to find out the IP address.
Using the ip addr command
This does the same thing as the ip a command or we can say ip a is the shorthand for ip addr . The output of both the commands is same and can be used interchangeably.
Using the hostname command
The hostname command is usually used to determine the hostname of a system. On the other hand, using the hostname command with the -l option can provide you with the IP address information.
Using the ip route command
In Linux operating systems, the ip route command is used to configure and display static routes. This command also displays the private IP address of the system.
To find your private IP address, run the following command in your terminal.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
How to decompress x.tar.xz format files under Linux
Publish Date:2025/04/08 Views:186 Category:OPERATING SYSTEM
-
A lot of software found today is in the tar.xz format, which is a lossless data compression file format that uses the LZMA compression algorithm. Like gzip and bzip2, it supports multiple file compression, but the convention is not to compr
Summary of vim common commands
Publish Date:2025/04/08 Views:115 Category:OPERATING SYSTEM
-
In Linux, the best editor should be vim. However, the complex commands behind vim's powerful functions also make us daunted. Of course, these commands do not need to be memorized by rote. As long as you practice using vim more, you can reme
Detailed explanation of command return value $? in Linux
Publish Date:2025/04/08 Views:58 Category:OPERATING SYSTEM
-
? is a special variable. This variable represents the return value of the previous command. That is to say, when we run certain commands, these commands will return a code after running. Generally, if the command is successfully run, the re
Common judgment formulas for Linux script shell
Publish Date:2025/04/08 Views:159 Category:OPERATING SYSTEM
-
In shell script programming, predicates are often used. There are two ways to use predicates, one is to use test, and the other is to use []. Let's take a look at how to use these two methods through two simple examples. Example 1 # test –
Shell script programming practice - specify a directory to delete files
Publish Date:2025/04/08 Views:98 Category:OPERATING SYSTEM
-
Usually, in Linux system we need to frequently delete some temporary files or junk files. If we delete them one by one manually, it will be quite troublesome. I have also been learning shell script programming recently, so I tried to write
Use of Linux command at - set time to execute command only once
Publish Date:2025/04/08 Views:158 Category:OPERATING SYSTEM
-
This article mainly involves a knowledge point, which is the atd service. Similar to this service is the crond service. The functions of these two services can be similar to the two functional functions of javascript. Those who have learned
Use of Linux command crontab - loop execution of set commands
Publish Date:2025/04/08 Views:170 Category:OPERATING SYSTEM
-
Compared with at , which executes a command only once, crontab, which we are going to talk about in this article, executes the set commands in a loop. Similarly, the use of crontab requires the support of the crond service. The service is s
Linux practice - regularly delete files under the directory
Publish Date:2025/04/08 Views:198 Category:OPERATING SYSTEM
-
Since we want to delete the files under the directory regularly, we need to use the Linux crontab command. And the content format of each work routine is also introduced in the format of each crontab work. Similarly, we need to use shell sc
How to use the Linux file remote copy command scp
Publish Date:2025/04/08 Views:151 Category:OPERATING SYSTEM
-
Scp copies files between two hosts over the network, and the data is encrypted during transmission. Its underlying layer uses ssh for data transmission. And it has the same authentication mechanism and the same security level as ssh. When u