getent Command in Linux: Query Users, Groups, and System Databases
The getent command in Linux is used to access the user account, password, and group databases.
Only the databases configured in the /etc/nsswitch.conf file can be accessed with this command.
The command syntax is:
$ getent base_de_dados chave
The database can have the following values:
- passwd: refers to the /etc/passwd file;
- shadow: refers to the /etc/shadow file;
- group: refers to the /etc/group file;
The key is the item in the database you want information about.
See the example, it shows the zabbix user account data:
$ getent passwd zabbixzabbix:x:500:501::/home/zabbix:/bin/bash
Only root can access the shadow database:
# getent shadow zabbixzabbix:$6$..5pDu8/$SBoEjzWpYE3hRNhoPI8pJW5rPpM2eEqc3OyWgAqFAJWJsaOyxqMGs9BylcNiTKk.su.OQCuSEWRUEPoAuZFq0.:16537:0:99999:7::16509:
The getent command is useful for getting the data of a specific user account or group, without having to list the contents of the passwd, shadow or group files and filter the results with grep.
If you are an IT professional, support technician, or developer, have you ever thought about learning Linux for real?
And also getting an LPI Linux Essentials certification as a bonus?
And even better, with the best Online Linux course?
[RICH_REVIEWS_SHOW category="CURSO" num="all"]
Do it like these people and create your account now.
Here you have everything you need to succeed in LPI and CompTIA exams
- Practical Shell Lessons
- Flashcards for memorization
- Crossword puzzles
- 06 virtual servers on Amazon just for you
- Mind Maps
- Video Glossary
- Practice exam for the tests
- Custom class schedule
- Guided exercises – Real labs
- Class resources (notes and more)
Want to know if a certification is worth it? Find out why the salaries are good, and why companies are looking for Linux professionals.
You will understand that the benefits far outweigh the sacrifice.
And if you have already decided, see our Certification Guide.
And if you want to know where to take the exams, check the city list.
If you want to know the exam language, see this post.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, you can access here.
Did you like it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.