Linux, Command Line & Metacentrum
Total Page:16
File Type:pdf, Size:1020Kb
Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Linux, command line & MetaCentrum Use of Linux command line not only for CESNET’s MetaCentrum Vojtěch Zeisek Department of Botany, Faculty of Science, Charles University, Prague Institute of Botany, Czech Academy of Sciences, Průhonice https://trapa.cz/, [email protected] February 6 to 8, 2018 . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 1 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Outline I 1 Introduction Learning machine What it is a “UNIX” Licenses and money 2 Linux Choose one Differences 3 UN*X Disks and filesystems Types of users Files and directories Permissions Text 4 Command line . SSH — secure shell and screen . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 2 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Outline II BASH and others Variables Input, output and their redirecting Information and processes Directories Archives Searching Network Parallelisation Timing 5 Text Reading Extractions AWK Manipulations . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 3 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Outline III Comparisons Editors Regular expressions 6 Scripting Basic skeleton BASH variables Functions Reading variables Branching the code Loops 7 Software Packages Compilation Java Windows applications . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 4 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Outline IV 8 MetaCentrum Information Usage Tasks Graphical connection 9 Administration System services 10 Git 11 The End Resources The very end . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 5 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money Introduction 1 Introduction Learning machine What it is a “UNIX” Licenses and money . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 6 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money The course information • The course page: https://trapa.cz/en/course-linux-command-line-2018 • Česky: https://trapa.cz/cs/kurz-prikazove-radky-linuxu-2018 • Subject in SIS: https://is.cuni.cz/studium/eng/predmety/ index.php?do=predmet&kod=MB120C17 • Česky: https://is.cuni.cz/studium/predmety/index.php?do= predmet&kod=MB120C17 • For students having subscribed the subject, requirements are on next slide • Working version is available at https://github.com/V-Z/ course-linux-command-line-bash-scripting-metacentrum — feel free to contribute, request new parts or report bugs . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 7 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money Requirements to exam (“zápočet”) 1 Be present whole course. 2 Be active — ask and answer questions. 3 Write short script solving any task the student is (going to be) solving. E.g. prepare script to process student’s data on MetaCentrum. Or short script to do anything the student needs to do. This will be very individual. According to topics and interests of every student. Students can of course discuss with anyone, use Internet, manuals, etc. The aim is learn how to solve real problem the student has/is going to have. 4 Write at least one page (can be split into multiple articles) on Wikipedia about any topic discussed during the course. Again, this is very open, students can write about any topic they like. I prefer native language of the student (typically to make larger non-English Wikipedia). Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 8 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money Materials to help you… • Download the presentation from https://soubory.trapa.cz/ linuxcourse/linux_bash_metacentrum_course.pdf • Download the scripts and toy data from https://soubory.trapa.cz/linuxcourse/scripts_data.zip • Note: Open the scripts in some good text editor (slide 68) — showing syntax highlight, line numbers, etc. (NO Windows notepad); the files are in UTF-8 encoding and with UNIX end of lines (so that too silly programs like Windows notepad won’t be able to open them correctly) • Never ever open any script file in software like MS Word — they destroy quotation marks and other things by “typographical enhancements” making the script unusable . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 9 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money Virtual machine for learning • If you do not have Linux installed, download and install VirtualBox from https: //www.virtualbox.org/ • Download openSUSE Leap 42.3 Linux distribution for this course from ftp://botany. natur.cuni.cz/openSUSE_ Leap_Linux_course.ova (3.7 GB) • Launch VirtualBox and go to menu File | Import appliance… to import it. When do, launch it (Start) . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 10 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money VirtualBox shared folder I VirtualBox can be configured to share folder with host operating system . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 11 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money VirtualBox shared folder II Go to menu “Devices | Shared Folders” and set pair of folders 1 sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) shared /mnt . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 12 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money What it is UNIX, Linux and GNU I • UNIX • Originally developed in Bell labs of AT&T in 1696, written in C, since then huge radiation, hybridization, HGT, … • Trademark — only systems passing certain conditions (paid certification) can be called “UNIX” — Solaris, HP-UX, AIX, etc. (commercial systems for big servers) • Main principles: simple, multitasking, hierarchical, network, for more users (takes cares about permissions etc.), configuration written in plain text files, important relationships among applications (generally one application = one task — they are chained), work primarily with text, has kernel and API (interface to communicate with the rest of the system) • UNIX-like (UN*X, *nix) • Systems compatible with UNIX (Linux, BSD and its variants, macOS, …) • Mainly open-source (UNIX is commonly commercial — source code is not available for public, but its specification is) . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 13 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money What it is UNIX, Linux and GNU II • Nowadays prevailing over “old” UNIX systems, used in many devices from tiny embedded toys to huge data centers • Try to provide same quality as paid systems, but (mostly) for free • Many courts about copyrights, parts of code, patents — USA allow software patents, EU not — GNU, Linux, BSD, etc. try to ensure to have only code not covered by any patents to avoid possible courts • GNU • “GNU’s Not Unix!” — but it is compatible, respects its principles • Since 1984 Richard Stallman (founder of Free Software Foundation) tried to make new kernel (Hurd — not finished yet…) • Generally set of basic system tools — working with many kernels (Linux BSD*, Mac’s Darwin, …), also present in many commercial paid UNIX systems • Source code is free — anyone can study it (Security!), report bugs, contribute, modify, share it, … • GNU General Public License (GPL) — free spirit of open-source — license, idea, how to share software . Vojtěch Zeisek (https://trapa.cz/) Linux, command line & MetaCentrum February 6 to 8, 2018 14 / 232 Introduction Linux UN*X Command line Text Scripting Software MetaCentrum Administration Git The End Learning machine What it is a “UNIX” Licenses and money What it is UNIX, Linux and GNU III • Linux • First version of kernel written by Linus Torvalds in Helsinki in 1991 • Kernel was in principle inspired by various UNIX systems and using GNU tools for work • Quickly became popular — anyone can take it and use for any needs • Used in small embedded (commonly network) devices, mobile devices (book readers, Android, …), personal computers, servers (from home level to biggest