Page MenuHomec4science

No OneTemporary

File Metadata

Created
Sun, Dec 22, 11:35
diff --git a/assets/File-tree-2.svg b/assets/File-tree-2.svg
new file mode 100644
index 0000000..a6f367b
--- /dev/null
+++ b/assets/File-tree-2.svg
@@ -0,0 +1,2 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="461px" height="442px" version="1.1"><defs/><g transform="translate(0.5,0.5)"><rect x="10" y="230" width="100" height="60" fill="#f8cecc" stroke="#b85450" stroke-dasharray="3 3" pointer-events="none"/><path d="M 120.17 40.17 L 120.17 60.17 L 300.17 60.17 L 300.17 73.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 300.17 79.05 L 296.67 72.05 L 300.17 73.8 L 303.67 72.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="100" y="0" width="40" height="40" fill="#ffe6cc" stroke="#d79b00" pointer-events="none"/><g transform="translate(116.5,7.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="6" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 8px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">/</font></div></div></foreignObject><text x="3" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60.17 120.17 L 60.17 140.17 L 220.17 140.17 L 220.17 153.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 220.17 159.05 L 216.67 152.05 L 220.17 153.8 L 223.67 152.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 120.17 L 60.17 140.17 L 380.17 140.17 L 380.17 153.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 380.17 159.05 L 376.67 152.05 L 380.17 153.8 L 383.67 152.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="20" y="80" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(31.5,87.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="56" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 56px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">home</font></div></div></foreignObject><text x="28" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="140" y="80" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(164.5,87.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="30" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><span style="font-size: 22px">var</span></div></div></foreignObject><text x="15" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 120.17 40.17 L 120.17 60.17 L 180.17 60.17 L 180.17 73.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 180.17 79.05 L 176.67 72.05 L 180.17 73.8 L 183.67 72.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="320" width="120" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(14.5,327.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="90" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 92px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">subfolder</font></div></div></foreignObject><text x="45" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="160" y="320" width="120" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(205.5,327.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="28" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 30px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">file</font></div></div></foreignObject><text x="14" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="0" y="400" width="120" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(45.5,407.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="28" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 30px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">file</font></div></div></foreignObject><text x="14" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="160" y="400" width="160" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(182.5,407.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="114" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 116px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">another_file</font></div></div></foreignObject><text x="57" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60.17 360.17 L 60.17 380.17 L 240.17 380.17 L 240.17 393.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 240.17 399.05 L 236.67 392.05 L 240.17 393.8 L 243.67 392.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="380" y="80" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(410.5,87.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 120.17 40.17 L 120.17 60.17 L 420.17 60.17 L 420.17 73.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 420.17 79.05 L 416.67 72.05 L 420.17 73.8 L 423.67 72.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="360" y="400" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(390.5,407.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="320" y="320" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(350.5,327.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60.17 360.17 L 60.17 380.17 L 400.17 380.17 L 400.17 393.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 400.17 398.88 L 396.67 391.88 L 400.17 393.63 L 403.67 391.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 200.17 L 60.17 220.17 L 220.17 220.17 L 220.17 233.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 220.17 239.05 L 216.67 232.05 L 220.17 233.8 L 223.67 232.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 200.17 L 60.17 220.17 L 380.17 220.17 L 380.17 233.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 380.17 239.05 L 376.67 232.05 L 380.17 233.8 L 383.67 232.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="20" y="160" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(38.5,167.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="42" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 44px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">user</font></div></div></foreignObject><text x="21" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="140" y="160" width="160" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(154.5,167.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="130" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 130px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">another_user</font></div></div></foreignObject><text x="65" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">&lt;font style="font-size: 22px"&gt;another_user&lt;/font&gt;</text></switch></g><rect x="340" y="160" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(370.5,167.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60.17 280 L 60.17 300.17 L 220.17 300.17 L 220.17 313.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 220.17 319.05 L 216.67 312.05 L 220.17 313.8 L 223.67 312.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 280 L 60.17 300.17 L 360.17 300.17 L 360.17 313.8" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 360.17 319.05 L 356.67 312.05 L 360.17 313.8 L 363.67 312.05 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="20" y="240" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(31.5,247.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="56" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 56px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">folder</font></div></div></foreignObject><text x="28" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="140" y="240" width="160" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(148.5,247.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="142" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 142px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">another_folder</font></div></div></foreignObject><text x="71" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">&lt;font style="font-size: 22px"&gt;another_folder&lt;/font&gt;</text></switch></g><rect x="340" y="240" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(370.5,247.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="260" y="80" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(284.5,87.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="30" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 30px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><span style="font-size: 22px">etc</span></div></div></foreignObject><text x="15" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 120.17 40.17 L 120.17 60.17 L 60.17 60.17 L 60.17 68.19" fill="none" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 75.69 L 55.17 65.69 L 60.17 68.19 L 65.17 65.69 Z" fill="#b85450" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 120.17 L 60.17 148.19" fill="none" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 155.69 L 55.17 145.69 L 60.17 148.19 L 65.17 145.69 Z" fill="#b85450" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 200 L 60.17 220.17 L 60.17 228.19" fill="none" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 235.69 L 55.17 225.69 L 60.17 228.19 L 65.17 225.69 Z" fill="#b85450" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 280.17 L 60.17 308.19" fill="none" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 315.69 L 55.17 305.69 L 60.17 308.19 L 65.17 305.69 Z" fill="#b85450" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 360.17 L 60.17 390.17 L 60.17 388.19" fill="none" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/><path d="M 60.17 395.69 L 55.17 385.69 L 60.17 388.19 L 65.17 385.69 Z" fill="#b85450" stroke="#b85450" stroke-width="4" stroke-miterlimit="10" pointer-events="none"/></g></svg>
\ No newline at end of file
diff --git a/assets/File-tree-3.svg b/assets/File-tree-3.svg
new file mode 100644
index 0000000..e1bb1a4
--- /dev/null
+++ b/assets/File-tree-3.svg
@@ -0,0 +1,2 @@
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="441px" height="309px" version="1.1"><defs/><g transform="translate(0.5,0.5)"><rect x="130" y="98" width="180" height="60" fill="#f8cecc" stroke="#b85450" stroke-dasharray="3 3" pointer-events="none"/><rect x="0" y="188" width="120" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(14.5,195.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="90" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 92px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">subfolder</font></div></div></foreignObject><text x="45" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="160" y="188" width="120" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(205.5,195.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="28" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 30px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">file</font></div></div></foreignObject><text x="14" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="0" y="268" width="120" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(45.5,275.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="28" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 30px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">file</font></div></div></foreignObject><text x="14" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="160" y="268" width="160" height="40" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(182.5,275.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="114" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 116px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">another_file</font></div></div></foreignObject><text x="57" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60 228 L 60 248 L 240 248 L 240 261.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 240 266.88 L 236.5 259.88 L 240 261.63 L 243.5 259.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="360" y="268" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(390.5,275.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="320" y="188" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(350.5,195.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60 228 L 60 248 L 400 248 L 400 261.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 400 266.88 L 396.5 259.88 L 400 261.63 L 403.5 259.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 90 68 L 90 88 L 220 88 L 220 101.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 220 106.88 L 216.5 99.88 L 220 101.63 L 223.5 99.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 90 68 L 90 88 L 380 88 L 380 101.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 380 106.88 L 376.5 99.88 L 380 101.63 L 383.5 99.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="20" y="28" width="140" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(34.5,35.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="110" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 112px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">/home/user</font></div></div></foreignObject><text x="55" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60 148 L 60 168 L 220 168 L 220 181.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 220 186.88 L 216.5 179.88 L 220 181.63 L 223.5 179.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 148 L 60 168 L 360 168 L 360 181.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 360 186.88 L 356.5 179.88 L 360 181.63 L 363.5 179.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="20" y="108" width="80" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(31.5,115.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="56" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 56px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">folder</font></div></div></foreignObject><text x="28" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 220 108 L 220 48 L 170.1 48" fill="none" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 163.35 48 L 172.35 43.5 L 170.1 48 L 172.35 52.5 Z" fill="#b85450" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><rect x="140" y="108" width="160" height="40" fill="#fff2cc" stroke="#d6b656" pointer-events="none"/><g transform="translate(148.5,115.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="142" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 142px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">another_folder</font></div></div></foreignObject><text x="71" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">&lt;font style="font-size: 22px"&gt;another_folder&lt;/font&gt;</text></switch></g><rect x="340" y="108" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(370.5,115.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="18" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 20px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><font style="font-size: 22px">...</font></div></div></foreignObject><text x="9" y="18" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 60 148 L 60 177.9" fill="none" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 184.65 L 55.5 175.65 L 60 177.9 L 64.5 175.65 Z" fill="#b85450" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 228 L 60 258 L 60 257.9" fill="none" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 264.65 L 55.5 255.65 L 60 257.9 L 64.5 255.65 Z" fill="#b85450" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 90 68 L 90 88 L 60 88 L 60 97.9" fill="none" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 104.65 L 55.5 95.65 L 60 97.9 L 64.5 95.65 Z" fill="#b85450" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 125 28 L 125 8 L 55 8 L 55 17.9" fill="none" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 55 24.65 L 50.5 15.65 L 55 17.9 L 59.5 15.65 Z" fill="#b85450" stroke="#b85450" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/></g></svg>
\ No newline at end of file
diff --git a/css/common.css b/css/common.css
index 51a9f9a..b912405 100644
--- a/css/common.css
+++ b/css/common.css
@@ -1,147 +1,149 @@
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.remark-code-line .hljs-constant { color: #5BFF68 }
.remark-slide-content { font-size: 24px; }
table.stack {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
margin: auto;
}
.stack tr td:first-child {
border: 1px black solid;
height: 3em;
width: 60%;
}
.stack .bluebg {
background: SkyBlue
}
table.quiz {
width: 100%;
margin: auto;
}
.quiz td {
border: 1px black solid;
+ padding-top: 0.4em;
+ padding-bottom: 0.4em;
}
.quiz .clicked.Y {
background: #CCFFCC;
}
.quiz .clicked.N {
background: #FFCCCC;
}
.two-columns table {
table-layout: fixed;
}
.two-columns td {
width: 50%;
}
.mnemonic {
border: 1px solid firebrick;
border-radius: 0.3em;
margin-bottom: 0.5em;
}
.mnemonic::before {
content: "Mnemonic:";
margin-left: 0.25em;
font-style: italic;
color: firebrick;
}
.mnemonic p {
margin: 0.5em;
}
.acronym {
border: 1px solid #007b37;
border-radius: 0.3em;
margin-bottom: 0.5em;
}
.acronym::before {
content: "Acronym:";
margin-left: 0.25em;
font-style: italic;
color: #007b37;
}
.acronym p {
margin: 0.5em;
}
.exercise {
border: 1px solid blue;
border-radius: 0.3em;
margin-bottom: 0.5em;
}
.exercise::before {
content: "Exercise:";
margin-left: 0.25em;
font-style: italic;
color: blue;
}
.exercise p {
margin: 0.5em;
}
.highlight {
color: red;
font-weight: bold;
}
.middle img {
vertical-align: middle;
}
.small {
font-size: smaller;
}
.minusmargin {
margin-left: -10%;
margin-right: -10%;
}
div.blinking {
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
display: inline-block;
}
@-webkit-keyframes blink {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
@keyframes blink {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
\ No newline at end of file
diff --git a/linux_1.html b/linux_1.html
index 985d575..a63e8d3 100644
--- a/linux_1.html
+++ b/linux_1.html
@@ -1,2284 +1,2199 @@
<!DOCTYPE html>
<html>
<head>
<title>Introduction to Linux, Part 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" type="text/css" href="css/linux_1.css">
</head>
<body>
<textarea id="source">
class: center, middle
# Introduction to Linux
## Part I
-https://scits.math.unibe.ch/linux_1.html
-
-???
-
-Notes for the _first_ slide!
+`https://goo.gl/8t6byZ`
---
# Agenda
1. What is Linux?
2. Linux interface: GUI vs CLI
3. Connecting to a remote Linux system
4. Linux directory structure
5. Moving and looking around
6. Reading and writing files
7. Organizing files and folders
8. Moving data from/to a remote Linux system
---
class: center, middle
# What is Linux?
![](assets/Tux.png)
---
class: center
# What is Linux?
--
<br>
The most common answer you'll hear is:
## "Linux is an operating system"
--
<br>
But what does this mean?
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>Kernel</td>
<td></td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>System software<br><em>(shell, utilities, libraries, ...)</em></td>
<td></td>
</tr>
<tr>
<td>Kernel</td>
<td></td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td>User software</td>
<td></td>
</tr>
<tr>
<td>System software<br><em>(shell, utilities, libraries, ...)</em></td>
<td></td>
</tr>
<tr>
<td>Kernel</td>
<td></td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td>User software</td>
<td></td>
</tr>
<tr>
<td class="bluebg">System software<br><em>(shell, utilities, libraries, ...)</em></td>
<td rowspan="2"><strong>Operating system</strong><br>Windows, Linux, MacOS, Android, ...</td>
</tr>
<tr>
<td class="bluebg">Kernel</td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
---
class: center
# Operating systems
<br>
<div class="center">
<table class="stack">
<tr>
<td>User software</td>
<td></td>
</tr>
<tr>
<td class="bluebg">System software<br><em>(shell, utilities, libraries, ...)</em></td>
<td rowspan="2"><strong>Linux</strong></td>
</tr>
<tr>
<td class="bluebg">Kernel</td>
</tr>
<tr>
- <td>Hardware</td>
+ <td>Hardware + Firmware</td>
<td></td>
</tr>
</table>
</div>
## In practice, we call this part "Linux"
---
# Linux? Wait, I also heard "UNIX"?
UNIX is the name of an operating system from 1970 that pioneered concepts that
will form the basis of Linux (and other OSes) today.
More importantly, it introduced a set of conventions that its descendents follow.
A system that follows them is called "UNIX-like".
Most of what you learn here will easily transfer to other UNIX-like OSes (e.g. macOS).
---
![:scale 100%](assets/Unix_timeline.en.svg)
---
class: center, two-columns
# User Interface
GUI | CLI
------------------- | -------------
Graphical Interface | Command Line
![:scale 80%](assets/ubuntu-desktop.png) | ![:scale 100%](assets/terminal.png)
| Some synonyms:
| "Shell", "Terminal", "TTY"
---
# Command Line Interface
```
user@host:~ $ cowsay "Command Line Interface"
________________________
< Command Line Interface >
------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
--
* Input, output, and commands are **text**.
--
* Easy on the computer: can run on any hardware.
--
* Network-friendly: a few bytes of text vs realtime stream of images / GUI updates => tool of choice for remote access.
--
* Scripting/automation-friendly: text is easier to manipulate.
--
* Expert-friendly, but _beginner-unfriendly._
---
# Connecting to a remote Linux system
The standard tool to connect to a remote system is `ssh`.
-.mnemonic[
+.acronym[
SSH: .highlight[S]ecure .highlight[Sh]ell
]
It securely connects you to a remote system.
Communication is encrypted, both parties are authenticated.
First, you will need to log in to the system.
If your credentials are accepted, it creates a new shell for you.
It is then displayed on your screen and controlled by your keyboard,
relayed over the network.
---
# Connecting from MacOS / Linux:
Good news: you already have a terminal and `ssh` of your own!
--
First, open the terminal:
* For MacOS, it's accessible from Launchpad, Utilities.
* For Linux GUI, usually look for a program called Terminal.
--
Then, you need to input the command to connect to a remote host:
```
local.user@local:~ $ ssh user@remote
[..some mutual* authentication later..]
user@remote:~ $
```
---
# Connecting from Windows:
You will need an SSH client. Standard one: PuTTY
.center[.middle[
![:scale 20%](assets/putty-logo.jpg) ![:scale 50%](assets/putty-main.jpg)
]]
Download the appropriate installer: https://goo.gl/pHFReU
---
# Connecting from Windows:
* Make sure "Connection type: SSH" is selected.
* Put the remote's host name / IP in the form.
* Select "Open"
A terminal window will open..
```
[..some mutual* authentication later..]
user@remote:~ $
```
---
background-image: url(assets/tofu.svg)
background-position: top right
background-size: 40%
# Mutual authentication?
(and what's up with this side picture?)
---
background-image: url(assets/tofu.svg)
background-position: top right
background-size: 40%
# Mutual authentication?
SSH authenticates both parties:
* Client to server
* Username + password
* Username + cryptographic key
* Something else!
* Server to client
* The server has a cryptographic key to prove its identity
--
The first time you connect, you need to explicitly say you trust the (previously unknown) server.
On subsequent connections, SSH will verify that you are still connecting to a server with the same key,
and will warn you before login credentials are transmitted if you aren't.
--
This is called TOFU (.highlight[T]rust .highlight[O]n .highlight[F]irst .highlight[U]se).
---
layout: true
# Mutual authentication
So, the first time you connect to a new server, you should _expect_ a warning you need to confirm:
---
In Linux/MacOS:
```
local.user@local:~ $ ssh user@remote
The authenticity of host 'remote (11.22.33.44)' can't be established.
ECDSA key fingerprint is SHA256:eQZbiUM4qV6ptjc0fN6/pFglj45qaNlXbLCULCTzSGM.
Are you sure you want to continue connecting (yes/no)?
```
---
In Linux/MacOS:
```
local.user@local:~ $ ssh user@remote
The authenticity of host 'remote (11.22.33.44)' can't be established.
ECDSA key fingerprint is SHA256:eQZbiUM4qV6ptjc0fN6/pFglj45qaNlXbLCULCTzSGM.
Are you sure you want to continue connecting (yes/no)? yes
```
---
In Linux/MacOS:
```
local.user@local:~ $ ssh user@remote
The authenticity of host 'remote (11.22.33.44)' can't be established.
ECDSA key fingerprint is SHA256:eQZbiUM4qV6ptjc0fN6/pFglj45qaNlXbLCULCTzSGM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remote,11.22.33.44' (ECDSA) to the list of known
hosts.
[..some client authentication later..]
user@remote:~ $
```
---
In Windows/PuTTY:
.center[
![:scale 60%](assets/putty-server-auth.png)
]
---
layout: false
# Hands-on time: Connect to a server
-Using [some credentials], use SSH/PuTTY to connect to [training server].
+Using your Campus account username/password, use SSH/PuTTY to connect to UBELIX at `submit.unibe.ch`.
```
ssh user@submit.unibe.ch
```
A reminder, PuTTY can be obtained from https://goo.gl/pHFReU
---
# Greetings from a shell
![:scale 100%](assets/greetings_shell.jpg)
---
# Greetings from a shell
After connecting, you will be greeted with something like this:
```
user@remote:~ $
```
--
What you see is the interface of the .highlight[shell]: a text-based interface that allows you to launch other programs with commands.
--
.mnemonic[
It's called a shell .highlight[prompt] since it's .highlight[prompting] you to enter a command.
]
The prompt contains a short summary of current state of the shell.
---
# Anatomy of a prompt
The prompt looks like this:
```
user@remote:~ $
```
This may vary slightly from system to system, and is fully configurable, but this is the typical form.
--
This form of the prompt answers 3 questions:
-* Who are you? .highlight[`username`]
+* Who are you? .highlight[Username `user`]
-* Where are you? .highlight[`hostname`]
+* Where are you? .highlight[Hostname `remote`]
* Where in the filesystem are you? .highlight[`~`] (explained later)
--
-Terminating the prompt is (traditionally) a `$` character:
+Terminating the prompt is (traditionally) a .highlight[`$`] character:
it delimits where your input goes.
---
layout: true
# Taking command
The shell expects a textual command; most of the time you type the command and press [ENTER] to commit it.
Let's try this (in slow motion)!
---
```
user@remote:~ $
```
---
```
user@remote:~ $ whoami
```
1. Typing in "whoami" as the shell waits
---
```
user@remote:~ $ whoami
```
1. Typing in "whoami" as the shell waits
2. Pressing [ENTER]. The shell will process the command (launch the program `whoami`)
---
```
user@remote:~ $ whoami
user
```
1. Typing in "whoami" as the shell waits.
2. Pressing [ENTER]. The shell will process the command — launch the program `whoami`.
3. The program will take over input/output — in this case, it will output your username).
---
```
user@remote:~ $ whoami
user
user@remote:~ $ ⠀
```
1. Typing in "whoami" as the shell waits.
2. Pressing [ENTER]. The shell will process the command — launch the program `whoami`.
3. The program will take over input/output — in this case, it will output your username).
4. The program terminates, and control returns to the shell; it shows a new prompt.
---
layout: false
# Try it!
Here's a few commands for you to try:
```
whoami
echo Hello!
pwd
ls -l
date
sleep 3
clear
history 5
```
Each should do something and return you to the shell prompt.
Can you guess what they do?
Note that you can use up/down arrows to access/repeat previous commands.
---
# Safety first, or emergency exits!
So far every command we encountered automatically returned control back to the shell.
But what if a program is stuck, or expecting some input and you're not sure what to do?
Typical shortcuts to stop / quit a program:
* `Ctrl` + `C` (also called .highlight[interrupt])
* `Esc` (from ".highlight[escape]")
* `q` (from ".highlight[q]uit")
* `Ctrl` + `D` (.highlight[end of input], in case a program is waiting)
If you try those, usually you'll either exit the program or get some hint on how to do it.
`Ctrl` is sometimes denoted as `^`, e.g. `^C` for `Ctrl`+`C`.
---
exclude: true
# Anatomy of a shell command
The shell expects input. What does it (typically) look like?
```
user@remote:~ $ program -f --option abc 123
```
Here, `program` is the .highlight[command] being executed, and the rest is the list of its .highlight[arguments]:
1. `-f`
2. `--option`
3. `abc`
4. `123`
Arguments that start with `-` or `--` are often called .highlight[flags] or .highlight[switches] and traditionally change
some options of the command.
---
# The Working Directory
One of the commands you executed, `pwd`, printed a directory path (of your home directory, by default):
```
akashev@submit01:~ $ pwd
/home/ubelix/math/akashev
```
--
.mnemonic[
`pwd` stands for .highlight[P]rint .highlight[W]orking .highlight[D]irectory
]
--
Whenever you use the shell, there is a concept of the current (or "working") directory.
This affects how commands search for files and how they interpret paths.
Think of it as of "where" you are: if a server is a building you're in, a working directory
is the room you're in within that building.
---
# The Working Directory
One of the commands you executed, `pwd`, printed a directory path (of your home directory, by default):
```
akashev@submit01:~ $ pwd
/home/ubelix/math/akashev
```
Usually, this information is printed in the shell prompt itself, to remind you of the current state.
--
In this example it's `~`, which represents the .highlight[home directory].
--
Here's how it would look if you were somewhere else, for example in `/var/log`:
```
akashev@submit01:/var/log $
```
---
# UNIX directory structure
If you're reading this tutorial, you likely already know that files are normally organized
into nested "directories" (or "folders"). For example, on Windows you may have such a path:
```
C:\folder\subfolder\file
```
On Linux, paths looks similarly:
```
/home/user/folder/subfolder/file
```
---
# UNIX directory structure
```
/folder/subfolder/file
```
* a file .highlight[`file`]
* inside a directory .highlight[`subfolder`]
* which is inside a directory .highlight[`folder`]
* which itself is inside the .highlight[root directory] `/`
![](assets/file-tree.svg)
---
# The `/` as directory separator
Forward slashes (`/`) separate the folders in the path.
Using multiple is valid, so the following is the same file:
```
/home/user/folder/subfolder/file
///home/user///folder/subfolder//file
```
--
A path to a regular file never ends in `/`, e.g. this is not valid:
```
/home/user/folder/subfolder/file/
```
--
Directories can be referred to with or without the final `/`:
```
/home/user/folder/subfolder
/home/user/folder/subfolder/
```
--
Root directory is special: `/` is its only name.
---
# Absolute and relative paths
If a path starts with `/`, it's an .highlight[absolute] path that starts at root:
```
/home/user/folder/subfolder/file
```
--
If it does not, then it's a .highlight[relative] path
that starts at the current working directory instead of `/`.
If the current working directory is
```
/home/user/folder
```
then the following paths point to the same file:
```
/home/user/folder/subfolder/file
subfolder/file
```
---
+# Absolute and relative paths
+
+```
+/home/user/folder/subfolder/file
+subfolder/file
+```
+
+![:scale 60%](assets/File-tree-2.svg)
+
+---
+
# Special folders `.` and `..`
There are 2 special folders inside each folder: `.` and `..`
* `.` points to the folder itself.
```
/home/user/folder/subfolder/./file
```
--
* `..` points to one folder "up" in the path. At root, it points to root itself.
```
/home/user/another_folder/../folder/file
/home/../../home/user/folder/file
```
--
It's mostly important for relative paths:
```
# From /home/user/another_folder
../folder/file
```
---
+# Special folders `.` and `..`
+
+From `/home/user/another_folder`
+
+```
+/home/user/folder/subfolder/file
+.././folder/file
+```
+
+![:scale 60%](assets/File-tree-3.svg)
+
+---
+
# Home directories
Each user has a .highlight[home directory] assigned.
It acts as your default working directory.
By convention, its path usually starts with `/home/`
and ends with your username:
```
/home/<maybe something else>/username
```
It's frequently referred to as `~`:
```
/home/username/folder/file
~/folder/file
```
You can even refer to others' home folder with `~username`:
```
/home/someone/file
~someone/file
```
---
# Quiz time! [1/3]
Suppose the following:
```
Username: userA
Home directory: /home/userA
+
Working directory: /scratch/folder/B
Target: /scratch/folder/A/a
```
Which of those paths point to the target? (click to reveal)
<div class="center">
<table class="quiz">
<tr>
<td class="N"><code>~/../scratch/folder/A/a</code></td>
</tr>
<tr>
<td class="Y"><code>~userA/../../scratch/folder/A/a</code></td>
</tr>
<tr>
<td class="N"><code>A/a</code></td>
</tr>
<tr>
<td class="Y"><code>../A/a</code></td>
</tr>
<tr>
<td class="Y"><code>/scratch/./folder/A/a</code></td>
</tr>
</table>
</div>
---
# Quiz time! [2/3]
Suppose the following:
```
Username: userA
Home directory: /home/userA
+
Working directory: /home/userA/temp
Target: ../../userB/folder/file
```
Which of those paths point to the target? (click to reveal)
<div class="center">
<table class="quiz">
<tr>
<td class="N"><code>/home/userB/userB/folder/file</code></td>
</tr>
<tr>
<td class="Y"><code>/home/userB/folder/file</code></td>
</tr>
<tr>
<td class="N"><code>~/folder/file</code></td>
</tr>
<tr>
<td class="Y"><code>~/../userB/folder/file</code></td>
</tr>
<tr>
<td class="Y"><code>~userB/folder/file</code></td>
</tr>
</table>
</div>
---
# Quiz time! [3/3]
Suppose the following:
```
Username: userA
Home directory: /home/userA
+
Working directory: /home/userA/folder
Target: /home/userA/folder/file
```
Which of those paths point to the target? (click to reveal)
<div class="center">
<table class="quiz">
<tr>
<td class="Y"><code>file</code></td>
</tr>
<tr>
<td class="Y"><code>./file</code></td>
</tr>
<tr>
<td class="N"><code>~/file</code></td>
</tr>
<tr>
<td class="Y"><code>~/folder/file</code></td>
</tr>
<tr>
<td class="Y"><code>/home/userA/folder/subfolder/../file</code></td>
</tr>
</table>
</div>
---
# Preparing for training
Please execute the following command to add the exercises to your home folder:
```
$ wget https://scits.math.unibe.ch/script -O - | /bin/bash
```
This should be the only time you don't understand what you're doing;
and by the end of Part II you should understand it.
---
# Moving around
Now that we know:
* Files and directories are organised in a tree
* There's a "current"/working directory that we are in
we need to learn to move around in that tree.
--
For that, we need the `cd` command:
```
user@remote:~ $ cd scits-training
user@remote:~/scits-training $ pwd
/home/username/scits-training
user@remote:~/scits-training $
```
-.mnemonic[
+.acronym[
`cd` stands for ".highlight[C]hange .highlight[D]irectory"
]
---
# Moving around
The general format of the command is `cd DESTINATION`, where `DESTINATION` is a path
(relative or absolute) to a directory.
```
user@remote:~ $ cd scits-training
user@remote:~/scits-training $ cd /usr/local/bin
user@remote:/usr/local/bin $
```
--
-To go "back", one uses the special `..` directory:
+To go "back up", one uses the special `..` directory:
```
user@remote:/var/local/bin $ cd ..
user@remote:/usr/local $ cd ../..
user@remote:/ $
```
--
-To go to your home directory, you can use `~` or even nothing at all:
+To go to your home directory, you can use `~`:
```
user@remote:/ $ cd ~
-user@remote:~ $ cd
+user@remote:~ $
+```
+
+---
+
+# `cd` shortcuts
+
+There are two useful tricks when using `cd`:
+
+"`cd -`" goes back to the previous directory you were in:
+
+```
+user@remote:~ $ cd -
+user@remote:/ $
+```
+
+And "`cd`" without arguments goes to your home folder:
+```
+user@remote:/ $ cd
user@remote:~ $
```
---
# Tab-completion
This is a good point to introduce a helpful CLI tool: .highlight[tab completion]
-When entering a command, you can press the `Tab` key to suggest a command, or path,
+When entering a command, you can press the `[Tab]` key to suggest a command, or path,
based on already entered input.
```
user@remote:~ $ cd scits-training/a
```
-Pressing `Tab` now completes the name, since it's the only one that matches the beginning:
+Pressing `[Tab]` now completes the name, since it's the only one that matches the beginning:
```
user@remote:~ $ cd scits-training/animals/
```
(continues on next slide)
---
layout: true
# Tab-completion
```
user@remote:~ $ cd scits-training/animals/
```
-Pressing `Tab` once again won't change anything, since there are mutiple choices for completion;
+Pressing `[Tab]` once again won't change anything, since there are mutiple choices for completion;
however, if it is pressed again, it shows possibilities:
```
user@remote:~ $ cd scits-training/animals/
Aardvark/ Badger/
user@remote:~ $ cd scits-training/animals/
```
---
---
The shell needs to know the next letter to proceed. So, we type only "A" and press `Tab` again:
```
user@remote:~ $ cd scits-training/animals/A
```
---
The shell needs to know the next letter to proceed. So, we type only "A" and press `Tab` again:
```
user@remote:~ $ cd scits-training/animals/Aardvark/
```
---
The shell needs to know the next letter to proceed. So, we type only "A" and press `Tab` again:
```
user@remote:~ $ cd scits-training/animals/Aardvark/
user@remote:~/scits-training/animals/Aardvark/ $
```
---
layout: false
# Looking around
To look around in a UNIX filesystem, you use the `ls` command:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls
description empty_file <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
.mnemonic[
`ls` stands for .highlight[list]
]
This lists the names for contents of the working directory.
--
We can specify another folder to look at:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls ../Badger/
Arctonyx Meles Mellivora Melogale Mydaus
```
---
# Looking around (in depth)
To show more information, we can use the `-l` (for .highlight[l]ong) flag:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls -l
total 25640
-rw-r--r-- 1 username groupname 26214400 Aug 28 18:20 big_file
-rw-r--r-- 1 username groupname 754 Aug 25 17:55 description
-rw-r--r-- 1 username groupname 0 Aug 28 16:51 empty_file
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
Important information from this output:
-* `-rw-r--r--` is the .highlight[mode] of the file (explained in Part II).
+* `-rw-r--r--` is called the .highlight[mode] (explained in Part II).
* `d` denotes .highlight[directory] in this example.
+ * `rw-r--r--` deals with permissions for the files.
* `username` and `groupname` are .highlight[owners] of the file.
* The number after `groupname` is the .highlight[size] (in bytes) of the file.
- * Note: for folders, it's not the size of all contents.
-* The date/time after the size is the .highlight[modification date]
+ * Important: for folders, it's not the size of all contents.
+* The date/time after the size is the .highlight[modification date].
---
# Looking around (as puny humans)
One can use the flag `-h` (for .highlight[h]uman-readable) for more familiar size units:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls -l -h
total 26M
-rw-r--r-- 1 username groupname 25M Aug 28 18:20 big_file
-rw-r--r-- 1 username groupname 754 Aug 25 17:55 description
-rw-r--r-- 1 username groupname 0 Aug 28 16:51 empty_file
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
Single-letter flags in commands can often be combined:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls -lh
total 26M
-rw-r--r-- 1 username groupname 25M Aug 28 18:20 big_file
-rw-r--r-- 1 username groupname 754 Aug 25 17:55 description
-rw-r--r-- 1 username groupname 0 Aug 28 16:51 empty_file
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
---
# Looking around (into hidden corners)
Another often-used flag is `-a` (for .highlight[a]ll): it lists contents with names that start with a dot `.`
which are normally hidden in UNIX.
```
user@remote:~/scits-training/animals/Aardvark/ $ ls -a
<span style="color:#3030ff;font-weight:bold">.</span> <span style="color:#3030ff;font-weight:bold">..</span> big_file description empty_file .hidden <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
As usual, it can be combined with others:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls -lah
total 26M
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">.</span>
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">..</span>
-rw-r--r-- 1 username groupname 25M Aug 28 18:20 big_file
-rw-r--r-- 1 username groupname 754 Aug 25 17:55 description
-rw-r--r-- 1 username groupname 0 Aug 28 16:51 empty_file
drwxr-xr-x 2 username groupname 4096 Aug 28 16:52 <span style="color:#3030ff;font-weight:bold">subfolder</span>
-rw-r--r-- 1 username groupname 0 Aug 28 16:51 .hidden
```
---
# Looking around (in orderly fashion)
By default, files are ordered by name.
This behavior can be changed with flags; here are some examples:
* `-r` .highlight[r]everses the sort order.
* `-S` sorts files by .highlight[s]ize.
* `-t` sorts files by modification .highlight[t]ime.
* `-X` sorts files by filename e.highlight[x]tension, e.g. `png` in `image.png`.
As usual, this can be combined with the previous ones.
.exercise[
List files in `Aardvark` by increasing size.
]
---
# I'm never going to remember this!
.center[
![](assets/tar.png)
]
## Good news: you don't have to.
-As long as you remember the command, you can look up its correct usage from the terminal itself.
+As long as you remember the command's name, you can look up its correct usage from the terminal itself.
.small[Image credit: https://xkcd.com/1168/]
---
layout: true
# Getting help
Some common methods of getting help:
---
* Many programs support .highlight[`--help` flag] to print out their usage instructions:
```
user@remote:~/scits-training/animals/Aardvark/ $ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
[...]
```
---
* For most programs, you can look up their .highlight[manual file] with `man`:
```
user@remote:~/scits-training/animals/Aardvark/ $ man ls
```
Instead of just outputting the text and returning, you'll enter a mode for showing long files.
Look around using arrow keys and `PgDn`/`PgUp`.
Remember the hints on how to exit (here, it's `q`).
You can search a `man` page for "something" with `/something` and just `/` to go to the next find.
---
* Some commands are not separate programs, but are .highlight[built into the shell], e.g. `cd`.
For those, you can use `help`:
```
user@remote:~/scits-training/animals/Aardvark/ $ help cd
```
--
You can see what `help` can help with as well:
```
user@remote:~/scits-training/animals/Aardvark/ $ help
```
---
layout: false
# Try out `man`
Try opening the manual for `ls`:
```
user@remote:~/scits-training/animals/Aardvark/ $ man ls
```
Reminders:
* You can search a `man` page for "something" with `/something` and `n` to go to the next find.
* To exit, you can use `q`.
.exercise[
Try searching for the meaning of `-R` flag, and try to use it.
]
---
# Reading files
We know how to look around the filesystem (with `ls`) and how to move around (with `cd`).
However, we still need to access the contents of files.
There are many ways to do that, I'll show a few more common ones.
---
background-image: url(assets/cat.svg)
background-position: top 5% right 30%
background-size: 15%
# Simple file reading
The simplest program to read the file is `cat`
```
user@remote:~/scits-training/animals/Aardvark/ $ ls
big_file description empty_file naming <span style="color:#3030ff;font-weight:bold">subfolder</span>
user@remote:~/scits-training/animals/Aardvark/ $ cat description
The aardvark (ARD-vark; Orycteropus afer) is a medium-sized, burrowing,
[...]
```
.mnemonic[
`cat` comes from the word "con.highlight[cat]enate",
which means joining things together in a series.
]
.exercise[
What happens if we call `cat` with two filenames?
```cat description naming```
]
---
background-image: url(assets/cat_long.svg)
background-position: top 5% right 20%
background-size: 25%
# File is too long!
Sometimes a file is too long to be comfortably read with `cat`
```
user@remote:~/scits-training/animals/Aardvark/ $ cd ../../numbers/
user@remote:~/scits-training/numbers/ $ cat hundred
1
2
[...]
99
100
```
A hundred lines is too much to fit into the terminal window.
While you can scroll to look through the output, sometimes files are much longer than that.
We can display only parts of the file, or use a program that allows to navigate a file.
---
background-image: url(assets/cat_parts.svg)
background-position: top 5% right 30%
background-size: 15%
# Parts of a cat?
If a cat is too long, perhaps we only need to look at its beginning (`head`)
or end (`tail`):
```
user@remote:~/scits-training/numbers/ $ head hundred
1
[...]
10
```
```
-user@remote:~/scits-training/numbers/ $ head hundred
+user@remote:~/scits-training/numbers/ $ tail hundred
91
[...]
100
```
Those commands display the first and last 10 lines of a file, respectively.
.mnemonic[
Remembering `cat` together with `head` and `tail` may help.
]
---
# Self-help test
Of course, you can look up other options with the self-help methods like `man`.
.exercise[
-Use one of the help methods to learn how to display 5 lines instead of 10 with `head`.
+Use one of the help methods (`man head` or `head --help`) to learn how to display 5 lines instead of 10 with `head`.
]
Hint: it will be a flag that should go before the filename.
--
**Answer:** `-n 5`, `-n5` or `--lines=5`
```
user@remote:~/scits-training/numbers/ $ head -n 5 hundred
1
2
3
4
5
```
---
# The file is too long, show less
One way to navigate a big file is `less`:
```
user@remote:~/scits-training/numbers/ $ less hundred
```
You will recognize this interface, since `man` also uses `less`.
Commands to try:
* .highlight[Arrow keys] to scroll line by line
* .highlight[`PgUp`] / .highlight[`PgDn`] to scroll screen by screen
* .highlight[`/something`] to search for "something"
* .highlight[`n`] to go to next found "something", .highlight[`N`] to go back
* .highlight[`>`] to go to the end of the file, .highlight[`<`] to go to the beginning
* .highlight[`h`] to show help
* .highlight[`q`] to quit
---
# Modifying files
Besides reading, we need to be able to create and modify files.
There are many editors available, and which one is "best" can lead to [hot debate](https://xkcd.com/378/).
We will mention and briefly explain two editors that are likely to be installed on any system you encounter nowadays.
* `nano`
* `vim`
---
# `nano`
```
user@remote:~/scits-training/numbers/ $ nano hundred
<span style="background:white;color:black;">GNU nano 2.5.3 File: hundred </span>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<span style="background:white;color:black;">[ Read 100 lines ]</span>
<span style="background:white;color:black;">^G</span> Get Help <span style="background:white;color:black;">^O</span> Write Out <span style="background:white;color:black;">^W</span> Where Is <span style="background:white;color:black;">^K</span> Cut Text <span style="background:white;color:black;">^J</span> Justify <span style="background:white;color:black;">^C</span> Cur Pos
<span style="background:white;color:black;">^X</span> Exit <span style="background:white;color:black;">^R</span> Read File <span style="background:white;color:black;">^\</span> Replace <span style="background:white;color:black;">^U</span> Uncut Text<span style="background:white;color:black;">^T</span> To Spell <span style="background:white;color:black;">^_</span> Go To Line
```
---
# `nano`
-`nano` is a small and simple editor which shows its commands at most times at the bottom (reminder, `^` means `Ctrl`):
+`nano` is a small and simple editor which helpfully shows its commands at the bottom (reminder, `^` means `Ctrl`):
```
<span style="background:white;color:black;">^G</span> Get Help <span style="background:white;color:black;">^O</span> Write Out <span style="background:white;color:black;">^W</span> Where Is <span style="background:white;color:black;">^K</span> Cut Text <span style="background:white;color:black;">^J</span> Justify <span style="background:white;color:black;">^C</span> Cur Pos
<span style="background:white;color:black;">^X</span> Exit <span style="background:white;color:black;">^R</span> Read File <span style="background:white;color:black;">^\</span> Replace <span style="background:white;color:black;">^U</span> Uncut Text<span style="background:white;color:black;">^T</span> To Spell <span style="background:white;color:black;">^_</span> Go To Line
```
You can use arrow keys to move around, input text as normal from where the cursor is.
Key commands:
* `Ctrl` + `W` ".highlight[w]here is" for searching the file
* `Ctrl` + `O` "write .highlight[o]ut" to save changes
* `Ctrl` + `X` "e.highlight[x]it" to get back to the shell
---
# Try `nano`
.exercise[
1. Open a new file, `ten`, with `nano`:
```
user@remote:~/scits-training/numbers/ $ nano ten
```
-2. Add numbers from 1 to 5 to it, on separate lines
+2. Add numbers from 1 to 10 to it, on separate lines
3. Save and exit `nano`
4. Verify what's in the file using `cat`
]
---
# `vim`
-```
-user@remote:~/scits-training/numbers/ $ vim hundred
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-"hundred" 100L, 292C 1,1 Top
-```
-
----
-
-# `vim`
-
`vim` (or, technically, "Vi IMproved") is one of two "Swiss knife" editors that
most Linux professionals prefer to use (the other one being `emacs`).
`vim` is available almost everywhere, and with proper configuration can do
very sophisticated things.
With power comes complexity, but for basic editing one doesn't have to remember a lot.
----
-
-.center[
- [![:scale 60%](assets/exiting_vim.png)](http://www.commitstrip.com/en/2017/05/29/trapped/)
-]
-
----
-
-# `vim` modes: command mode
-
-A central concept of `vim` is .highlight[modes].
-
-When you first open a file, if you try to start writing you'll (at best) not
-succeed, and at worst mangle your file and/or dig deeper into `vim`.
-
-This is because `vim` is by default in .highlight[command mode], that uses the entire keyboard
-for various command shortcuts and not actual text input.
-
-You can always get back to command mode by .highlight[pressing `Esc` enough times].
-
----
-
-# `vim` command mode: useful commands
-
-From command mode, the following commands are very useful (confirm with Enter):
-
-* .highlight[`/something`] searches for "something".
-
-* .highlight[`?something`] does the same, but backwards.
-
-* .highlight[`/`] or .highlight[`n`] goes to the next match.
-
-* .highlight[`?`] or .highlight[`N`] goes to the previous match.
-
-All of the above works in `less` as well.
-
-* .highlight[`:NUMBER`] goes to line number `NUMBER` – very useful when debugging.
-
- E.g. `:50` goes to 50th line in the file.
-
----
-
-# `vim` modes: insert mode
-
-After navigating around the file using arrow keys, `PgUp`/`PgDn` or other commands,
-you eventually want to edit the text.
-
-Press .highlight[`i`] to switch to .highlight[insert mode]:
+If you wish to (later) explore `vim`, you can go through its built-in tutorial:
```
-<span style="font-weight:bold">-- INSERT --</span> 1,1 Top
+vimtutor
```
-Here, you can use your keyboard as usual to edit/input text.
-
-As a reminder, to get back to command mode you should press `Esc`.
-
---
-# Exiting `vim`, eventually
-
-When you're done with editing, go back to command mode, and use one of the commands to exit:
-
-* .highlight[`:q`] will .highlight[q]uit Vim if there are no unsaved changes to the file. It will stop you if there are any.
-
-* .highlight[`:w` w]rites the changes to file.
-
-* .highlight[`:w filename`] writes the changes to another file, `filename`.
- It is essentially the "Save As" command.
-
-* .highlight[`:wq`] combines the two: saves current file and exits.
-
-* .highlight[`:q!`] quits forcefully, discarding unsaved changes.
-
----
-
-# `vim`: minimal survival guide
-
-The absolute minimum knowledge required to use `vim`:
-
-* Use arrow keys to move around in any mode.
-
-* Press `i` to start entering ("inserting") text.
-
-* Press `Esc` before you do anything else.
-
-* `:wq` to write your changes and quit, or
-
-* `:q!` to discard your changes and quit.
-
-Further `vim` help and training is available with `vimtutor` shell command.
-
----
-
-# Try `vim`
-
-.exercise[
-1. Open the file `ten` with `vim`:
-
- ```
- user@remote:~/scits-training/numbers/ $ vim ten
- ```
-
-2. Add numbers from 6 to 10 to the end, on separate lines
-
-3. Save and exit `vim` (hint: write and quit)
-
-4. Verify what's in the file using `cat`
+.center[
+ [![:scale 60%](assets/exiting_vim.png)](http://www.commitstrip.com/en/2017/05/29/trapped/)
]
---
# Organizing files and folders
To recap, you should now be able to:
* Navigate the file tree (with `cd`)
* List folder contents (with `ls`)
-* Read and write files (with e.g. `vim`)
+* Read and write files (with `nano`)
Our goal now is:
* Make new folders
* To move and copy files and folders around
* Delete files and folders
---
# Creating new folders
To create new folders, use the `mkdir` command:
```
user@remote:~/scits-training/numbers/ $ cd ..
user@remote:~/scits-training/ $ ls
<span style="color:#3030ff;font-weight:bold">animals</span> <span style="color:#3030ff;font-weight:bold">numbers</span>
user@remote:~/scits-training/ $ mkdir new-folder
user@remote:~/scits-training/ $ ls
<span style="color:#3030ff;font-weight:bold">animals</span> <span style="color:#3030ff;font-weight:bold">new-folder</span> <span style="color:#3030ff;font-weight:bold">numbers</span>
```
.mnemonic[
.highlight[`mkdir`] stands for .highlight[make dir]ectory
]
.exercise[
1. Create `new-folder` as shown above
2. Create directory `subfolder` inside it
3. Verify with `ls`
]
---
# Creating new folders
`mkdir` will fail if the folder already exists:
```
user@remote:~/scits-training/ $ mkdir new-folder
mkdir: cannot create directory ‘new-folder’: File exists
```
Using it with `-p` means "create if needed", and also works with chains of directories:
```
user@remote:~/scits-training/ $ mkdir -p new-folder/subfolder/subsubfolder
user@remote:~/scits-training/ $ ls -R new-folder
new-folder:
<span style="color:#3030ff;font-weight:bold">subfolder</span>
new-folder/subfolder:
<span style="color:#3030ff;font-weight:bold">subsubfolder</span>
new-folder/subfolder/subsubfolder:
user@remote:~/scits-training/ $
```
---
# Moving files
-Move operations can be broken down into two (potentially overlapping) cases:
+Move operations can be broken down into two cases:
-* Moving files and folders between folders:
+1. Moving files and folders between folders:
- folder1/something → folder2/something
+ `folder1/something` → `folder2/something`
-* Renaming files and folders: technically, moving from old name to new.
+2. Renaming files and folders:
- something → other
+ `something` → `other`
+
+ Technically, it's "moving" from old name to new.
Both cases are served with the `mv` command.
.mnemonic[
.highlight[`mv`] stands for .highlight[move]
]
---
# Preparing for exercises
```
user@remote:~/scits-training/ $ cd moving
user@remote:~/scits-training/moving $ ls
<span style="color:#3030ff;font-weight:bold">source</span> <span style="color:#3030ff;font-weight:bold">destination</span>
user@remote:~/scits-training/moving $ ls source
A1 A10 A11 A12 A2 A3 A4 A5 A6 A7 A8 A9 <span style="color:#3030ff;font-weight:bold">subfolder</span>
user@remote:~/scits-training/moving $ ls source/subfolder
B1 B2 B3 B4 B5 B6 B7 B8 B9
user@remote:~/scits-training/moving $ ls destination
user@remote:~/scits-training/moving $
```
---
# Moving files
To move something to another folder: .highlight[`mv NAME DESTINATION`],
as long as the .highlight[`DESTINATION` is a directory that exists].
```
user@remote:~/scits-training/moving $ mv source/A2 destination
```
You can specify multiple things to move at the same time, including folders:
```
$ mv source/A3 source/subfolder destination
```
+Moves both `source/A3` and `source/subfolder` into `destination`.
+
.exercise[
Move `subfolder` back into `source`
]
---
# Renaming
Renaming is easy: `mv OLDNAME NEWNAME`, if `NEWNAME` is *not* a directory.
For example, let's rename `destination` to `dest`:
```
user@remote:~/scits-training/moving $ mv destination dest
```
If you're renaming something in another folder, you must specify the path twice:
```
$ mv source/A4 source/A40
```
.exercise[
1. Rename `dest` back into `destination`
2. Rename `source/subfolder/B1` into `source/subfolder/B10`
]
---
# Move + rename
.exercise[
Try the following:
```
user@remote:~/scits-training/moving $ mv source/A5 A50
```
Use `ls` to understand what happened (`-R` may help)
]
--
**Answer:** Since there is no path for the second name, it moved into the current directory
and got renamed:
`~/scits-training/moving/source/A5`
`~/scits-training/moving/A50`
---
# Copying
Copying is done with `cp`
.mnemonic[
.highlight[`cp`] stands for .highlight[copy].
]
Syntax is the same:
* For copying to another directory, `cp NAME DESTINATION`
* For copying to another name, `cp OLDNAME NEWNAME`
.exercise[
1. Copy `source/A6` and `source/A7` into `destination`
2. Copy `source/A6` into `source/A66`
]
---
# Copying folders
-`cp`, unlike `mv`, will not copy directories:
+`cp`, unlike `mv`, will not copy directories by default:
```
$ cp source/subfolder destination
cp: omitting directory 'source/subfolder'
```
You need to use `-R` to copy folders together with their content
```
$ cp -R source/subfolder destination
```
.mnemonic[
.highlight[`-R`] stands for .highlight[r]ecursive
]
---
# Deleting
To remove files or folders, use `rm`
.mnemonic[
.highlight[`rm`] stands for .highlight[rem]ove
]
* `rm NAME` to remove a file
* `rm -r FOLDER` to remove a folder
You can pass several names at once:
```
$ rm destination/subfolder/B1 destination/subfolder/B2
```
---
# `rm` is unrecoverable!
When you delete files and folders with `rm`, you should be aware that there is no concept of "Trash".
Anything you delete (or overwrite) is lost with no easy way to recover.
You can use a flag `-i` to ask before any destructive operation.
```
user@remote:~/scits-training/moving $ cp -i -R source/subfolder destination
cp: overwrite 'destination/subfolder/B1'?
```
On the other hand, sometimes you want to override those confirmations, especially for `rm` – you can do it with `-f`.
.mnemonic[
.highlight[`-i`] stands for .highlight[interactive]
.highlight[`-f`] stands for .highlight[force]
]
---
# Wildcards
There are many A-files in `source`:
```
user@remote:~/scits-training/moving $ ls source
A1 A10 A11 A12 A40 A6 A66 A7 A8 A9 <span style="color:#3030ff;font-weight:bold">subfolder</span>
```
We may want to copy them all at once. We can use wildcards:
* .highlight[`*`] in a name means "any amount of any characters"
* For example, .highlight[`A*`] can mean `A`, `A1` and `A10`
* .highlight[`?`] in a name means "any single character"
* For example, .highlight[`A?`] can mean `A1`, `A6` but not `A10`
The wildcards will .highlight[not jump through directories]:
* .highlight[`*1`] can mean `A1`, `A11`, but not `subfolder/B1`
* .highlight[`\*/\*`] can match `subfolder/B1`
---
# Wildcard quiz (1/3)
Which of the following names match the pattern .highlight[`A\*a\*`]
<div class="center">
<table class="quiz">
<tr>
<td class="Y"><code>AAa</code></td>
</tr>
<tr>
<td class="N"><code>A/a</code></td>
</tr>
<tr>
<td class="N"><code>aaA</code></td>
</tr>
<tr>
- <td class="Y"><code>CBAcba</code></td>
+ <td class="N"><code>CBAcba</code></td>
</tr>
<tr>
<td class="N"><code>abcABC</code></td>
</tr>
</table>
</div>
---
# Wildcard quiz (2/3)
Which of the following names match the pattern .highlight[`A?a?`]
<div class="center">
<table class="quiz">
<tr>
<td class="N"><code>AAa</code></td>
</tr>
<tr>
<td class="Y"><code>AAaa</code></td>
</tr>
<tr>
<td class="Y"><code>Aaaa</code></td>
</tr>
<tr>
<td class="N"><code>AAaaa</code></td>
</tr>
<tr>
<td class="N"><code>aAAaa</code></td>
</tr>
</table>
</div>
---
# Wildcard quiz (3/3)
Which of the following patterns match the name .highlight[`A110`]
<div class="center">
<table class="quiz">
<tr>
<td class="Y"><code>A*</code></td>
</tr>
<tr>
<td class="Y"><code>*</code></td>
</tr>
<tr>
<td class="Y"><code>*A*</code></td>
</tr>
<tr>
<td class="N"><code>*A</code></td>
</tr>
<tr>
<td class="Y"><code>A???</code></td>
</tr>
</table>
</div>
---
# Using wildcards
-Putting a name with a wildcard is equivalend to putting several names:
+Putting a name with a wildcard is equivalent to putting several names:
```
$ cp source/A6* destination
```
is equivalent to
```
$ cp source/A6 source/A66 destination
```
So, you can use wildcards in any command that expects multiple files.
---
# Try wildcards
Use wildcards to do the following, from `~/scits-training/moving`:
.exercise[
1. List all files starting with `A` inside `source/` (use `ls` with a pattern).
2. Copy all files starting with `B` from `source/subfolder` into `destination`.
3. Move all files starting with `A1` from `source` into `destination`.
4. Delete all files starting with `A` from `destination`.
]
---
# Moving data in and out
So far we have moved the data around on the system itself.
It doesn't help if you want to load external data or
download the results of your programs.
--
Perhaps, it's your own system and you have access to cloud storage
or external storage devices.
Sometimes, you have a shared network folder between your computer
and the target system.
But how to do it, if your only interface to the server is SSH?
--
We will cover two ways:
1. Downloading data from the Internet with `wget`
2. Copying data between computers with `scp`
---
# Downloading from the shell
Sometimes, the data you need is a file on the Internet.
`wget` is the simplest-to-use tool for it:
```
user@remote:~/scits-training/moving $ cd ..
user@remote:~/scits-training/ $ wget https://example.com/
--2017-09-12 12:00:00-- https://example.com/
Resolving example.com (example.com)... 93.184.216.34
Connecting to example.com (example.com)|93.184.216.34|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1270 (1.2K) [text/html]
Saving to: ‘index.html’
100%[======================================>] 1,270 --.-K/s in 0s
2017-09-12 12:00:00 (36.2 MB/s) - ‘index.html’ saved [1270/1270]
user@remote:~/scits-training/ $ tail index.html
```
.mnemonic[
.highlight[`wget`] stands for .highlight[Web get]
]
---
# Downloading from the shell
Notable option: renaming the file immediately.
* .highlight[-O] (for .highlight[o]utput) chooses a specific file to write to
```
-$ wget https://tools.ietf.org/rfc/rfc1149.txt april.txt
+$ wget https://tools.ietf.org/rfc/rfc1149.txt -O april.txt
[...]
$ less april.txt
```
As usual, use `man wget` to see more options.
It can work with HTTP/HTTPS/FTP-hosted files.
---
# Transferring files between systems
To send files between two computers using SSH, the simplest command is `scp`.
.mnemonic[
.highlight[`scp`] stands for .highlight[secure copy]
]
`scp` behaves a lot like `cp`, but you can provide locations on other computers.
How to use `scp` on your own machine depends on the OS.
---
# `scp` on Windows
While PuTTY includes a command-line client `pscp` with the same functions,
it may be better to use a GUI client `WinSCP`.
It can be downloaded from https://winscp.net/
You can then connect using SCP (or SFTP) with your normal credentials
and transfer files between your PC and the remote:
![](assets/winscp.png)
---
# `scp` on Linux / MacOS
From your .highlight[local] terminal, you can transfer a file from UBELIX:
```
user@local:~ $ scp user@submit.unibe.ch:~/scits-training/numbers/hundred .
[..some authentication..]
user@local:~ $ less hundred
```
`scp`'s parameters work similarly to `cp`, but you can refer to files on other systems
by adding `user@remote:` to the path.
It works both ways, and can rename as well:
```
$ scp hundred user@submit.unibe.ch:~/scits-training/numbers/another_hundred
```
---
# Moving data in and out
.exercise[
1. Copy all of the `B`-files from `moving/source/subfolder` to your computer with one command (use wildcards).
2. Copy some folder from your computer to the home folder of the remote system (use `-r`).
]
--
In addition to `scp`, there's a command that works better
for repeatedly copying large folders with small changes: .highlight[`rsync`].
It will not be covered here, but look up information on it if it's your use case.
</textarea>
<script src="js/vendor/remark.min.js"></script>
<script src="js/vendor/jquery-3.2.1.min.js"></script>
<script src="js/terminal.language.js"></script>
<script src="js/common.js"></script>
<script src="js/linux_1.js"></script>
</body>
</html>
\ No newline at end of file
diff --git a/linux_2.html b/linux_2.html
index fe01650..71e5144 100644
--- a/linux_2.html
+++ b/linux_2.html
@@ -1,1269 +1,1266 @@
<!DOCTYPE html>
<html>
<head>
<title>Introduction to Linux, Part II</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" type="text/css" href="css/linux_1.css">
</head>
<body>
<textarea id="source">
class: center, middle
# Introduction to Linux
## Part II
-https://scits.math.unibe.ch/linux_2.html
-
-???
-
-Notes for the _first_ slide!
+`https://goo.gl/cypvZ1`
---
# Agenda
1. Linux resources you can use
2. Standard input/output and its redirection
3. UNIX pipelines
4. Background processes
5. Durable sessions with `screen`
6. File ownership and permissions
7. Shell scripting basics
-8. Customizing your environment
+8. (Customizing your environment)
---
# What Linux resources can I use?
To do development and run light workloads:
* Your own computer may already run Linux.
* You can install Linux in a virtual machine.
I recommend Virtualbox.
* If you're running Windows 10, you can install
[Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)
---
# What if it's not enough?
To create persistent services:
* Ask your group's sysadmin for servers/VM resources.
* UniBe Informatikdienste offers virtual machines.
* Cloud resources: [SWITCHengines](https://www.switch.ch/engines/), other cloud services.
To run heavy calculations:
* [UBELIX Linux cluster](https://docs.id.unibe.ch/ubelix/ubelix-101).
* Your group may have in-house infrastructure.
* Again, cloud services.
---
# Prepare for the tutorial
You should be either running Linux, or connected to a Linux system.
Log in to UBELIX, or inform me that you need access to another system.
Execute the following to set up training (if you haven't already):
```
$ wget https://scits.math.unibe.ch/script -O - | /bin/bash
```
---
# Processes and their input/output
When you're connected to a Linux system,
what you normally see is the shell prompt, awaiting input:
```
user@host:~ $
```
A .highlight[process] called shell is responsible for input/output at this moment.
By default, the input is either a keyboard connected to the system,
or your keypresses being relayed over the network.
The output, by default, is the screen connected to the system,
or text being relayed for display over the network.
---
# Processes and their input/output
Those are called .highlight[standard input] and .highlight[standard output],
or .highlight[STDIN/STDOUT].
.center[
![](assets/shell_stdio.svg)
]
--
If the user issues a command that calls another program, the shell
creates a .highlight[child process] and attaches the input/output to it.
.center[
![](assets/child_stdio.svg)
]
The shell will wait until the program terminates,
after which STDIN/STDOUT get reattached and a prompt is displayed.
---
# Redirecting output
Sometimes, we want to capture what a command is outputting to the screen.
For example, suppose that we want to save into a file the directory structure returned by `ls -R`:
```
user@host:~ $ ls -R ~/scits-training
scits-training:
animals moving numbers io scripts
[...]
user@host:~ $
```
We can instruct the shell to .highlight[redirect] the standard output:
.center[
![](assets/stdout_redirect.svg)
]
---
# Redirecting output
To redirect the output, we add .highlight[`> FILE`] to the command:
```
user@host:~ $ cd ~/scits-training/io
user@host:~/scits-training/io $ ls -R ~/scits-training > listing
user@host:~/scits-training/io $ cat listing
scits-training:
animals moving numbers io scripts
[...]
```
This will overwrite the contents of `FILE` (if any) with the output of the command.
The file will be created, if it does not exist yet.
---
# Appending output
Sometimes we don't want to overwrite (sometimes called "clobber") the file
with new contents and add them to the end instead.
To do that, use .highlight[`>> FILE`] instead of `> FILE`.
.exercise[
1. Try running the command `date` to see what it outputs.
2. Run `date` 3 times, appending the output to a file `date.log`.
3. Verify with `cat` that the file contains 3 records.
]
---
# Error output
Try saving the output of a command with errors
and you'll see that it still outputs to the screen:
```
user@host:~/scits-training/io $ ls , > listing
ls: cannot access ,: No such file or directory
user@host:~/scits-training/io $
```
--
This is intentional: Linux actually has two output streams for
its command line, STDOUT for normal data and .highlight[STDERR] for errors.
.center[
![](assets/stderr.svg)
]
This simplifies debugging: errors are separate from data.
---
# Error output
STDERR is not redirected when using `>` or `>>`:
.center[
![](assets/stderr_noredirect.svg)
]
--
It's possible to redirect it as well with .highlight[`2>`] or .highlight[`2>>`]:
```
user@host:~/scits-training/io $ ls .. , > listing 2> errors
user@host:~/scits-training/io $ cat errors
ls: cannot access ,: No such file or directory
user@host:~/scits-training/io $ cat listing
..:
animals io moving numbers scripts
```
---
# Discarding output
Sometimes we don't need output at all.
In this case, we can redirect it to a special file, .highlight[`/dev/null`]
It's a .highlight[device] that will accept any input, discarding it immediately.
--
For example, one might want to silence errors:
```
user@host:~/scits-training/io $ ls .. , 2> /dev/null
..:
animals io moving numbers scripts
```
---
# Interactive input
Most commands we've seen don't require any interactive input.
`tr` (for .highlight[translate]) is a command that transforms its input:
it substitutes some characters with others.
For example, `tr 'a-z' 'A-Z'` would translate all lowercase letters into uppercase.
--
Let's try this:
```
user@host:~/scits-training/io $ tr 'a-z' 'A-Z'
Let's input some text
LET'S INPUT SOME TEXT
```
---
# Interactive input
```
user@host:~/scits-training/io $ tr 'a-z' 'A-Z'
Let's input some text
LET'S INPUT SOME TEXT
But enter doesn't stop it!
BUT ENTER DOESN'T STOP IT!
```
A problem: text can contain many lines, and the program won't know when to stop.
--
We can terminate the program with Ctrl+C, but it actually expects an .highlight[end of input].
We can signal end of input with Ctrl+D on an empty line (or pressing it twice).
--
.exercise[
What happens if we press Ctrl+D while back at the shell prompt?
]
---
# Redirecting input
What if we want to use a file as an input in a command that doesn't accept files as arguments,
we need instruct the shell to use the file as the program's standard input:
.center[
![](assets/stdin_redirect.svg)
]
This is done with adding .highlight[`< FILE`] to the command.
```
user@host:~/scits-training/io $ tr 'a-z' 'A-Z' < errors
LS: CANNOT ACCESS ,: NO SUCH FILE OR DIRECTORY
```
---
# Redirects
.exercise[
1. Combine input and output redirection to save the output of last `tr` command into `errors.uppercase`
2. Use `cat` to verify the saved output.
]
---
# Pipelines
We have shown how to save outputs to a file, and further process files as inputs.
Sometimes, we don't need to save this intermediate representation.
In that case, we can directly connect the output of one program to the input of another
with .highlight[pipes].
To do so, separate two commands with .highlight[`|`]:
```
user@host:~/scits-training/io $ ls . | tr 'a-z' 'A-Z'
DATE.LOG
ERRORS
LISTING
```
---
# Pipelines
```
user@host:~/scits-training/io $ ls . | tr 'a-z' 'A-Z'
DATE.LOG
ERRORS
LISTING
```
Given this command, shell starts two processes in parallel and ties their respective output and input together.
Standard input/output is connected at the ends of the chain:
.center[
![](assets/pipe.svg)
]
--
Such .highlight[pipelines] can be longer than two commands, and can be combined with file redirects.
---
# Pipelines and errors
You will notice that all errors are still output normally:
```
user@host:~/scits-training/io $ ls . , | tr 'a-z' 'A-Z'
ls: cannot access ,: No such file or directory
.:
DATE.LOG
ERRORS
LISTING
```
--
As before, errors are not normally redirected, and collected from all processes in the pipe:
.center[
![](assets/pipe_err.svg)
]
---
# Background jobs
Recall that, when running a command, the shell waits until it is terminated: all input goes to the program (or nowhere).
.center[
![](assets/child_stdio.svg)
]
Sometimes, we don't need to wait until the program terminates – we actually want it running in background.
---
# Background jobs
If you specify .highlight[`&`] at the end of the command, the shell will start it, but keep control of STDIN:
.center[
![](assets/job_stdio.svg)
]
Instead of a .highlight[foreground] process, it becomes a .highlight[background] job.
--
You are immediately returned to the shell and can run other commands while the job executes.
Note that both the shell and the background job are connected to STDOUT.
Redirect output to prevent mix-ups.
---
# Background jobs
Compare:
```
user@host:~/scits-training/io $ sleep 3
user@host:~/scits-training/io $ sleep 3 &
[1] 12231
user@host:~/scits-training/io $
```
Here, `[1]` is the .highlight[job number], and `12231` is the .highlight[process ID], or PID.
After 3 seconds and when another command finishes (you can just press Enter for an empty command),
you'll be informed that the job terminated:
```
user@host:~/scits-training/io $
[1]+ Done sleep 3
user@host:~/scits-training/io $
```
---
# Listing jobs
You can list running background jobs with .highlight[`jobs`]:
```
user@host:~/scits-training/io $ sleep 100 &
[1] 12232
user@host:~/scits-training/io $ sleep 0 &
[2] 12233
user@host:~/scits-training/io $ jobs
[1]- Running sleep 100 &
[2]+ Done sleep 0
```
---
# Terminating jobs
You can forcibly .highlight[terminate] a job with the .highlight[`kill`] command,
which accepts either PID or job ID (with `%`):
```
user@host:~/scits-training/io $ sleep 100 &
[1] 12234
user@host:~/scits-training/io $ kill 12234
user@host:~/scits-training/io $ jobs
[1]+ Terminated sleep 100
user@host:~/scits-training/io $ sleep 100 &
[1] 12235
user@host:~/scits-training/io $ kill %1
```
You can search for more process IDs to terminate with .highlight[`ps ax`], in case something is misbehaving.
---
# Stopped jobs
Background jobs have nothing connected to their standard input.
If a background job cannot continue without user input, it will .highlight[stop],
which the shell will signal to you:
```
user@host:~/scits-training/io $ tr 'a-z' 'A-Z' &
[1] 12236
user@host:~/scits-training/io $
[1]+ Stopped tr /a-z/ /A-Z/
user@host:~/scits-training/io $
```
--
You can bring a job to .highlight[foreground] to pass STDIN from the shell
to the running job with `fg` (or `fg %N` for a specific job number):
```
user@host:~/scits-training/io $ fg
tr /a-z/ /A-Z/
You are now talking to the job
YOU ARE NOW TALKING TO THE JOB
```
---
# Stopping and resuming programs
You can stop most currently-running programs with `Ctrl`+`Z`:
```
user@host:~/scits-training/io $ sleep 100
^Z
[1]+ Stopped sleep 100
user@host:~/scits-training/io $
```
--
From there, you can use `fg` to resume normal execution of the program,
or use .highlight[`bg`] to let it continue to run in the background.
```
user@host:~/scits-training/io $ bg
[1]+ sleep 100 &
user@host:~/scits-training/io $ jobs
[1]+ Running sleep 100 &
```
---
# Background jobs are fragile
What will happen if you start a background job, and then close the terminal?
--
Closing the terminal (or disconnecting the SSH session) kills the shell you were talking to.
Since the job was a .highlight[child process] of that shell, it will also be killed.
--
A minor inconvenience if you're working on your own machine (you can just leave the terminal open),
but a much bigger problem with remote connections.
If the connection is broken, the shell is also terminated along with all processes launched from it.
How to protect against it?
---
# `screen`
To protect your session, you can use .highlight[`screen`].
`screen` starts a new shell that exists independently of your current one.
Even if the current shell dies (e.g. because you disconnected),
the shell running in `screen` will continue together with all its child processes.
--
Starting a new `screen` session is simple:
```
user@host:~/scits-training/io $ screen
[terminal screen is cleared]
-user@host:~/scits-training/io $ echo "Hello, I'm in a screen!"
+user@host:~/scits-training/io $ echo "Hello, I'm in a screen"
Hello, I'm in a screen!
user@host:~/scits-training/io $
```
---
# Reattaching to `screen`
Now suppose your connection was terminated.
Close the terminal where it is running to simulate that, then log in again.
--
You can use .highlight[`screen -ls`] to list active sessions:
```
user@host:~ $ screen -ls
There is a screen on:
13383.pts-2.host (11/09/17 03:02:23) (Detached)
1 Socket in /var/run/screen/S-user.
```
--
You can attach to a screen session (possibly detaching it first, if it's being used somewhere)
with .highlight[`-dR`] (for .highlight[detach, reattach])
```
user@host:~ $ screen -dR
[terminal screen is cleared]
-user@host:~/scits-training/io $ echo "Hello, I'm in a screen!"
+user@host:~/scits-training/io $ echo "Hello, I'm in a screen"
Hello, I'm in a screen!
user@host:~/scits-training/io $
```
---
# Controlling screen
`screen` can be used for other things, such as having multiple parallel shell sessions open.
Controlling screen consists of pressing .highlight[`Ctrl`+`A`], then a screen-specific command.
For example,
* .highlight[`c`] will .highlight[create] a new shell within screen
* .highlight[`n`] will switch to the .highlight[next] shell
* .highlight[`d`] will .highlight[detach] from `screen`, returning you to the original shell
Finally, you can use .highlight[`?`] to access built-in help,
or use `man screen` for a more detailed manual.
--
Another popular alternative to `screen` is `tmux`. It will not be covered by this tutorial,
but is worth looking into.
---
# Users and groups
Before we discuss permissions, we need to understand users and groups in Linux.
A .highlight[user] is a unit of access control; it has a set of credentials to access the system
and .highlight[owns] some files on it.
A .highlight[group] is a collection of users to facilitate shared access to resources.
A user can belong to many groups but one group is considered primary.
You can use `id` to check your user and groups:
```
akashev@submit01:~ $ id
uid=7265(akashev) gid=1109(math) groups=1109(math),902(l_gaussian)
```
Here, `akashev` is my user, `math` is my primary group and `l_gaussian` is another group I belong to.
---
# Permissions: `rwx`
Each file and directory in UNIX filesystems has 3 permissions (for a particular user).
Regular files:
* .highlight[`r`], or .highlight[Read], means that you can read the contents of a file.
* .highlight[`w`], or .highlight[Write], means that you can modify the file.
* .highlight[`x`], or .highlight[eXecute], means that the file may be launched as a program.
Directories:
* .highlight[`r`] means that you can read the list of files within the directory.
* .highlight[`w`] means that you can add or delete files from the directory.
* .highlight[`x`] means you can .highlight[traverse] the folder: enter it with `cd` and read the contents of its files.
---
# Inspecting permissions
Try running `ls -la` to see permissions on files and folders:
```
$ ls -la
total 20
drwxrwxr-x 2 user group 4096 Sep 11 01:26 .
drwxrwxr-x 6 user group 4096 Sep 10 23:06 ..
-rw-rw-r-- 1 user group 90 Sep 10 23:08 date.log
-rw-rw-r-- 1 user group 47 Sep 11 00:50 errors
-rw-rw-r-- 1 user group 30 Sep 11 01:09 listing
```
We're interested in the first column: the cryptic `drwxrwxr-x` and `-rw-rwr--`,
which are called .highlight[mode].
--
* The first character denotes the .highlight[file type].
* `-` means "regular file".
* `d` means "directory".
* The rest is divided in groups of three:
* Access for the owner
* Access for the group
* Access for everyone else
---
# File ownership
```
drwxrwxr-x 2 user group 4096 Sep 11 01:26 .
-rw-rw-r-- 1 user group 90 Sep 10 23:08 date.log
```
Each file in a UNIX filesystem has an .highlight[owner] and a .highlight[group] attached.
In the example above, `user` is the owner and `group` is the designated group.
Note that the user .highlight[doesn't have to be in the assigned group].
---
# Effective permissions
```
-rwxr-x--- 1 user group 90 Sep 10 23:08 script
```
To determine which permissions apply, the following is checked:
* If the user is the owner, the first set applies (`rwx`, full permissions)
* If the user is in the designated group, the second set applies (`r-x`, so cannot write)
* For all other users, the third set applies (`---`, so cannot do anything)
--
A special user, .highlight[superuser] (normally called .highlight[root]),
can completely disregard permissions and do anything to any file on the system.
---
# Permissions: first match applies
Note that the system does not apply "best" permissions – only the first set that matches.
Let's reverse the situation:
```
----r-xrwx 1 user group 90 Sep 10 23:08 script
```
For this file, the owner cannot do anything to the file, anyone in `group` cannot modify it,
but everyone else has full permissions.
Note: the owner can always change a file's permissions.
---
# Modifying permissions
To modify a file's permissions, use .highlight[`chmod CHANGES FILE`]
.mnemonic[
`chmod` stands for .highlight[change mode].
]
Possible changes:
-* .highlight[`+r`], .highlight[`+w`], .highlight[`+x` add] permissions for the owner.
+* .highlight[`+r`], .highlight[`+w`], .highlight[`+x` add] permissions.
Can combine: `+rw`
* .highlight[`-r` removes] permissions.
* .highlight[`=r`] sets pemissions to .highlight[exactly] `r--`.
-* Prefix .highlight[`g`] changes permissions for the .highlight[group], e.g. `g+r`.
+* Prefix .highlight[`u`] changes permissions for the .highlight[group], e.g. `u+r`.
+* Prefix .highlight[`g`] changes permissions for the .highlight[group], e.g. `g+rw`.
* Prefix .highlight[`o`] changes permissions for .highlight[others], e.g. `o-w`.
-* Prefix .highlight[`a`] changes permissions for .highlight[all] three sets at once.
+* Prefix .highlight[`a`] or no prefix changes permissions for .highlight[all] three sets.
* An .highlight[octal number] (e.g. 750) sets permissions to a specific configuration
(in this case, `rwxr-x---`).
---
# Modifying permissions
Several changes can be applied at once, separated by commas:
```
user@host:~/scits-training/io $ ls -la date.log
-rwxrw-r-- 1 user group 90 Sep 10 23:08 date.log
user@host:~/scits-training/io $ chmod +x,g=rx,o-r date.log
user@host:~/scits-training/io $ ls -la date.log
-rwxr-x--- 1 user group 90 Sep 10 23:08 date.log
```
.exercise[
Modify permissions on the file to be `r-xr--rw-`
]
---
# Changing ownership
Similarly to `chmod`, the .highlight[`chown`] command allows changing a file's owner and group.
* `chown USER FILE` changes the owner
* `chown :GROUP FILE` changes the group
* `chown USER:GROUP FILE` changes both
Note: once the owner is changed, the old owner no longer can modify access to the file.
.highlight[For this reason, only administrators can change the file owner, or assign a group the owner is not part of.]
.exercise[
Use `groups` to list groups you belong to.
Change a file's group to one of them, and then back to the original one.
]
---
# Shell scripting
Shell is not just an interface to launch other programs;
it comes with its own scripting language to automate complex tasks.
You can have variables, loops, conditionals – a full-featured programming language.
We will only show the very basics.
.exercise[
Navigate to `~/scits-training/scripts` and open `boom.sh` in your favourite editor (nano, vim)
]
---
layout: true
# Shell scripting
```bash
#!/bin/bash
# I hope you get the reference
echo "Someone set up us the bomb."
for i in {5..1}
do
echo "$i.."
sleep 1
done
explosion="Boom!"
echo $explosion
```
---
The first line of the script is special:
```bash
#!/bin/bash
```
It's called a .highlight["shebang"] (for .highlight[shell] and "!" .highlight[bang]).
It tells the shell what to execute the rest of the script with.
Since we're writing a `bash` shell script, we put there the path to `/bin/bash` itself.
---
Other lines starting with .highlight[`#`] are .highlight[comments]
```bash
# I hope you get the reference
```
They are ignored by `bash` and are used to leave notes to yourself or others.
---
.highlight[`echo`] command outputs its arguments to STDIN.
```bash
echo "Someone set up us the bomb."
```
Quotes are used to make text with spaces in it a single argument; here, they are optional.
---
.highlight[`for`] designates a .highlight[loop]: a .highlight[variable `i`] will change from 5 to 1.
```bash
for i in {5..1}
do
# something
done
```
The code in `# something` will repeat with `i` as 5, 4, 3, 2 and 1.
`do` and `done` delimit the bounds of the loop.
---
One can use the variable in expressions .highlight[prefixed by `$`], i.e. .highlight[`$i`]:
```bash
echo "$i.."
```
If there is ambiguity as to where a variable name ends, use braces: .highlight[`${i}`],
e.g. `"Sample ${i}A"` for "Sample 1A", etc.
---
Variables can also be simply .highlight[assigned to]:
```bash
explosion="Boom!"
echo $explosion
```
The lack of spaces around `=` is .highlight[significant].
Otherwise Bash will try to execute `explosion` as a command.
---
layout: false
# Running a script
OK, suppose we wrote the above script. How to execute it?
1. We need to make sure that it's allowed to execute:
```
user@host:~/scits-training/scripts $ chmod +x boom.sh
```
2. For security reasons, the current directory is not automatically considered when
starting other programs. We need to explicitly refer to it:
```
user@host:~/scits-training/scripts $ ./boom.sh
```
.exercise[
1. Execute the script, saving its output to a file.
2. Modify the script to count down from 10.
]
---
# Scripting, take two
The next script you will type out yourselves.
Open `beer.sh` in your favourite editor.
We'll write a simple script to determine if a user is old enough to drink beer.
---
# Scripting, take two
```bash
#!/bin/bash
```
Any bash script should start with an appropriate shebang.
We want to ask the user for his/her age; we can use the .highlight[`read`] command.
```bash
# -n prevents a line break, and note the extra space
echo -n "What's your age? "
read age
```
This will display a promt for the user and wait for input.
The result is then stored in the variable `$age`.
For simplicity, we will not check that the input is indeed a valid number.
---
# Scripting, take two
```bash
#!/bin/bash
echo -n "What's your age? "
read age
```
We need to make a decision based on age; we need an if-then-else construct.
```bash
if [ $age -lt 16 ]
then
echo "You're too young to drink!"
else
echo "You're old enough, have a beer!"
fi
```
.highlight[`fi`] here is `if` reversed, to close the .highlight[`if`] statement.
Conditionals in bash are a bit clunky, but .highlight[`-lt`] here stands for .highlight[less than].
Again, the whitespace here is .highlight[significant].
---
# Scripting, take two
```bash
#!/bin/bash
echo -n "What's your age? "
read age
if [ $age -lt 16 ]
then
echo "You're too young to drink!"
else
echo "You're old enough, have a beer!"
fi
```
.exercise[
1. Save this script to `beer.sh`.
2. Change the file's mode to allow execution.
3. Test the script with different values.
]
---
# Scripting improvements
Let's add a little personal touch.
`whoami` is a command that returns the username. Let's edit `beer.sh` to use it:
```bash
then
echo "$(whoami), you're too young to drink!"
else
echo "$(whoami), you're old enough, have a beer!"
fi
```
.highlight[`$(something)`] allows you to execute a command and substitute the result within another command.
.exercise[
Test the new additions.
]
---
# Scripting improvements
Let's read the age from the command line arguments.
`bash` automatically populates .highlight[`$0`] with the .highlight[name of the executable],
and .highlight[`$1`], .highlight[`$2`] and so on with .highlight[arguments].
Let's use `$1` as age if it's defined:
```bash
if [ $1 ]
then
age=$1
else
echo -n "What's your age? "
read age
fi
```
.exercise[
Test that `./beer.sh` now automatically gets the age from its first argument, and still asks if no argument is provided.
]
---
# Return values
Whenever a program terminates, it returns a single integer to the shell that called it;
it's called the .highlight[return value].
By convention:
* .highlight[0] means "no error".
* any .highlight[non-zero value] means "some kind of error".
Let's return appropriate values:
```bash
then
echo "$(whoami), you're too young to drink!"
exit 1
else
echo "$(whoami), you're old enough, have a beer!"
exit 0
fi
```
---
# Chaining commands
You can chain commands in shell with .highlight[`;`] or .highlight[`&&`].
.highlight[`;`] will execute commands one by one, regardless of errors.
```
$ command1; command2
```
.highlight[`&&`] will only execute the next command only if the previous one returned 0, i.e. finished without errors.
```
$ command1 && command2
```
.exercise[
1. Apply the return value changes to `beer.sh`
-2. Test it with `./beer.sh && echo "Cheers!"`
+2. Test it with `./beer.sh && echo 'Cheers!'`
]
---
# Customizing your environment
If you interact with a system often, you may want to add various shortcuts and customizations
to your shell.
--
Bash uses two files, `~/.bash_profile` and `~/.bashrc`, to allow you to apply such customizations
on every login.
Essentially, they are bash scripts that are run before the shell shows a prompt.
--
* `.bashrc` is applied when you open a new shell when already logged in.
* `.bash_profile` is applied when you log in (e.g. though SSH).
One can apply code in `.bashrc` from `.bash_profile` to cover both cases.
---
exclude: true
```bash
# In .bash_profile
# -f tests that file exists
# source executes commands in the current shell
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
```
---
# Environment variables
Your profile files can set various .highlight[environment variables]:
snippets of data inherited by programs running from shell.
You can see your current environment variables with:
```
$ env | less
```
Some programs rely on environmental variables to change their behavior. Example:
```bash
# Will replace the default editor with vim in some commands
export EDITOR=vim
```
This works exactly like setting a variable in a script, except for the extra
command .highlight[export], which propagates this variable to child processes.
By convention, environment variables are UPPERCASE.
---
# Environment variables
Your home directory is available in `$HOME` – in some contexts, using `~` is not possible.
Another important variable is `$PATH`.
It's a colon-separated list of directories which are searched when you try to run a program by name.
Notably, the current directory is not in `$PATH`.
If you have created some own scripts/programs and want them to be available by name from anywhere,
you can put them in a folder (e.g. `~/bin`) and add it to `$PATH`:
```bash
export PATH="$PATH:$HOME/bin"
```
---
# Custom shell prompt
The variable `$PS1` contains the format template for your shell prompt.
Throughout this training, we assumed the following:
```bash
export PS1="\u@\h:\w \\$ "
```
But you can customize it! Want the space for the command on a separate line?
```bash
export PS1="\u@\h:\w\\n\\$ " # \\n represents a line break
```
```
user@host:~
$
```
Want to add current time? Want to add some color?
There's [a guide](https://www.digitalocean.com/community/tutorials/how-to-customize-your-bash-prompt-on-a-linux-vps) for that.
---
# Aliases
If you use a certain command often, you can define a short name for it.
For example, if you want a shorter name for `ls -lh` because you always want to see human-readable sizes,
you can make an alias:
```
$ alias lh="ls -lh"
$ lh
total 26M
-rw-r--r-- 1 user group 25M Sep 11 07:22 big_file
-rw-r--r-- 1 user group 735 Sep 11 07:22 description
-rw-r--r-- 1 user group 0 Sep 11 07:22 empty_file
-rw-r--r-- 1 user group 551 Sep 11 07:22 naming
drwxr-xr-x 0 user group 512 Sep 11 07:22 subfolder
```
---
# Making customizations permanent
To make above tweaks permanent, they need to be added either to `.bash_profile` or `.bashrc`.
Then they will apply on each opened shell.
* `.bash_profile` is .highlight[sourced] at most once. Put things there that shouldn't be called multiple times.
* `.bashrc` is sourced almost every time `bash` is called, except for initial SSH shell.
To be safe, you can "include" `.bashrc` into `.bash_profile` like this:
```bash
# In .bash_profile
# -f tests that file exists
# source executes commands in the current shell
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
```
</textarea>
<script src="js/vendor/remark.min.js"></script>
<script src="js/vendor/jquery-3.2.1.min.js"></script>
<script src="js/terminal.language.js"></script>
<script src="js/common.js"></script>
<script src="js/linux_1.js"></script>
</body>
</html>
\ No newline at end of file

Event Timeline