Sandbox: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "== Hello Sandbox! == <blockquote> Living in a Sandbox is an optional course that aims at exploring the culture of free and open source UNIX-like software and computer hardware from the viewpoint of a small device: the Raspberry Pi. During this course, students will be exposed to historical and technical elements of computing that are nowadays buried under an app centric culture grown in the names of user-friendliness, transparency and deceptive allegories such as th...")
 
 
(61 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Hello Sandbox! ==
== Hello Sandbox! ==


<blockquote>
Every year's group of XPUB students carries along with them a "sandbox": a shared server that is used in classes, as part of Special Issues and the second year.  
[[Living in a Sandbox]] is an optional course that aims at exploring the culture of free and open source UNIX-like software and computer hardware from the viewpoint of a small device: the Raspberry Pi. During this course, students will be exposed to historical and technical elements of computing that are nowadays buried under an app centric culture grown in the names of user-friendliness, transparency and deceptive allegories such as the cloud.'''


New technologies, like smart phones and web services, promise cutting edge technologies and software as a means to empower users with a seemingly endless progression of new digital possibilities. In fact, many of these new services are striking for the many constraints they place (where can this be played, how many \“friends\” can connect, who decides what a remix means and if it can be \“shared\”).
The term "sandbox" and the thinking around it crosses different projects, courses, ideas and terms, including ...


Many of the platforms are themselves built on decades old technologies &amp; software. Sandbox aims to deconstruct the digital black boxes, revealing the hidden (historical) layers of software and system, with the aim of: (1) empowering students through literacy of reading these systems, and (2) encouraging new assemblages to be (strategically) reconstructed.
... Aymeric's PhD thesis [https://monoskop.org/log/?p=18777 Sandbox Culture: A Study of the Application of Free and Open Source Software Licensing Ideas to Art and Cultural Production] (2017), where he is using the image of the sandbox to refer to environments "where code becomes a constituent device for different communities to experience varying ideologies and practices".


When people hear the word sandbox, it is very likely that most of them will be thinking of the outdoor playset that consists of a container filled with sand. You probably have seen many already and have possibly played in one as a child. Using sand as medium and a couple of tools, the sandbox opens the door to a world where anything can be pretended and experimented with. For some others though, the sandbox is linked instead to the realm of software. Indeed, and similarly to its analogue counterpart, software sandboxes are used both to provide testing and prototyping environments, as well as to describe how users and processes can be isolated for security purposes. These two approaches play an important role in the development and execution of software. As a matter of fact, whether you are browsing a website, using an app, or working with your favourite digital tool, sandboxes have been and are currently used to enable and allow this action.
... [https://activearchives.org/mw/index.php?title=A_Social_Shell_%26_Mesh_Cookbooks A Social Shell & Mesh Cookbooks], one of the contributions to the summer school [http://relearn.be Relearn] (2014) in Brussels, prepared by Michael Murtaugh & Anne Laforet, in which they proposed "to deploy a network of small server nodes (via Raspberry Pi, Olimex, or possibly installed on individual's laptops)" that holds "a web-based commandline/shell environment (a social shell) in which commandline programming is enhanced by "dynamic" manual pages provided by a live "cookbook" or collection of stored "recipes"/scripts (the mesh cookbook)".


Truth is, digital sandboxes are everywhere and it is a bit … problematic. Indeed, stepping out of an analogue sandbox is as easy as dusting off from your clothes the particules left from the imaginary world. The same cannot be said of the digital sandboxes which bits are tightly interleaved with our daily activities and digital diet. Seeing our increasing dependence on software and network infrastructure and in a post-PRISM age, it is becoming urgent to understand how these sandboxes operate and impact production, communication and more generally social dynamics.
... [https://research.wdka.nl/index.php/news-activities/shadow-it-the-politics-of-digital-tools-in-research-and-teaching/ Shadow IT], which has been Aymeric's way to phrase and think about XPUB's infrastructure in relation to the larger institution that XPUB is part of.


The best way to explore these issues is to run your own sandbox! ''Living in a Sandbox'' aims to be a platform for:
... the game [https://silviolorusso.com/work/dir-derive/ Dir Derive (A Situationist Filesystem)] by Silvio Lorusso, Magnus Lawrie, Margaret Malcolm, Aymeric Mansoux; a project that emerged during RWX (Read/Write/eXecute) as part of Dave Young's initiative/project [https://web.archive.org/web/20180209095414/http://l-o-c-a-l-h-o-s-t.com/ l-o-c-a-l-h-o-s-t.com]. (2015), in which the filesystem is turned into a "collective ludic experience" (...) "in which multiple users discover new areas of the filesystem by interacting with each other".


* Critically (re)defining terms like Sharing, Network, Public/Private
... feminist server initiatives such as Anarchaserver, where "feminist servers have been a topic of discussion, a partially-achieved aim and a set of slow-political practices among an informal group of transfeminists interested in creating a more autonomous infrastructure to ensure that data, projects and memory of feminist groups are properly accessible, preserved and managed"[https://alexandria.anarchaserver.org/index.php/History_of_Anarchaserver_and_Feminists_Servers_visit_this_section].
* Understanding the history of networked computation, and an ability to trace to contemporary practices and to make strategic decisions in creating new work
 
</blockquote>
... [[Pubnix|public access unix systems]] (aka pubnix systems), where the server becomes a "social club" as "at its core, Unix has a social architecture, and as tilde.town users may know, there is a large subculture of people who have been using Unix and Unix-like operating systems this way for a long time"[https://tilde.town/~cmccabe/online-communities.html].
 
... and [[Living in a Sandbox]], a course taught by Aymeric & Michael at some point in time at WdKA/PZI (2008-2018?).
 
What these different initiatives have in common, is that they turn a server into a pedagogical space and social environment.


==Sandbox protocol==
==Sandbox protocol==
Line 22: Line 25:
(Soon!)
(Soon!)


== Command Line Interface (CLI) ==
Very short drafty version:
 
* a sandbox travels along with a group of students during the 2 years at XPUB
* after graduation:
** the sandbox will be archived in a static form
** students will be informed how they can download their files
** it won't be possible to log in anymore with ssh, ftp, or with jupyterlab
 
== Install yourself into the sandbox ==
 
* open the terminal (Mac, Linux) or powershell (Windows)
* <code>$ ssh XPUB1@192.168.1.XXX</code>
* what is an ip address?
** LAN: local area network (often starts with 192.168.XXX.XXX)
** WAN: wide area network
* send "hello" to the dot-matrix printer: <code>$ echo "hello" > /dev/usb/lp1</code>
* <code>$ who</code>
* <code>$ sudo adduser YOURUSERNAME</code>
* <code>logout</code> or <code>exit</code>
* <code>$ ssh YOURUSERNAME@192.168.1.XXX</code>
* <code>$ who</code>
* set your group permissions (sudo, users): <code>$ sudo adduser YOURUSERNAME GROUPNAME</code>
* try some commands: <code>$ wall</code>, <code>$ cd</code>, <code>$ ls</code>, <code>$ reboot</code>, <code>$ date</code>, <code>$ cowsay</code>, <code>$ figlet</code>
* <code>$ cd /home/</code> or <code>$ cd ~</code>, <code>$ ls</code>
 
== Log into the sandbox ==
 
We will mainly use the following ways to log into the sandbox: SSH, FTP and Jupyterlab.
 
<div class="columns-3">
===SSH===
 
====From the school====


<span id="ghost-in-the-shell"></span>
* make a user on the sandbox: <code>$ sudo adduser USERNAME</code>
=== Ghost in the Shell ===
* find the ip-address of the server: <code>$ ip address</code> (or <code>$ ip a</code> in short)
* log in remotely with [[SSH]]: <code>$ ssh USERNAME@ip-address</code>
* did it work?


From: https://vvvvvvaria.org/curriculum/In-the-Beginning-...-Was-the-Commandline/READER.html#how-to-work-with-text-commands
====From home or elsewhere====


<blockquote>Go ahead and start using the command line by opening a <code>terminal</code> application. You’ll see a text interface with a blinking cursor. What happened when you opened the terminal is that it actually opened a so-called <code>shell</code> for you. The shell (<code>sh</code>) is a software which takes your keyboard input and gives it to the computer’s operating system. There are various types of shells but the most common ones are <code>bash</code> (bourne again shell) or <code>zsh</code>.
To do this, you need to install the [[SSH_proxy_jump]] that will allow you to access the sandbox through the [[HUB|XPUB HUB]].
</blockquote>


=== Essential commands ===
===FTP===


From: https://pzwiki.wdka.nl/mediadesign/Shell_Cheat_Sheet
====From the school====


* install a FTP client, such as [https://filezilla-project.org/ Filezilla]
* add a server (using SFTP)
* host: ip-address of the sandbox
* user: YOUR USERNAME
* password: YOUR PASSWORD
====From home or elsewhere====
Not easy unfortunately...
As it is not so easy to use a proxy_jump in Filezilla (as far as i could figure out).
===Jupyter Lab===
====From the school, home or elsewhere====
(If Jupyter Lab is installed, because sometimes we install it only later in the year...)
Through the browser: <code>https://hub.xpub.nl/SANDBOXNAME/~USERNAME/__lab__/</code>
</div>
== Sandbox as Command Line Interface (CLI) ==
Once you're logged in, you can interact with the '''filesystem''' of the server and the '''programs''' that are installed on it. To do so, you need to type '''commands'''.
Let's first see who else is currently present on the server by typing the command <code>$ who</code>.
If there are others present, you can send a message to the <code>$ wall</code>! (write your message and send it with <code>CTRL+D</code>)
Every command works slightly differently, but luckily you don't have to remember all of them as these commands come with a manual :). To access these manuals, you can type: <code>$ man COMMAND</code>.
So, for example, if you type <code>$ man wall</code> and check the '''synopsis''', it says: <code>wall [-n] [-t timeout] [-g group] [message | file]</code>. This tells you that you ''need'' to type "wall", the name of the program, and ''optionally can'' use all the things in between <code>[]</code>'s. So in this case, we can also write <code>$ wall MESSAGE</code> in one line, and hit enter to send the message.
And if everyone does this at the same time, your command line may get very cosy and very noisy. :) TIP! You can prevent others to "write" to your terminal with <code>$ mesg</code>.
If you want to send a message to a particular user instead, you can use <code>$ write</code>.
Oke, it's time to move around!
Try for example the command <code>$ ls</code>... which stands for "list", this will show you all the files in the current folder.
Now try <code>$ cd /</code>... which stands for "change directory", to move to another folder, in this case "root" (<code>/</code>).
Try <code>$ ls</code> again to see what is here...
And wander a bit around!
Some places to definitely check out, because they will be places that you might come back to quite a bit:
* <code>/home/</code>
* <code>/etc/</code>
* <code>/var/</code>
===CLI introductions===
If you would like to go over all these thing more slowly, and step by step, you can try the following resources:
* [https://solarpunk.cool/zines/map-is-the-territory/ The Map is the Territory], shell introduction zine by [https://coolguy.website/ Zach Mandeville] and [https://angblev.com/ Angelica Blevins] from [https://solarpunk.cool/ solarpunk.cool]; [https://git.sr.ht/~zim/map-is-the-territory sources of the zine]
* [https://vvvvvvaria.org/curriculum/In-the-Beginning-...-Was-the-Commandline/READER.html#how-to-work-with-text-commands In the Beginning … Was the Commandline], reader publishing by Varia (2018)
== Way too many other CLI commands that you can try out ==
From: https://pzwiki.wdka.nl/mediadesign/Shell_Cheat_Sheet<br>
From: https://community.linuxmint.com/tutorial/view/244
From: https://community.linuxmint.com/tutorial/view/244


<div id="cli-cheatsheet">
==== System Info ====
==== System Info ====


Line 43: Line 143:
'''cal''' – Show this month’s calendar<br />
'''cal''' – Show this month’s calendar<br />
'''uptime''' – Show current uptime<br />
'''uptime''' – Show current uptime<br />
'''w''' – Display who is online<br />
'''w''' – Display who is online (same as '''who''')<br />
'''whoami''' – Who you are logged in as<br />
'''whoami''' – Who you are logged in as<br />
'''finger ''user''''' – Display information about '''''user'''''<br />
'''finger ''user''''' – Display information about '''''user'''''<br />
Line 57: Line 157:
'''Enter''' – Run the command<br />
'''Enter''' – Run the command<br />
'''Up Arrow''' – Show the previous command<br />
'''Up Arrow''' – Show the previous command<br />
'''Ctrl + R''' – Allows you to type a part of the command you’re looking for and finds it
'''Ctrl + Z''' – Stops the current command, resume with '''fg''' in the foreground or '''bg''' in the background<br />
'''Ctrl + C''' – Halts the current command, cancel the current operation and/or start with a fresh new line<br />
'''Ctrl + C''' – Halts the current command, cancel the current operation and/or start with a fresh new line<br />
'''Ctrl + L''' – Clear the screen
'''Ctrl + L''' – Clear the screen


'''''command'' | less''' – Allows the scrolling of the bash command window using '''Shift + Up Arrow''' and '''Shift + Down Arrow'''<br />
'''''command'' | less''' – Allows the scrolling of the bash command window using '''Shift + Up Arrow''' and '''Shift + Down Arrow'''<br />
'''!!''' – Repeats the last command<br />
'''!!''' – Repeats the last command
'''!\$''' – Repeats the last argument of the previous command<br />
'''Esc + . (a period)''' – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command


'''Ctrl + A''' – Return to the start of the command you’re typing<br />
'''Ctrl + A''' – Return to the start of the command you’re typing<br />
'''Ctrl + E''' – Go to the end of the command you’re typing<br />
'''Ctrl + E''' – Go to the end of the command you’re typing<br />
'''Ctrl + U''' – Cut everything before the cursor to a special clipboard, erases the whole line<br />
'''Ctrl + D''' – Log out of current session, similar to '''exit'''
'''Ctrl + K''' – Cut everything after the cursor to a special clipboard<br />
'''Ctrl + Y''' – Paste from the special clipboard that '''Ctrl + U''' and '''Ctrl + K''' save their data to<br />
'''Ctrl + T''' – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)<br />
'''Ctrl + W''' – Delete the word / argument left of the cursor in the current line '''Ctrl + D''' – Log out of current session, similar to '''exit'''
 
==== Learn the Commands ====
 
'''apropos''' '''''subject''''' – List manual pages for '''''subject'''''<br />
'''man -k ''keyword''''' – Display man pages containing '''''keyword'''''<br />
'''man ''command''''' – Show the manual for '''''command'''''<br />
'''man -t ''man'' | ps2pdf - &gt; ''man.pdf''''' – Make a pdf of a manual page<br />
'''which''' '''''command''''' – Show full path name of '''''command'''''<br />
'''time ''command''''' – See how long a '''''command''''' takes
 
'''whereis ''app''''' – Show possible locations of '''''app'''''<br />
'''which ''app''''' – Show which '''''app''''' will be run by default; it shows the full path


==== Searching ====
==== Searching ====
Line 141: Line 220:
'''ls''' – Directory listing<br />
'''ls''' – Directory listing<br />
'''ls -l''' – List files in current directory using long format<br />
'''ls -l''' – List files in current directory using long format<br />
'''ls -laC''' – List all files in current directory in long format and display in columns<br />
'''ls -F''' – List files in current directory and indicate the file type<br />
'''ls -al''' – Formatted listing with hidden files
'''ls -al''' – Formatted listing with hidden files


Line 222: Line 299:
Meta Characters are characters that have special meaning within the terminal
Meta Characters are characters that have special meaning within the terminal


* <code>~</code> the tilde stands for the user’s home. <code>cd ~/</code> change directory to home
<code>~</code> the tilde stands for the user’s home. <code>cd ~/</code> change directory to home
* <code>.</code> dot stands for '''this''' directory. <code>ls .</code> list this directory
* <code>..</code> dot dot stands for '''the parent directory''' to this directory. <code>cp myfile.jpg ..</code> copy myfile.jpg to the parent directory
* <code>*</code> asterisk is a wildcards which represents zero or more characters <code>ls P*.jpg</code> will list all the files, in the current directory, that begin with P and end with .jpg
* <code>\</code> backslash it is a literal character. It escape the meta value of the meta-characters and display them only as literal characters. <code>echo Foo \*</code> will output <code>Foo *</code> If \ wasn’t there it would output all the files in that directory.


==== man pages ====
<code>.</code> dot stands for '''this''' directory. <code>ls .</code> list this directory


'''man pages are manuals of program.''' They tells you what the program is, what it can do and how.
<code>..</code> dot dot stands for '''the parent directory''' to this directory. <code>cp myfile.jpg ..</code> copy myfile.jpg to the parent directory


<code>man df</code> show the manual for the program '''df''' that is used to display the free disk space
<code>*</code> asterisk is a wildcards which represents zero or more characters <code>ls P*.jpg</code> will list all the files, in the current directory, that begin with P and end with .jpg


Can you find out how to display the output from df in a human readable format?
<code>\</code> backslash it is a literal character. It escape the meta value of the meta-characters and display them only as literal characters. <code>echo Foo \*</code> will output <code>Foo *</code> If \ wasn’t there it would output all the files in that directory.


==== pipe ====
==== pipes ====


'''A pipes (” | “) sends the output of one program to the input of another program'''.
'''A pipe (” | “) sends the output of one program to the input of another program'''.


<code>echo &quot;my sentence&quot;| wc</code> the echoed sentence “my sentence” is ''pipped'' into the program wc which counts the number of lines, words, and characters
<code>echo &quot;my sentence&quot;| wc</code> the echoed sentence “my sentence” is ''pipped'' into the program wc which counts the number of lines, words, and characters
Line 264: Line 337:
<code>sudo apt remove [app name]</code>
<code>sudo apt remove [app name]</code>


== Links ==
</div>
 
------------------
 
== Sandbox as webserver ==
 
We can install webserver software on the sandbox, which will allow us to interact with the server using the web. The most often used webserver softwares are apache and nginx. At XPUB we often use nginx, so let's do the same here, so we can copy/paste configuration info ;). 
 
To install a webserver, someone needs to run the following, which will install the webserver for all users on the server:
 
$ sudo apt install nginx
 
Oke, nginx is installed!
 
Changes to the configuration of nginx are made here: <code>/etc/nginx/sites-available/default</code>
 
$ sudo cat /etc/nginx/sites-available/default
 
Here we can for example enable the "autoindex on" function, by adding:
 
location / {
    autoindex on;
}
 
Changes will apply after reloading nginx:
 
$ sudo service nginx reload
 
===Shared public folder===
 
When you install nginx, it automatically makes a specific folder where we can store web pages that we want to publish: <code>/var/www/html/</code>
 
$ cd /var/www/html/
 
See what is there:
 
$ ls
 
Let's make a folder for some "hello hyperworld" first pages on this sandbox:
 
$ mkdir hello
$ cd hello
 
Make a web page in this folder with nano (a CLI text editor):
 
$ nano /var/www/html/hello/YOURUSERNAME.html
 
You can press CTRL+X to close the file, and type "Y" to save the changes.
 
And now visit it in the browser: http://192.168.1.XXX/hello/
 
===Personal public folder===
 
Next to this folder, you can publish stuff in your ''home'' folder, in the <code>public_html</code> folder.
 
$ cd /home/
$ ls
$ cd YOURUSERNAME
$ cd public_html
 
Make a web page and publish it in your personal <code>public_html</code>:
 
$ nano /home/YOURUSERNAME/public_html/hello.html
 
or
 
$ nano ~/public_html/hello.html
 
And now visit it in the browser: http://192.168.1.XXX/~YOURUSERNAME/hello.html
 
'''Hmm, there is no <code>public_html</code> folder?'''
 
If this folder does not exist yet, you need to enable this feature in the nginx configuration:
 
$ sudo nano /etc/nginx/sites-enabled/default
 
Add the following:
 
        location ~ ^/~(.+?)(/.*)?$ {
                alias /home/$1/public_html$2;
                index index.html index.htm;
                autoindex on; # this feature automatically lists all files in the public_html folder!
        }
 
Test if your changes did not contain mistakes:
 
$ sudo nginx -t
 
And reload nginx to apply the changes:
 
$ sudo service nginx reload
 
===How to make a web page?===
 
If you want to dive further into HTML and CSS, see: [[HTML + CSS]] (also printed as a notebook)
 
=== Extra assignment: many hands on keyboards ===
 
Set up a collaborative way of making the index.html page for the server, using etherpad, and find a way to include hints in the page about how this web page has been made.
 
Constraints:
 
* only one file! (no extra files for css or js, also not extra media)
* all images and other media as base64
* '''hint''': <code>$ wget https://pad.xpub.nl/p/<yourpad>/export/txt > /var/www/html/index.html</code>
 
== Previous sandboxes ==
 
* https://hub.xpub.nl/sandbox/ (2019/2020)
* https://hub.xpub.nl/sandbot/ (2020/2021)
* https://hub.xpub.nl/soupboat/ (2021/2022)
* https://hub.xpub.nl/breadcube/ (2022/2023)
* https://hub.xpub.nl/chopchop/ (2023/2024)


* https://hub.xpub.nl/sandbox/ (XPUB4’s server)
See also: [[HUB]]
* https://hub.xpub.nl/sandbot/ (XPUB3’s server)
* https://hub.xpub.nl/soupboat/ (XPUB2’s server)
* https://pzwiki.wdka.nl/mediadesign/Sandbox (PZI wiki page about the idea of the Sandbox)
* https://www.bleu255.com/~aymeric/dump/aymeric_mansoux-sandbox_culture_phd_thesis-2017.pdf (Aymeric’s PhD Thesis “Sandbox Culture, A Study of the Application of Free and Open Source – Software Licensing Ideas to Art and Cultural Production”
* https://vvvvvvaria.org/curriculum/In-the-Beginning-...-Was-the-Commandline/READER.html#how-to-work-with-text-commands (In the Beginning … Was the Commandline, reader publishing by Varia (2018))
* https://pzwiki.wdka.nl/mediadesign/Shell_Cheat_Sheet (shell cheat sheet)
* https://solarpunk.cool/zines/map-is-the-territory/ (The Map is the Territory, shell introduction zine by Zach Mandeville (https://coolguy.website/) and Angelica Blevins (https://angblev.com/) from https://solarpunk.cool/; sources of the zine: https://git.sr.ht/~zim/map-is-the-territory)

Latest revision as of 20:56, 16 September 2024

Hello Sandbox!

Every year's group of XPUB students carries along with them a "sandbox": a shared server that is used in classes, as part of Special Issues and the second year.

The term "sandbox" and the thinking around it crosses different projects, courses, ideas and terms, including ...

... Aymeric's PhD thesis Sandbox Culture: A Study of the Application of Free and Open Source Software Licensing Ideas to Art and Cultural Production (2017), where he is using the image of the sandbox to refer to environments "where code becomes a constituent device for different communities to experience varying ideologies and practices".

... A Social Shell & Mesh Cookbooks, one of the contributions to the summer school Relearn (2014) in Brussels, prepared by Michael Murtaugh & Anne Laforet, in which they proposed "to deploy a network of small server nodes (via Raspberry Pi, Olimex, or possibly installed on individual's laptops)" that holds "a web-based commandline/shell environment (a social shell) in which commandline programming is enhanced by "dynamic" manual pages provided by a live "cookbook" or collection of stored "recipes"/scripts (the mesh cookbook)".

... Shadow IT, which has been Aymeric's way to phrase and think about XPUB's infrastructure in relation to the larger institution that XPUB is part of.

... the game Dir Derive (A Situationist Filesystem) by Silvio Lorusso, Magnus Lawrie, Margaret Malcolm, Aymeric Mansoux; a project that emerged during RWX (Read/Write/eXecute) as part of Dave Young's initiative/project l-o-c-a-l-h-o-s-t.com. (2015), in which the filesystem is turned into a "collective ludic experience" (...) "in which multiple users discover new areas of the filesystem by interacting with each other".

... feminist server initiatives such as Anarchaserver, where "feminist servers have been a topic of discussion, a partially-achieved aim and a set of slow-political practices among an informal group of transfeminists interested in creating a more autonomous infrastructure to ensure that data, projects and memory of feminist groups are properly accessible, preserved and managed"[1].

... public access unix systems (aka pubnix systems), where the server becomes a "social club" as "at its core, Unix has a social architecture, and as tilde.town users may know, there is a large subculture of people who have been using Unix and Unix-like operating systems this way for a long time"[2].

... and Living in a Sandbox, a course taught by Aymeric & Michael at some point in time at WdKA/PZI (2008-2018?).

What these different initiatives have in common, is that they turn a server into a pedagogical space and social environment.

Sandbox protocol

(Soon!)

Very short drafty version:

  • a sandbox travels along with a group of students during the 2 years at XPUB
  • after graduation:
    • the sandbox will be archived in a static form
    • students will be informed how they can download their files
    • it won't be possible to log in anymore with ssh, ftp, or with jupyterlab

Install yourself into the sandbox

  • open the terminal (Mac, Linux) or powershell (Windows)
  • $ ssh XPUB1@192.168.1.XXX
  • what is an ip address?
    • LAN: local area network (often starts with 192.168.XXX.XXX)
    • WAN: wide area network
  • send "hello" to the dot-matrix printer: $ echo "hello" > /dev/usb/lp1
  • $ who
  • $ sudo adduser YOURUSERNAME
  • logout or exit
  • $ ssh YOURUSERNAME@192.168.1.XXX
  • $ who
  • set your group permissions (sudo, users): $ sudo adduser YOURUSERNAME GROUPNAME
  • try some commands: $ wall, $ cd, $ ls, $ reboot, $ date, $ cowsay, $ figlet
  • $ cd /home/ or $ cd ~, $ ls

Log into the sandbox

We will mainly use the following ways to log into the sandbox: SSH, FTP and Jupyterlab.

SSH

From the school

  • make a user on the sandbox: $ sudo adduser USERNAME
  • find the ip-address of the server: $ ip address (or $ ip a in short)
  • log in remotely with SSH: $ ssh USERNAME@ip-address
  • did it work?

From home or elsewhere

To do this, you need to install the SSH_proxy_jump that will allow you to access the sandbox through the XPUB HUB.

FTP

From the school

  • install a FTP client, such as Filezilla
  • add a server (using SFTP)
  • host: ip-address of the sandbox
  • user: YOUR USERNAME
  • password: YOUR PASSWORD

From home or elsewhere

Not easy unfortunately...

As it is not so easy to use a proxy_jump in Filezilla (as far as i could figure out).

Jupyter Lab

From the school, home or elsewhere

(If Jupyter Lab is installed, because sometimes we install it only later in the year...)

Through the browser: https://hub.xpub.nl/SANDBOXNAME/~USERNAME/__lab__/

Sandbox as Command Line Interface (CLI)

Once you're logged in, you can interact with the filesystem of the server and the programs that are installed on it. To do so, you need to type commands.

Let's first see who else is currently present on the server by typing the command $ who.

If there are others present, you can send a message to the $ wall! (write your message and send it with CTRL+D)

Every command works slightly differently, but luckily you don't have to remember all of them as these commands come with a manual :). To access these manuals, you can type: $ man COMMAND.

So, for example, if you type $ man wall and check the synopsis, it says: wall [-n] [-t timeout] [-g group] [message | file]. This tells you that you need to type "wall", the name of the program, and optionally can use all the things in between []'s. So in this case, we can also write $ wall MESSAGE in one line, and hit enter to send the message.

And if everyone does this at the same time, your command line may get very cosy and very noisy. :) TIP! You can prevent others to "write" to your terminal with $ mesg.

If you want to send a message to a particular user instead, you can use $ write.

Oke, it's time to move around!

Try for example the command $ ls... which stands for "list", this will show you all the files in the current folder.

Now try $ cd /... which stands for "change directory", to move to another folder, in this case "root" (/).

Try $ ls again to see what is here...

And wander a bit around!

Some places to definitely check out, because they will be places that you might come back to quite a bit:

  • /home/
  • /etc/
  • /var/

CLI introductions

If you would like to go over all these thing more slowly, and step by step, you can try the following resources:

Way too many other CLI commands that you can try out

From: https://pzwiki.wdka.nl/mediadesign/Shell_Cheat_Sheet
From: https://community.linuxmint.com/tutorial/view/244

System Info

date – Show the current date and time
cal – Show this month’s calendar
uptime – Show current uptime
w – Display who is online (same as who)
whoami – Who you are logged in as
finger user – Display information about user
uname -a – Show kernel information
cat /proc/cpuinfo – CPU information
cat /proc/meminfo – Memory information
df -h – Show disk usage
du – Show directory space usage
free – Show memory and swap usage

Keyboard Shortcuts

Enter – Run the command
Up Arrow – Show the previous command
Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L – Clear the screen

command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
!! – Repeats the last command

Ctrl + A – Return to the start of the command you’re typing
Ctrl + E – Go to the end of the command you’re typing
Ctrl + D – Log out of current session, similar to exit

Searching

grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name “\filename\– Starting with the root directory, look for the file containing the string *filename*
locate filename** – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind

File Permissions

chmod octal file – Change the permissions of file to ’’octal’’, which can be found separately for user, group, and world by adding: 4 – read (r), 2 – write (w), 1 – execute (x)
Examples:
chmod 777 filename – read, write, execute for all
chmod 755 filename – rwx for owner, rx for group and world

chmod symbolic file – You can also change permissions in symbolic mode.
Examples:
chmod ugo+x filename – to make a file executable
chmod g+w filename – to grant write access to the group
chmod o-r filename – to remove read access to others

u: user
g: group
o: others

r: read
w: write
x: executable

-R: recursively

For more options, see man chmod.

File Ownership

chown – change ownership

chown name_of_new_owner ’’filename’’
chown newuser:newgroup filename – To change ownership of a file to newuser and the group newgroup
chown root:www-data /var/www/html/ – To change ownership of a file to root and the group www-data

Check the current ownership of a file with: ls -l
Check which groups you are in with: groups

File Commands

ls – Directory listing
ls -l – List files in current directory using long format
ls -al – Formatted listing with hidden files

cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory

rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)

cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn’t exist
cp file /home/dirname – Copy the filename called file to the /home/dirname directory

mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2

ln -s file link – Create symbolic link link to file
touch file – Create or update file
cat > file – Places standard input into file
cat file – Display the file called file

more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines

Network

ifconfig – List IP addresses for all devices on the local machine
iwconfig – Used to set the parameters of the network interface which are specific to the wireless operation (for example: the frequency)
iwlist – used to display some additional information from a wireless network interface that is not displayed by iwconfig
ping host – Ping host and output results
whois domain – Get whois information for domain
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
wget file – Download file
wget -c file – Continue a stopped download

SSH

ssh user@host – Connect to host as user
ssh -p port user@host – Connect to host on port port as user
ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login

User Administration

adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user

Process Management

ps – Display your currently active processes
top – Display all running processes
kill pid – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground

Stopping & Starting

shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system

meta characters

Meta Characters are characters that have special meaning within the terminal

~ the tilde stands for the user’s home. cd ~/ change directory to home

. dot stands for this directory. ls . list this directory

.. dot dot stands for the parent directory to this directory. cp myfile.jpg .. copy myfile.jpg to the parent directory

* asterisk is a wildcards which represents zero or more characters ls P*.jpg will list all the files, in the current directory, that begin with P and end with .jpg

\ backslash it is a literal character. It escape the meta value of the meta-characters and display them only as literal characters. echo Foo \* will output Foo * If \ wasn’t there it would output all the files in that directory.

pipes

A pipe (” | “) sends the output of one program to the input of another program.

echo "my sentence"| wc the echoed sentence “my sentence” is pipped into the program wc which counts the number of lines, words, and characters

write

> Writes the output of a command to a file, rather than to print on terminal.

df > df_output.txt redirect the content of man dfM to a file called df_output.txt

If the said file doesn’t exit it will create it, if it already exists it will overwrite its contents/

append

>> appends the output of a command to a file, without overwriting the original file.

echo 'also add this' >> df_output.txt will add ‘also add this’ to the contents of df_output.txt

package managers

Package managers like apt-get and aptitude (on Debian/Ubuntu Linux distributions) and Homebrew and MacPorts on Mac, allow more (command-line, but not only) programs, than the ones that come with the operating, to be installed on our system.

sudo apt search [app name]
sudo apt install [app name]
sudo apt remove [app name]


Sandbox as webserver

We can install webserver software on the sandbox, which will allow us to interact with the server using the web. The most often used webserver softwares are apache and nginx. At XPUB we often use nginx, so let's do the same here, so we can copy/paste configuration info ;).

To install a webserver, someone needs to run the following, which will install the webserver for all users on the server:

$ sudo apt install nginx

Oke, nginx is installed!

Changes to the configuration of nginx are made here: /etc/nginx/sites-available/default

$ sudo cat /etc/nginx/sites-available/default

Here we can for example enable the "autoindex on" function, by adding:

location / {
   autoindex on;
}

Changes will apply after reloading nginx:

$ sudo service nginx reload

Shared public folder

When you install nginx, it automatically makes a specific folder where we can store web pages that we want to publish: /var/www/html/

$ cd /var/www/html/

See what is there:

$ ls 

Let's make a folder for some "hello hyperworld" first pages on this sandbox:

$ mkdir hello
$ cd hello

Make a web page in this folder with nano (a CLI text editor):

$ nano /var/www/html/hello/YOURUSERNAME.html

You can press CTRL+X to close the file, and type "Y" to save the changes.

And now visit it in the browser: http://192.168.1.XXX/hello/

Personal public folder

Next to this folder, you can publish stuff in your home folder, in the public_html folder.

$ cd /home/
$ ls
$ cd YOURUSERNAME
$ cd public_html

Make a web page and publish it in your personal public_html:

$ nano /home/YOURUSERNAME/public_html/hello.html

or

$ nano ~/public_html/hello.html

And now visit it in the browser: http://192.168.1.XXX/~YOURUSERNAME/hello.html

Hmm, there is no public_html folder?

If this folder does not exist yet, you need to enable this feature in the nginx configuration:

$ sudo nano /etc/nginx/sites-enabled/default

Add the following:

       location ~ ^/~(.+?)(/.*)?$ {
               alias /home/$1/public_html$2;
               index index.html index.htm;
               autoindex on; # this feature automatically lists all files in the public_html folder!
       }

Test if your changes did not contain mistakes:

$ sudo nginx -t

And reload nginx to apply the changes:

$ sudo service nginx reload

How to make a web page?

If you want to dive further into HTML and CSS, see: HTML + CSS (also printed as a notebook)

Extra assignment: many hands on keyboards

Set up a collaborative way of making the index.html page for the server, using etherpad, and find a way to include hints in the page about how this web page has been made.

Constraints:

  • only one file! (no extra files for css or js, also not extra media)
  • all images and other media as base64
  • hint: $ wget https://pad.xpub.nl/p/<yourpad>/export/txt > /var/www/html/index.html

Previous sandboxes

See also: HUB