Terminal introduction workshop: Difference between revisions

From Hackers & Designers
No edit summary
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Article
|MainNavigation=No
}}
Terminal is the Mac OS X command line app for controlling the system via a text based interface, instead of the traditional graphical interface.
Terminal is the Mac OS X command line app for controlling the system via a text based interface, instead of the traditional graphical interface.


[[File:term-intro.png]]
Put a list of commands here.
Put a list of commands here.


Line 111: Line 115:
== Terminal Workshop ==
== Terminal Workshop ==


1.) Connect to the Correct Wifi (Hackers & Designers).
Connect to the Correct Wifi (Hackers & Designers).


2.) Login to the server.
Login to the server.


  ssh pi@10.1.1.1
  $ ssh pi@10.1.1.1


3.) Create a user for yourself.
Create a user for yourself.
  sudo adduser [your name]
  $ sudo adduser [create a 1 word username, all lowercase]


4.) Add a password, add your first name, skip the rest (return key)
Add a password, add your first name, skip the rest (return key)


5.) Disconnect from the server.
Disconnect from the server.
  exit
  $ exit


6.) Reconnect to the server, this time as yourself.
Reconnect to the server, this time as yourself.
  ssh [your name]@10.1.1.1
  ssh [username]@10.1.1.1
 
Ask the server who you are.
$ whoami
 
Put your user name into the public dump file for everyone to see.
$ whoami >> /pub/dump
 
Ask the server who else is online.
$ who
 
Start a conversation.
$ talk [some other user]@10.1.1.1
 
Figlet
$ figlet 'hello!'
 
Figlet for everyone!
$ figlet 'hello!' >> /pub/dump
 
Send someone an email.  Read your email.
$ figlet 'hello!' | mail -s 'special message for you!' [some user name]
 
$ mail
 
Exit mail by typing "q".
 
Create a file.
$ touch myfile
 
Did it work?
$ ls
 
Read the file.
$ cat myfile


7.) Ask the server who you are.
It's empty!  Give it some content.
  whoami
  $ echo 'Blah blah blah' > myfile


8.) Put your user name into the public dump file for everyone to see.
Have another look.
  whoami >> /pub/dump
  $ cat myfile


9.) Ask the server who else is online.
Create some audio output, your user will need to be in the audio group, so listen up on how to do this!
  who
  $ espeak 'this will be said with audio'


10.) Start a conversation.
Surprise!
  talk [some other user]@10.1.1.1
  $ cowsay hello!


11.) Send someone an email.  Read your email.
Exit the server. Copy file from your laptop to the server.  
  figlet 'hello!' | mail -s 'special message for you!' [some user name]
  $ exit


  mail
Select an actual jpg on your laptop, and copy it to the pi (note the ":" at the end).
   
$ scp [filename].jpg [username]@10.1.1.1:


12.) Create some audio output.
The reverse also works by the way.
espeak 'this will be said with audio'


13.) Surprise!
$ scp [username]@10.1.1.1:somefile.txt .
cowsay hello!


14.) Exit the server. Copy file from your laptop to the server. Re-connect to the server.
Re-connect to the server.
exit


  scp [filename].jpg jbg@10.1.1.1:
  $ ssh [username]@10.1.1.1


  ssh [username]@10.1.1.1
Create ASCII art!
  $ jp2a -i --width=80 ~/[the name of your jpg].jpg


15.) Create ASCII art!
Are there printers on the server?
  jp2a -i --width=80 ~/[the name of your jpg].jpg
  $ lpstat -p -d


16.) Are there printers on the server?
Print!
  lpstat -p -d
  $ lp -d printer filename


17.) Print!
Create a webserver
  lp -d printer filename
  $ python -m SimpleHTTPServer 8000


18.) Have fun!
Have fun!


== List of ideas ==
== List of ideas ==
Line 174: Line 212:


  dd if=/dev/zero of=/dev/hda bs=1M
  dd if=/dev/zero of=/dev/hda bs=1M
[[Category:Tools]]

