Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How do you list Raspberry Pi’s users?

By Nikhil Agnihotri October 30, 2023

Raspberry Pi (RPi) is a popular microcomputer used for embedded systems design, hosting high-level applications that run over an operating system. Many of these applications have multiple active users with different permissions and access to system resources. 

As a result, there may be situations when it’s important to know what users are sharing the device. Fortunately, there are several ways to get a list of RPi’s registered users on the Linux system.  

In this article, we’ll discuss some of the common methods to obtain a list of RPi users. 

Listing users on Raspberry Pi
There are multiple methods for listing users on RPi, including the following.

1. Using the ‘cat’ command
2. Using the ‘getent’ command
3. Using the ‘cut’ and ‘awk’ commands
4. Using the ‘id’ command
5. Using the ‘w’ or ‘who’ command
6. Using the ‘/etc/passwd’ file
7. Using lslogin command
8. Using the ‘cut’ command for group members
9. Using GUI

Using the ‘cat’ command
The cat command in RPi and other Linux or Unix-based operating systems is a basic utility that displays the contents of one or more text files on the terminal. Cat stands for concatenate, one of its primary functions. The command has this syntax: 

cat [options] [file(s)]

The command can read data from a “passwd” file to obtain information about RPi’s users. The passwd file is present in all the Linux-based systems, including Raspberry Pi. It contains information about all users with access to the system. 

The following command can be used to attain the users: 

$ cat /etc/passwd

The command can be modified to obtain information about the users placed in the home directory by adding a filter using the ‘grep’ and ‘cat’ commands.

The grep command in RPi and other Linux/Unix-based operating systems is a powerful text-search utility used to search for specific patterns or strings within text files or the output of other commands. Grep stands for Global Regular Expression Print, which reflects its primary function of searching and printing lines that match a specified pattern.

The ‘cat’ and ‘grep’ commands can list the users of the home directory as follows:

$ cat /etc/passwd | grep home

Using the ‘getent’ command
The ‘getent’ command is another way to obtain information about RPi’s users. This command is a versatile utility that queries and retrieves information from various administrative databases. It can retrieve information about users, groups, hosts, networks, and other system-related data. It’s also particularly useful for getting data managed by database sources specified in the ‘/etc/nsswitch.conf’ configuration file. 

It has this syntax:

getent database [key]

The database specifies the type of retrieval information available (e.g., the “passwd” for the user information, the group for group information, the host for the host information, etc.). The key is an optional parameter that can search for a specific entry within the database.

To get a list of RPi’s users, use the ‘getent’ and ‘awk’ commands as per below.

$ getent passwd | awk -F ‘:’ ‘{print $1}’

To obtain information about a specific user, use this command:

$ getent passwd <username>

This command can also be used to sort a list of users within a specific range when it’s used with the ‘awk’ command as follows:

$ getent passwd {1000..6000}

Using the ‘cut’ and ‘awk’ commands
The ‘cut’ command in RPi and other Linux/Unix-based operating systems is a text-processing utility used to extract specific columns or fields from lines of text or delimited files. It’s useful for manipulating and processing structured data. This command can separate text into columns based on a delimiter character and then select specific columns for output. It has this syntax: 

cut [options] [file(s)]

The ‘[options]’ are the optional flags that modify the behavior of the ‘cut’ command, including specifying the delimiter and selecting fields and ‘[file(s)].’ The ‘[file(s)]’ are the files from which the ‘cut’ command will read data. 

To obtain information about RPi’s users, the command can be used to extract information from the ‘passwd’ file as follows:

$ cut -d: -f1 /etc/passwd

The ‘awk’ command in RPi and other Unix-like operating systems is a versatile text-processing utility that allows you to process and manipulate text data in a highly flexible and programmable manner. This command is powerful when working with structured text files, such as CSV files, log files, and other tabular or delimited data. The command has this syntax:

awk [options] ‘program’ [file(s)]

