Last updated: January 25, 2021
Carleton University School of Computer Science
COMP 3000 (WINTER 2021) OPERATING SYSTEMS TUTORIAL 1
Tasks/Questions
1. Whenyouhaveloggedintoashell,how(i.e.,usingwhatcommands?)doyoufirstfindout information about the environment?
a. The version of your Linux distribution and the version of your Linux kernel. lsb_release -a, and uname -a
b. The name (binary path) of the current shell. echo $SHELL
c. RAM, disk space, and CPU. Among multiple ways: free, df,
cat /proc/cpuinfo
2. Usingthemancommand,findoutwhatthefollowingcommandsdo:which,pwd,who, ,and whereis.
3. Linuxcommandscanbeclassifiedasinternal(builtintotheshell)andexternal(separateprogram binaries). How can you tell if a specific command (e.g., cd) is internal or external? Figure out where at least three external commands reside on the system.
Check if the output of this is empty (then it¡¯s internal): which
4. Makingyourowncommands:thePATHenvironmentvariableliststhedirectoriestheshellusesto search for external commands. Where can you find documentation on it? How can you add the current directory (whichever directory you are currently in) to PATH? Then, how to make that change permanent? Try to identify multiple ways.
You are making your own commands when you add the path of your command binary to $PATH. Specifically, you can append something to the existing PATH variable (e.g., /home/student):
export PATH=$PATH:/home/student
To make it permanent (so that you don¡¯t need to type the command above every single time before you use it), you can get it executed automatically by either the OS or the shell. In the case of bash, there are files like (to name a few) ~/.bash_profile, ~/.bash_login and ~/.bashrc, you can put this line in. You do not need to do this unless you really want to add a command.
5. Look at the permissions of the program binaries of the external commands you have just found above. Who owns them? What group are they in?
whoami
6. For those same program binaries, figure out what the permission bits mean by reading the man page of chmod (this is the command you could use to change those permission bits).
We will discuss this in class.
7. What are the owner, group, and permissions of /etc/passwd and /etc/shadow? What are these files used for?
We will discuss this in class.
8. What does it mean to have execute permission on a directory?
Whether you can enter (cd into) that directory.
9. The ls command can be used to get a listing of the files in a directory. What options are passed to ls to see: the permission bits above; all the files within a directory (including hidden files)? How to make a file hidden?
Any file/directory with a name starting with a dot (.) character is hidden.
10. Compile and run csimpleshell.c. How does its functionality compare to that of bash? List at least 3 differences.
There should be many differences as it merely does very little. Examples: 1) if you want to hit Tab to autocomplete typing a command, it will not work here. 2) It does not support operators like & (to run in background) and > (redirection). 3) It does not have syntax highlighting, i.e., all text in the same color. 4) You cannot use the up and down arrows to
browse previously used commands.
2