\documentclass[a4paper, 10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{fancyhdr}
\usepackage{caption}
\usepackage{listings}   
\usepackage{color}
\usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=1.5cm,bindingoffset=0cm]{geometry}
\captionsetup{labelsep=period}
\pagestyle{fancy}

\renewcommand{\headrulewidth}{0pt}
\fancyfoot[L] {\thepage\bf}
\fancyfoot[C] {}
\begin{document}
	\begin{titlepage}
		\begin{center}
			\large
			Университет ИТМО
			\vspace{3cm}
			
			
			Кафедра вычислительной техники
			\vspace{4cm}
			
			\textsc{ \textbf{Отчёт по лабораторной работе  № 1} \\ по дисциплине: "Системное Программное Обеспечение"}\\[8mm]
			
			\bigskip
		\end{center}
		\vspace{3cm}
		
		\hfill\begin{flushright}
			 \vfill
			 Преподаватель:\\ Афанасьев Д. Б.
		\end{flushright}
		\vfill
		\vfill
		\vfill
		\vfill
		\vfill
		\begin{center}
			Санкт-Петербург \\2015 г.
		\end{center}
	\end{titlepage}
\section*{Задание}
Вариант 9.\\
\begin{enumerate}
\item Напечатать имя текущего каталога
\item Напечатать содержимое текущего каталога
\item Создать каталог
\item Предоставить всем право на запись в каталог
\item Убрать всем право на запись в каталог
\item Выйти из программы
\end{enumerate}
\section*{Скрипт}

\lstset{
  basicstyle=\sffamily,
  backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  language=Bash,                 % the language of the code
  otherkeywords={read,chmod, exit...},           % if you want to add more keywords to the set
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=2,                    % the step between two line-numbers. If it's 1, each line will be numbered
  tabsize=2,	                   % sets default tabsize to 2 spaces
}
\begin{lstlisting}
#!/usr/bin/ksh

LOG_FILE=$HOME/lab1_err

while : ; do
   echo 'Menu:
1. Print current directory name.
2. Print directory content.
3. Create directory.
4. Add write rights to the directory.
5. Remove write rights to the directory.
6. Quit.'

   echo "Enter code:"; read item
   case $item in
      1) basename `pwd` ;;
      2) ls ;;
      3)  
         echo "Directory name:"; read dirname
         mkdir -- "$dirname" 2>>$LOG_FILE || echo "Cannot create a directory: $dirname." >&2 ;;
      4) 
         echo "Directory name:"; read dirname
         [ -d $dirname ] && { 
            chmod a+w "$dirname" 2>>$LOG_FILE || echo "Cannot change permissions: $dirname" >&2 
         } || echo "No such directory: $dirname" >&2 ;;         
      5) 
         echo "Directory name:"; read dirname
         [ -d $dirname ] && { 
            chmod a-w "$dirname" 2>>$LOG_FILE || echo "Cannot change permissions: $dirname" >&2 
         } || echo "No such directory: $dirname" >&2 ;;
      6) exit 0 ;;
      *) [ -z $item ] && exit -1 || echo 'Unknown code' ;;
   esac 
done
\end{lstlisting}

\end{document}
