Basic information
- Teacher: Petr Kučera <>, room S304
- Schedule: Tuesday 10:40 — 12:10 SU2
Useful links
- Lecture web pages
- Web pages of the UNIX lab
- Local copy of the last UNIX specification
- The UNIX Specification
- Exercise assignments in book “Shell v příkladech” by Libor Forst, translated to English.
- Shell script checker
- Literature:
- Classic Shell Scripting by Arnold Robbins, Nelson H. F. Beebe
- UNIX Shells by Example by Ellie Quigley
- Shell Programming in Unix, Linux and OS X: The Fourth Edition of Unix Shell Programming (4th Edition) (Developer's Library) by Stephen G. Kochan, Patrick Wood
- Shell Scripting Recipes: A Problem-Solution Approach by Chris Johnson
Credit requirements
At the end of each practical homework shall be assigned, I will expect to receive solutions to them 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. Otherwise you will need to finish additional homework to get enough points. In case you submit solutions to less than 1/3 of homework assignments, you will not have a possibility to get a credit. Each set of homework exercises assigned after each 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 a single but more difficult exercise.
If not stated otherwise, you are only allowed to use 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. Either write your solution as a part of e-mail body, or append them in a form of plain text files, do not use pdf, word or similar file types. 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 12 homework assignments and thus the number of points required to get the credit is 24. Additional homework exercises for those who do note have enough points will be added to the last exercise.
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. 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:
- 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). - 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. - 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 agetent
command as follows:
getent passwd
for other parameters and general help on this command usegetent --help
. - The same applies to
/etc/group
andgetent group
. - 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 usefind
to search on local directories such as/tmp, /etc, /usr
etc. The exercises usually suggest it.
Content of the practicals
1st practical (19th February, 2019)
Basic commands, shell command line edit.
More detailed:
- Command line edit: Ctrl-a, Ctrl-e, Ctrl-h, Ctrl-r, arrows (left, right, up and down), Ctrl-d, Ctrl-k (deletes text from the cursor position to the end of line).
-
Commands:
man, ls, cd, pwd, cat, more, less, head, tail, wc, mkdir, rmdir, cp, mv, rm, echo.
- Redirecting and pipes: <, >,
>>, 2>, 2>>, |,
/dev/null
. - Shell expansion: *, ?, [list], [!list], [[:class:]], apostrophes and quotation marks, filenames starting with a dot.
Exercises
- In your home directory create a directory named DIR
- 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.
- Create a subdirectory called SUBDIR in your DIR directory.
- The first five lines of each file you have copied from /usr/include copy to file ~/DIR/SUBDIR/firstfive.
- The last lines of files in ~/DIR copy to file ~/DIR/SUBDIR/last.
- Concatenate the two files in ~/DIR/SUBDIR into one file ~/DIR/SUBDIR/firstandlast
- Delete the files in ~/DIR/SUBDIR except firstandlast.
- Store the number of files and directories in ~/DIR into a file ~/DIR/SUBDIR/count
- Output the long information on ~/DIR/SUBDIR directory. (Not its content, but information on it).
- Delete the contents of ~/DIR/SUBDIR/firstandlast file without removing the file itself.
- Add a line containing just a star sign (i.e. *) to file ~/DIR/SUBDIR/firstandlast.
- Delete ~/DIR together with all the files it contains.
-
(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.php(288): geshi_highlight() #6 {main} thrown in /home/kucerap/public_html/include/geshi.php on line 4698