Module 1: terminal commands
Unmigrated media: TC 1.0.pdf (application/pdf, 637.9 KB)
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
- 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)
- 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.88.81
Mac specific commands:
- fsck -yf after command-s startup (single user mode)
- say command after ssh login
Migrated from Apple Server Wiki. Original page ID: V1v8j1