CS 270
CS 270 Documentation

Recitation R0: Linux, C, and Checkin


Objectives of this Lab

  1. login to department systems,
  2. login to the Canvas course,
  3. learn how to launch Linux applications,
  4. introduce a small set of Linux commands,
  5. discuss the Linux file system and play with text files.
  6. write your "Hello World" program in C
  7. start the Canvas quiz for this recitation

Logging In

  1. Login to the machine using your eID (same username that you use for Canvas).
  2. The initial password should be your student ID number (same as nine digit number on your RamCard).
  3. Choose "Xfce session" from the list of linux configurations in the upper right hand corner of the screen.
  4. Click "Use default configuration" when the pop-up message comes up (first log-in only).
  5. The teaching assistant will show you how to change your password as described below.
  6. Troubleshooting: Raise your hand if you cannot login!

Class Website

  1. Start your preferred internet browser and type in your course URL
    • www.cs.colostate.edu/~cs270
  2. Note that semester that appears as part of the url!
  3. Look at the syllabus and progress pages.
  4. Open another tab and in the url type http://info.canvas.colostate.edu/login.aspx
  5. Login to Canvas using your EID and password and make sure you can see this course.

Launching Applications

  • Your TA will show you how to launch applications and add them to the task bar.
  • Select "Activities" in the upper left corner of the screen, then select "Applications".
  • Run firefox, kate, file manager, and a terminal.
  • The terminal command brings up a window where you can type in Linux commands.
  • Note: this is similar to using the DOS command prompt on Windows.
  • Use the passwd command to change your password.
  • We recommend changing it to your RamWeb password, if possible.

Useful Terminal Commands

Your TA will show you how to use the man command. For each of the following, figure out what action is performed and try the command. Be careful with the remove command!
  • man - read the manual page for a command
  • pwd - print working directory
  • ls - list working directory
  • cd - change working directory
  • cp - copy file(s)
  • mv - move or rename file(s)
  • rm - remove file(s)
  • cat - list file(s)
  • less - list file(s)
  • diff - compare files
  • mkdir - make directory
Your TA will talk about launching programs from a terminal using the ampersand (&), and will show you how to look at the history of commands, and how auto completetion with the tab key works.

Linux File System

Your TA will describe the Linux file system. Make sure you know each of the following shortcuts for directory names:
  • ~ home directory
  • . current directory
  • .. parent directory
  • / file extensions

Manipulating Text Files

Perform the following tasks and add to your notes to show the TA:
  1. Create a directory in your home directory called cs270
  2. Use gedit to create the Name.txt:
     gedit Name.txt & 
  3. The file should contain one line which has your first and last name.
  4. Save the file .
  5. Copy Name.txt to another file called Name.bak
  6. Compare the contents of the files by using the diff command. Are they the same? How can you tell?
  7. Open Name.bak as a second tab in gedit.
  8. Add a second line to Name.bak with your preferred email address.
  9. Compare the files again. Are they the same? How can you tell?
  10. Remove Name.txt
  11. Move Name.bak to Name.txt
  12. Cat the contents of Name.txt. Is your email there?

Hello World

  1. In your cs270 directory, create an R0 directory
  2. Using gedit, create the file hello.c with the following content:
    #include <stdio.h>
    int main()
    {
       printf("Hello, World!\n");
       return 0;
    }
    
  3. Now in the terminal in the same directory where you created the hello.c file type the command:
    gcc hello.c
    
  4. This is the most basic way to compile your code and will result in the file a.out. Now we are going to compile the code with a few more options:
    gcc -g -Wall -o hello hello.c
    Use the internet to figure out what the -g -Wall and -o flags mean.
  5. Now you can check the file hello.c into the checkin server and verify it passed all the tests. If it does you will get full credit for this part of the recitation.

VIM

VIM is an advanced text editor that has many helpful features for fast editing of text from the console. Its predecessor VI has a very similar interface and in some cases, such as when working on older systems or striped down VM's, it may be the only tool you have to edit text. Try out the VIM tutorial which can be accessed by typing:
vimtutor
Although VIM has a steep learning curve, when utilized at it's full potential, it can be much quicker than a text editor. At the bare minimum, you should be passable at using VIM.

What to turn in

Grades for this lab will be based on the file you turned into checkin and the Recitation 0 quiz on Canvas. Since this is the first week of class you have until next Monday to complete them. Starting next week recitation related work will be due at 11:59pm on the day of the recitation.