Tags

    Raspberry Pi Buster notes

    Comments

    /groups/isr/search/index.rss?tag=hotlist/groups/isr/search/?tag=hotWhat’s HotHotListHot!?tag=hot0/groups/isr/sidebar/HotListNo items tagged with hot.hot/groups/isr/search/index.rss?sort=modifiedDate&kind=all&sortDirection=reverse&excludePages=wiki/welcomelist/groups/isr/search/?sort=modifiedDate&kind=all&sortDirection=reverse&excludePages=wiki/welcomeRecent ChangesRecentChangesListUpdates?sort=modifiedDate&kind=all&sortDirection=reverse&excludePages=wiki/welcome0/groups/isr/sidebar/RecentChangesListmodifiedDateallRecent ChangesRecentChangesListUpdateswiki/welcomeNo recent changes.reverse5search

    Raspberry Pi Debian Buster basics

    Download file "Raspberry Pi Debian Buster basics.pdf"

    What you will need:

    • computer of some sort with a terminal application
    • internet connection on the local area network
    • permission from the owners of the computers you are working on
    • permission from the system admin (Dr. Bill) to do this, at a specific time and place (so our intrusion detection system does not block you)

    Module 1: first steps (see notes below)

    1. download a terminal app
    2. test the app by using the ping command to 10.14.0.1, the HPA router
    3. record the ping time in your notes
    4. ping your raspberry pi unit at the IP address given you
    5. ping the other units, record your results

    Module 2: SSH

    1. secure shell is a means of securely accessing the command line (“terminal”) of a computer
    2. use the command ssh 10.14.88.x to reach your raspberry pi
    3. you should be “in” your pi unit now, look at the prompt
    4. from that prompt, try the ping command as you did before to the other pi units, record your results

    Module 3: commands

    1. from your ssh terminal, type pwd, which shows the path you are now located at, record this
    2. try the ls command, this lists the files near you in the current directory
    3. try the cd .. command, which should take you up one directory, repeat pwd and notice the difference.
    4. cd back to the directory you were first in, likely it is /home/pi

    Module 4: nomachine (if no desktop access)

    1. install nomachine on your laptop
    2. connect to your pi unit
    3. right click to see the directory or file system
    4. find the folder “pi”
    5. go back to your ssh terminal and type ls in various directories, verify that they show up the same way in the folder window

    Module 5: nano text editor

    1. from your ssh window, in the pi directory, type: sudo nano test
    2. type some stuff
    3. hold control while typing the o key and return
    4. hold control while typing the x key and return
    5. you have just created a document in the folder, find it on the nomachine window

    Module 6: what’s going on? who?

    1. try these commands: top, ps, who, last, history, record your results
    2. try these commands: traceroute, ifconfig, record your results

    Module 7: commands, modifiers

    1. from your ssh window, try using the secret version of ls: ls -la
    2. note that all commands can have modifiers, like ls -la, l means long, a means all files
    3. try creating a new file with nano, and name it something with a period in front
    4. see if it shows up in the file manager window
    5. see if it shows up using ls -la

    Module 8: creating directories

    1. using your ssh window, enter the command mkdir followed by some name
    2. watch what happens in the file manager window
    3. create a text document in this new folder
    4. look up the cp, mv and rm commands using man cp and so on

    Module 9: update your computer, install apps

    1. using the sudo apt-get update command, update your computer
    2. use the sudo apt-get upgrade to upgrade the computer
    3. use the sudo apt-get install hardinfo -y to install hardinfo
    4. type hardinfo and record your results
    5. install the wavemon program the same way, test and record

    Module 10: control x and control z

    1. control x means stop
    2. control z means halt, no nice manners
    3. try this with ifconfig to determine your IP addresses (wired and wireless)


    More complete notes:


    Module 1: Terminal first steps

    Using terminal on the raspberry pi:

    Start with ping:

    ping sends a data packet to a machine on the internet, and tells you how long it takes to return, like sonar

    try pinging 10.14.0.1 Time listed will be in milliseconds, so 1000 ms means one second

    ping www.apple.com

    Notice different ping times

    Stopping stuff:

    ctrl-c means cancel

    ctrl-z means halt (stop everything, not gracefully)

    Tracing around the internet:

    traceroute www.apple.com (note hops and delays)

    Evil stuff: ping flood attack:

    ping flood, only use here as a test

    sudo ping -f (notice that you have to use sudo, which means "superuser do" or treat me like computer god for this)

    What's going on in your terminal:

    who also whoami

    last last command, also the up arrow

    top lists all processes, useful with kill (see later)

    history: shows recent commands like this, useful for retracing your steps or seeing who might have been in your machine:

    1 ping 10.14.0.1

    2 ping www.hpa.edu

    3 traceroute

    4 traceroute www.hpa.edu

    5 ifconfig

    6 ping 10.14.252.22

    7 sudo ping -f 10.14.252.22

    8 last

    9 who

    10 ping 10.14.252.47

    11 history

    12 ssh pi@10.14.252.47

    13 netstat

    14 man netstat

    15 man ping

    16 history

    navigation commands:

    cd change directory, usually followed by a directory name, like "cd var/www/html/"

    ls list directory, see also ls -l which lists all files in long form. Try also ls -lh *human long form"

    ls -la lists even invisible files (the -a flag means "all") You can also hide files by adding . to the beginning

    pwd print working directory, shows where you are in the file system (directory)


    Try navigating to the desktop this way:

    pwd (print working directory, "where am I")

    ls (shows what is at this level)

    cd or cd .. (cd to a directory, cd .. means one level up)

    Here is where your desktop is: /home/pi/Desktop

    Shortcut:

    cd /home/pi/Desktop

    try ls and see what is there, should be nothing.

    Creating a directory:

    mkdir creates a directory

    mkdir test

    This should create a folder on your desktop called "test"

    click on this to see a directory browser, go nuts

    Permissions

    ls -la will show you permissions in the format drwx, for directory, read, write and execute

    read is 1, write is 2, execute is 4, so all added up 1+2+4 =7

    chmod change "mod" or permissions of file, 777 is everything, see drwx format below and the 421 rule

    You may also find this under chmod u+x on a file, which means make the file or program executable

    Manual pages:

    man pages are manual pages, so "man ping" would give you manual pages on the ping command

    less means look into a file (contrast with "more")

    * means wild card, so if you want to see all files ending in jpg, you would say *.jpg

    Secure shell login:

    ssh means secure shell login, like ssh pi@10.14.252.2


    Mac specific commands:

    fsck -yf after command-s startup (single user mode)

    say command after ssh login

    Module 2: wild cards, man pages, deleting files

    This is how wild cards work:

    Instead of typing out herobrine, you could type

    h*

    just make sure that nothing else matches the h part.

    Another example:

    These files are in a folder called test:

    malcolm mary tom

    if you type

    rm m*

    it will delete mary and malcolm

    if you type

    rm mal*

    it will delete only malcom

    if you type

    rm *

    it will remove everything.

    You can also use this to delete certain types of files (jpg, txt, mp4)

    rm *.jpg

    will remove every jpg file in the folder


    Now you try it:


    1. open terminal
    2. navigate to your desktop (remember, it is called Desktop)
    3. create a folder using mkdir called test
    4. navigate into that folder
    5. create three text files using sudo nano, the first will be called malcolm, then mary, then tom
    6. read each one using less or more
    7. take a screenshot of this folder from the gui (graphical user interface), command-3 takes a screen shot, command-4 is a screenshot of only what you select.
    8. copy this screenshot into your weblog, so you can remember how you did this
    9. remove one file at a time using the rm command, take more screenshots

    Ok, at this point, you can navigate around, login to remote computers, create and delete text files.

    What's next?

    Internet...

    Module 3: Internet

    Your computer needs 4 things to be able to get onto the internet:

    IP address, example 10.14.8.4

    Subnet mask, example 255.255.0.0

    Gateway/router, example 10.14.0.1

    Domain name server (DNS), example 10.9.250.13


    Here's what each one does:

    IP address:

    All traffic on the internet or local area network (LAN) is in the form of packets of information, like mail envelopes with a letter inside. Each letter you mail has two important things: the address you want it to go to, and the message inside the envelope.

    TCP/IP is the format of these, which stands for Transmission control protocol and internet protocol.

    The TCP part is the message, and the IP part is the envelope, with an IP address on it.

    Check the IP address of your machine:

    From the GUI: open system preferences, network

    From the terminal: type ifconfig


    Subnet mask:

    Imagine you want to stay in one of two large 254 room hotels. One has long hallways, and very few floors, the other has many floors, but short hallways.

    If you want to sleep, you don't want many people walking down the hall in front of your room. You want many floors with fewer rooms per floors.

    This is what subnet masking does on a network. Each of the four segments can hold 254 addresses.

    At home, you probably have a network that looks like this:

    IP: 192.168.1.49

    mask: 255.255.255.0

    router: 192.168.1.1

    dns: 192.168.1.1


    This means that the last zero can hold up to 254 addresses (from 192.168.1.1 to 192.168.1.254)

    HPA has this sort of mask:

    255.255.0.0

    which means that

    10.14.0.0

    is the elab, which can have 254 x 254 addresses

    It makes for a quieter network, also providing some security as others cannot see you easily.


    Router/gateway:

    This is the gateway for all of your traffic, usually the access point at your home. The technical difference between these words is that a router routes traffic between two networks of the same type (like ethernet), while a gateway is between different types of networks (like a cable modem or DSL gateway)


    Domain name server:

    This is the computer on your network or outside that translates names into numbers, like a digital phone book.

    Try this in terminal:

    nslookup physics.hpa.edu

    1. when you get the address, write it down
    2. open a browser
    3. go to physics.hpa.edu
    4. now go to the numbers you wrote down.
    5. Try this with another name, either on campus or off

    Ping and traceroute:

    Imagine you want to find out if a machine is responding (you can block this by using "stealth mode")

    In terminal ping one of the IP addresses in your class

    ping an address out on the internet

    what is the difference?


    now try this:

    traceroute www.apple.com


    It should give you a trace of the path your connection took.

    Try this with other addresses on and off campus.


    NSLOOKUP:

    Say you want to find out the name of something, or the IP address from the name.

    try this:

    nslookup

    (you will get a funny > sign)

    type:

    server 10.9.250.13

    type:

    physics.hpa.edu

    what do you get?

    where is this machine?

    Try again using 8.8.8.8 as the server


    The best use of this is to find out what OTHER people might call a machine.

    We have several DNS servers on campus, the main one is at 10.9.250.13

    Others to try:

    4.4.4.4

    8.8.8.8

    10.14.1.2


    you can get out by typing

    exit

    or control-z (halt)


    Module 4: web server and web pages (html)

    Creating a web page, installing a web server:

    On the raspberry pi, run the following commands:

    sudo apt-get update (this updates your computer)

    sudo apt-get install apache2 -y (this installs apache web server on your computer, answering yes to all prompts)

    Go your browser and enter 127.0.0.1 (which means "me" on the internet)

    Now type ifconfig in your terminal and look for your internet address, which should start with 10.14.x.y

    Look at this address using your browser

    Editing web pages:

    On the terminal, navigate to the following directory:

    cd /var/www/html/

    run the ls command, you should see a file called index.html

    You can edit this, either by using the nano command (cooler) or a text editor (simpler)

    sudo nano /var/www/html/index.html

    This is a complex bit of html, so just look for something you recognize from the 127.0.0.1 test and change it

    nano is a text editor, so ctrl-o means overwrite, and ctrl-x means exit

    If you are using a text editor, it might not let you save.

    Back to permissions----

    type chmod 777 /var/www/html

    which makes everything in the html directory read and writable to everyone (including you)

    Making a new web page:

    Using either nano or a text editor, create a new page:

    sudo nano /var/www/html/test.html

    You'll notice this is blank.

    Add the following to your new web page:

    <html>

    <head>

    test

    </head>

    <body>

    Wow, this is really easy

    </body>

    </html>


    remember to overwrite (ctrl-o) and exit (ctrl-x)

    Now go to your browser and enter http://127.0.0.1/test.html


    What do you see?