ECE 177 Lab 1 The purpose of this lab is to introduce you to some of the more common command-line commands used in a linux system. In doing so, we will also introduce you to the use of "ssh" to log on to the Command Line Interface (CLI) of another computer, in this case a Raspberry Pi. The following link will provide most all of what you need to do this lab: http://web.eece.maine.edu/eason/ece177/gccLinuxQuickStart.txt To "ssh" from Windows machines, it is recommended to install a program called puTTY. (See notes in the above link for installation). Mac and Linux users should be able to "ssh" from the command line inside a terminal. You will be given directions in lab to log on to a Raspberry Pi. From there you should do all the following and demonstrate the results to a Teaching Assistant (TA). 0) Change your password 1) Create a file with your last name (no spaces) and have it contain your name on the first line and your email address on the second line. The following does this with a simple editor. $ nano 2) Create a directory called "lab01" 3) Change to that directory 4) Create and edit a file called "hello.c" When compiled, this file will simply print a line that says "Hello, world!" (ending in a newline). See ex01.c (shown in class and on the course "assignments" page), class notes, Zybooks exercises, and as always, ask a TA if you need help! 5) Compile your program using: $ gcc hello.c -o hello 6) Execute your program using: $ ./hello 7) Copy your program to another filename called "clever.c" (use "cp" command). Edit it so it instead prints something clever. Then compile and run it. 8) change your directory up one level and copy your whole lab01 directory to another one called dup01 9) Change directory to "dup01" 10) Rename "clever.c" in this directory to "clever2.c". Compile and run it (name clever2) 11) Delete (hint: remove, rm) the file called "clever" 12) Change back to the original lab01 directory 13) Copy the file "ex01.c" from the course web page using the command: wget http://web.eece.maine.edu/eason/ece177/ex01.c "wget" is a command for downloading files from web pages to the current directory. Compile and run the program. 14) Print ex01.c on the screen using the "cat" command 15) Run ex01 so it redirects its output to a file called "ex01.out" Print the contents of this new file using the "cat" command 16) Create a new file that only contains a single one-digit number 17) Run "ex01" again taking its input from this new file. 18) Copy "ex01.c" to "ex02.c", edit the new file so it has computes a slightly different expression, compile and run the new program. 19) Find the differences between the "ex01.c" and "ex02.c" and redirect the output to a file called "exdiff" 20) Create a listing of files in the lab01 directory and redirect the output to a file called "listing" 21) Create a "long listing" of files in the lab01 directory, but this time *append* the output to the "listing" file 22) Use "grep" to print lines in any files in your "lab01" directory that contain the word "printf" 23) Do the same grep again, but redirect the output to a file called "theprints" 24) Do the same grep again without redirecting the output. What changed? 25) Do a history of all the commands you've typed so far. 26) Rerun a previous "ex01" command using "!nnn" where "nnn" is the number in your history output associated with a previous use of that command 27) Do a history and "pipe" the results through "grep" to list only commands that contained "gcc" Note that the "grep" command won't have a filename as it takes its input from the history information that is "piped" to it 28) Do it again and redirect the resulting output to a file called "gcchistory" 29) Do a full history one more time (without piping to "grep") and redirect the results to a file called "myhistory" 30) Show your results to a TA. The TA might ask you to demonstrate some things. 31) With remaining time, play around more with these commands to get more comfortable with them. Use the "man" command to learn more about each of the commands you used. 32) After finishing type "sudo poweroff" to shutdown your pi. Wait for the light to stop blinking, then remove the SD card. Always do this to avoid corrupting the SD card. However, if you've got more time during the lab period, then first do the further challenges below. Here are some further challenges: How do you get a long listing of files in order of last time they were modified? Can you do it in reverse order (showing the most recently modified files last)? Get a long listing of files in order of their size (largest first). Repeat, reversing the order. Using a single "grep" command print (in all files) each line that contains "printf" along with the line before it and the line after it. Use "grep" to print only the names of files that contain "printf" somewhere within (but do not print the lines themselves) Use "grep" to print the lines in "ex01.c" that *do not* contain the word "printf" Can you make "grep" do a "case insensitive" match? For example, it would match "hello", "Hello", "HELLO", or "hElLo", etc. Pipe your history to "grep" showing lines that contain "gcc". Do it again, but this time add an additional pipe to another grep that eliminates all lines that contain "ex01" Use "man" on the commands "less", "head", "tail" to see what they do. Do your history and pipe the results to "less". Then do it again, instead piping the results to "head". Repeat piping to "tail" Pipe your history again to "head" but this time only show the first 5 lines Pipe your history to "tail" then pipe that output to "head" in such a way that the the first 5 of the last 10 commands are printed. Use "sort" to print the lines of ex01.c in sorted order Remember to type "exit" to logout and close your login session