# Module 1: terminal commands

[Download TC 1.0.pdf (application/pdf, 637.9 KB)](https://bookstack.kamuela.org/attachments/309)

<span style="font-weight: bold;">Module 1: Terminal first steps</span>

- Using terminal on the raspberry pi:
- Start with ping:
- <span style="font-weight: bold;">ping</span> 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
- <span style="font-weight: bold;">ping</span> www.apple.com
- Notice different ping times

Stopping stuff:

- <span style="font-weight: bold;">ctrl-c</span> means cancel
- <span style="font-weight: bold;">ctrl-z</span> means halt (stop everything, not gracefully)

<span style="text-decoration: underline;">Tracing around the internet:</span>

<span style="font-weight: bold;"><span style="background-color: rgb(236, 238, 168); color: rgb(102, 102, 102);">traceroute</span></span> www.apple.com (note hops and delays)

<span style="text-decoration: underline;">Evil stuff: ping flood attack:</span>

ping flood, only use here as a test

<span style="font-weight: bold;">sudo ping -f</span> (notice that you have to use sudo, which means "superuser do" or treat me like computer god for this)

<span style="text-decoration: underline;">What's going on in your terminal:</span>

- <span style="font-weight: bold;">who</span> also whoami
- <span style="font-weight: bold;">last</span> last command, also the up arrow
- <span style="font-weight: bold;">top </span>lists all processes, useful with kill (see later)
- <span style="font-weight: bold;">history</span>: 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


<span style="text-decoration: underline;">navigation commands:</span>

- <span style="font-weight: bold;">cd</span> change directory, usually followed by a directory name, like "cd var/www/html/"
- <span style="font-weight: bold;">ls</span> list directory, see also ls -l which lists all files in long form. Try also ls -lh \*human long form"
- <span style="font-weight: bold;">ls -la</span> lists even invisible files (the -a flag means "all") You can also hide files by adding . to the beginning
- <span style="font-weight: bold;">pwd</span> print working directory, shows where you are in the file system (directory)

<span style="text-decoration: underline;">Try navigating to the desktop this way:</span>

- <span style="font-weight: bold;">pwd</span> (print working directory, "where am I")
- <span style="font-weight: bold;">ls</span> (shows what is at this level)
- <span style="font-weight: bold;">cd</span> or <span style="font-weight: bold;">cd ..</span> (cd to a directory, cd .. means one level up)
- Here is where your desktop is: /home/pi/Desktop

Shortcut:

<span style="font-weight: bold;">cd /home/pi/Desktop</span>

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

<span style="text-decoration: underline;">Creating a directory:</span>

- 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

<span style="text-decoration: underline;">Permissions</span>

- <span style="font-weight: bold;">ls -la </span>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 <span style="font-weight: bold;">chmod u+x</span> on a file, which means make the file or program executable

<span style="text-decoration: underline;">Manual pages:</span>

- 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

<span style="text-decoration: underline;">Secure shell login:</span>

ssh means secure shell login, like ssh pi@10.14.88.81

<span style="font-weight: bold;">Mac specific commands:</span>

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

  

---

<small>Migrated from Apple Server Wiki. Original page ID: V1v8j1</small>