// The Sudo Playground

Understand sudo.
Understand the foundation.

Sudo is more than a terminal command. It's a model for access, authority, and trust that runs through every software system — including Legalitize. Explore it here.

What is sudo?
How it works
Sudo in software
Sudo in everyday life

Superuser Do.

sudo stands for "superuser do." In Unix-based systems (Linux, macOS), it is a command that allows a permitted user to execute commands with elevated privileges — typically as the system administrator (root).

The idea is simple and profound: you don't always have permission to do everything. Some actions require a higher level of authority. sudo is the controlled gateway to that authority.

It's not about power for its own sake. It's about controlled trust — the system knows who you are, knows what you're allowed to do, and grants temporary elevated access only when the situation legitimately requires it.

This concept — restricted access, explicit authorization, audit trail — is a foundational model that shows up throughout software, security, law, and everyday life.

# Without sudo — permission denied
user@server:~$ apt-get install nginx
E: Could not open lock file /var/lib/apt/locks/apt.lock
E: Are you root?

# With sudo — elevated access granted
user@server:~$ sudo apt-get install nginx
[sudo] password for user:
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  nginx nginx-common nginx-core
Setting up nginx (1.24.0) ... done

# The difference: authorization + audit trail
user@server:~$ sudo -l
User user may run the following on server:
  (ALL) /usr/bin/apt-get

Trust, delegation, and audit.

sudo works through a configuration file called /etc/sudoers. This file defines exactly who can run which commands with which privileges. It's not binary — you can grant very specific, scoped permissions.

When you run sudo [command], three things happen: the system checks if you're in the sudoers file, prompts you to authenticate (typically your own password, not root's), and if authorized, executes the command at elevated privilege — then logs the event.

The log is essential. Every sudo command creates an audit trail. This is a security principle: authority without accountability is dangerous. Sudo's architecture ensures that elevated access leaves a record.

# /etc/sudoers — who gets what access
root    ALL=(ALL:ALL) ALL
alexa   ALL=(ALL) /usr/bin/apt-get
devteam server1=(www-data) /usr/sbin/nginx

# Three step execution model
user@server:~$ sudo service nginx restart

# Step 1: Authorization check
→ Is 'user' in sudoers for 'service'? YES
# Step 2: Authentication
[sudo] password for user: ••••••••
→ Authentication: PASSED
# Step 3: Execution + audit log
→ nginx restarted successfully
→ /var/log/auth.log: user:pts/0 CMD (service nginx restart)

The sudo pattern is everywhere in software.

The concept behind sudo — scoped authority, explicit authorization, audit trail — is not unique to Linux. It is the foundational pattern for access control in all modern software.

In Legalitize, the same principles govern what users can do within the system. A standard user can manage their own matters. An enterprise administrator can manage users in their organization. API keys grant scoped access to specific endpoints. Everything is logged.

Role-Based Access Control (RBAC) is sudo at scale. JWT tokens are sudo's password check. OAuth scopes are sudo's sudoers file. Audit logs are sudo's /var/log/auth.log. The names change. The architecture doesn't.

// RBAC in Legalitize — the sudo pattern in TypeScript

const PERMISSIONS = {
  user: ['matter:read', 'matter:create',
         'document:generate'],
  admin: ['*'], // like root in sudo
  api: ['matter:read', 'document:export']
};

// Middleware checks authorization — like sudoers
function requirePermission(permission) {
  return (req, res, next) => {
    const user = verifyJWT(req.headers.authorization);
    if (!hasPermission(user.role, permission)) {
      return res.status(403).json({ error: 'Forbidden' });
    }
    auditLog(user.id, permission); // log it
    next();
  };
}

Sudo exists everywhere you can't act alone.

The sudo model — you have ordinary access, but certain actions require demonstrated authorization from a higher authority — shows up constantly in life outside of computers.

A pharmacist can fill most prescriptions, but controlled substances require a signed authorization from a licensed physician. That prescription is the sudo command. The DEA schedule is the sudoers file.

A judge's court order grants a sheriff the elevated authority to carry out an action that no private citizen could do — like forcibly removing someone from a property. The order is sudo. The sheriff is the process running with elevated privileges.

A corporate officer can sign contracts up to a certain dollar value. Larger transactions require board approval. The approval chain is a sudo hierarchy. The minutes of the meeting are the audit log.

In legal proceedings, a subpoena compels production of documents that a party would otherwise refuse to provide. The court's authority — acting through the subpoena — is the sudo elevation that overrides ordinary refusal. The case number is the audit trail.

Legalitize exists because most people navigating legal systems don't have a sudo command — they don't know the right incantation, the right form, the right authority to invoke. The platform gives them that access.

// INTERACTIVE TERMINAL — Type commands and explore
sudocoder — sudo playground v1.0 INTERACTIVE
help
sudo --explain
whoami
sudo -l
sudo install legalitize
cat /etc/sudoers
real world examples
list modules
history
clear
visitor@sudocoder:~$ 
// From sudo to Legalitize

The same principles. A different domain.

Every concept that makes sudo powerful maps directly to what Legalitize provides in the legal system.

sudo [command]
File a motion with the court

In sudo, you invoke a command with elevated authority. In law, you invoke the court's authority through a motion. Both require knowing the right command, the right format, and the right permissions.

/etc/sudoers
Rules of Civil Procedure

The sudoers file defines who can do what. The Federal Rules of Civil Procedure, Pa.R.C.P., and local court rules define exactly what you can file, how, when, and in what format.

Authentication check
Standing and case caption

sudo requires you to prove you're who you say you are. Courts require proper party identification, standing, and a correctly formatted caption before your filing is even read.

Audit log (/var/log)
Docket and certificate of service

Every sudo action is logged. Every court filing is docketed, served on all parties, and tracked via a certificate of service. The system records that the authority was invoked and by whom.

Permission denied
Dismissed or rejected filing

Without sudo authorization, the command fails. Without proper procedural compliance, a filing is rejected or dismissed. The error message is different. The frustration is the same.

Root access (sudo su)
Legalitize — what we built

Legalitize gives you the legal equivalent of root access — not by bypassing the rules, but by giving you the exact commands, in the exact format, with the exact authorization the system requires. Knowledge is the sudo password.