Polecenia Linuksa

How to Run Linux “getent” Command

How to Run Linux “getent” Command
In the Linux operating system, tons of command-line tools are used to get user's details from a database. So, here's one of the commands, which is called “getent”. The “getent” is a short form of “get entries from the administrative database”.

“getent” is a Linux command that allows users to fetch details from several text files called databases. The “getent” uses the same service name as the system, and it will display all user details and network information.

It contains various databases:

This post is focusing on how to fetch data from different databases.

Syntax:

Here's the syntax of the “getent” command:

$ getent [database] [databse_name]

How to use the “getent” Command:

Options:

The “getent” command has various options; let's discuss them with examples:

getent passwd:

Use “passwd” as a database to get the information of the currently logged user. It displays the username, user's id, and folder name. Run the command:

$ getent passwd user
$ getent passwd aqsa


getent group:

If you want to get all group details on Linux, use “group” with the “getent” command:

$ getent group

getent services:

Use “services” with the port number to find the service name and its protocol, For instance:

FTP-data server uses port no. 20 with TCP protocol.

An FTP server uses port no. 21 with TCP protocol.

SSH server uses port no. 2 with TCP protocol.

$ getent services 20
$ getent services 21
$ getent services 22

getent networks:

Use the “networks” option to check the network and IP address of your system.

$ getent networks

getent hosts:

Use the “hosts” option to get the IP address. The hostname of my Linux system is “linuxMachine”. So, I will pass linuxMachine as a parameter and give the host's IP address.

$ getent hosts linuxMachine

getent help:

To print the help message in the terminal, type the “-help” command. It will print all the related options, usage, and support databases of the “getent” command.

$ getent --help

getent usage:

If you want to know how to use of “getent” command, use the below-given command:

$ getent --usage

getent version:

To get detailed information about the “getent” version, use:

$ getent --version

Conclusion:

Getent command is used to look up the user information on Linux. The “getent” command collects data from the defined administrative database. We can get user's account information, IP address, servers, protocols, and some other information from the specified database. Through this tutorial, we have seen how to use the “getent” command with different options.

Gry Jak zainstalować League Of Legends na Ubuntu 14.04
Jak zainstalować League Of Legends na Ubuntu 14.04
Jeśli jesteś fanem League of Legends, to jest okazja do przetestowania League of Legends. Pamiętaj, że LOL jest obsługiwany w PlayOnLinux, jeśli jeste...
Gry Zainstaluj najnowszą grę strategiczną OpenRA na Ubuntu Linux
Zainstaluj najnowszą grę strategiczną OpenRA na Ubuntu Linux
OpenRA to darmowy silnik gier strategicznych czasu rzeczywistego, który odtwarza wczesne gry Westwood, takie jak klasyczny Command & Conquer: Red Aler...
Gry Zainstaluj najnowszy emulator Dolphin dla Gamecube i Wii w systemie Linux
Zainstaluj najnowszy emulator Dolphin dla Gamecube i Wii w systemie Linux
Emulator Dolphin pozwala grać w wybrane gry Gamecube i Wii na komputerach osobistych z systemem Linux (PC). Będąc ogólnodostępnym emulatorem gier o o...