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
brew list # List of installed packages (brew formulae)
1140
-
brew info FORMULA # Information about particular formula
1140
+
brew info FORMULA # Information about particular formula (package)
1141
1141
brew search KEYWORD # Search for applications
1142
1142
brew update # Update Homebrew
1143
1143
brew upgrade # Update all packages installed by Homebrew
@@ -1240,16 +1240,16 @@ \subsection{Screen}
1240
1240
\end{bashcode}
1241
1241
\vfill
1242
1242
\begin{itemize}
1243
-
\item Toy server: user names \texttt{cu01}--\texttt{cu20}
1243
+
\item Toy server: user names \texttt{courseuser01}--\texttt{courseuser15}
1244
1244
\end{itemize}
1245
1245
\vfill
1246
1246
\begin{bashcode}
1247
-
ssh cuXY@vyuka.natur.cuni.cz
1247
+
ssh courseuserXY@vyuka.natur.cuni.cz
1248
1248
\end{bashcode}
1249
1249
\vfill
1250
1250
\begin{itemize}
1251
1251
\item If fingerprint key changes, ssh complains a~lot --- possible \href{https://en.wikipedia.org/wiki/Man-in-the-middle_attack}{man in the middle attack}
1252
-
\item From Windows use \href{https://www.putty.org/}{Putty}
1252
+
\item From Windows use \href{https://www.putty.org/}{Putty} (see right figure)
1253
1253
\end{itemize}
1254
1254
\begin{center}
1255
1255
\includegraphics[height=6cm]{putty.png}
@@ -1293,22 +1293,30 @@ \subsection{BASH}
1293
1293
\end{itemize}
1294
1294
\end{frame}
1295
1295
1296
-
\begin{frame}[allowframebreaks]{Nice BASH features for easier work (selection)}% TODO Add more BASH features
1296
+
\begin{frame}[allowframebreaks]{Nice BASH features for easier work (selection)}
1297
1297
\begin{itemize}
1298
1298
\item Arrows up and down list in the history of commands
1299
1299
\item List whole history by command \texttt{history}
1300
1300
\item\texttt{Ctrl+R} --- reverse search in history --- type to search last command(s) containing typed character(s) --- repeat typing \texttt{Ctrl+R} to search deeper in history
1301
+
\begin{itemize}
1302
+
\item When on correct entry, hit Enter or use L/R arrow keys to edit it
1303
+
\end{itemize}
1304
+
\item\texttt{Ctrl+J} --- exit search
1301
1305
\item\texttt{TAB} --- list command and files starting by typed characters
1302
-
\item\texttt{Home}/\texttt{End} --- go to beginning/end of the line
1306
+
\item\texttt{Home}/\texttt{End} (or \texttt{Ctrl+A}/\texttt{Ctrl+E}) --- go to beginning/end of the line
*.tar & tar cvf archive.tar file1 file2 file3 & tar xvf archive.tar\\
1487
-
*.tar.gz\alert{/} *.tgz & tar czvf archive.tar.gz\alert{/}.tgz file1 file2 & tar xzvf archive.tar.gz\alert{/}.tgz\\
1488
-
*.tar.bz\alert{/} *.tbz\alert{/} *.tar.bz2 & tar cjvf archive.tar.bz\alert{/}.tbz\alert{/}.tar.bz2 file1 file2 file3 file4 & tar xjvf archive.tar.bz\alert{/}.tbz\alert{/}.tar.bz2\\
1489
-
*.tar.xz & tar cvJf archive.tar.xz file1 file2file4 & tar xvJf archive.tar.xz\\
1495
+
*.tar.gz\alert{/} *.tgz & tar czvf archive.tar.gz\alert{/}.tgz file1 file2 & tar xzvf archive.tar.gz\alert{/}.tgz\\
1496
+
*.tar.bz\alert{/} *.tbz\alert{/} *.tar.bz2 & tar cjvf archive.tar.bz\alert{/}.tbz\alert{/}.tar.bz2 file1 file2 file3 file4 & tar xjvf archive.tar.bz\alert{/}.tbz\alert{/}.tar.bz2\\
1497
+
*.tar.xz & tar cvJf archive.tar.xz file1 file2file3 & tar xvJf archive.tar.xz\\
1490
1498
*.tar.lzma & tar cvf - file1 file2 file3 file4 | lzma > archive.tar.lzma & lzcat archive.tar.lzma | tar xvf -\\
1491
1499
*.gz & gzip file & gunzip archive.gz\\
1492
1500
*.bz2 & bzip2 file & bunzip2 archive.bz2\\
@@ -1499,9 +1507,9 @@ \subsection{Archives}
1499
1507
1500
1508
\begin{frame}{Compressing and decompressing archives}
1501
1509
\begin{itemize}
1502
-
\item\texttt{gzip}, \texttt{bzip2}, \texttt{xz} and \texttt{lzma} are able to pack only one file --- use them together with \texttt{tar} to pack multiple files (when used \textbf{without} \texttt{tar} they \alert{move} file into archive)
1510
+
\item\texttt{gzip}, \texttt{bzip2}, \texttt{xz} and \texttt{lzma} are able to \textbf{pack only one file} --- use them together with \texttt{tar} to pack multiple files (when used \textbf{without} \texttt{tar} they \alert{move} file into archive)
1503
1511
\item In Linux, \texttt{gzip} (and less \texttt{bzip2}) are the most commonly used
1504
-
\item Rar is not used at Linux/UNIX at all
1512
+
\item Rar and arj are not used at Linux/UNIX at all
1505
1513
\item Zip is probably the most portable between Linux/UNIX and Windows
1506
1514
\item\texttt{lzma} and \texttt{xz} have excellent compression, but can be very slow, use similar algorithm, often confused
1507
1515
\end{itemize}
@@ -1750,12 +1758,28 @@ \subsection{Variables}
1750
1758
\end{bashcode}
1751
1759
\end{frame}
1752
1760
1761
+
\begin{frame}{How quotes influence reading of variable content III}
1762
+
\begin{itemize}
1763
+
\item As soon as variable contains only Latin alphanumerical characters, assignment like \texttt{MYVAR=whatever} works, but it is not recommended
1764
+
\item If variable should contain another variable, special characters, etc, use double quotes, e.g. \texttt{WORKDIR="/home/\$USER/data"}
1765
+
\begin{itemize}
1766
+
\item It might be called like \texttt{echo \$MYVAR}, but if there would be non-standard characters anywhere, it'd fail, so prefer \texttt{"\$MYVAR"} (it \textit{might} work without quotes, but don't risk it) or \texttt{"\$\textbraceleft MYVAR\textbraceright"}
1767
+
\end{itemize}
1768
+
\item If variable should contain any special character (including space), or you wish to be sure you keep it's literal value, use single quotes, e.g. \texttt{MYDATA='$\sim$/My Doc/exp 1/data.fsa'} (and then \texttt{"\$MYVAR"})
1769
+
\item Similar for using variables
1770
+
\begin{itemize}
1771
+
\item Using \texttt{\$MYVAR} is fine if it doesn't contain anything special (but are you really sure?)
1772
+
\item Best practice is to use \texttt{"\$\textbraceleft MYVAR\textbraceright"} as there is highest security if \texttt{MYVAR} would contain special characters, and there is room for various manipulations (see next slide)
1773
+
\end{itemize}
1774
+
\end{itemize}
1775
+
\end{frame}
1776
+
1753
1777
\begin{frame}[fragile]{The PATH variable}
1754
1778
\label{PATH}
1755
1779
\begin{itemize}
1756
1780
\item Lists directories (separated by colon \texttt{:}) where the current shell searches for commands
1757
1781
\item If some software is installed outside standard locations, the user must specify the full path (or update the \texttt{\$PATH})
1758
-
\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
1782
+
\item In case there are two commands with the same name (e.g. \texttt{/usr/bin/somecommand} and \texttt{/home/\$USER/bin/somecommand}), the order of directories in \texttt{\$PATH} matters --- the first occurrence is used, any possible later ignored
1759
1783
\item Computing clusters (like MetaCentrum) use to have special command (e.g. \texttt{module}) to load particular software (including particular version) by extending user's \texttt{\$PATH}
1760
1784
\end{itemize}
1761
1785
\begin{bashcode}
@@ -1789,11 +1813,30 @@ \subsection{Variables}
1789
1813
\end{bashcode}
1790
1814
\end{frame}
1791
1815
1792
-
% TODO Add manipulation with variables like ${VAR%...}
1816
+
\begin{frame}[fragile]{Manipulating with content of variable}
1817
+
\begin{itemize}
1818
+
\item It is possible to change/remove extension (suffix) of variable, do simple search and replace with its content, etc. (useful in scripts e.g. for input and output files)
1819
+
\item Search and replace syntax is related to \texttt{sed} (slide~\ref{sedex})
1820
+
\end{itemize}
1821
+
\begin{bashcode}
1822
+
MYVAR='oxalis_assembly_6235.aln.fasta' # Assign new variable
1823
+
echo "$MYVAR" # See it - it works: oxalis_assembly_6235.aln.fasta
\item Key feature of BASH --- work with individual commands as with Lego to get new functionality
1834
1877
\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)
1878
+
\begin{itemize}
1879
+
\item If the application has any output, it goes to the screen, so it can be bit messy\ldots
1880
+
\end{itemize}
1835
1881
\item\alert{\texttt{\&\&}} --- second command is launched only when first command exits without error (exits with status \texttt{0}): \texttt{mkdir NewDir \&\& cd NewDir}
1836
1882
\item\alert{\texttt{;}} --- second command is launched regardless exit status of the first one: \texttt{kshfskcbd; hostname}
1837
1883
\item\alert{\texttt{\textbraceleft\ldots\textbraceright}} --- commands within curl brackets are launched as one block
1838
1884
\begin{itemize}
1839
1885
\item Closing bracket \texttt{\textbraceright} must be either on new line or preceded by semicolon (\texttt{\ldots{ }; \textbraceright})
1840
1886
\end{itemize}
1841
-
\item\alert{\texttt{||}} --- second command is launched when first command fails (has nonzero exit status):\\\texttt{cd newdir || \textbraceleft~mkdir newdir \&\& cd newdir; \textbraceright}
1887
+
\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}
1842
1888
\begin{itemize}
1843
1889
\item Easy way how to do something when previous command fails, either exit script (\texttt{\ldots{ }|| exit 1}) or somehow fix it (see above), report problem (\texttt{\ldots{ }|| \textbraceleft echo "It failed!"\&\& exit 1; \textbraceright}) or so
\begin{frame}[fragile]{Basic network information and testing}
2201
+
\begin{frame}[fragile]{Basic network information and testing}% TODO rewrite netstat examples for ss
2156
2202
\begin{bashcode}
2157
2203
hostname # Get name of the computer
2158
2204
ping web.natur.cuni.cz # Ping host. Is it alive? Cancel by Ctrl+C
@@ -2167,7 +2213,7 @@ \subsection{Network}
2167
2213
netstat -atn # Information about all network connections
2168
2214
netstat -ntplu # Show open TCP/UDP ports
2169
2215
netstat -anp # Show active connections
2170
-
netstat -h # See for explanation of 3 above examples
2216
+
ss --help # netstat is deprecated, prefer usage of ss
2171
2217
# If using nmap at faculty, firewall disconnects you for 10 minutes!
2172
2218
nmap -r someserver.cz # Scan someserver.cz for opened ports
2173
2219
nmap botany.natur.cuni.cz --script ssh-hostkey # See SSH key
@@ -2252,15 +2298,15 @@ \subsection{Network}
2252
2298
\begin{itemize}
2253
2299
\item Private key is typically in \texttt{$\sim$/.ssh/id\_*} file(s) (according to cipher)
2254
2300
\item Public key is typically in \texttt{$\sim$/.ssh/id\_*.pub} file(s) (according to selected cipher) and are copied to target servers
2255
-
\item Private key is unlocked by password and it then allows to login to any server having the public key
2301
+
\item Private key is unlocked by password (might be without password) and it then allows to login to any server having the public key
2256
2302
\item Having only public key is not enough to login, private key without password is still not enough, but user must be sure private key is kept securely and not lost or stolen
2257
-
\item When running it, \texttt{ssh-keygen} asks bunch of questions --- unless having special needs, keep defaults (hit Enter), using password for key is optional
2303
+
\item When running it, \texttt{ssh-keygen} asks bunch of questions --- unless having special needs, keep defaults (hit Enter), using password for key is optional (but recommended)
2258
2304
\end{itemize}
2259
-
\item File \texttt{$\sim$/.ssh/known\_hosts} contain servers you have ever connect to, and their SSH fingerprints (unique IDs) --- if this changes, SSH complains a lot as it could be \href{https://en.wikipedia.org/wiki/Man-in-the-middle_attack}{Man-in-the-middle attack}
2305
+
\item File \texttt{$\sim$/.ssh/known\_hosts} contain servers you have ever connected to, and their SSH fingerprints (unique IDs) --- if this changes, SSH complains a lot as it could be \href{https://en.wikipedia.org/wiki/Man-in-the-middle_attack}{Man-in-the-middle attack}
2260
2306
\item File \texttt{$\sim$/.ssh/authorized\_keys} contains public keys allowing logging to the machine
2261
-
\item\texttt{~/.ssh/config} can store various settings for particular servers
2307
+
\item\texttt{$\sim$//.ssh/config} can store various settings for particular servers
2262
2308
\item SSH keys work in all applications using SSH (SFTP, SSHFS, rsync, many graphical file managers,~\ldots)
2263
-
\item User can have various local passwords on servers, but use single SSH key to connect to all of them
2309
+
\item User can have various local passwords on servers, but use single SSH key to connect to all of them, very convenient if connecting to multiple servers
2264
2310
\end{itemize}
2265
2311
\end{frame}
2266
2312
@@ -2323,7 +2369,7 @@ \subsection{Network}
2323
2369
\end{enumerate}
2324
2370
\end{frame}
2325
2371
2326
-
\begin{frame}{Faculty web server}
2372
+
\begin{frame}{Faculty web server(s)}
2327
2373
\begin{itemize}
2328
2374
\item Login requires same credentials as to \href{https://ldapuser.cuni.cz/}{CAS} (login name, no ISIC number)
2329
2375
\item Faculty information are \href{https://www.natur.cuni.cz/fakulta/cit/web-aplikace/webhosting}{only in Czech}
\item\href{https://www.gnu.org/software/parallel/}{GNU Parallel} can distribute task among CPU threads of one computer, or even among different computers in network
2345
2391
\item It is not (so) effective for short/small tasks
2346
-
\item Important operands (for more see \texttt{man parallel})
2392
+
\item Important operands (for more see \texttt{man parallel} and next slides)
2347
2393
\begin{itemize}
2348
2394
\item\texttt{\{\}} --- input line --- whole line read from input source (typically standard input)
2349
2395
\item\texttt{\{.\}} --- input line without extension
@@ -5190,4 +5236,3 @@ \subsection{The very end}
5190
5236
% * Přeskládat řetězení, přesměrování, globbing, proměnné, atd.
0 commit comments