Running a Linux terminal in your Windows browser

Here's an introduction to running a Linux terminal inside a browser and some of the tools available to you.

If you want to try using a Linux terminal and aren’t sitting anywhere near a Linux system, don’t despair. There are some services that will allow you to run a Linux terminal inside a browser. This post examines some of these and should give you a feel for what you can do and the performance you might experience.

The Linux terminal sessions described here were all run on a Windows system using a Chrome browser. While you could as easily run a Linux terminal in a browser on a Linux system, you’d likely be less motivated to do so.

JSLinux

JSLinux is essentially a computer that’s implemented in JavaScript. So, all you need to do is open a browser and type the right URL to get started.

You’ll find available links to JSLinux through this site:

https://bellard.org/jslinux/

Of the eight systems listed, six are Linux. Go for one of the console windows listed. These URLs include:

I prefer the Fedora 33 implementation from JSLinux because it includes man pages while the other two don’t seem to.

You’ll end up being logged in as root, though the who command won’t be available to acknowledge your presence. Even so, the whoami and the pwd command will confirm your identity:

localhost:~# who; whoami; pwd
sh: who: not found
root
/root

If you like, you can compile the hello.c program and run it, you should see this.

localhost:~# cc -o hello hello.c
localhost:~# ls
bench.py hello hello.js hello.c readme.txt localhost:~# hello sh: hello: not found localhost:~# ./hello hello world

You might want to run some of your favorite Linux commands, put together a script or two and explore the command line. I put together and ran a simple bash script to count the files in each of the directories in my search path.

$ cat count_commands
#!/bin/bash

for dir in `echo $PATH | sed “s,:, ,g”`
do
  echo $dir
  ls $dir | wc -l
  echo “==========”
done
[root@localhost ~]# ./count_commands
/usr/local/sbin
0
===========
/bin
2349
===========
/sbin
609
===========
/usr/bin
2349
===========
/usr/sbin
609
===========
/usr/local/bin
9

Clearly, the system is equipped with lots of Linux commands.

If you run into problems when trying to run a script, source the script like this:

[root@localhost ~]# ./count_commands
sh: ./count_commands: not found
[root@localhost ~]# . count_commands

Even with the current file system location in my search path on one of the systems, I needed to source the script to get it to work.

To check out your search path, use a command like this:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

The man page directories on Fedora look like this:

[root@localhost ~]# ls /usr/local/share/man
man1   man2   man3   man4   man5   man6   man7   man8   man9   mann
man1x  man2x  man3x  man4x  man5x  man6x  man7x  man8x  man9x
[root@localhost ~]# ls /usr/share/man
ca  es  it     man1   man2x  man4   man6   man8   mann  pt_BR  sv     zh_TW
cs  fr  ja     man1p  man3   man4x  man6x  man8x  nl    ru     tr
da  hu  ko     man1x  man3p  man5   man7   man9   pl    sk     uk
de  id  man0p  man2   man3x  man5x  man7x  man9x  pt    sr     zh_CN

Running a man page command when the man pages are available works as you’d expect.

[root#localhost !]# man date
[root@localhost ~]# DATE(1)                          User Commands                         DATE(1)
 
NAME
       date - print or set the system date and time
 
SYNOPSIS
       date [OPTION]... [+FORMAT]
       date [-u|—utc|—universal] [MMDDhhmm[[CC]YY][.ss]]
 
DESCRIPTION
       Display the current time in the given FORMAT, or set the system date.
 
       Mandatory  arguments  to  long  options are mandatory for short options
       too.
...

Asking about the IP address of the system I was using, I saw the loopback (127.0.0.1) interface and an internal 10.x.x.x address.

localhost:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNO
WN qlen 1000
    link/ether 02:46:81:31:ca:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.5.218.60/16 brd 10.5.255.255 scope global dynamic eth0
       valid_lft 817sec preferred_lft 667sec

NOTE: When you open one of these JSLinux consoles, you will always start at the same place—a fresh Linux terminal. Any scripts or changes you make will not be preserved in any way.

copy.sh

Copy.sh is another virtualization tool that allows you to run Linux (or a number of other OSes) inside a browser. To see all of the options available, go to http://copy.sh/v86/. You’ll find a couple dozen options that include Windows, FreeBSD, Oberon and a number of others in addition to Linux.

I took a look at these options:

The Damn Small Linux option provides a graphical interface which I’ve yet to fully explore.

Once again, how to run my script varied with the distro I was using. I had to source my script on the buildroot terminal, but not on the archlinux one.

~% cat showme
#!/bin/bash

echo “Hi, there”
echo -n “What are you looking for?: “
read ans
echo “Sorry, I have never heard of coffee”
~% .showme
./showme: not found
~% . ./showme
Hi, there
What are you looking for?: coffee
Sorry, I have never heard of coffee

I also ran the count_commands script

~% . ./count_commands
/sbin
55
===========
/usr/sbin
32
===========
/bin
75
===========
/usr/bin
131
===========

One of things I liked very much about copy.sh was that it gave me the option to “Save State” and “Load State”. This means that I was able to preserve the scripts that I added and recover them when I next connected from the v86state.bin file that had been saved on my system.

The only strange problem I ran into with the copy.sh terminals involved having to use Control-Alt+Delete followed by hitting “Cancel” to release my trackball from the clutches of the terminal.

Wrap-Up

Speed on terminal-in-a-browser options is not always impressive, but it’s nice to try Linux inside a browser and explore what it can do for you. Lots of Linux commands are available and, in spite of a few quirks and performance issues, the virtualized Linux systems can be very nice to use.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.
Related:

Copyright © 2022 IDG Communications, Inc.