CSE 303: Concepts and Tools for Software Development, Winter 2008
  CSE Home   About Us   Search   Contact Info 
 
Course Home
 Home
Administation
 Overview
 Course Wiki
 Email archive
 Anonymous feedback
 View feedback
 Homework Turnin
 
Most Everything
 Schedule
 
Other Information
 UW/ACM Tutorials
 303 Computing: Getting Started
   

CSE 303 Homework 1

Due: Friday 1/11/08
Turnin: nothing to turn in

This assignment is designed to begin your experience using a Unix shell (in particular, bash, although most commands used here will work in any shell, as they have a lot in common). Do this assignment, but don't hand anything in about it. You can do this on any Unix machine, or with cygwin (unless you've failed to install something needed by one of the commands). We have tested that everything works as expected on attu.

Listed below are a set of commands to execute. There are explanations for what some of them do, but not for all. When you execute them, what they do may be apparent to you. To find out more, though, you can always use man. For example, man pushd will tell you about the pushd command.

If you see the following notation: Ctrl+X;  on a line, hold down the control key and press the letter specified. (Ctrl+X, for example, specifies the cut operation in Windows.) Don't hold down the shift key to make the letter uppercase.

    echo Print this
  1. echo $SHELL
  2. If your shell is not bash (it will probably be csh in that case), it would be better to change your shell. Unfortunately, we can't give you instructions on how to permanently change your login shell to bash, because it depends on more things than we can predict. The commands below work (for us) on attu.cs.washington.edu. Especially if you have trouble with this step, this page may provide useful additional information.

    1. cat /etc/shells
      Prints full path names for all legal login shells on this system.
    2. chsh -s /xxx/bash
      The argument to chsh should be the full path name for bash, as printed in response to the previous command (e.g., /bin/bash on attu.cs.washington.edu).
      Note 1: This affects what shell is created in the future when you login, not the one you're working in now.
      Note 2: This update must propagate to a number of servers, and can take up to a few hours to become effective every time you login.
      Note 3: This step can not work. See this page.
    3. /xxx/bash
      Your keyboard is now connected to a bash shell.

     
  3. ps

    A list of processes with the same user id (uid) as the shell will be printed. Since the uid of the shell is your user id, these are the processes you are running when this command executes. You should see two of them, your shell and the ps command itself.

  4. cat /usr/include/stdio.h
      Prints that file. The file contents won't make much sense to you. Sorry, but I need a reasonably large file that exists on pretty much all Unix systems for this example.
  5. less /usr/include/stdio.h
      less is a program that scrolls the printing of long files. It lets you move forward, move backward, search, and many other things. Try typing the following while it's running:
      • [space]
      • u
      • [space space]
      • p
      • /fileno
      • n
      • n
      • q
  6. man man
      No need to read this page in detail at this point, but man is the Unix word for 'help.' The format of the page you see is followed by all other man pages: how to invoke it is at the top, a brief description of what it does follows, followed by often a large amount of information with more details.

      man displays the output using less, so the commands you just learned about less work.

  7. man -k userid

  8. pwd
  9. ls /var
  10. cd /var
  11. pwd
  12. ls
  13. ls -l
  14. ls -a
  15. ls -al

  16. lw[backspace]s
  17. loops[left-arrow, then backspace three times, then the enter key]
  18. erase this line[Ctrl+u]

  19. cd
  20. pwd
  21. mkdir HW1
  22. cd hw1
  23. cd HW1
  24. pwd

  25. ls -al
  26. ls -al .
  27. ls -al ..
  28. cp /usr/include/stdio.h testfile
  29. ls -l

  30. mv testfile test
  31. ls -l test
  32. ls -l te[now hit a tab]
  33. cp test test2
  34. ls -l te[now hit 3 tabs]
  35. rm test2
  36. ls
  37. cp test test2; ls
  38. cp test notTest; ls -l
  39. ls -l *
  40. ls -l t*
  41. ls -l test*
  42. ls -l *2*

  43. cd ..
  44. pwd
  45. mkdir HW1prime
  46. cd HW1prime
  47. ls ../HW1
  48. cd /etc
  49. pwd
  50. ls ~
  51. ls ~/HW1
  52. cd

  53. pushd /etc
  54. pwd
  55. pushd /var
  56. pwd
  57. popd
  58. pwd
  59. popd
  60. pwd

  61. pu[now hit tab twice, then type an 's', then hit tab again] /etc
  62. popd

  63. history
  64. [up arrow 2 times]
  65. !!
  66. !h
  67. !pu
  68. !pop

  69. ls /usr/include/stdio.h
  70. ls !$
  71. [up arrow, then the left arrow, then type to create a ls -l version of the last command]
  72. [up arrow twice, then the Ctrl+a Ctrl+f Ctrl+f Ctrl+f, then type to create a ls -l version of the last command]
  73. ^stdio^paths

  74. alias list='ls -al'
  75. list
  76. cd
  77. list

  78. ls -l
  79. ls -l >test.out
  80. less test.out
  81. ls -l >>test.out [Note the two right angle brackets]
  82. rm test.out

  83. rmdir HW1prime
  84. list
  85. rmdir HW1
  86. rm -r HW1
  87. list

  88. info bash
    info is an alternative to man. It often provides more and better organized information. It is based on a notion something like web links. The links are the asterisk'ed lines (or maybe just the asterisk and the following word, or ... info info should reveal the exact rules). You follow a link by getting the cursor on it (using the arrow keys) and then hitting the enter key. You go 'back' by typing u (for up).

    Do the following:

    • Put the cursor on the asterisk next to 'Introduction'.
    • Hit enter.
    • u
    • q

How to terminate the shell can vary a bit, depending on what system you're on. In some cases (basically, where that shell is your only connection to the machine you're talking to - a simple ssh to a remote server, say), terminating the shell is also how you logout. Here are some possible alternatives (all intended to logout):

  • Ctrl+d
  • logout
  • exit

Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to zahorjan at cs.washington.edu]