You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: presentation/linux_bash_metacentrum_course.tex
+29-24Lines changed: 29 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -516,7 +516,7 @@ \subsection{Differences}
516
516
\item Package management --- especially in command line
517
517
\item Development model --- conservative or experimental, fast or slow
518
518
\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
520
520
\item Kernel is almost same, applications are same and used in same way\ldots
521
521
\item Command line is almost same across Linux, and almost same as in other UNIX systems (macOS,~\ldots)
\begin{frame}[allowframebreaks]{Directory structure in Linux}
698
698
\begin{itemize}
699
699
\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
700
701
\item Top directory \enquote{\texttt{/}} --- \enquote{root}
701
702
\item Everything else (including disks and network shares) are mounted in subdirectories (\texttt{/\ldots})
702
703
\item\texttt{/bin} --- very basic command line utilities
\item\texttt{/usr} --- binaries (executable applications) and libraries of installed applications
721
722
\item\alert{\texttt{/var}} --- data of most of applications and services, including e.g. database data, system logs,~\ldots
722
723
\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)
723
725
\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}
725
727
\item Usually, work only in your home, anywhere else modify files only if you are absolutely sure what you are doing
726
728
\item Normal user doesn't have permission to modify files outside his directory (with exception of plugged removable media, etc.)
727
729
\item Try \texttt{man hier} for details
728
730
\end{itemize}
729
731
\end{frame}
730
732
731
-
\begin{frame}{Configuration in /etc (examples)}
733
+
\begin{frame}{Configuration in \texttt{/etc} (examples)}
732
734
\begin{itemize}
733
735
\item Configuration of system services (servers,~\ldots) and behavior
\begin{frame}[fragile]{Example of configuration in /etc/ssh/sshd\_config}
750
+
\begin{frame}[fragile]{Example of configuration in \texttt{/etc/ssh/sshd\_config}}
749
751
\begin{bashcode}
750
752
# This is the ssh client system-wide configuration file. See
751
753
# ssh_config(5) for more information. This file provides defaults for
@@ -840,21 +842,21 @@ \subsection{Files and directories}
840
842
\begin{frame}[fragile]{Links}
841
843
\label{links}
842
844
\begin{itemize}
843
-
\itemSoft 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
844
846
\begin{itemize}
845
847
\item When we delete link, nothing happens, when target, non-working link remains
846
848
\end{itemize}
847
849
\end{itemize}
848
850
\vfill
849
851
\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)
851
853
ls -l bin/cinema5
852
854
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
854
856
\end{bashcode}
855
857
\vfill
856
858
\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}
858
860
\begin{itemize}
859
861
\item If any one of the two files is deleted, the second remains to be fully working
860
862
\end{itemize}
@@ -865,8 +867,8 @@ \subsection{Files and directories}
865
867
ls -l .bash* # Numbers in first column show links pointing to it
866
868
# For directories - number of items, for files = 1
867
869
-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
870
872
\end{bashcode}
871
873
\end{frame}
872
874
@@ -881,7 +883,7 @@ \subsection{Permissions}
881
883
\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)
882
884
\item Information about users and groups and their IDs are in \texttt{/etc/group} and \texttt{/etc/passwd}
883
885
\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})
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)
922
924
\end{tabular}
923
925
\end{center}
924
926
\begin{itemize}
925
927
\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})
926
928
\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)
928
930
\end{itemize}
929
931
\end{frame}
930
932
@@ -957,7 +959,7 @@ \subsection{Permissions}
957
959
\begin{bashcode}
958
960
ls -l # Long list - file names and attributes
959
961
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
961
963
ls -h # Human readable size units (use with -l or -s)
962
964
ls --color ## Colored output
963
965
ls -laFh --color # Combine any parameters you like
@@ -975,16 +977,18 @@ \subsection{Permissions}
975
977
\end{bashcode}
976
978
\end{frame}
977
979
978
-
\begin{frame}{Extending permissions --- ACL}{Access control list}
980
+
\begin{frame}[allowframebreaks]{Extending permissions --- ACL (Access control list)}
979
981
\label{acl}
980
982
\begin{itemize}
981
983
\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
982
984
\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
983
985
\item Command \texttt{getfacl} lists those extra permissions, \texttt{setfacl} sets
984
986
\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}
985
987
\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
988
992
\end{itemize}
989
993
\end{frame}
990
994
@@ -1006,7 +1010,7 @@ \subsection{Permissions}
1006
1010
# folder 'dokumenty/arabidopsis' (no extra group is required)
setfacl -b FILE # Remove all ACL from FILE (combine with -R ...)
1010
1014
\end{bashcode}
1011
1015
\end{frame}
1012
1016
@@ -1020,12 +1024,11 @@ \subsection{Permissions}
1020
1024
\item\texttt{umask 027} (or other number) is typically set in file \texttt{$\sim$/.bashrc}
1021
1025
\begin{itemize}
1022
1026
\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})
1024
1028
\end{itemize}
1025
1029
\item Typically used in network environment
1026
1030
\item Set with care --- new permissions will have plenty of consequences --- different are typically needed for web pages, private files, shared files,~\ldots
1027
1031
\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
1029
1032
\end{itemize}
1030
1033
\end{frame}
1031
1034
@@ -1069,20 +1072,20 @@ \subsection{Text}
1069
1072
\begin{itemize}
1070
1073
\item Windows and UNIX have different internal symbol for end of line (\href{https://en.wikipedia.org/wiki/Newline}{new line}) --- EOL
\item Mac v. < 9: CR (\texttt{\textbackslash r}) (Mac up to 9~wasn't UN*X, since OS~X it is)
1075
1078
\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
1077
1080
\item Different systems use different encoding
1078
1081
\begin{itemize}
1079
1082
\item UNIX: mainly UTF-8 (Unicode, universal), UTF-16 for Asian languages
1080
1083
\item Windows: win-cp-125X (variants according to region)
1081
1084
\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
1083
1086
\item Important mainly for accented characters
1084
1087
\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}
1086
1089
\end{itemize}
1087
1090
\end{frame}
1088
1091
@@ -1321,6 +1324,7 @@ \subsection{BASH}
1321
1324
\end{frame}
1322
1325
1323
1326
\begin{frame}[fragile]{BASH settings (popular examples)}{Write them into BASH configuration file}
1327
+
\label{bashrc}
1324
1328
\begin{itemize}
1325
1329
\item In any text editor open \texttt{$\sim$/.bashrc} and edit it
1326
1330
\item Behavior of BASH can be set to fit user's needs
@@ -2559,6 +2563,7 @@ \section{Text}
2559
2563
\end{frame}
2560
2564
2561
2565
\begin{frame}[fragile]{Converting the text}{Prevent bad display and weird errors when launching scripts}
2566
+
\label{eolencoding}
2562
2567
\begin{bashcode}
2563
2568
unix2dos textfile # Convert text file from UNIX to Windows EOL
2564
2569
unix2mac textfile # Convert text file from UNIX to old Mac EOL
0 commit comments