• Home
  • Hosting
  • Tech
  • Server
  • Security
Mex Linux
  • Home
  • Hosting
  • Tech
  • Server
  • Security
No Result
View All Result
mexlinux.com
  • Home
  • Hosting
  • Tech
  • Server
  • Security
No Result
View All Result
mexlinux.com
No Result
View All Result

How to List All Users Linux

admin by admin
July 11, 2020
Home Latest
Share on FacebookShare on Twitter

Since Linux is a multi-user operating system, it can consist of multiple users. This short guide explains how to list all users of the Linux operating system. Before entering a topic, we see what the /etc/passwd file is. Because we rely on this file for the rest of this manual.

File /etc/passwdQuick Help

Under Linux (and Unix in general) basic information about each user account is stored in /etc/passwd. This is a simple text file with the attributes of all user accounts present on the Linux system. By default, this file is read by all users using a text or graphics program such as Vi, Nano, Gedit etc. or commands such as cat. Reference Linux Server Support.

When you open that file…

cat $ /etc/passwd

…you’ll see different records, as shown below:

root:x:0:0:root:/root:/bin/bash
demon:x:1:1:demon:/usr/sbin:/usr/sbin/nologin
bin:x:2:/bin:/usr/sbin/nologin
sys:x :3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
[…….]

Each line in /etc/passwd represents a user. The main user is at the top of the page. Each line contains seven attributes or fields separated by a colon with no space between them. The names of the seven fields are listed below:

  1. Name,
  2. Password,
  3. User ID,
  4. Group identification,
  5. the Gekons,
  6. Home directory,
  7. The hull.

The name field is the username you use to login to your Linux box.

The password field only contains the letter X. Value – The password is encrypted and is stored in a separate file named /etc/shadow for security reasons. The /etc/ shadow file cannot be read by normal users. Here X means that the user has a password. If this field is empty, the user does not have a password, so he can login without a password.

A User ID (or UID for short) is a unique numeric identification number of the user. The UID of the main account is 0 (zero). Numbers from 1 to 99 are reserved for system accounts. And numbers from 100 to 999 are reserved for normal users and groups.

The Group ID (or GID for short) specifies the main identification of the group to which the user belongs. As a rule, the GID corresponds to the UID.

The Gecko field contains general information about the user. For example, it may contain a real username. This file can be empty, separated by colons or contain multiple items, separated by commas.

The Home directory field shows the full path to the user’s home directory, for example /home/sk This is the directory where the user logs in first. The home directory usually contains programs and configuration files belonging to the user.

Last service, shell. It specifies the default full shell path for that user.

Now let’s take the following line as an example:

root:x:0:0:root:/root:/bin/bash

On the line above,

  • root is a username,
  • x – indicates that the root user has a password,
  • 0 – The first 0 (zero) indicates the UID,
  • 0 – The second zero indicates the GID
  • root – indicates the real username.
  • /root is the root user’s home directory,
  • /bin/bash is the default shell for the root user.

I hope you have an idea of the /etc/passwd file. Now back to our topic, that’s the list of all Linux users.

List of all users on Linux

There are several ways to list all users of the Linux system. I’ve taken every possible means here.

Team Cat.

As the name suggests, the cat command is generally used to combine files and print their content.

To make a list of all Linux users with the cut command, execute it:

cat $ /etc/passwd

This command gives an overview of all available users

Taking samples:

root:x:0:0:root:/root:/bin/bashdemon:x:1:demon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534 :sync:/games:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail :/var/mail:/news:x:9:9 news:/var/spool/news:/usr/sbin/nologinuucp:x:10:uucp:/var/spool/uucp:/usr/sbin/nologinproxy:x:13:13:proxy:/bin:/usr/sbin/nologinww-data :x:33:33:www-data:/var/www:/usr/sbin/nologinbackup:x:34:34:backup:/var/backups:/usr/sbin/nologinlist:x:38:38:38:Mailing list manager:/var/list:/usr/sbin/nologinirc :x:39:ircd:/var/run/ircd:/Gnats Bug Reporting System (admin):/var/lib/gnats:/usr/sbin/nologinnobody:x:65534:nobody:/exist:/usr/sbin/nologinsystemd-network :x:100:102:systemd network management,,,,:/run/systemd/netif:/usr/sbin/nologinsystemd-resolve:x:101:103:systemd resolver,,,:/run/systemd/resolve :/usr/sbin/nologinsyslog:x:102:106::/home/syslog:/usr/sbin/nologinmessagebus:x:103:107::/exist:/usr/sbin/nologin_apt:x:104:65534::/nonexistent:/usr/sbin/nologin :x:105:111::/run/uuuuuidd:/usr/sbin/nologinavahi-autoipd:x:106:112:Avahi-autoipd:/var/lib/avahi-autoipd:/usr/sbin/nologinusbmux:x:107:46:usbmux demon,,,..:/var/lib/usbmux:/usr/sbin/nologindnsmasq:x:108:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologinrtkit:x:109:114 :RealtimeKit,,/proc: /usr/sbin/nologincups-pk-helper: x:110:116: User of the cup-pk-helper service,,/home/cups-pk-helper :/usr/sbin/nologinDistributor the langue:x:111:29:Distributor the langue,,/var/run/speech-dispatcher:/bin/falsewhoopsie:x:112:117::/not available:/bin/false nodes:x:113:65534:Kernel Oops Tracking Daemon,,,,/:/:/usr/sbin/nologinsaned :x:114:119::/var/lib/saned:/usr/sbin/nologinavahi:x:116:122:Avahi mDNA daemon,,,, /var/run/avahi-daemon:/usr/sbin/nologincolord:x:117:123:Color control daemon,,,, /var/lib/colord:/usr/sbin/nologinhplip:x:118:7:HPLIP user,,, :/var/run/hplip:/bin/falsegeoclue:x:119:124::/var/lib/geoclue:/usr/sbin/nologinhplip:x:120:65534::/run/gnome-initial-setup/:/bin/falsegdm:x:121:125:Gnome Display Manager:/var/lib/gdm3:/bin/falsesk:x:1000:sk,,,..:/Debian-exim:x:122:128::/var/spool/exim4:/usr/sbin/nologinpulse:x:115:120:PulseAudio daemon,,,,:/var/run/pulse:/usr/sbin/nologinsystemd-timesync:x:123:127:systemd time synchronization,,,:/run/systemd:/usr/sbin/nologintss:x:124:131 :TPM Software Stack,,,,:/var/lib/tpm:/bin/falsetcpdump:x:125:132::/not available:/usr/sbin/nologin_flatpak:x:126:133:Flatpak System Installation Wizard,,,:/existent:/usr/sbin/nologinsystemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin

