*Social Shell
===================
'SSHartre: Shell is other people'
We create *user accounts* on the server for each participant and introduction to using the *shell*
- Debian (and Mac OSX) is based on UNIX, a multi-user system developed in the 1960s at a time when computers were room sized and extremely expensive machines. Time sharing systems were a radical step that allowed multiple users to connect simultaeously to the same computer and share its resources. As a result, UNIX includes many commands, design features, and idiosyncracies that reflect the social nature of the computer as a shared resource.
- The multiuser capabilities of the operating system are a bit like vestigial organs in a modern operating system where often you are the sole primary user of your laptop. The social features of the shell only really become apparent when you use a *remote* login to connect to a *shared server*. *ssh* is a commandline software program that allows you to remotely login to another machine. It stands for *secure shell*. All traffic on *ssh* is encrypted. Linux and mac users have *ssh* already built in. Windows users should download a software like [PuTTY]( http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ).
Superuser
-------------------
Select one person to play the *superuser*, preferrably somebody that never used the shell before. Those with experience should offer to help.
The *superuser* opens a terminal window and types the command:
You will see the following:
- The authenticity of host '10.9.8.7 (10.9.8.7)' can't be established.
- ECDSA key fingerprint is 42:3f:ec:d1:97:19:19:ea:5f:8b:f9:b8:d4:60:39:3a.
- Are you sure you want to continue connecting (yes/no)?
type:
and then the password:
You should see the relearn server's welcome message.
If things go wrong (you don't see the message), just start again from:
You can now create accounts for the other people seated at your table (and also one for yourself!).
Each person should choose a *username* (it should not have spaces) and write it on the IP card and pass it to the super user, who in turn should perform the command:
Now, while logged in as *admin* to the server, the superuser enters the following commands to create a user for each person:
When you use sudo the first time, you will need to re-enter the password "relearn".
You will see:
- We trust you have received the usual lecture from the local System
- Administrator. It usually boils down to these three things:
- #1) Respect the privacy of others.
- #2) Think before you type.
- #3) With great power comes great responsibility.
Fill in the *administrative questions* if you like (or leave them blank ;)
For the password: give each user the same password "relearn" (they can change it later).
Finally *add each user to the "www-data" group* (use the same USERNAME):
- sudo adduser USERNAME www-data
Having all the users in the www-data group allows us to share files with each other using the web server.
That's it, you have made a user login: pass back the card to the user.
when all users have been added, the superuser logs out by typing:
You should see:
- logout
- Connection to 10.9.8.7 closed.
What to do with your new login
----------------------------------------------------
Once you have been given your card back from the superuser, try to login with your username:
The first time you connect, you will see the following:
- The authenticity of host '10.9.8.7 (10.9.8.7)' can't be established.
- ECDSA key fingerprint is 42:3f:ec:d1:97:19:19:ea:5f:8b:f9:b8:d4:60:39:3a.
- Are you sure you want to continue connecting (yes/no)?
type:
Use the password "relearn".
You are now connected to the relearn server.
The *who* command will show you others that are logged in, you can speak to other users with the write command, just use their username:
What pts/n means in the list?
"A tty is a native terminal device, the backend is either hardware or kernel emulated. [ what is hardware? a typewriter hardwired to the motherboard?]
A pty (pseudo terminal device) is a terminal device which is emulated by an other program (example: xterm, screen, or ssh are such programs).
A pts is the slave part of a pty."
Try:
The write command will wait for your input; it reads from *stdin* (or "standard in") which means it reads from the keyboard by default.
Type your message, then hit return and press _one time (on a blank line) Ctrl-D (which means "end of file").
(NB: In OSX: you want to use the _ctrl_ key and not the regular _Command_ key (which splits the terminal. Pressing Cmd-Shift-D will undo this)
Note: Press it just once (at the start of a blank line) when a command (like write) is reading from stdin. If you press Ctrl-D again (at the normal shell prompt) you will logout from the server. To login, you will then need to start again with the ssh command.
To check whether you are still logged in, your prompt should look
To prevent messages from appearing on your screen
- mesg n
- (thanks! how to put them on again? mesg y?)... try man mesg (but y!)
BONUS
Try also:
You can customize your "plan" by adding a file called .plan in your homefolder.
The mail command can be used to compose and receive email messages.
Command History
-----------------
You can generally use the arrow keys to go back and forth in the history of your commands. Try it!
Read a manual
Try some more commands:
- date
- man date
- man man <3
- figlet hello
- man figlet
When you use the *man* command you enter a program to read the manual of a particular command; you can scroll with the arrow keys and you can press _q_ to quit it and return to the terminal.
When you start figlet without any options, it also reads from *stdin* (standard input). By default this is the keyboard; note how it responsds as you type. To stop, press Ctrl-D on a line by itself.
Programs often take options, typically preceded by the "dash" character (-). Like:
The explanation for all the options of a program are given in the man page:
Promiscuous Pipelines
-----------------------
The special character "|" is called the pipe and can be used to connect multiple commands.
Try these commands:
date +%A
date +%A | figlet
- whoami | figlet | write SOMEBODY
Password
--------------------
You can change you password if you want using:
passwd
add yourself to the sudo group
(level: advanced)
you can add yourself to the sudo-group, and use the sudo-command.
to do this, you should be root. To become root, type the command
../images/who.png