In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the Linux system to see what all user commands are, the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian take you to study and learn "Linux system to see what all user commands are".
Linux is a multi-user system, and all user information is stored in the/etc/passwd file.
Method 1: Use the/etc/passwd file to print a list of users created on Linux using any of the file manipulation commands like cat, more, less, etc.
/etc/passwd is a text file that contains the information for each user necessary to log on to the Linux system. It holds useful information about the user, such as username, password, user ID, group ID, user ID information, user's home directory, and shell.
The/etc/passwd file writes each user's details as a single line with seven fields separated by colons:
#cat/etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin 2gadmin:x:500:10::/home/viadmin:/bin/bash apache:x:48:48:Apache:/var/www:/sbin/nologin zabbix:x:498:499:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin mysql:x:497: 502::/home/mysql:/bin/bash zend: x: 502:503::/u01/zend/gui/lighttpd:/sbin/nologin rpc: x: 32:32: Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin 2daygeek: x: 503:504::/home/2daygeek:/bin/bash named: x: 25:25: Named:/var/named:/sbin/nologin mageshm: x: 506:507: 2g Admin-Magesh M:/home/mageshm:/bin/bash Details of the 7 fields are as follows.
User name (magesh): The user name of the created user, 1 to 12 characters long.
Password (x): The encrypted password is stored in the `/etc/shadow file.
* * User ID (506): Represents the ID number of the user, each user must have a unique ID. UID numbers 0 are reserved for root users, UID numbers 1 through 99 are reserved for system users, and UID numbers 100 through 999 are reserved for system accounts and groups.
* * Group ID (507): The ID number representing the group. Each group must have a unique GID, which is stored in the/etc/group file.
* * User information (2g Admin-Magesh M): Represents a description field that can be used to describe user information.
* * Home directory (/home/mageshm): Represents the user's home directory.
* * Shell (/bin/bash): Represents the type of shell the user uses.
You can use awk or cut to print out just a list of the usernames of all users on your Linux system. The results shown are the same.
#awk-F ':'{print $1}'/etc/passwd or #cut-d: -f1/etc/passwd root bin daemon lp sync shutdown halt mail ftp postfix sshd tcpdump 2gadmin apache zabbix mysql zend rpc 2daygeek named mageshm Method 2: Use the getent command to display entries from databases supported by the Name Service Switch library. The configuration file for these libraries is/etc/nsswitch.conf.
The getent command displays user details similar to the/etc/passwd file, displaying each user detail as a single line of seven fields.
#getent passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin 2gadmin:x:500:10::/home/viadmin:/bin/bash apache:x:48:48:Apache:/var/www:/sbin/nologin zabbix:x:498:499:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin mysql:x:497:502::/home/mysql:/bin/bash zend: x: 502:503::/u 01/zend/zend/gui/lighttpd:/sbin/nologin rpc: x: 32:32: Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin 2daygeek: x: 503:504:::/home/2daygeek:/bin/bash named: x: 25:25: Named:/var/named:/sbin/nologin mageshm: x: 506:507: 2g Admin-Magesh M:/home/mageshm:/bin/bash Details of the 7 fields are as described above. (LCTT)
You can also use awk or cut to print out just a list of the usernames of all users on Linux. The results shown are the same.
Method 3: Use the getent command compgen is a built-in command of bash that will display all available commands, aliases, and functions.
#compgen-u root bin daemon adm lp sync shutdown halt mail ftp postfix sshd tcpdump 2gadmin apache zabbix mysql zend rpc 2daygeek named mageshmLinux versions are: Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and other versions. Deepin is one of the best Linux distributions in China; Ubuntu Kylin is a derivative distribution based on Ubuntu; Manjaro is a Linux distribution based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP and easy to use; Ubuntu is a Linux operating system based on desktop applications.
The above is about "Linux system to see what all user commands have" content, if the article is helpful to you and think it is well written, please share it with your friends to learn new knowledge, if you want to know more related knowledge content, please pay more attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.