Skip to content

Commit ee620c0

Browse files
committed
Small updates of UNIX chapters.
1 parent 9db5edd commit ee620c0

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

presentation/linux_bash_metacentrum_course.tex

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ \subsection{Differences}
516516
\item Package management --- especially in command line
517517
\item Development model --- conservative or experimental, fast or slow
518518
\item Management of system services (how to start/stop certain services like database or web server) --- not important for daily usage for most of users
519-
\item Sometimes in location of some system files --- also not important in daily usage of most of users
519+
\item Sometimes in location of some system files (can be customized) --- also not important in daily usage of most of users
520520
\item Kernel is almost same, applications are same and used in same way\ldots
521521
\item Command line is almost same across Linux, and almost same as in other UNIX systems (macOS,~\ldots)
522522
\end{itemize}
@@ -697,6 +697,7 @@ \subsection{Directory structure}
697697
\begin{frame}[allowframebreaks]{Directory structure in Linux}
698698
\begin{itemize}
699699
\item It is similar also in another UN*X systems
700+
\item Directory structure in Linux is similar to macOS (but there it is bit hidden, users usually don't see everything), but very different from Windows logic
700701
\item Top directory \enquote{\texttt{/}} --- \enquote{root}
701702
\item Everything else (including disks and network shares) are mounted in subdirectories (\texttt{/\ldots})
702703
\item \texttt{/bin} --- very basic command line utilities
@@ -720,15 +721,16 @@ \subsection{Directory structure}
720721
\item \texttt{/usr} --- binaries (executable applications) and libraries of installed applications
721722
\item \alert{\texttt{/var}} --- data of most of applications and services, including e.g. database data, system logs,~\ldots
722723
\item \alert{\texttt{/windows}} --- if on dual boot, Windows disks are commonly mounted here
724+
\item In newest Linux distributions, most of \texttt{/bin}, \texttt{/etc}, \texttt{/lib}, \texttt{/lib64} and \texttt{/sbin} are mostly in \texttt{/usr} (original locations are just links)
723725
\item Can be altered, modified
724-
\item E.g. MetaCentrum has storage servers in various locations accessible from front and calculation nodes in \texttt{/storage}
726+
\item E.g. MetaCentrum has storage servers in various locations accessible from front ends and calculation nodes in \texttt{/storage}
725727
\item Usually, work only in your home, anywhere else modify files only if you are absolutely sure what you are doing
726728
\item Normal user doesn't have permission to modify files outside his directory (with exception of plugged removable media, etc.)
727729
\item Try \texttt{man hier} for details
728730
\end{itemize}
729731
\end{frame}
730732

731-
\begin{frame}{Configuration in /etc (examples)}
733+
\begin{frame}{Configuration in \texttt{/etc} (examples)}
732734
\begin{itemize}
733735
\item Configuration of system services (servers,~\ldots) and behavior
734736
\begin{itemize}
@@ -745,7 +747,7 @@ \subsection{Directory structure}
745747
\end{itemize}
746748
\end{frame}
747749

748-
\begin{frame}[fragile]{Example of configuration in /etc/ssh/sshd\_config}
750+
\begin{frame}[fragile]{Example of configuration in \texttt{/etc/ssh/sshd\_config}}
749751
\begin{bashcode}
750752
# This is the ssh client system-wide configuration file. See
751753
# ssh_config(5) for more information. This file provides defaults for
@@ -840,21 +842,21 @@ \subsection{Files and directories}
840842
\begin{frame}[fragile]{Links}
841843
\label{links}
842844
\begin{itemize}
843-
\item Soft links --- like links on the web --- short-cut to another place
845+
\item \textbf{Symbolic (soft) links (symlinks)} --- like links on the web --- short-cut to another place
844846
\begin{itemize}
845847
\item When we delete link, nothing happens, when target, non-working link remains
846848
\end{itemize}
847849
\end{itemize}
848850
\vfill
849851
\begin{bashcode}
850-
ln -s source target # Source will point to target
852+
ln -s target link_name # Link points to target (existing file/directory)
851853
ls -l bin/cinema5
852854
lrwxrwxrwx 1 vojta users 42 5. dub 2014 cinema5 -> # "l" marks link
853-
/home/vojta/bin/cinema5-0.2.1-beta/cinema5* # "->" points to target
855+
/home/vojta/bin/cinema5-0.2.1-beta/cinema5* # "->" points to target
854856
\end{bashcode}
855857
\vfill
856858
\begin{itemize}
857-
\item Hard links --- only second name for file already presented on the disk (available only for files): \texttt{ln source target}
859+
\item \textbf{Hard links} --- only second name for file already presented on the disk (available only for files): \texttt{ln target link\_name}
858860
\begin{itemize}
859861
\item If any one of the two files is deleted, the second remains to be fully working
860862
\end{itemize}
@@ -865,8 +867,8 @@ \subsection{Files and directories}
865867
ls -l .bash* # Numbers in first column show links pointing to it
866868
# For directories - number of items, for files = 1
867869
-rw------- 1 vojta users 7298 21. jan 16.43 .bash_history # One link
868-
-rw-r--r-- 2 vojta users 2707 29. nov 16.21 .bashrc # Same file as below
869-
-rw-r--r-- 2 vojta users 2707 29. nov 16.21 .bashrcX # Two links
870+
-rw-r--r-- 2 vojta users 2707 29. nov 16.21 .bashrc # Same as below
871+
-rw-r--r-- 2 vojta users 2707 29. nov 16.21 .bashrcX # Two links
870872
\end{bashcode}
871873
\end{frame}
872874

@@ -881,7 +883,7 @@ \subsection{Permissions}
881883
\item Commands \texttt{chgrp} to change group often requires root privileges --- user has to be member of particular group to be able to change ownership to it (if not, \texttt{root} must do it)
882884
\item Information about users and groups and their IDs are in \texttt{/etc/group} and \texttt{/etc/passwd}
883885
\item Ownership (and permissions, slide~\ref{permissions}) are important especially on servers with plenty of users (e.g. on MetaCentrum)
884-
\item It is not possible to add particular permissions for particular user on one file --- there must be special group or ACL must be used (slide~\ref{acl})
886+
\item It is not possible to add particular permissions for particular user on one file/directory --- there must be special group or ACL must be used (slide~\ref{acl})
885887
\end{itemize}
886888
\end{frame}
887889

@@ -918,13 +920,13 @@ \subsection{Permissions}
918920
\textbf{Permission} & \textbf{Number} & \textbf{Directory} & \textbf{File}\\
919921
r & 4 & Read directory content & Read file content\\
920922
w & 2 & Write into it (add/remove items) & Write into it, modify, delete it\\
921-
x & 1 & Enter it & Launch application (scrip)
923+
x & 1 & Enter it & Launch application (script)
922924
\end{tabular}
923925
\end{center}
924926
\begin{itemize}
925927
\item \texttt{rwxrw-r-{-}} --- 3$\times$3 characters for permissions for owner of the file/directory, group it is belonging to, and other users (\texttt{d} on beginning marks directories, \texttt{l} links, \texttt{+} ACL, slide \ref{acl})
926928
\item \texttt{764} --- same as above --- numbers for each role are summed --- first one is for owner, second for group and last for others
927-
\item Executable scripts and binaries \textbf{require} executable permission (\texttt{x}, e.g. \texttt{chmod +x} or \texttt{chmod u+x})
929+
\item Executable scripts and binaries \textbf{require} executable permission (\texttt{x}, e.g. \texttt{chmod +x} or \texttt{chmod u+x}) --- not supported on FAT drives (USB sticks, memory cards,~\ldots)
928930
\end{itemize}
929931
\end{frame}
930932

@@ -957,7 +959,7 @@ \subsection{Permissions}
957959
\begin{bashcode}
958960
ls -l # Long list - file names and attributes
959961
ls -a # All, including hidden files (starting with dot)
960-
ls -F # Add on the end of name / for directories and * for executable
962+
ls -F # Add on the end of name "/" for directories and "*" for executable
961963
ls -h # Human readable size units (use with -l or -s)
962964
ls --color ## Colored output
963965
ls -laFh --color # Combine any parameters you like
@@ -975,16 +977,18 @@ \subsection{Permissions}
975977
\end{bashcode}
976978
\end{frame}
977979

978-
\begin{frame}{Extending permissions --- ACL}{Access control list}
980+
\begin{frame}[allowframebreaks]{Extending permissions --- ACL (Access control list)}
979981
\label{acl}
980982
\begin{itemize}
981983
\item By default, it is not possible to give specific permission to the user who is not owner, nor member of group owning the file
982984
\item In ext4 FS it has to be turned on manually (usually it is by default), it is part of Btrfs, XFS and ZFS --- it is not available on every computer/server
983985
\item Command \texttt{getfacl} lists those extra permissions, \texttt{setfacl} sets
984986
\item \alert{When in use, \enquote{basic} tools listing permissions (e.g. \texttt{ls -l}, ACL in use is marked by \texttt{+} after permissions --- next slide) sometimes do not show correct result and permissions may work unexpectedly}
985987
\item Important especially in network environment with many users
986-
\item If intensively used, \texttt{ls -l} sometimes doesn't show correct permissions (see next slide)
987-
\item If not in use on server (like e.g. on CESNET data storage), relatively high number of groups is required to be able to correctly setup sharing permissions
988+
\item If intensively used, \texttt{ls -l} sometimes doesn't show correct permissions (see next slide), it can be confusing and lead into various issues
989+
\item If not in use on server (like e.g. on CESNET data storage in Ostrava, \texttt{du4.cesnet.cz}), relatively high number of groups is required to be able to correctly setup sharing permissions
990+
\item MetaCentrum has storages and clusters connected via NFSv4 protocol (see also slide~\ref{netfs}) --- commands \texttt{getfacl} and \texttt{setfacl} do not work there, use \texttt{nfs4\_getfacl}, \texttt{nfs4\_setfacl} and \texttt{nfs4\_editfacl} instead (usage is very similar), see also \url{https://wiki.metacentrum.cz/wiki/Access_Control_Lists_on_NFSv4}
991+
\item Permissions (\enquote{classical} as well as ACL) require some time to practice and master it\ldots
988992
\end{itemize}
989993
\end{frame}
990994

@@ -1006,7 +1010,7 @@ \subsection{Permissions}
10061010
# folder 'dokumenty/arabidopsis' (no extra group is required)
10071011
setfacl -mR u:arabidopsis_data:r dokumenty/arabidopsis
10081012
setfacl -R ... # Recursive (including subdirectories)
1009-
setfacl -b FILE # Remove all ACL from FILE
1013+
setfacl -b FILE # Remove all ACL from FILE (combine with -R ...)
10101014
\end{bashcode}
10111015
\end{frame}
10121016

@@ -1020,12 +1024,11 @@ \subsection{Permissions}
10201024
\item \texttt{umask 027} (or other number) is typically set in file \texttt{$\sim$/.bashrc}
10211025
\begin{itemize}
10221026
\item \texttt{$\sim$} means user's home directory
1023-
\item \texttt{.bashrc} is user's configuration for BASH
1027+
\item \texttt{.bashrc} is user's configuration for BASH (see slide~\ref{bashrc})
10241028
\end{itemize}
10251029
\item Typically used in network environment
10261030
\item Set with care --- new permissions will have plenty of consequences --- different are typically needed for web pages, private files, shared files,~\ldots
10271031
\item \texttt{umask} work recursively for all new files in user home directory --- it is not possible to set new implicit rules for particular directory
1028-
\item ACL can be used to set default permissions/ownership for new files in particular directory
10291032
\end{itemize}
10301033
\end{frame}
10311034

@@ -1069,20 +1072,20 @@ \subsection{Text}
10691072
\begin{itemize}
10701073
\item Windows and UNIX have different internal symbol for end of line (\href{https://en.wikipedia.org/wiki/Newline}{new line}) --- EOL
10711074
\begin{itemize}
1072-
\item UNIX: LF (\texttt{\textbackslash n})
1075+
\item UNIX (Linux, macOS,~\ldots): LF (\texttt{\textbackslash n})
10731076
\item Windows/DOS: CR+LF (\texttt{\textbackslash r\textbackslash n})
10741077
\item Mac v. < 9: CR (\texttt{\textbackslash r}) (Mac up to 9~wasn't UN*X, since OS~X it is)
10751078
\end{itemize}
1076-
\item Good text editor can open correctly any EOL, but for example execution of script written in Windows will probably fail on Linux if it has wrong EOL
1079+
\item Good text editor (slide~\ref{editors}) can open correctly any EOL, but for example execution of script written in Windows will probably fail on Linux if it has wrong EOL
10771080
\item Different systems use different encoding
10781081
\begin{itemize}
10791082
\item UNIX: mainly UTF-8 (Unicode, universal), UTF-16 for Asian languages
10801083
\item Windows: win-cp-125X (variants according to region)
10811084
\item Older UNIX: ISO-8859-X (variants according to region)
1082-
\item Other much less common (historical) types
1085+
\item Other much less common (historical) types\ldots
10831086
\item Important mainly for accented characters
10841087
\end{itemize}
1085-
\item Text editors can usually open any encoding, but automatic detection commonly fails --- set it manually
1088+
\item Text editors can usually open any encoding, but automatic detection commonly fails --- set it manually, see also slide~\ref{eolencoding}
10861089
\end{itemize}
10871090
\end{frame}
10881091

@@ -1321,6 +1324,7 @@ \subsection{BASH}
13211324
\end{frame}
13221325

13231326
\begin{frame}[fragile]{BASH settings (popular examples)}{Write them into BASH configuration file}
1327+
\label{bashrc}
13241328
\begin{itemize}
13251329
\item In any text editor open \texttt{$\sim$/.bashrc} and edit it
13261330
\item Behavior of BASH can be set to fit user's needs
@@ -2559,6 +2563,7 @@ \section{Text}
25592563
\end{frame}
25602564
25612565
\begin{frame}[fragile]{Converting the text}{Prevent bad display and weird errors when launching scripts}
2566+
\label{eolencoding}
25622567
\begin{bashcode}
25632568
unix2dos textfile # Convert text file from UNIX to Windows EOL
25642569
unix2mac textfile # Convert text file from UNIX to old Mac EOL

0 commit comments

Comments
 (0)