PRoot - A repl that uses proot to emulate some linux container without any special permission
PRoot on Replit
This is a PRoot implementation of alpha version for Replit.
This repl is using Alpine Container to demonstrate PRoot on Replit. Just press the start button and look at Console/Shell.
You may install some packages like coreutils, neofetch, and more so like that.
Basics
proot -0 -r rootfsDir -b /dev -b /prop -b /sys -w /root /bin/sh
-r
- option to specify the rootfs where Linux distribution was installed.-0
- tells PRoot to simulate a root user which expected to be always available in Linux distributions. This option will allow you to use package manager.-b /dev -b /prop -b /sys
- options to make file systems at /dev, /proc, /sys appear in the rootfs. These 3 bindings are important and used by variety of utilities./bin/sh
- a program that should be executed inside the rootfs. Typically a shell.
Alpine Linux Basics
Installing & Uninstalling packages
Installing packages
apk add [package name]
Uninstalling packages
apk del [package name]
Learn more at: https://wiki.alpinelinux.org
Why using Alpine instead of Ubuntu, Debian, or Fedora?
First, AlpineLinux is known as a lightweight linux distro. Because replit only has a small storage, Those distro is not very perfect for this condition. Mainly because it's package repo/manager like apt
.
Their recommended packages that should installed is very alot which will uses a lot of storage. Just imagine, neofetch is originally 400 KB only. But in debian apt, it will uses 50 MB of storage which is big pain. That's why i choose alpine for this proot demonstration.
AlpineLinux rootfs itself is 40% Very small (5 MB) compared to other linux distro rootfs:
- Ubuntu: 42.0 MB
- Debian: 99 MB
- Fedora: 35.3 MB
Sources
- PRoot: https://proot-me.github.io
- Talloc (Proot Dependencies): https://talloc.samba.org
- Alpine Linux: https://alpinelinux.org
In Summary: PRoot is like chroot but for non-rooted environment. Basically it's using
ptrace
to work.