getent命令简述

getent - get entries(entry的复数,条目、项目、记载、记录)

getent命令可以用来察看系统的数据库中的相关记录

经常使用getent查看用户账号:

  • 之前实验我们创建了一个UID为211的apahce系统账号,我们现在要查看apahce账号的信息
  • 通常的做法是我们cat etc下的passwd得到账号apache信息
  • 因为passwd也是系统的一种数据库,我们这时候就可以使用getent命令查看
[23:04:08 root@C8[ ~]#cat /etc/passwd | grep apahce
apahce:x:211:211:Apahce211:/var/www:/sbin/nologin
[23:04:14 root@C8[ ~]#getent passwd apahce
apahce:x:211:211:Apahce211:/var/www:/sbin/nologin

[22:57:00 root@C8[ ~]#getent --help
Usage: getent [OPTION...] database [key ...]
Get entries from administrative database. -i, --no-idn disable IDN encoding
-s, --service=CONFIG Service configuration to be used
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Supported databases:

ahosts ahostsv4 ahostsv6 aliases ethers group gshadow hosts initgroups

netgroup networks passwd protocols rpc services shadow

For bug reporting instructions, please see:

http://www.gnu.org/software/libc/bugs.html.

[23:04:48 root@C8[ ~]#man getent

GETENT(1)                                                User Commands                                               GETENT(1)

NAME
getent - get entries from Name Service Switch libraries SYNOPSIS
getent [option]... database key... DESCRIPTION
The getent command displays entries from databases supported by the Name Service Switch libraries, which are configured
in /etc/nsswitch.conf. If one or more key arguments are provided, then only the entries that match the supplied keys
will be displayed. Otherwise, if no key is provided, all entries will be displayed (unless the database does not sup‐
port enumeration). The database may be any of those supported by the GNU C Library, listed below: ahosts When no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to enumerate the hosts data‐
base. This is identical to using hosts. When one or more key arguments are provided, pass each key in
succession to getaddrinfo(3) with the address family AF_UNSPEC, enumerating each socket address structure
returned. ahostsv4 Same as ahosts, but use the address family AF_INET. ahostsv6 Same as ahosts, but use the address family AF_INET6. The call to getaddrinfo(3) in this case includes the
AI_V4MAPPED flag. aliases When no key is provided, use setaliasent(3), getaliasent(3), and endaliasent(3) to enumerate the aliases
database. When one or more key arguments are provided, pass each key in succession to getaliasbyname(3)
and display the result. ethers When one or more key arguments are provided, pass each key in succession to ether_aton(3) and ether_host‐
ton(3) until a result is obtained, and display the result. Enumeration is not supported on ethers, so a
key must be provided. group When no key is provided, use setgrent(3), getgrent(3), and endgrent(3) to enumerate the group database.
When one or more key arguments are provided, pass each numeric key to getgrgid(3) and each nonnumeric key
to getgrnam(3) and display the result. gshadow When no key is provided, use setsgent(3), getsgent(3), and endsgent(3) to enumerate the gshadow database.
When one or more key arguments are provided, pass each key in succession to getsgnam(3) and display the
result. hosts When no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to enumerate the hosts data‐
base. When one or more key arguments are provided, pass each key to gethostbyaddr(3) or gethostby‐
name2(3), depending on whether a call to inet_pton(3) indicates that the key is an IPv6 or IPv4 address or
not, and display the result. initgroups
When one or more key arguments are provided, pass each key in succession to getgrouplist(3) and display
the result. Enumeration is not supported on initgroups, so a key must be provided. netgroup When one key is provided, pass the key to setnetgrent(3) and, using getnetgrent(3) display the resulting
string triple (hostname, username, domainname). Alternatively, three keys may be provided, which are
interpreted as the hostname, username and domainname to match to a netgroup name via innetgr(3). Enumera‐
tion is not supported on netgroup, so either one or three keys must be provided. networks When no key is provided, use setnetent(3), getnetent(3), and endnetent(3) to enumerate the networks data‐
base. When one or more key arguments are provided, pass each numeric key to getnetbyaddr(3) and each non‐
numeric key to getnetbyname(3) and display the result. passwd When no key is provided, use setpwent(3), getpwent(3), and endpwent(3) to enumerate the passwd database.
When one or more key arguments are provided, pass each numeric key to getpwuid(3) and each nonnumeric key
to getpwnam(3) and display the result. protocols When no key is provided, use setprotoent(3), getprotoent(3), and endprotoent(3) to enumerate the protocols
database. When one or more key arguments are provided, pass each numeric key to getprotobynumber(3) and
each nonnumeric key to getprotobyname(3) and display the result. rpc When no key is provided, use setrpcent(3), getrpcent(3), and endrpcent(3) to enumerate the rpc database.
When one or more key arguments are provided, pass each numeric key to getrpcbynumber(3) and each nonnu‐
meric key to getrpcbyname(3) and display the result. services When no key is provided, use setservent(3), getservent(3), and endservent(3) to enumerate the services
database. When one or more key arguments are provided, pass each numeric key to getservbynumber(3) and
each nonnumeric key to getservbyname(3) and display the result. shadow When no key is provided, use setspent(3), getspent(3), and endspent(3) to enumerate the shadow database.
When one or more key arguments are provided, pass each key in succession to getspnam(3) and display the
result. OPTIONS
-s service, --service service
Override all databases with the specified service. (Since glibc 2.2.5.) -s database:service, --service database:service
Override only specified databases with the specified service. The option may be used multiple times, but only
the last service for each database will be used. (Since glibc 2.4.) -i, --no-idn
Disables IDN encoding in lookups for ahosts/getaddrinfo(3) (Since glibc-2.13.) -?, --help
Print a usage summary and exit. --usage
Print a short usage summary and exit. -V, --version
Print the version number, license, and disclaimer of warranty for getent. EXIT STATUS
One of the following exit values can be returned by getent: 0 Command completed successfully. 1 Missing arguments, or database unknown. 2 One or more supplied key could not be found in the database. 3 Enumeration not supported on this database. SEE ALSO
nsswitch.conf(5) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about
reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2015-04-19

Linux基础命令之getent的更多相关文章

  1. 第四节,Linux基础命令

    第四节,Linux基础命令 命令是系统操作员对系统传入的指令,传入指令后回车,系统接收到指令做出相应的行为 1.查看用户位于系统什么位置 [pmd]检查操作用户位于系统的什么位置 命令         ...

  2. 【Python之路】第一篇--Linux基础命令

    pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 .   表示当前目录 ..  表示上级目录 /  表示根目录 ls ...

  3. linux基础命令学习笔记(二)

    linux基础命令学习笔记(二) 1.kill :终止进程  kill pid (唯一标示一个进程) kill -9  强制终止  kill -15 命令未结束不能终止 # ps aux 查看所有进程 ...

  4. 2.Linux基础命令

    linux内一切皆文件,没有文件夹只有目录,目录也是一种文件 1.一些常用按键: 将鼠标的光标从虚拟机里切换回来:Ctrl+Alt 拖动Ubuntu内的对话框:Alt键+鼠标左键拖动 清屏:Ctrl+ ...

  5. linux基础命令一

    linux基础命令一 1.date命令 date命令介绍:显示或者设置系统日期 date命令的语法: 显示日期:date  [options...]  [+FORMAT] FORMAT:为显示日期的格 ...

  6. linux基础命令:

    linux基础命令: 显示 echo 输出我写的内容 ls 查看当前目录的文件 pwd 查看当前目录 ifconfig 查看网卡信息 grep 过滤 -v 取反 -n man 查看命令的帮助信息 md ...

  7. 常用的linux基础命令

    常用的linux基础命令 1.ls 显示目录属性 -l:(也可以简写成ll),列表显示权限等属性 -a:显示所有文件包括隐藏文件等 -d:只列出目录本身 2.chgrp 改变档案所属群组 eg:chg ...

  8. Linux基础命令-文件与目录

    Linux基础命令-文件与目录 参考:<鸟哥linux私房菜>五-七章,17/12/5复习,18/01/15复习 文件权限 rwx421:用户,用户组,其他 umask查看默认权限:000 ...

  9. Linux基础命令回顾

    前言 说到linux基础命令,网上一搜一箩筐,想学也有很多教程,如果你不幸看到此篇文章,想看就认真看完,毕竟你点进来了不是嘛? 我每次写的文章都是为了分享自己的学习成果或重要知识点,希望能帮助更多的人 ...

随机推荐

  1. 再不迁移到Material Design Components 就out啦

    翻译自国外文档加自己理解 原文 我们最近宣布了 Material Design Components(MDC)1.1.0 ,这是一个库更新,为您的 Android 应用程序带来了 Material T ...

  2. element ui 分页记忆checked

    <el-table :data="tableData" border ref="multipleTableChannel" @selection-chan ...

  3. 北京数途科技有限公司--EAM MAXIMO交通行业

    北京数途科技有限公司--EAM MAXIMO交通行业 一.行业背景: 自从1863年世界上第一条地铁在英国伦敦建成通车,标志着城市轨道交通方式的诞生.在不同国家.不同发展阶段内,凡经济发达的 国家与城 ...

  4. Powershell编程基础-003-脚本的绝对路径及所在的目录

    在运行脚本的时候,有时候需要通过脚本文件所在目录路径来做一些事, 如脚本5201351.ps1脚本, 常规思路实现>>>>: 1.如果要获取这个脚本所在的绝对路径,可以使用内置 ...

  5. MySQL: 1、MySQL基础

    一.数据库基本概念 1.什么是数据库? 数据就是存储和管理数据库的仓库,本质上是一个文件系统,以文件的方式将数据保存再电脑上 2.为什么使用数据库? 使用数据库存储数据用户可以方便的对数据库中的数据进 ...

  6. chrome浏览器的两个坑,以及其他

    chrome打开本地网页时,不能保存cookiechrome拒绝使用ajax访问本地文件(火狐可以) ipinfo.io/ip 获得公网iphttps://v1.hitokoto.cn/ 获得一句动漫 ...

  7. 小伙伴问我:如何搭建Maven私服?我连夜肝了这篇实战文章!!

    写在前面 十一假期期间,也有很多小伙伴不忘学习呀,看来有很多小伙伴想通过十一长假来提升自己的专业技能!这不,就有小伙伴在微信上问我:如何搭建Maven私服?让我专门推一篇搭建Maven私服的文章.安排 ...

  8. 01Linux系统简介

    Linux 简介 一.介绍 1.1 内容 Linux 的历史,Linux 与 Windows 的区别等知识. 1.2 知识点 linux为何物 linux历史简介 linux重要人物 linux与wi ...

  9. P5322 排兵布阵解题报告

    本想在洛谷上交篇题解的,结果发现交不了,所以只能在这边写了... 作为一个蒟蒻,看到省选题,第一眼考虑怎么打暴力 我们可以分情况考虑 当\(s==1\)的时候 我们可以把他当成一个\(01\)背包,背 ...

  10. GAN网络之入门教程(四)之基于DCGAN动漫头像生成

    目录 使用前准备 数据集 定义参数 构建网络 构建G网络 构建D网络 构建GAN网络 关于GAN的小trick 训练 总结 参考 这一篇博客以代码为主,主要是来介绍如果使用keras构建一个DCGAN ...