1.1 Fun with terminal
Migration
comp-eng terminal fun
setup:
IMPORTANT:
With great power comes great responsibility: the tools you learn today are powerful, and if used correctly can make you a computer ninja. Abusing them can get you in progresstrouble with HPA or in the outside world, with greater consequences. Attacking or invading another computer without permission is grounds for dismissal at HPA, according to the student handbook and acceptable use policy at HPA.
What we do in the elab, stays in the elab.
First notes:
Why do we mess with terminal?
- it is seen everywhere
- it can be done remotely
- it give you god-like powers
- it looks cool
Stopping stuff:
- ctrl-c means cancel
- ctrl-z means halt (stop everything, not gracefully)
Part one: internet tools: ping, traceroute, nslookup, dns
ping:
- what is it?
- sends a data packet to a computer and records the time it takes to echo back to your computer:

- Note that it repeats, sending a packet 64 bytes in size to the computer at 10.14.84.12, taking about 1.85 ms (milliseconds) to return.
- 1000 milliseconds =1 second 1 second, so this computer is likely on your network, wired and responsive
- what is it?
- traces the path to a computer, listing the time each packet spends at each node:

- Notice that each of these has a name attached to it.
- In the internet, each number is an address, and a domain name server (dns) converts these from names to numbers and reverse.
- Notice that each name has a number in parentheses after it
- Notice also that there are times listed after each one-this is the time spent at each node between your computer and www.apple.com
- what is it?
- looks up and translates names into numbers, using DNS servers, either the one setup on your computer, or others you can choose, so you can see what IP address a name represents from what DNS server (internal or external)

- Ok, lots going on here: first you see 10.14.1.4, which is the DNS server in the elab, which translates names like www.apple.com into numbers like 23.2.84.211
- Do you see the same number in the traceroute test?
- There are other more complex addresses like 2600:141a:8000:18d::1aca, which is something called IPv6
- Why?
- We are running out of original IP addresses on the internet in the form of 255.255.255.255, so we use "fake" IP addresses inside homes, schools, and businesses, in the form 192.168.1.x or 10.14.x.y
- you can query (ask) either internal name servers like ours at 10.14.1.4, or you can ask outside name servers
- why are they different?
- look below:
Part two: secure shell (ssh)
- what is it?
- a secure connection in terminal between your computer and another computer

- Ok, first thing I did here was ssh into 10.14.84.2 as pi
- notice the format: ssh who@IPADDRESS
- it then asks me if I'm ok trading secure keys with this maching
- you say "yes" then the key is added to both machines in a hidden file (ask about this if you are curious)
- it permanently adds 10.14.84.2 to the list of "known hosts"
- what is not obvious is that the green bit at the bottom is actually INSIDE the second computer
- you are now inside the second computer and can run commands-from anywhere in the world
Part three: secure shell commands
- who also whoami
- last your last command, also the up arrow
- top lists all processes, useful with kill (see later), looks very cool if you are POS
- history: shows recent commands like this, useful for retracing your steps or seeing who might have been in your machine
Part four: where the heck am i?
New commands:
- ls means "list files here"
- pwd means print working directory, or "where am I?"
- cd means "change directory"
- cd .. means "go up a floor"



- in the first frame, notice the folders with capital letters like Desktop or Documents
- note the red one, this is an app to be installed
- rpdiags.txt is a text file
- in the second frame, we are in the directory /home/pi
- the ~ character means your home directory, you can use this on your mac as well to do cool stuff
- in the third frame, I changed from /home/pi to /home/pi/Desktop
- to change back, I could use cd ..
Part five: creating files
New commands:
- nano is a text editor in the terminal
- less means "show me what is in a file"
- more means the same thing, just more detailed

Part six: creating directories (folders)
New commands:
- mkdir means"make a new directory" which is a folder with that name on it

Challenge: Linux folder challenge
- we will be working in pairs for this part ASK PERMISSION FIRST
- ssh into your neighbor's computer and look at the who command to see who is logged in and from where:
- ssh pi@10.14.84.x or ssh pi@name.hpa.edu
- password
- who
- last
- navigate to their desktop and create a file there called "payload"
- cd /home/pi/Desktop
- sudo nano payload
- type a note to them, make it nice!
- ctrl-o, return, ctrl-x
- have them verify that you sent them a little message with their file browser
- create a folder on their computer called "stuff"
- cd /home/pi/Desktop
- pwd
- ls
- mkdir stuff
- cd stuff
- pwd
- ls
- sudo nano herobrine
- type your name in the message
- ctrl-o, return, ctrl-x
- Have them look in the new folder and open the herobrine document
- shutdown their computer using the shutdown - r now command
- thank them for letting them invade their computer
- checklist: payload folder on another computer, herobrine text file inside with a message
- login to victim.hpa.edu (login info on the board)
- locate the herobrine file
- write a note in the same folder with your name on it
- checklist: in the victim.hpa.edu computer a note with your name on it in the same folder as the herobrine file
- ping
- traceroute
- nslookup
- ctrl-c
- ctrl-z
- network icon
- sudo shutdown -r now
- ifconfig
- who
- top
- history
- ls
- pwd
- cd
- cd ..
- sudo nano
- mkdir
- sudo apt update -y
- sudo apt upgrade -y
- ssh pi@10.14.84.20
- IP address, netmask, gateway, dns
Migrated from Apple WikiServer Wiki. Original page u4a1W5r8D.ID: u4a1W5r8D