Practicals to Introduction to UNIX, summer semester 2015/16

Petr Kučera, KTIML MFF UK

Basic information

Useful links

Credit requirements

At the end of each practical homeworks shall be assigned, I will expect to receive their solution by e-mail before the beginning of the next practical. If by the end of the semester you have at least 2/3 of possible number of points, you get a credit. If you have at least 1/3 of possible number of points (but less than 2/3), you will have to finish additional homeworks to achieve the credit (number and complexity of these additional homeworks will be in proportional to missing number of points). Each set of homeworks assigned after a practical will be worth 3 points, at the beginning of the semester that could mean three exercises while at the end it can be just one more difficult. Whoever is not able to achieve at least 1/3 will not get a credit from me.

If not stated otherwise, you are allowed to use only the commands, tools and structures we have used on practicals before the homework was assigned (including the one to which homework was assigned). In some cases the tools might be even more restricted. If I come across a solution which is just a copy of another one I will assign no points for this solution. If this case repeats there will be no possibility to obtain a credit from me.

Please, send me your solutions via an e-mail and do so before the beginning of the next practical. The homework assignments are appended below a list of exercises we have done at the corresponding practical (i.e. the current homework exercises are always at the bottom of this web page).

There have been 13 homeworks assigned and thus the number of points required to get the credit is 26. The homeworks assigned to 14th practical are considered as additional and do not count into the limit.

Some peculiarities of the Malá Strana UNIX lab

I think it is worth to know and bear in mind some specifics of the Malá Strana UNIX lab. To Czech students I recommend to check the web pages of the UNIX lab, but as far as I know there is no English version (yet) of these web pages. So I will warn you of the lab properties as we come across them. In this section I would to mention at least the most apparent of them:

  1. Users home directories are placed in a remote AFS filesystem, where standard UNIX permissions do not apply and the standard UNIX commands for file permissions manipulations (mainly chmod) cannot be used or they can be used only in a very restricted way (there is a web page about the ACL which is the system in use, but it is only in Czech to the best of my knowledge).
  2. This means that when you try the chmod command or anything which has some connection to the standard UNIX permission system, you should do so in local directories (such as /tmp in which you are allowed more or less anything). There the standard UNIX permissions apply.
  3. As user accounts are stored remotely, local file /etc/passwd does not contain information about your account or accounts of other lab users. If you want to get your and other users account info in the format of /etc/passwd you can achieve that using a getent command as follows:
    getent passwd
    for other parameters and general help on this command use getent --help.
  4. The same applies to /etc/group and getent group.
  5. The find command (still most probably) is not in the best of terms with AFS filesystem — when used on network AFS drives in the lab such as your home dir you can get unexpected results. You can use find to search on local directories such as /tmp, /etc, /usr etc. The exercises usually suggest it.

Content of the practicals

1st practical (26th February, 2016)

Basic commands, shell command line edit.

More detailed:

Exercises:

  1. In your home directory create a directory named DIR
  2. Copy all files whose filenames satisfy the following conditions to ~/DIR. The files are in /usr/include directory, their names start with m, end with .h and contain a number.
  3. Create a subdirectory called SUBDIR in your DIR directory.
  4. The first five lines of each file you have copied from /usr/include copy to file ~/DIR/SUBDIR/firstfive.
  5. The last lines of files in ~/DIR copy to file ~/DIR/SUBDIR/last.
  6. Concatenate the two files in ~/DIR/SUBDIR into one file ~/DIR/SUBDIR/firstandlast
  7. Delete the files in ~/DIR/SUBDIR except firstandlast.
  8. Store the number of files and directories in ~/DIR into a file ~/DIR/SUBDIR/count
  9. Output the long information on ~/DIR/SUBDIR directory. (Not its content, but information on it).
  10. Delete the contents of ~/DIR/SUBDIR/firstandlast file without removing the file itself.
  11. Add a line containing just a star sign (i.e. *) to file ~/DIR/SUBDIR/firstandlast.
  12. Delete ~/DIR together with all the files it contains.
  13. (Show solutions to preceding exercises)

    Fatal error: Uncaught Error: Call to undefined function create_function() in /home/kucerap/public_html/include/geshi.php:4698 Stack trace: #0 /home/kucerap/public_html/include/geshi.php(4621): GeSHi->_optimize_regexp_list_tokens_to_string() #1 /home/kucerap/public_html/include/geshi.php(1655): GeSHi->optimize_regexp_list() #2 /home/kucerap/public_html/include/geshi.php(2029): GeSHi->optimize_keyword_group() #3 /home/kucerap/public_html/include/geshi.php(2168): GeSHi->build_parse_cache() #4 /home/kucerap/public_html/include/geshi.php(4728): GeSHi->parse_code() #5 /home/kucerap/public_html/unix/index-en-16.php(275): geshi_highlight() #6 {main} thrown in /home/kucerap/public_html/include/geshi.php on line 4698