How to List All Users Linux

As I said before, the first field in the above entries is for users. If you do not want all fields to display only usernames, the following methods may help.

Breakdown of the team

The cut command is used to remove sections (or fields) from each line of the file.

To make a list of all users with the cut command on a Linux system, execute it:

Truncation $-d: -f1 /etc/passwd

This command displays only the usernames in the /etc/passwd file and ignores all other fields.

Taking samples:

root
demon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
systemd-network
systemd-resolve
syslog
messagebus
_apt
uuidd
avahi-autoipd
usbmux
dnsmasq
rtkit
cups-pk-helper
speech-dispatcher
whoopsie
kernoops
saned
avahi
colord
hplip
geoclue
gnome initialenetup
gdm
sk
debian-exim
pulse
systemd-timesync
tss
tcpdump
_flat pack
systemd-coredump

How to List All Users Linux

TeamAwk

We can also use the awk command to list all Linux users.

$ awk -F’ : { print $1} /etc/passwd

This command also displays only users and omits all other details.

How to List All Users Linux

Upgrade

Compgen is integrated in BASH to handle programmable terminating tools.

To create a list of all users using compgen, run it:

$ compgen -u

Obtaining thecommand

Another way to create a user list on Linux is to use the tented command, as shown below

pass

This command reads the /etc/passwd file and lists all users in that file.

How to List All Users Linux

One of the notable advantages of the tented command is that it not only lists the users in /etc/passwd, but also all users in all user-backends that are configured, such as LDAP, on a given system.

Teams plus or minus

Fewer and fewer commands are used to open a particular file for interactive viewing, so you can browse and search.

To print all users with more or less commands, launch the :

More than $ /etc/passwd

Or..,

min /etc/passwd

Sounds like reading:

I hope this helps.

Thank you so much for coming!

Help us to help you:

Have a nice day!linux list users logged in,linux list users and groups,ubuntu list users and groups,create user linux,list users centos,delete user linux,list users ubuntu,how to switch user in linux

admin

admin

Next Post
How to List All Users Linux

10th Gen Comet Lake-S is splashing down on embedded PCs

Recommended.

How to List All Users Linux

Making Infosec Jobs Easier: Responding to Cyber Security Incident

August 19, 2020
How to List All Users Linux

Cybersecurity Awareness Month. 2020 the perfect year to talk, think and act cybersecurity. – HOTforSecurity

October 10, 2020

Trending.

How to List All Users Linux

How to restart the Ubuntu 20.04-Linux Hint network

September 25, 2020
How to List All Users Linux

Got Kids? Limit Computer Usage Per Account in Linux With Timekpr-nExt

October 29, 2020

Install WINE on Linux Mint 20-Hint for Linux

September 15, 2020
How to List All Users Linux

LockBit ransomware seamlessly encrypts 225 systems

May 13, 2020
How to List All Users Linux

How to capitalize the first letter of the python string and other uses of the capitalize) (function – Linux Hint

May 5, 2020
mexlinux.com

MexLinux.com

We develop for Linux for a living, We used to develop for DOS.
Going from DOS to Linux is like trading a glider for an F117.

Categories

  • Hosting
  • Latest
  • Security
  • Server
  • Tech

Recent News

How to List All Users Linux

Delivering value to a remote workforce: A practical approach

November 19, 2020
How to List All Users Linux

Tetrade hackers target 112 financial apps with Ghimob banking TrojanSecurity Affairs

November 18, 2020
  • Home
  • Hosting
  • Tech
  • Server
  • Security

© 2020 MexLinux - Sitemap

No Result
View All Result
  • Home
  • Hosting
  • Tech
  • Server
  • Security

© 2020 MexLinux - Sitemap