CS534 Operating Systems - Lab 1
Using basic commands
From your home directory (/home/your_user_name),
create a subdirectory called cs534lab1...do
not change to the cs534lab1 directory at this time.
Run the pwd utility to determine the
path to your home directory and make note of the path.
Use the man pages to look up the following:
- man
- cat
- chmod
- tar
- gzip
- whereis
- nice
- ls
- diff
- mkdir
- rm
- Redirect the information
found in these man pages to a file in your home directory
called manstuff.txt. NOTE
that manstuff.txt should contain ALL the information from all the above
man pages in ONE file. Use the append feature to accomplish this task.
- Again, use the pwd command to display your current position in the
file structure. Use the appropriate command to move to the /
directory.
- Do a directory listing of the
/ directory and display ALL files and directories. Redirect
the output of the directory listing to a file in /home/your_user_name
directory called rootdir.txt
- Return to your home directory.
Use the cat utility to view rootdir.txt.
- Use the less utility
to view rootdir.txt.
- Create a copy of
rootdir.txt in your home directory and name
the file rootdir1.txt. Run a directory listing to make sure
that the file exists.
- Using vi, open rootdir1.txt
and ADD three bogus file entries to the bottom of the file listing
in the same format as any other file entry in the directory listing
- Use the diff utility
to display the differences between rootdir.txt and rootdir1.txt to the
screen. Run diff against the same set of files and redirect the output to a file in your home
directory named differences.txt
- Use the file utility
to display information about rootdir.txt and rootdir1.txt to the screen.
Run file against the same set of files and redirect the output to a file
in your home directory named fileinfo.txt
- Use the head command
to display the first 15 lines of the file manstuff.txt
- Use the tail command
to display the last 15 lines of the file manstuff.txt.
- Perform the previous two
steps again and redirect the output of both runs to a single file
called headtail.txt
that will be located in your home directory.
- Create a subdirectory under
the cs534lab1 directory called tester.
- Copy manstuff.txt,
rootdir.txt, rootdir1.txt, differences.txt, fileinfo.txt, and headtail.txt
to the tester directory, and the cs534lab1 directory. Change to the
tester subdirectory. Attempt to delete the tester directory and its
contents while in the tester directory. Were you successful? No. Why?
Change to the cs534lab1 directory and attempt to delete the tester
directory WITHOUT using any switches. Were you successful? No. Why?
Delete all the files in tester directory, THEN delete the tester directory
from a directory at least one level above tester in the tree.
- Recreate the tester
directory under the cs534lab1 directory, then copy the same files you copied before to
tester. Remain logged in to the cs534lab1 directory. Use the
appropriate command/switch combination to delete the tester directory and
its contents at the same time. CAUTION: make sure that you delete tester and the files
contained in tester ONLY!
- Run the ls
–la command on the cs534lab1 directory and make a
note of the file permissions of the files contained in that directory. Use
the chmod command to add read and
write permissions to group for the file headtail.txt
- Run the ls
–la command on the cs534lab1 directory again and
redirect the output to a file called permission1.txt located in cs534lab1.
Use the chmod command to grant read and
write permissions to other for the file permissions1.txt.
- Use the ls
–la command on the cs534lab1 directory and
redirect the output to a file called allfiles.txt located in cs534lab1.
Use the chmod command to grant read
only and execute permissions to group for the file allfiles.txt.
- Create a tarball
(a gzipped tar file) named cs534_yourfirstname_yourlastname_lab1.tgz
in your cs534lab1 directory. The compressed archive will include ALL of the files that
are in your cs534lab1 directory. Use the
following command to create the tarball:
tar
cvzf filname.tgz *
Where: c means create an archive
v means give a
verbose listing of the files as the archive is created
z means gzip the archive
f stands for the
filename that contains the archive
NOTE 1: Make sure that there is ONE SPACE
character between the z in .tgz and the * (asterisk)
that follows
NOTE 2: A dash (-) preceding the options to the
tar command IS NOT REQUIRED. Including the dash will not hurt...it just won't
add any functionality.
NOTE 3: The order of the options given to the tar
command is important. The c MUST be first and the f MUST be last.
NOTE 4: It will be helpful to be IN the cs534lab1
directory when you create the tarball...if not,
you'll have to provide a path to the files that will be included in the tarball.
NOTE 5: You can view the contents of the tarball without extracting the files from it. This feature
can come in VERY handy. The command is:
tar -tzvf
filname.tgz
Where: t means list
all files in the archive
z means gunzip the archive
v means give a verbose listing of the files
f stands for the
filename that contains the archive
At the appropriate time you will be instructed on
how to deliver the lab to the instructor for evaluation whether you are working
in the lab or at home.