<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\setbeamercolor{progress bar}{bg=color3!50!black!30,fg=color3}
\setbeamercolor{alerted text}{fg=color3}
\label{sec:Linux}
\section{\texorpdfstring{\faIcon{terminal} Linux Introduction}{Linux Introduction}}

\begin{frame}
    \begin{center}
        \Huge\faIcon{linux} \\
        \vspace{4mm}
        \normalsize Who has had anything to do with Linux before?
    \end{center}
\end{frame}

\subsection{Overview}

\begin{frame}{What's that?}
    \begin{itemize}
        \item Open operating system, an alternative to Windows and macOS
        \item Many different distributions
        \item Popular as a server operating system, use for personal computers is less common
        \begin{itemize}
            \item Fancied among colis
        \end{itemize}
        \item Most computers at the institute run linux
    \end{itemize}
\end{frame}

\begin{frame}{How do you operate it?}
    \begin{itemize}
        \item There are graphical user interfaces (as for Windows and macOS)\dots
        \item \dots but you can also use merely text-based interfaces
        \item The latter is of high importance for remote operation of servers
    \end{itemize}
\end{frame}    

\begin{frame}{The terminal}
    \begin{itemize}
        \item Takes getting used to, but is very powerful
        \item At the pool: \keys{Alt + F2}, then ``\textit{konsole}" to open it
        \item Connecting to the pool from your own device using a ``SSH client"
        \item The search engine of your choice will provide you with the most helpful tips
    \end{itemize}
\end{frame}

\begin{frame}{Using the pool without being at the pool: SSH}
	\textbf{Connecting to linux computers - \structure{ssh} (\structure{s}ecure \structure{sh}ell)}

	\begin{itemize}
	\item Remote access to a linux terminal from home
	\item Optionally with a graphical user interface (not very performant)
	\item Using Linux/Mac/Windows 10 at home? Perfect!
	\begin{itemize}
		\item \texttt{ssh \textless login\textgreater @last.cl.uni-heidelberg.de}
		\item \texttt{ssh \textless login\textgreater @ella.cl.uni-heidelberg.de}
		\item \texttt{ssh \textless login\textgreater @pool.cl.uni-heidelberg.de -p 2222} (exception!)
		\item ...
	\end{itemize}
	\item For older versions of Windows: \href{https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html}{PuTTY}
	\item Recommendation: Try it out, contact us when you have problems
	\end{itemize}
\end{frame}

\begin{frame}{Using the pool computers}
    \begin{itemize}
        \item Set computers to \textbf{standby} (= sleep) if you don't need them
        \item Away for a short time: Standby (automatically locks session)
        \item Done: Log out, \textbf{then click ``sleep''}
        \item Monitor off? Press any key
        \item Computer off? Please ignore it (we take care of it)
        \item In the deep hours of the night, all PCs will be rebooted
    \end{itemize}
\end{frame}

\begin{frame}{Computers, users and data}
    \begin{itemize}
        \item Many users can use one computer
        \item Personal data (home directory) is available at every computer
        \item The disk space for your home directory is limited!\\ Get the current status: \alert{quota -s}
            \begin{itemize}
                \item Space: Soft \textbf{37 GB}, Hard \textbf{42 GB}
                \item Amount of files: Soft \textbf{200.000}, Hard \textbf{250.000}
            \end{itemize}
        \item \textcolor{cwarning}{Suspension}: When violating the quota for too long, your account will be suspended.
        \item No problem: just clean up your home directory (don't just move the items to the trash)
    \end{itemize}
\end{frame}

\begin{frame}{Claustrophobia: project directories}
    \begin{itemize}
        \item If you need more disk space when working on a larger software project, don't hesistate to contact us for a project directory
        \item Available on every machine (like the home directories)
    \end{itemize}
\end{frame}

\subsection{Essentials and Basic Commands}

\begin{frame}[fragile]{The prompt}
    \begin{semiverbatim}
        moser@pool10:~\$
        moser@pool03:~/Desktop\$
        moser@ella:/home/students/\$
    \end{semiverbatim}
    \begin{tabular}{ l l }
        \texttt{moser} &amp; Username \\ 
        \texttt{@} &amp; \textit{Separator}\\
        \texttt{pool10} &amp; Hostname (e.g. \texttt{pool15} or \texttt{ella})\\
        \texttt{:} &amp; \textit{Separator}\\
        \texttt{\textasciitilde} &amp; Current working directory\\
        \texttt{\$} &amp; \textit{Separator}
    \end{tabular}
\end{frame}

\begin{frame}{Linux Path Structure}
    \begin{itemize}
        \item Within a directory, there can be files and more directories
        \item This structure resembles the structure of branches of a tree
        \item Each node within this tree can be identified by its \textbf{path}
        \item By the way: Linux doesn't care about file extensions. \texttt{diary.txt} could be a \texttt{gif} file too
    \end{itemize}
\end{frame}

\begin{frame}{Linux Path Structure}
    \includegraphics[width=\textwidth]{../img/baumstruktur.png}
    % https://publicdomainvectors.org/en/free-clipart/Barren-tree/49392.html
\end{frame}


\begin{frame}{Paths}
    \textbf{Absolute paths}
    \begin{itemize}
        \item describe the location of a file / directory relative to the root directory \alert{/}
        \item are distinct within the system
        \item e.g. \alert{/home/students/hfischer/folien/einfuehrung.pdf}
    \end{itemize}
    \textbf{Relative paths}
    \begin{itemize}
        \item describe the location of a file / directory relative to the current working location
        \item start with a relative anchor (\alert{\textasciitilde} or \alert{.} or \alert{..})
        \item \alert{\textasciitilde/folien/einfuehrung.pdf}\\
         \alert{./folien/einfuehrung.pdf} (= \alert{folien/einfuehrung.pdf}) \\
         \alert{../hfischer/folien/einfuehrung.pdf}\\
    \end{itemize}
\end{frame}

\begin{frame}{Paths: Anchors}
    All paths start with an anchor:
    \begin{tabular}{ l l }
        \alert{/} &amp; The root directory \\
        \alert{\textasciitilde} &amp; The home directory \\
        &amp; (usually \alert{/home/students/\textit{username}}) \\
        \alert{.} &amp; The current working directory \\
        &amp; (This anchor can be left out most of the time) \\
        \alert{..} &amp; The next higher / superior directory
    \end{tabular}

    \smallskip % Die Leerzeile darüber muss bleiben!
    Also important: you have to watch out for case sensitivity!
\end{frame}

\begin{frame}{Commands}
    \begin{itemize}
        \item You can or must usually place parameters after commands.
        \item Example: \texttt{ls -a /home/students/piersig}
        \item Note that the command name and any parameters are separated by a space.
    \end{itemize}
\end{frame}

\begin{frame}{Navigation}
    \textbf{Changing the working directory - \structure{cd} (\structure{c}hange \structure{d}irectory)}\\
    \begin{description}[\alert{cd \textless absolute path\textgreater}]
        \item[\alert{cd \textless absolute path\textgreater}]  changes into the specific absolute path
        \item[\alert{cd \textless relative path\textgreater}]  changes into the specific relative path
        \item[\alert{cd \textasciitilde}] changes into your home directory (abbreviation: \alert{cd})
        \item[\alert{cd ..}] changes into the next higher / superior directory
        \item[...]
    \end{description}
    \smaller
    \textbf{Examples:}\\
    \alert{cd /home/students/moser/} changes into the home directory of the user \textit{moser}\\
    \alert{cd Desktop} changes into the subdirectory \textit{Desktop} within the current directory\\
     \alert{cd} changes into the home directory of the current user\\
\end{frame}

\begin{frame}{Directory Management}
    \textbf{Showing the path of the current working directory - \structure{pwd} (\structure{p}rint \structure{w}orking \structure{d}irectory) }\\[0.5cm]
    
    \textbf{Showing folder content - \structure{ls} (\structure{l}i\structure{s}t directory contents)}
    \begin{description}
        \item[\alert{ls \textless path\textgreater}] shows the content of a relative/absolute path
        \item[\alert{ls}] shows the content of the current directory
        \item[\alert{ls -l}] shows the content + other useful information
        \item[\alert{ls -la}] shows the content + useful information + hidden files
    \end{description}

    \textbf{Creating folders - \structure{mkdir} (\structure{m}a\structure{k}e \structure{dir}ectory) }
    \begin{description}
        \item[\alert{mkdir aFolder}] creates the folder \texttt{aFolder} in the current directory
        \item[\alert{mkdir \textasciitilde/aFolder}] creates the folder \texttt{aFolder} in your home directory
    \end{description}
\end{frame}

\begin{frame}{File Management I}

    \textbf{Copying files - \structure{cp} (\structure{c}o\structure{p}y files and directories)}
    \begin{description}
        \item[\alert{cp aFile ../aFile}] copies \texttt{aFile} into the superior directory
        \item[\alert{cp -r aFolder aFolder2}] copies \texttt{aFolder} (into the same directory)\\[0.5cm]
    \end{description}

    \textbf{Renaming/Moving files - \structure{mv} (\structure{m}o\structure{v}e/rename files)}:
    \begin{description}
        \item[\alert{mv -i file1 file2}] renames \texttt{file1} to \texttt{file2} (confirm with \keys{Y})
        \item[\alert{mv -i pfad1/file pfad2/file}] moves the file
    \end{description}
    If you leave out \alert{-i}, files will be overwritten without further question.
    Overwritten files are \textbf{\textcolor{cwarning}{gone}}!\\[0.5cm]
\end{frame}

\begin{frame}{File Management II}
    \textbf{Deleting files - rm (\structure{r}e\structure{m}ove files or directories)}
    \begin{description}
        \item[\alert{rm -i \textless file\textgreater}] deletes a file
        \item[\alert{rm -i -r \textless directory\textgreater}] deletes a folder with files and subdirectories
    \end{description}
    Files deleted using \alert{rm} are \textbf{\textcolor{cwarning}{gone}} as well! (not in the trash folder)
    And if you leave out \alert{-i}, you won't even be asked if you really want to delete...
\end{frame}

\begin{frame}{Opening and Creating Text Files}
    \textbf{Reading text files - \structure{cat}}
    \begin{description}
        \item[\alert{cat \textless file\textgreater}] prints the content of the file
        % \item[\alert{/}] searches for a string $\rightarrow$ \structure{n} shows the next match
        % \item[\alert{q}] closes reading view\\[0.5cm]
    \end{description}
    \textbf{Creating empty files - \structure{touch}}
    \begin{description}
        \item[\alert{touch \textless file\textgreater}] creates an empty file with the respective name
    \end{description}
\end{frame}

\begin{frame}{Editing Text Files}
    \textbf{Text editors}
    \begin{itemize}
        \item There is a variety of text editors available
        \item Not every editor is installed on every system by default
        \item Common editors: \texttt{nano}, \texttt{vi}, \texttt{vim}, \texttt{emacs}
        \item Create a new or edit an existing text file i.e. by using \\
                \textbf{\alert{vim \textless file\textgreater}}
    \end{itemize}
    \textbf{Lifehack: Ouput forwarding using \texttt{\textgreater, \textgreater\textgreater}}
    \begin{description}
        \item[\alert{echo "Hello" \texttt{ \textgreater\textgreater} hello.txt}] appends ``Hello'' to the contents of \texttt{hello.txt}
    \end{description}
\end{frame}

\begin{frame}{In the Footsteps of Gutenberg}
    \textbf{Printing files - \structure{lp} (\structure{l}ine \structure{p}rinter devices)}
    \begin{description}
        \item[\alert{lp -h miller \textless path\textgreater}] sends the file to the pool printer
        \item ideally a \texttt{.txt} or \texttt{.pdf} file\\[0.5cm]
    \end{description}
    \textbf{Checking the print status}
    \begin{itemize}
        \item Web interface: \structure{\url{http://miller:631/jobs}}
        \item Favorable price tag per page: only 0 Euro
        \item Quota: 30 pages every week per user
    \end{itemize}
\end{frame}

\begin{frame}{Let's just take the file and move it to last}
    \textbf{Moving files via the network to other computers - rsync}
    \begin{description}
        \item[\alert{rsync \textless source\textgreater \hspace{1pt}\textless target\textgreater}] copies the file from the source to the target
        \item[\alert{rsync hi.txt hfischer@last.cl.uni-heidelberg.de:\textasciitilde /briefe/}] copies \texttt{hi.txt} from the local working directory to the folder \texttt{briefe} in the home directory of the user \texttt{hfischer} on last
    \end{description}
\end{frame}

\begin{frame}{Linux Manual Pages}
    \textbf{Help for commands - \structure{man} (\structure{man}ual pager utils)}
    \begin{description}
        \item[\alert{man \textless command\textgreater}] shows manual page for the specified command
    \end{description}
    \smaller
    \textbf{Examples:}\\
    \alert{man man} How, why and whatfore do you use \texttt{man}?

    \medskip
    \normalsize
    If you are still kind of scared by the terminal, have a look at \url{https://linux.die.net/man/} or use a search engine of your choice.
\end{frame}

\begin{frame}{Wildcards}
    \textbf{The Asterisk}
    \begin{itemize}
        \item matches multiple files
        \item replaces multiple characters (zero aswell)\\[0.5cm]
    \end{itemize}
    \textbf{Example: \structure{rm *.txt}}\\
    \begin{itemize}
        \item \texttt{lel.txt} - deleted
        \item \texttt{lel.pdf} - not deleted
        \item \texttt{asd.txt} - deleted
        \item \texttt{lel.pdf.txt} - deleted
    \end{itemize}
    Reminder: file extensions are irrelevant to the system
\end{frame}

\begin{frame}{More useful commands}
    \begin{description}
        \item[\alert{grep}] Searching the content of files
        \item[\alert{find}] Searching files (i.e. by name)
        \item[\alert{less}] View text file in pager, incl. search functionality 
        \item[\alert{head}] Printing the first few lines of a file
        \item[\alert{tail}] Printing the last few lines of a file
    \end{description}
    Great sources for more information on a command are (besides \alert{man})
    webpages like \href{https://wiki.ubuntuusers.de}{\texttt{wiki.ubuntuusers.de}} or \href{https://www.cyberciti.biz/faq}{\texttt{www.cyberciti.biz/faq}}.
\end{frame}

\subsection{Working with others and over the network}

\begin{frame}{Networks and their users}
    \textbf{Computers in the network}
    \begin{itemize}
        \item{every computer is in the network}
        \item{every user can log on to every computer}
        \item{every user gets to use the same data}
        \item{every user gets to use the same resources}
    \end{itemize}
    
    \textbf{Users and groups}
    \begin{itemize}
        \item each user has its own username and is at least in one group (students/mitarb)
        \item e.g.: \alert{schubert} in \alert{students}
        \item you can list all groups of a user with the \alert{groups} command
    \end{itemize}
\end{frame}

\begin{frame}{Access Rights I}
    The UNIX abbreviation for the three access rights:
    \begin{description}[r]
        \item[\alert{r}]read permission. The permission to read the file’s/folder’s content
        \item[\alert{w}]write permission: The permission to change/delete the file/folder
        \item[\alert{x}]execution permission (eXecute): The permission to execute the file as a program
    \end{description}
    \vspace{1.5em}
    And for the classes of user and group management:
    \begin{description}[r]
        \item[\alert{u}] The user who owns the file
        \item[\alert{g}] The users who are in the group which owns the file
        \item[\alert{o}] Every other user
    \end{description}
\end{frame}

\begin{frame}{Access Rights II}
    How the access rights for a specific file or folder are set can be checked with \alert{ls -l \textless path\textgreater}.
    \\[.5cm]
    Two typical entries could look like this:\\
    {\color{red}\texttt{ uuugggooo\\}}
    \texttt{drwxrwxrwx 160 moser  students   5440 Oct 21 21:25 topics\\
    -rw-r-----   145 moser  students   2670 Mar 18 13:12 cheat}
    \\[.5cm]
    The first entry is a directory which the user, group und others are able to read, write and execute.
    The second entry is not a directory, but a file. The user is allowed to read and write the files, the group may only read the file. Others are not allowed to do anything.
\end{frame}

\begin{frame}{Access Rights III}
    \textbf{Changing access rights - \structure{chmod} (\structure{ch}ange \structure{mod}e)}
    \begin{description}[Hi] % Das Hi definiert nur, dass die Einrückung zwei Zeichen weit sein soll
    \item[\alert{chmod \textless class(es)\textgreater\textbf{+}\textless permissions\textgreater \hspace{1pt} \textless file\textgreater}]\hspace{10cm} Allocates the given rights to the given class
    \item[\alert{chmod \textless class(es)\textgreater \textbf{-}\textless permissions\textgreater \hspace{1pt} \textless file\textgreater}]\hspace{10cm} Withdraws the given rights from the given classes 
    \end{description}
        
    \smaller
    \textbf{Examples:}\\
    \alert{chmod go-rwx \textless file\textgreater} withdraws the rights to read, write and execute from the users in the group and all others. \\
    \alert{chmod u+w \textless file\textgreater} allocates write access to the user\\
    \alert{chmod a-w \textless file\textgreater} withdraws the write access from everyone (= \alert{chmod ugo-w})

    \normalsize
    \textit{file} can always also be a \textit{directory}
\end{frame}

\begin{frame}{Experimenting with Linux and solving the pool test}
    \begin{center}
        \includegraphics[width=0.8\textwidth]{../img/yalikejazz.png}
        \\
        \url{https://yalikejazz.cl.uni-heidelberg.de/}
    \end{center}
\end{frame}

\begin{frame}{Experimenting with Linux and solving the pool test}
    \begin{itemize}
        \item Allows you to safely play around with a Linux terminal and practice commands.
        \item There are some practice tasks in the style of the tasks that are asked in the pool test.
        \item Because the Linux environment is simulated only in the browser not all programs are available. In particular, there is no \texttt{nano}, \texttt{vim} or \texttt{emacs}.
        \begin{itemize}
            \item If a text editor is necessary, one can use \texttt{vi}. The same keyboard shortcuts apply here as with \texttt{vim}, so especially the complicated methodology for closing the editor: \keys{ESC} + \texttt{:wq} to save and \keys{ESC} + \texttt{:q!} to discard the changes.
            \item You do not always need an editor to fill a text file.
        \end{itemize}
    \end{itemize}
\end{frame}
</pre></body></html>