The ‘[options]’ are the optional flags that modify the behavior of the ‘awk’ command. The ‘program’ is a series of ‘awk’ commands enclosed in single quotes that define the actions to be performed on each line of input. The ‘[file(s)]’ are the files from which the ‘awk’ command will read data.

To obtain information about RPi’s users, this command can be used to extract information from the ‘passwd’ file as follows:

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

Using the ‘id’ command
The ‘id’ command in Raspberry Pi and other Unix-like operating systems displays information about a user or group, including their user and group IDs (UID and GID), supplementary group IDs, and further details related to the user or group’s identity and privileges. 

This command can help you quickly access information about the current user or a specific user or group on the system. The command has this syntax: 

id [options] [username]

The ‘[options]’ are the optional flags that modify the behavior of the ‘id’ command. The ‘[username]’ is an optional argument specifying the username you want to display. If this is not specified, it defaults to the current user. The command can be used to get information about a specific RPi user as follows:

$ id <username>

Using the ‘w’ or ‘who’ commands
The ‘w’ command in Raspberry Pi and other Unix-like operating systems displays information about currently logged-in users and their activities. It provides a summary of who’s logged into the system, what they’re doing, and where they’re connected from. This command is useful for system administrators to monitor user sessions and resource use. The command has this syntax:

w [options]

The ‘ [options]’ are the optional flags that modify the behavior of the ‘w’ command. It’s executed as follows:

$ w

The ‘who’ command in Raspberry Pi and other Unix-like operating systems displays information about currently logged-in users. It provides a summary of who’s logged into the system, including details about their login sessions — such as the username, terminal or pseudo-terminal, login time, and remote IP address or hostname (if applicable).

While the ‘w’ command provides detailed information, including the terminal they are using, the ‘who’ command offers a simpler list. It has this syntax:

who [options]

The ‘ [options]’ are the optional flags that modify the behavior of the ‘who’ command. It’s executed as follows:

$ who

Using the /etc/passwd file
The information about RPi’s users can also be obtained by directly accessing the ‘passwd’ file using a text editor or pager like ‘nano’ or ‘less.’ It can be accessed as follows:

$ nano /etc/passwd

The ‘passwd’ file can be accessed using the less pager as follows:

$ less /etc/passwd

Using the ‘lslogin’ command
The ‘lslogin’ command lists all of RPi or any other Linux-based system’s current login sessions. It can be used to get information about the users who are logged in, the terminals they’re using, and the time they log in.

To list the current login sessions on your RPi, type the following command:

$ lslogin -u

Using the ‘cut’ command for group members
To list users belonging to a specific group, use the ‘cut’ and ‘grep’ commands as follows:

grep ‘^<groupname>:’ /etc/group | cut -d: -f4

Using GUI
In the desktop mode, a list of RPi users can be found by opening the file manager and navigating to the ‘home’ folder. In this folder, there are additional folders of all of the RPi’s users.

Conclusion
There are multiple ways to get information about Raspberry Pi’s users. Most of these methods access the ‘passwd’ file and manipulate its content. For example, information about users who are currently logged in can be obtained through commands like ‘w,’ ‘who,’ and ‘lslogins’. A folder for each user is in RPi’s home directory, which includes the names of all of the users.

You may also like:


  • RPi Python Programming 05: Introduction to Python
  • RPi Python programming 04
    RPi Python programming 04: Setting up Raspberry Pi Linux computer
  • Screenshot of Raspbian OS on Raspberry Pi
    RPi Python Programming 03: Raspberry Pi as Linux System
  • Raspberry Pi 4
    RPi Python Programming 01: Introduction to Raspberry Pi 4

  • How to build a Raspberry Pi VPN server

  • How to use Raspberry Pi camera module with Python
  • Connect Raspberry Pi to WiFi Prototype
    How to Connect Raspberry Pi to WiFi- (Part 3/12)

Filed Under: Electronic Projects, Raspberry pi, Tutorials
Tagged With: raspberrypi, rpi, users
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe