gusers
is a Go-based CLI application that replicates the functionality of the users
command in Linux. It reads from utmpx
files to display a list of logged-in users on the system. The application is built using Go and includes a library to interact with utmpx
.
- Lightweight and Fast: Written in Go for high performance.
- Library Support: Includes a reusable library for interacting with
utmpx
. - Help and Version Commands: Supports common CLI arguments
--help
and--version
.
You can install gusers
using the go install
command:
go install github.com/drunkleen/gusers@latest
$ gusers [OPTIONS]
--help
: Display usage information.--version
: Show version information.
Example:
$ gusers
user1 user2 user3
You can also use the utmpx
library in your Go projects to interact with utmpx
files.
go get github.com/drunkleen/gusers/utmpx
package main
import (
"fmt"
"github.com/drunkleen/gusers/utmpx"
)
func main() {
entries := utmpx.GetAll()
for _, entry := range entries {
fmt.Println(entry.User)
}
}
.
├── go.mod
├── LICENSE
├── main.go
├── README.md
├── utils
│ └── args.go
└── utmpx
├── helpers.go
├── libs.go
├── types.go
└── utmpx.go
main.go
: Entry point for the application.utils/args.go
: Handles command-line argument parsing.utmpx/
: Contains the core library for interacting withutmpx
files.
- Go 1.19 or higher
-
Ensure Go is installed on your system.
-
Clone the repository:
git clone https://github.com/drunkleen/gusers.git
-
Navigate to the project directory:
6779 li>cd gusers
-
Run the following command to build the application:
go build -o bin/gusers
(Currently, no automated tests are included for now. Future versions will address this.)
This project is licensed under the GPLv3+ license. See the LICENSE file for more details.