UNIX: Exercise Sheet 2
-
Try the following command sequence:
- cd
- pwd
- ls -al
- cd .
- pwd (where did that get you?)
- cd ..
- pwd
- ls -al
- cd ..
- pwd
- ls -al
- cd ..
- pwd (what happens now)
- cd /etc
- ls -al | more
- cat passwd
- cd -
- pwd
-
Continue to explore the filesystem tree using cd,
ls, pwd and cat. Look in /bin, /usr/bin,
/sbin, /tmp and /boot. What do you see?
-
Explore /dev. Can you identify what devices are
available? Which are character-oriented and which are block-oriented?
Can you identify your by (terminal) device (typing who am
i might help); who is the owner of your by (use ls -l)?
-
Explore /proc. Display the contents of the files
interrupts, devices, cpuinfo, meminfo
and uptime using cat. Can you see why we say /proc
is a pseudo-filesystem which allows access to kernel data structures?
-
Change to the home directory of another user directly, using
cd ~username.
-
Change back into your home directory.
-
Make subdirectories called work and play.
-
Delete the subdirectory called work.
-
Copy the file /etc/passwd into your home directory.
-
Move it into the subdirectory play.
-
Change into subdirectory play and create a symbolic
link called terminal that points to your by device. What happens
if you try to make a hard link to the by device?
-
What is the difference between listing the contents of directory
play with ls -l and ls -L?
-
Create a file called hello.txt that contains the
words
hello world
. Can you use cp using terminal
as the source file to achieve the same effect?
-
Copy hello.txt to terminal. What happens?
-
Imagine you were working on a system and someone accidentally
deleted the ls command (/bin/ls). How could you get a
list of the files in the current directory? Try it.
-
How would you create and then delete a file called
$SHELL?
Try it.
-
How would you create and then delete a file that begins with
the symbol #? Try it.
-
How would you create and then delete a file that begins with
the symbol -? Try it.
-
What is the output of the command: echo {con,pre}{sent,fer}{s,ed}?
Now, from your home directory, copy /etc/passwd and /etc/group
into your home directory in one command given that you can only type /etc
once.
-
Still in your home directory, copy the entire directory play
to a directory called work, preserving the symbolic link.
-
Delete the work directory and its contents with
one command. Accept no complaints or queries.
-
Change into a directory that does not belong to you and try
to delete all the files (avoid /proc or /dev, just in
case!)
-
Experiment with the options on the ls command. What
do the d, i, R and F options do?
(Contents)