Users and Groups
axeberg implements Linux-like multi-user support with file-based persistence.
User Database
Users are stored in /etc/passwd with standard format:
root:x:0:0::root:/bin/sh
user:x:1000:1000::/home/user:/bin/sh
nobody:x:65534:65534::/nonexistent:/bin/sh
Format: name:x:uid:gid:gecos:home:shell
Password Storage
Passwords are stored in /etc/shadow:
!or*means no password (login allowed)- Hash is a simple hash for demo purposes
Groups
Groups are stored in /etc/group:
Format: name:x:gid:member1,member2,...
Default Users
| User | UID | Home | Notes |
|---|---|---|---|
| root | 0 | /root | Password: "root" |
| user | 1000 | /home/user | No password |
| nobody | 65534 | /nonexistent | Unprivileged |
Default Groups
| Group | GID | Members |
|---|---|---|
| root | 0 | |
| wheel | 10 | user |
| user | 1000 |
User Management Commands
login
Creates a new session as the specified user.
logout
Ends the current session.
su
$ su # Switch to root (requires password)
$ su alice # Switch to alice
$ su - alice # Login shell (sets HOME, etc.)
sudo
Requires membership in wheel group.
useradd
groupadd
passwd
$ passwd secret # Set own password
$ passwd alice newpass # Set alice's password (root only)
$ passwd alice # Clear password (root only)
id
whoami
who / w
Permission Model
File permissions follow Unix conventions:
-rwxr-xr-x 1 root root 4096 Jan 1 00:00 /bin/ls
drwxr-xr-x 2 alice users 4096 Jan 1 00:00 /home/alice
Permission Bits
| Bit | Meaning |
|---|---|
| r (4) | Read |
| w (2) | Write |
| x (1) | Execute/search |
Categories
- Owner (u): Matches file's uid
- Group (g): Matches file's gid or supplementary groups
- Other (o): Everyone else
Root Bypass
UID 0 (root) bypasses all permission checks.
Kernel API
UserDb Structure
pub struct UserDb {
users: HashMap<Uid, User>,
groups: HashMap<Gid, Group>,
}
pub struct User {
pub name: String,
pub uid: Uid,
pub gid: Gid,
pub home: String,
pub shell: String,
pub password_hash: Option<String>,
}
Persistence Functions
// Save to /etc/passwd, /etc/shadow, /etc/group
kernel.save_user_db();
// Load from files
kernel.load_user_db();
Syscalls
| Syscall | Description |
|---|---|
getuid() |
Get real user ID |
geteuid() |
Get effective user ID |
getgid() |
Get real group ID |
getegid() |
Get effective group ID |
setuid(uid) |
Set user ID |
setgid(gid) |
Set group ID |
seteuid(uid) |
Set effective UID |
setegid(gid) |
Set effective GID |
getgroups() |
Get supplementary groups |
Related Documentation
- Process Model - Process credentials
- Syscall Interface - User syscalls
- Shell - User commands