Getting Started on worms.sh
This is a guide for getting an account set up on
worms.sh and logging in your first time. Since
worms.sh is a basic
UNIX-like1
server with 1 CPU core and 1 GB RAM, thereâs no graphical interface,
just a simple text terminal! If this is your first time using a
terminal, donât worry â youâll learn quickly and feel comfortable in
no time.
If you have questions, check the Companion FAQ!
Note: this guide only has instructions for Mac and is limited in its scope -- for a more comprehensive guide, including instructions for Windows, check out this guide!
Mac
Since MacOS is a UNIX-like OS, getting set up is relatively straightforward.
Youâll need access to the Terminal application. You can
find it by searching for it in Spotlight (Cmd-Space) or looking in
your Applications folder. It may be in a âUtilitiesâ sub-folder.
Command line shell basics
Before getting into how to access worms.sh, Iâll go
over some command line basics. If you want a more thorough
introduction,
this one from Ubuntu Linux
is pretty good. A couple details wonât apply on your Mac (or on
worms.sh), but the basics are the same.
Open up your Terminal app. You should see something like:
baba@macbook ~ %
This is an interactive command line shell! The primary purpose of a
UNIX shell is to take program names as input and run those commands.
For example, try typing ls and press Enter. You should
see a list of familiar names appear on the screen. You just ran the
ls program, which lists the files and directories in
your current directory!2
To find out what your current directory is, try running the
pwd program:
baba@macbook ~ % pwd
/Users/baba
pwd is short for âParent Working Directoryâ, and the
program prints the directory you are currently in. You should see
that youâre currently in your userâs home directory, explaining why
ls showed you the files in your home directory.
cd is another useful program which stands for âChange
Directory.â Try running cd Documents and then running
the pwd and ls commands. You can navigate
to virtually any directory on your computer with cd and
check out its contents with ls.
The UNIX shell can run all sorts of programs, including file management programs, text editors, data processing programs, and more. Anything that a computer can do that doesnât inherently depend on graphics can be done through the command line interface!
The UNIX shell is a powerful tool and will be the primary way that
you interact with worms.sh. While thereâs a
lot more to the UNIX shell and many programs to learn
about, weâll stop here and get you set up on worms.sh.
Once youâre logged onto worms.sh, you can explore
freely without worrying about messing up any important files on your
computer!
Setting up your credentials
Youâll use
ssh
to access your interactive shell on worms.sh. SSH is
the most widely used protocol for securely accessing remote shells
and is already installed on your Mac! To authenticate with
worms.sh, you need to create an SSH
key pair. You can read up on the technical details if youâre interested,
but you donât need to know the details to set it up. The basic idea
is that youâll generate a random key which will allow you to
authenticate with the worms.sh server. This key will
live on your computer, meaning you can only log in to your account
using the computer you generate the key with! If you have multiple
computers, you can repeat the process with each to add a key from
each computer.
To generate an SSH key, follow these steps (if at any point you make
a mistake, you can type Ctrl-C to terminate the
command):
- Open a new Terminal window.
-
Run the following command:
ssh-keygen -t ed25519 -
You will be guided through an interactive process. For the first
prompt, press
Enterto accept the default key file.3 It should be something like/Users/<username>/.ssh/id_ed25519. - For the next prompt, enter a passphrase for the key. Please choose a secure passphrase! While youâre allowed to make a key without a passphrase, this lowers the security considerably. Note that when you type, you wonât see any characters appear on screen. Donât worry, your inputs are still registering!
- Youâll be asked to confirm the passphrase
- If successful, youâll see a message telling you where your identifications and public key are saved, along with a âkey fingerprintâ and a randomart image. You now have an SSH key!
In actuality, your SSH key is two keys. It consists of a
private key (id_ed25519) and a
public key (id_ed25519.pub). As the names
suggest, your private key is secret and your public key is public!4
You can share your public key as widely as you please. In fact,
youâll need to share it with me, the administrator, in order for me
to grant you access to worms.sh. However, you should
take great care to keep your private key secret!
To view your public key, type the following command:
cat ~/.ssh/id_ed25519.pub. Hereâs my public key as an
example:
baba@macbook ~ % cat ~/.ssh/id_ed25519.pub
ssh-ed25519
AAAAC3NzaC1lZDI1NTE5AAAAIGV6m2CcaZXez2AesDqBETIJJzigsE4Vtv/StBo+q/oe
baba@macbook
Once you generate your public key, youâll need to send it to the
admin along with your username! Once this is done, you can continue
below to Connecting to worms.sh.
Connecting to worms.sh
At this point, you should have an SSH key pair generated and confirmation from baba that your account is set up with your SSH public key authorized. Logging in is simple:
baba@macbook ~ % ssh admin@worms.sh
Enter passphrase for key '/Users/baba/.ssh/id_ed25519':
Last login: Sat Aug 3 05:48:28 2024 from tmux(64826).%4
FreeBSD 14.1-RELEASE (GENERIC) releng/14.1-n267679-10e31f0946d8
Welcome to worms.sh!
This system runs FreeBSD 14.1.
If you have questions, break anything, or have suggestions,
don't hesitate to
reach out! We're all here to learn together :)
admin@earth /home/admin
>
In this example, I am logging in as user admin; youâll
use the username you chose, i.e. ssh <your-username>@worms.sh. Once logged in, youâll be dropped into an interactive shell, just
like the one on your Mac â except now youâre remotely interacting
with the worms.sh server!5
You can now run the commands you were running before, like
ls. If you run ls, youâll see just one
file â a directory called public_html. Try running
cd public_html and then ls again. This
time, youâll see a file called index.html. This is your
homepage which is hosted on
worms.sh/~<your-username>! Now weâll go over how
to edit this file.
Editing text
To edit your homepage, youâll need to use a text editor. FreeBSD has
a simple built-in editor called ee. Try running
ee from your interactive prompt; the text in your
terminal should clear and be replaced by the text editor interface.
At the top will be a few lines of text like this:
^[ (escape) menu ^y search prompt ^k delete line ^p prev li ^g prev page
^o ascii code ^x search ^l undelete line ^n next li ^v next page
^u end of file ^a begin of line ^w delete word ^b back 1 char ^z next word
^t top of text ^e end of line ^r restore word ^f forward char
^c command ^d delete char ^j undelete char ESC-Enter: exit
=====line 1 col 0 lines from top 1 ============================================
These are the available shortcuts in ee, where
^ is Ctrl. If you start typing text, you
should see it appear under this menu. When you run ee,
youâll start editing a new file. Since we want to edit
index.html, letâs exit out and start over â press
ESC-Enter and then select the
b) no save option with Enter. Youâll be
dropped back into your shell in the directory you were in.
In addition to running programs, the command line shell can also
pass âargumentsâ to those programs. Arguments are ways of giving the
program additional inputs such as file names, input text, or
enabling optional features (âoptionsâ). Each program has different
allowed inputs and options; thankfully, you can always read up on
how to use a program by reading its manual with the
man program. Try running man ee. You
should see a document like this:
ee(1) ee(1)
NAME
ee - easy editor
SYNOPSIS
ee [-e] [-i] [-h] [+#] [file ...]
ree [-e] [-i] [-h] [+#] [file ...]
[...]
You can scroll through with your arrow keys (mouse scrolling might
work too). You donât really need to know the details about
ee, but the synopsis gives us useful information. Here,
we see the allowed methods of running ee. The square
brackets indicate optional arguments â since theyâre all optional,
you can run ee on its own, like we did just earlier!
But we can also provide one or more files [file ...].
Letâs try it â press q to quick out of the manual
program and get back to your shell.6
Now, make sure youâre in the public_html directory,
where index.html lives. If youâre not, use
cd to navigate to ~/public_html (~
is shorthand for your home directory in file paths). Then, run
ee again, but this time give index.html as
an argument: ee index.html. You should see some HTML
code, which you can now start editing! You can save your work by
opening the main menu with ESC and navigating to the
file operations submenu, where youâll see a save
option. ee supports Emacs-style keybindings â this is a
way of saying you can string a series of key presses together to
specify certain commands without manually navigating each menu. For
instance, you can save by pressing ESC c c, one key
press after the other.
As soon as you edit index.html and save, you can
refresh your browser and see the updated changes at
worms.sh/~<your-username>!
Finally, to navigate back to your home directory, you can do
cd ... The .. is a shorthand for the
parent directory to the one youâre currently in.
Conclusion
Congratulations! You now have all the tools you need to start
editing your home page and exploring the FreeBSD operating system on
worms.sh! It might seem intimidating and cumbersome at
first, but itâll all become second nature as you grow accustomed to
working through a terminal interface.
A couple final notes. 1. Please donât be afraid to ask questions! Weâre all here to learn together. 2. Donât be afraid to experiment! Try things, write scripts and programs, write web pages that bring down the whole server â the more you break things, the more I get to learn as an administrator :)
Notes, next steps, useful programs, tidbits, etcâŠ
Next steps?
We went through a few basic UNIX shell commands, but we barely
scratched the surface. You donât even know how to make a new
directory, rename a file, or delete stuff!
This article
gives a pretty good overview of core UNIX commands. The first two
sections are the most important. Hereâs what I would consider the
minimal list of commands to know: cd, ls,
pwd, mkdir, rmdir,
cp, mv, rm, cat,
less, and man. You can probably guess what
most of these do (except for catâŠ) just by their names.
If you know these by heart and have a text editor handy, you can do
basically anything!
A word of caution: be very careful when using
commands like cp, mv, and
especially rm. All of these can and will
irrevocably delete or overwrite files without asking for
confirmation. Always double check that these commands will do what
you want them to do, and donât run commands or use options you donât
understand! On that note, also keep in mind that this server is not
backed up. Keep a copy of important data (like your webpage!!)
somewhere else.
Cool programs
Thereâs a range of terminal-based editors out there if you want to
improve your editing workflow (my favorite is
vim/neovim). You can also edit on your
computer and push changes in via a number of methods, like
scp or by creating a remote git repository. This
website itself (and the entire server infrastructure, eventually) is
kept in a git repository at
github.com/worms-sh/worms.sh!
tmux is a tool Iâve been using daily for years now
(including now, as I write this). You probably donât need it right
away, but if you ever find yourself spending more than a few minutes
at a time in the shell, youâll find it handy.
Your shell is configurable. By default, youâll be dropped into a
zsh shell when you log in. Unless you have a reason to,
you probably shouldnât change this. You can configure
zsh by editing configuration files in your home
directory such as ~/.zshrc. You probably donât have one
now; to look at mine, try running
cat /home/baba/.zshrc.
Side note: files that start with a . character (like
~/.zshrc) are hidden. You can see them by using the
-a option in ls: ls -a. If
you run that in your home directory, youâll probably see a few
hidden files already. Many of these are used for configuring
programs.
Resources
This guide from a college webdev course's pubnix server is super helpful! It has a more comprehensive introduction to the terminal. The course website is also very cool! I learned some formatting tricks from just reading the page source.
W3C has an
HTML tutorial
that Iâve been following. MDN [has guides as well][mdn] and seems
like the go-to online web dev reference. They also both have
tutorials for CSS and JavaScript, which are technologies youâll
probably want to use. There are tools out there which can make
editing your web page easier â this page was written in
Markdown
and translated into html using pandoc, which is a great
for simple pages like this. There are a million web frameworks out
there and Iâd be happy to help you set any of them up! Hereâs some
relevant terminology Iâve found to aid your research: static site
generator (SSG), template engine, CSS framework, JS framework.
git is an extremely useful tool to track and distribute changes to your code. The git website has a good guide to getting started, although itâs a bit tedious to go through the whole thing. Section 1.6 will get you set up and Chapter 2 goes through the basics. Youâll need to host a remote git repository somewhere; GitHub is the most popular and is easy to use, but alternatives are aplenty. Codeberg is a non-commercial alternative, if that floats your boat.
Remember to read man pages before you run new commands!
Theyâre intimidating, but they contain a wealth of information, and
reading just the Synopsis and the Description sections will go a
long way. Additionally, the
FreeBSD Handbook
is the go-to reference for anything system-related. You probably
donât need this (itâs more for me than for you), but if you want to
gain a deeper appreciation of how the system works, Chapter 3 of the
Handbook is a good place to start.
Lmk if you have suggestions for additional resources or any feedback on this guide!
-
Running FreeBSDâ©ïž
-
A âdirectoryâ is the same thing as a âfolder,â but the former is usually used in the BSD/Linux world, especially when referring to command line interfaces.â©ïž
-
If youâve generated an SSH key pair before, you can use your existing one or make a new one. If you generate a new one, make sure you donât overwrite any existing keys! You can see if you have any existing keys by running
ls ~/.ssh. If you see a file namedid_*.pub(where*is any string of characters), then thatâs an SSH key!â©ïž -
The Arch Linux wiki has a good concise explanation of how this works: https://wiki.archlinux.org/title/SSH_keys#Background.â©ïž
-
Actually, the hostname and fully-qualified domain name of the machine youâre logging into is
earth.worms.sh. But thatâs just a pedantic detail when thereâs only one server in theworms.shgalaxy!â©ïž -
The program that actually displays the manual is
less.manfinds the manual page and opens it usingless, which is a terminal pager. You can configure what program the manual gets opened in â seeman man.â©ïž