|
|
|
|
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
echo $SHELL
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.
cat /etc/shells
Prints full path names for all legal login shells
on this system.
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.
/xxx/bash
Your keyboard is now connected to a bash shell.
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.
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.
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
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.
man -k userid
pwd
ls /var
cd /var
pwd
ls
ls -l
ls -a
ls -al
lw[backspace]s
loops[left-arrow, then backspace three times, then the enter key]
erase this line[Ctrl+u]
cd
pwd
mkdir HW1
cd hw1
cd HW1
pwd
ls -al
ls -al .
ls -al ..
cp /usr/include/stdio.h testfile
ls -l
mv testfile test
ls -l test
ls -l te[now hit a tab]
cp test test2
ls -l te[now hit 3 tabs]
rm test2
ls
cp test test2; ls
cp test notTest; ls -l
ls -l *
ls -l t*
ls -l test*
ls -l *2*
cd ..
pwd
mkdir HW1prime
cd HW1prime
ls ../HW1
cd /etc
pwd
ls ~
ls ~/HW1
cd
pushd /etc
pwd
pushd /var
pwd
popd
pwd
popd
pwd
pu[now hit tab twice, then type an 's', then hit tab again] /etc
popd
history
- [up arrow 2 times]
!!
!h
!pu
!pop
ls /usr/include/stdio.h
ls !$
- [up arrow, then the left arrow, then type to create a
ls -l
version of the last command]
- [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]
^stdio^paths
alias list='ls -al'
list
cd
list
ls -l
ls -l >test.out
less test.out
ls -l >>test.out [Note the two right angle brackets]
rm test.out
rmdir HW1prime
list
rmdir HW1
rm -r HW1
list
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):
|