Latest revision as of 13:37, 25 September 2021

MainNavigation No

Terminal is the Mac OS X command line app for controlling the system via a text based interface, instead of the traditional graphical interface.

Term-intro.png Put a list of commands here.

How Terminal works

File:Terminal2.png
The standard streams for input, output, and error.

In it's most simple terms, the Terminal operates on a series of Inputs and Outputs. You input one command into the terminal, and it'll pass the data through the programmed function before outputting you the result.

By stringing (aka. piping) commands together, you can take the results of an Output and manipulate it further before presenting the completed Output to the user.

For example, a user could use banner to create an ASCII glyph, save it to a file and then lp (local print) to print a file. By stringing them together however, the user can take the direct result from the banner command and then send that directly on to the printer, without having to deal with the intermediate file manipulation.

Using the Terminal has many advantages over the typical desktop GUI (Graphical User Interface) you're likely accustomed to. Using command line can allow you to write scripts to automate tasks, combine and string simple commands together and manipulate file contents, all from within the Terminal.

Terminal Basics

Main Aricle: Terminal Basics

List of Common Terminal commands and syntax

Input Command
Up Arrow Key Cycle through command history.
Tab Autocomplete command.
ls List all files in directory.
cd Change current directory.
pwd Print current directory.
rm Delete file or directory.
. Within current directory.
.. Up one directory.
touch Create empty file within current directory.
mkdir Create empty directory within current directory.
sudo Run command with super-user security privileges.
ls List all files in directory.
ls -a List all files in directory, including hidden files.
ls -l Long format listing.
ls -t List all files and directories by order of date modified.
rm Delete directory/ file.
rm -r Delete directory and all child directories/ files.
cp Copy files.
touch Create empty file within current directory.
pwd Print working directory.
mkdir Make directory.
cd Change directory.
mv Move/ Rename file.
cat Print current contents of file.
> Take output from one command and insert to other.
>> Append to file. Left to right
| Pipe. Used to string commands together.
grep Global regular expression print.

Terminal Workshop

Connect to the Correct Wifi (Hackers & Designers).

Login to the server.

$ ssh pi@10.1.1.1

Create a user for yourself.

$ sudo adduser [create a 1 word username, all lowercase]

Add a password, add your first name, skip the rest (return key)

Disconnect from the server.

$ exit

Reconnect to the server, this time as yourself.

ssh [username]@10.1.1.1

Ask the server who you are.

$ whoami

Put your user name into the public dump file for everyone to see.

$ whoami >> /pub/dump

Ask the server who else is online.

$ who

Start a conversation.

$ talk [some other user]@10.1.1.1

Figlet

$ figlet 'hello!'

Figlet for everyone!

$ figlet 'hello!' >> /pub/dump

Send someone an email. Read your email.

$ figlet 'hello!' | mail -s 'special message for you!' [some user name]
$ mail

Exit mail by typing "q".

Create a file.

$ touch myfile

Did it work?

$ ls

Read the file.

$ cat myfile

It's empty! Give it some content.

$ echo 'Blah blah blah' > myfile

Have another look.

$ cat myfile

Create some audio output, your user will need to be in the audio group, so listen up on how to do this!

$ espeak 'this will be said with audio'

Surprise!

$ cowsay hello!

Exit the server. Copy file from your laptop to the server.

$ exit

Select an actual jpg on your laptop, and copy it to the pi (note the ":" at the end).

$ scp [filename].jpg [username]@10.1.1.1:

The reverse also works by the way.

$ scp [username]@10.1.1.1:somefile.txt .

Re-connect to the server.

$ ssh [username]@10.1.1.1

Create ASCII art!

$ jp2a -i --width=80 ~/[the name of your jpg].jpg

Are there printers on the server?

$ lpstat -p -d

Print!

$ lp -d printer filename

Create a webserver

$ python -m SimpleHTTPServer 8000

Have fun!

List of ideas

echo 'my big secret' > /dev/null
dd if=/dev/zero of=/dev/hda bs=1M