CSC15 Assignment 1: Using Fedora Linux

Due Thursday, 9/10


This lab is intended for you to:
  1. Learn basic Linux "survival skills"
  2. Learn how to enter and execute a couple of simple Python programs.
  3. Take a glimpse at the joys and pains of programming by modifying some simple program lines.


Like most operating systems, Linux has graphical interface and many aspects of it are self-explanatory. But there are several differences between Linux and Windows and Macintosh computers that you need to understand.

  1. Once you've logged in, explore the desktop environment. Try to bring up the Firefox web browser. Go to and bookmark the class homepage: www.cs.hofstra.edu/~cscccl/csc15p
  2. Bring up a "terminal" window under "Applications" -> "System Tools". This is the main interface you will use.
  3. The command prompt should read something like "$-sh-". Type "bash".. This gives you the prompt bash-3.00$.
  4. Type "pwd" - this command shows you what directory you're currently in.
  5. Type "ls" - this command shows the contents of the current directory - don't be surprised if there's nothing there - that's why we're here! You can also use "dir" instead of "ls".
  6. Type "ls -a" - As with MS Windows, there are some hidden systems files that are not usually visible. This command will display all files and directories in the current directory.
  7. Type "ls -l" - This is the same as ls but gives you additional information for each file and folder.
  8. Basic Command Summary
    1. cd (directory name): change directory to named directory
      cd .. : go to parent directory
      cd /(path) : absolute directories begin with "/", the root directory.
      For example, if you are in directory /shared/csc/local, typing "cd .." will take you to the /shared/csc directory.
    2. Typing "cd" by itself will take you to your home directory.
    3. pwd : tells you the current directory you're in.
    4. cp file1 file2 : copies the contents of file1 into a file called file2.
    5. ls : lists directory contents
    6. mkdir dirname : creates a new directory called dirname in the current directory
    7. mv file1 file2 : renames file1 into file2
    8. rm file1 : deletes file1
    9. rm -rf dirname : deletes the named directory and all its contents. Use with care!
    10. more filename : a quick way to view the contents of a text file.
    Many of these operations can also be performed using the mouse in the "file manager" window. However, you'll need to learn these commands if you want to use the workstations remotely using telnet (I'll show you how to do that later). Besides, all serious computer users know them.

    Let's now practice these commands (please do not deviate from instructions)
  9. Make sure you're in your home directory (type "cd")
  10. Type "mkdir csc15" - what does this do? You should creat a directory for this class because you'll be using your account for other classes as well.

    NOTE: if you're using one of the public accounts (adams01 - adams04), create a directory with your username instead, so you can keep your files separate.

  11. Type "cd csc15" - you're now in the directory you just created.
  12. Type "cd .." - you're back in the directory you were in before
  13. Go back into your csc15 directory

  14. Using Python in interactive mode.
    Type "Python" to enter the interactive environment. Go to the "python tutorial" link on the class homepage, and try to follow some of the examples in section 3. You're encouraged to experiment. The interactive mode allows you to quickly the range of valid syntax in Python. When you're done, type Control-D to exit the Python interpreter.

    Please note that while you're inside the python interpreter, you'll see a prompt like ">>>". This is NOT where you can enter linux commands like ls, cd, etc ... To do that, you need to be at the "shell" prompt (like bash-3.00$).

  15. Time to write a program.
    To do that you need to learn how to use an editor. A very powerful (though less easy than MS word) editor used by programmers is "emacs" - type "emacs &" - you'll see a window come up. You should recognize a toolbar with familiar buttons such as "file", "edit" and "help". Select "file" and open a file called "firstprog.py"
  16. Type in the first program provided on the first attached sheet. You do not have to type in all the comments marked with "#", but put your name in comments at the top. Comments are lines that begin with a "#".
  17. save it under the name "firstprog.py" in your csc15 directory.
  18. Make sure you're in the csc15 directory. Execute the program with "python firstprog.py" Did you get any errors? If you did, that means you had a typo while copying the program, so go back and edit the program, save it, and try again.
  19. Change the program so that it prints your name 20 times instead of 10
  20. (harder). Change the program so that it prints your name 20 times BACKWARDS
  21. Quit emacs (click the "file" menu option)
  22. You can also start emacs and open a file at the same time by typing emacs (filename) &. The "&" is important: without it, you'll lose the ability to use the terminal window while emacs is running.
  23. Now type in the second Python program, "secondprog.py"

You are to turn in the printouts of the two programs you typed in and modified. Make sure the printouts have your names on it. To print, type (in the same directory where the file resides) lpr filename. This will always print to the lazer printer in Adams 204.

Final Note: you are expected to remember what you learned today, for these skills are required throughout the semester. Practice these skills further on your own time.