{"id":13484809,"url":"https://github.com/sorah/subsystemctl","last_synced_at":"2025-04-04T14:06:01.723Z","repository":{"id":43760676,"uuid":"271388956","full_name":"sorah/subsystemctl","owner":"sorah","description":"Utility to run systemd in WSL2 with a Linux namespace","archived":false,"fork":false,"pushed_at":"2022-02-04T13:27:33.000Z","size":65,"stargazers_count":332,"open_issues_count":10,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T13:06:53.956Z","etag":null,"topics":["systemd","wsl","wsl2"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sorah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-10T21:25:56.000Z","updated_at":"2025-03-26T05:49:10.000Z","dependencies_parsed_at":"2022-08-27T03:51:20.141Z","dependency_job_id":null,"html_url":"https://github.com/sorah/subsystemctl","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorah%2Fsubsystemctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorah%2Fsubsystemctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorah%2Fsubsystemctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorah%2Fsubsystemctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorah","download_url":"https://codeload.github.com/sorah/subsystemctl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190226,"owners_count":20898699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["systemd","wsl","wsl2"],"created_at":"2024-07-31T17:01:34.279Z","updated_at":"2025-04-04T14:06:01.693Z","avatar_url":"https://github.com/sorah.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# subsystemd: Run systemd in WSL2\n\n__Maintanence Note:__ You may want to use [nullpo-head/wsl-distrod](https://github.com/nullpo-head/wsl-distrod) which provides better compatibility with systemd and easier installation, and well maintained.\n\nRun systemd under Linux namespace in WSL2. Heavily inspired by [arkane-systems/genie][genie], but written in Rust.\n\n## Difference with arkane-systems/genie\n\nSlightly following [genie]'s behavior, but noted below...\n\n- Interface\n  - Command line interface is not compatible.\n- Behavior\n  - Hostname altertion is optional with `--hostname`, `--hostname-suffix`\n    - `/etc/hosts` are not updated. Users are encouraged to use `nss-myhostname`.\n  - Uses `machinectl shell` to launch a user shell; this allows running systemd user session\n- Internal\n  - Removed dependency to `unshare`, `daemonize`, `nsenter` command line tools\n  - systemd-wide environment variables are set via `systemd.conf` drop-in, using `DefaultEnvironment=`\n  - systemd PID from root namespace is stored at `/run/subsystemctl/systemd.pid`\n\n## Install\n\n### Arch Linux\n\nPKGBUILD: https://github.com/sorah/arch.sorah.jp/tree/master/aur-sorah/PKGBUILDs/subsystemctl\n\n_(PKGBUILD originally submitted to AUR (https://aur.archlinux.org/packages/subsystemctl) was deleted as [they unwelcomes WSL-exclusive packages](https://lists.archlinux.org/pipermail/aur-requests/2020-June/041193.html).)_\n\n### Debian/Ubuntu\n\nRefer to https://github.com/nkmideb/subsystemctl for debian source.\n\nPre-built package binaries available at https://github.com/nkmideb/subsystemctl/releases for your convenient.\n\n### Self build\n\n```\ncargo install subsystemctl\n```\n\nor from git source:\n\n```bash\ncargo build --release\ninstall -m6755 -oroot -groot ./target/release/subsystemctl /usr/local/bin/subsystemctl\n```\n\n## Usage\n\n### `subsystemctl start`: Start `systemd` environment\n\n```ps1\nPS\u003e wsl -u root -- subsystemctl start\n```\n\n### `subsystemctl shell`: shell login to systemd-enabled environment\n\n```ps1\nPS\u003e wsl subsystemctl shell\nConnected to the local host. Press ^] three times within 1s to exit session.\nsomeone@hostname$ ...\n```\n\n#### Specifying uid to login\n\n```ps1\nPS\u003e wsl -u root -- subsystemctl shell --uid=1000\nConnected to the local host. Press ^] three times within 1s to exit session.\nsomeone@hostname$ ...\n```\n\n#### Automatically starting and entering a user shell\n\n```ps1\nPS\u003e wsl -u root -d Arch -- subsystemctl shell --uid=1000 --start\n[2021-06-27T16:32:20Z INFO  subsystemctl] Starting systemd\nConnected to the local host. Press ^] three times within 1s to exit session.\n\nsomeone@hostname$ ...\n```\n\n### `subsystemctl exec`: Raw `nsenter` like interface\n\n```ps1\nPS\u003e wsl subsystemctl exec id\nuid=1000(sorah) gid=1000(sorah) groups=1000(sorah),116(admin)\n```\n\n#### Specifying uid (and gid)\n\n```ps1\nPS\u003e wsl -u root -- subsystemctl exec id\nuid=0(root) gid=0(root) groups=0(root)\n\nPS\u003e wsl -u root -- subsystemctl exec --uid=1000 id\nuid=1000(sorah) gid=1000(sorah) groups=1000(sorah),116(admin)\n\nPS\u003e wsl -u root -- subsystemctl exec --uid=1000 --gid=116 id\nuid=1000(sorah) gid=116(admin) groups=116(admin)\n```\n\n### `subsystemctl is-running`\n\n```bash\n#!/bin/bash\nif subsystemctl is-running; then\n  echo \"running\"\nelse\n  echo \"not-running\"\nfi\n```\n\n### `subsystemctl is-inside`\n\n```bash\n#!/bin/bash\nif subsystemctl is-inside; then\n  echo \"inside\"\nelse\n  echo \"outside\"\nfi\n```\n\n## Tips\n\n### systemd-resolved, networkd are recommended to be disabled\n\notherwise `/etc/resolv.conf` might get overwritten to resolved stub-resolver.\n\n## Author\n\nSorah Fukumori https://sorah.jp/\n\n## License\n\nMIT\n\n\n[genie]: https://github.com/arkane-systems/genie\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorah%2Fsubsystemctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorah%2Fsubsystemctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorah%2Fsubsystemctl/lists"}