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
\item Lists directories (separated by colon \texttt{:}) where the current shell searches for commands
890
+
\item If some software is installed outside standard locations, the user must specify the full path (or update the \texttt{\$PATH})
891
+
\item In case there are two commands with the same name (e.g. \texttt{/bin/somecommand} and \texttt{/usr/bin/somecommand}), the order of directories in \texttt{\$PATH} matters -- the first occurrence is used, any possible later ignored
\item When you log off or network connection is broken, running tasks for particular terminal usually crash
1017
1035
\item Sometimes number of connections is limited
1018
1036
\item\texttt{screen} is solution -- virtual terminals
1019
-
\item Launch \texttt{screen} to start new screen terminal, read some info, confirm by Space key or Enter
1037
+
\item Launch \texttt{screen} to start new screen terminal, read some info, confirm by \textbf{Space key} or \textbf{Enter}
1020
1038
\item To detach from the screen press \texttt{Ctrl+A, D} -- screen is still running in background -- you can even log off
1021
1039
\item To return back to running screen use \texttt{screen -r} -- if only one screen is running, you get back to it
1022
1040
\item If more screens are running, use \texttt{screen -r 1234} (the number is seen from \texttt{screen -r})
@@ -1041,7 +1059,7 @@ \section{Command line}
1041
1059
\begin{bashcode}
1042
1060
systemctl status/start/stop cron.service # Check/start/stop if cron runs
1043
1061
crontab -l # List cron tasks
1044
-
crontab -e # Edit cron tasks (launches editor according to the variable):
1062
+
crontab -e # Edit cron tasks:
1045
1063
# Minute, Hour, Day in month, Month, Day in week, Command (absolute path)
1046
1064
# 0-59 0-23 1-31 1-12 0-6 starting with Sunday (WTF?)
1047
1065
* * * * * /usr/bin/command
@@ -1055,21 +1073,21 @@ \subsection{Chaining}
1055
1073
1056
1074
\begin{frame}{Chaining commands}
1057
1075
\begin{itemize}
1058
-
\item\alert{\&} -- command will be launched in background, terminal is available for next typing: \texttt{firefox \&}
1059
-
\item\alert{\&\&} -- second command is launched only when first command exits without error (exits with 0 status): \texttt{mkdir NewDir \&\& cd NewDir}
1060
-
\item\alert{;} -- second command is launched regardless exit status of the first one: \texttt{kshfskcbd; hostname}
1061
-
\item\alert{\textbraceleft\ldots\textbraceright} -- commands within curl brackets are launched as one block
1062
-
\item\alert{||} -- second command is launched when first command fails (has non zero exit status):\\\texttt{cd newdir || \textbraceleft~mkdir newdir \&\& cd newdir; \textbraceright}
1076
+
\item\alert{\texttt{\&}} -- command will be launched in background, terminal is available for next typing: \texttt{firefox \&} (when launching graphical application, hit \textbf{Enter} afterward if there is no active command line prompt)
1077
+
\item\alert{\texttt{\&\&}} -- second command is launched only when first command exits without error (exits with status\texttt{0}): \texttt{mkdir NewDir \&\& cd NewDir}
1078
+
\item\alert{\texttt{;}} -- second command is launched regardless exit status of the first one: \texttt{kshfskcbd; hostname}
1079
+
\item\alert{\texttt{\textbraceleft\ldots\textbraceright}} -- commands within curl brackets are launched as one block
1080
+
\item\alert{\texttt{||}} -- second command is launched when first command fails (has non zero exit status):\\\texttt{cd newdir || \textbraceleft~mkdir newdir \&\& cd newdir; \textbraceright}
1063
1081
\item Behavior in shells other than bash might be little bit different
1064
-
\item\alert{|} -- pipe -- redirects standard output of one command into standard input of second command: \texttt{ps aux | sort}
1082
+
\item\alert{\texttt{|}} -- pipe -- redirects standard output of one command into standard input of second command: \texttt{ps aux | sort}
1065
1083
\end{itemize}
1066
1084
\end{frame}
1067
1085
1068
1086
\begin{frame}[fragile]{Standard input and output and redirects}
1069
1087
\begin{itemize}
1070
1088
\item Standard input (\texttt{stdin}) is standard place where software takes input (keyboard and terminal) and writes results to standard output (\texttt{stdout}) -- typically monitor
1071
1089
\item Standard error output (\texttt{stderr}) is target of error messages -- typically also monitor (but can be log file or so)
1072
-
\item\alert{\textgreater} -- redirects output into new place (file, device, another command)
1090
+
\item\alert{\texttt{\textgreater}} redirects output into new place (file, device, another command,~\ldots)
1073
1091
\end{itemize}
1074
1092
\begin{bashcode}
1075
1093
cat /etc/group # Print whole file /etc/group
@@ -1078,7 +1096,7 @@ \subsection{Chaining}
1078
1096
cat users # See result
1079
1097
\end{bashcode}
1080
1098
\begin{itemize}
1081
-
\item\alert{\textgreater\textgreater} -- adds output to the end of the file (``\textgreater'' rewrites target file)
1099
+
\item\alert{\texttt{\textgreater\textgreater}} adds output to the end of the file (\texttt{\textgreater} rewrites target file)
1082
1100
\end{itemize}
1083
1101
\begin{bashcode}
1084
1102
grep root /etc/group >> users # Add new information into existing file
@@ -1105,10 +1123,10 @@ \subsection{Chaining}
1105
1123
command >> outputfile 2>error.log
1106
1124
\end{bashcode}
1107
1125
\begin{itemize}
1108
-
\item /dev/null -- ``black hole'' -- discards everything (don't care about errors?): \texttt{command 2\textgreater~/dev/null}
1109
-
\item /dev/stdin -- standard input (in case application reads files, not from standard input): \texttt{echo "Žluťoučký kůň" | iconv -f utf-8 -t cp1250 /dev/stdin}
1110
-
\item /dev/stdout -- standard output (we wish to see errors which would be discarded otherwise): \texttt{command 2\textgreater~/dev/stdout}
1111
-
\item /dev/stderr -- standard error output (right place to send errors to): \texttt{echo "error" > /dev/stderr}
1126
+
\item\texttt{/dev/null} -- ``black hole'' -- discards everything (don't care about errors?): \texttt{command 2\textgreater~/dev/null}
1127
+
\item\texttt{/dev/stdin} -- standard input (in case application reads files, not from standard input): \texttt{echo "Žluťoučký kůň" | iconv -f utf-8 -t cp1250 /dev/stdin}
1128
+
\item\texttt{/dev/stdout} -- standard output (we wish to see errors which would be discarded otherwise): \texttt{command 2\textgreater~/dev/stdout}
1129
+
\item\texttt{/dev/stderr} -- standard error output (right place to send errors to): \texttt{echo "error" > /dev/stderr}
1112
1130
\end{itemize}
1113
1131
\end{frame}
1114
1132
@@ -1118,6 +1136,7 @@ \subsection{Information and management}
1118
1136
\begin{bashcode}
1119
1137
uname -a # Information about Linux kernel (version, ...)
1120
1138
lsb_release -a # Information about Linux distribution release
1139
+
cat /etc/os-release # Similar to above command
1121
1140
lscpu # Information about CPU
1122
1141
cat /proc/cpuinfo # Raw list of information about CPU
1123
1142
lsusb # List of devices on USB
@@ -1132,6 +1151,7 @@ \subsection{Information and management}
1132
1151
uptime # How long is the system running, number of users, average load
1133
1152
date # Date and time - plenty of options for formatting
1134
1153
mount # Information about mounted file systems
1154
+
findmnt # Display mounted devices in tree structure
1135
1155
\end{bashcode}
1136
1156
\end{frame}
1137
1157
@@ -1158,24 +1178,6 @@ \subsection{Information and management}
1158
1178
\end{bashcode}
1159
1179
\end{frame}
1160
1180
1161
-
\begin{frame}[fragile]{Managing system services}
1162
-
\begin{itemize}
1163
-
\item Different among distributions -- several main methods
1164
-
\item Most common is SystemD, less common older init scripts and RC scripts
1165
-
\item Used to manage services like web server, database, \ldots
1166
-
\item\alert{Read documentation for your distribution!}
\item First \texttt{find}'s parameter is location, to search -- absolute or relative, ``\texttt{.}'' means current directory (the only compulsory parameter)
1318
+
\item First \texttt{find}'s parameter is location to search -- absolute or relative, ``\texttt{.}'' means current directory (the only compulsory parameter)
1315
1319
\item\texttt{-type} for only directories or only files (without this parameter, files as well as directories are looked for)
1316
1320
\item\texttt{-name} supports wildcarts (\texttt{*}, \texttt{?} and \texttt{[\ldots]})
1317
1321
\item\texttt{-print} is default action -- prints list of results
0 commit comments