C2110 UNIX and programming Lesson 1 / Module 4 -1C2110 UNIX and programming Petr Kulhanek kulhanek@chemi.muni.cz National Center for Biomolecular Research, Faculty of Science Masaryk University, Kamenice 5, CZ-62500 Brno Lesson 1 / Module 4 PS / 2020 Distance form of teaching: Rev2 C2110 UNIX and programming Lesson 1 / Module 4 -2First Steps ➢ Local vs remote access ➢ Local login ➢ Terminals ➢ Command line ➢ Remote login, command ssh C2110 UNIX and programming Lesson 1 / Module 4 -3Local vs Remote Access user local session user local session Remote Access C2110 UNIX and programming Lesson 1 / Module 4 -4Local Login Local terminals (historical order): • six text terminals (F1 ... F6) • one graphical terminal (F7, F8, ...) • toggled using the keys Ctrl + Alt + F1 ... Ctrl + Alt + F7 Local terminals (new order, Ubuntu > 18.04): • login to graphic terminal (F1) • graphic terminals - according to use (F2, F3,…) • text terminals - according to use (F2, F3,…) • toggle using the keys Ctrl + Alt + F1 ... Ctrl + Alt + F7 Login: • loginname (username) and password (password) must be entered The Linux operating system is very flexible and allows other ways of local login, such as using identification cards or cryptographic keys. More can be found in the help of PAM system (Pluggable Authentication Modules). $ man 8 pam C2110 UNIX and programming Lesson 1 / Module 4 -5Local Login Text terminal ➢ makes the command line (CLI - command line interface) ➢ the default directory is /home/username (home directory) ➢ graphics applications (X11) can only be run with export the display to a remote graphics terminal ➢ log off command exit Graphic terminal ➢ starts X11 server or Wayland composer and the window manager (KDE, Unity, GNOME, etc.) ➢ window manager (desktop environment) can be selected before self login ➢ allows direct launch of graphical programs (GUI - graphical user interface) ➢ the command line is available through special applications ➢ xterm ➢ console ➢ gnome-terminal ➢ log out using the menu in the menu window manager C2110 UNIX and programming Lesson 1 / Module 4 -6Local Login Login Name (Enter) The default keyboard is English (EN). When using the numeric keypad, make sure NumLock is turned on. Password (Enter) Ability to change the type of desktop environment (gnome, KDE, etc., some must be installed first) Ubuntu 18.04 LTS Login screen for graphics terminal (GUI) C2110 UNIX and programming Lesson 1 / Module 4 -7GNOME Desktop Settings, logout, shutdown Standard applications Dock (running applications, frequently used applications) Terminal C2110 UNIX and programming Lesson 1 / Module 4 -8- Terminals The command line is accessible directly from text terminals. In a graphical environment (X11/Wayland), it is necessary to run a suitable application emulating a text terminal: ➢ gnome-terminal (Terminal) ➢ console ➢ xterm console The default directory is: /home/username simple, yet highly configurable gnome-terminal simple, standard on all UNIX systems xterm C2110 UNIX and programming Lesson 1 / Module 4 -9Command Line [kulhanek@wolf ~]$ username computer name current directory (~ means home directory /home/username) Prompt - type of user / prompt ($ regular user, # super user, other possible %, >) place for command The command is executed by pressing the Enter key. Copying text: Do not use Ctrl + C! To copy text from the terminal, just highlight the text, press the mouse wheel (middle button) to paste it. Autocomplete: by pressing the Tab key (tab) the command line interpreter tries to complete the spelled word. Command names, paths and file names are added (if one press does not cause anything, there are more options to add, repeated press will display them). History: Use the up and down arrow keys to scroll through the list of commands you have already entered. The command s from the history can be reused or modified and then used in the modified form. The history is also accessible by command history. C2110 UNIX and programming Lesson 1 / Module 4 -10Remote Login ➢ ssh ➢ nested login C2110 UNIX and programming Lesson 1 / Module 4 -11Remote Login There are several remote login options (rsh, XDMCP, etc.) but the most used and the safest is the use of the ssh command (secure shell). $ ssh [user@]hostname [command] Syntax: username; if not specified, the name of the logged in user will be used computer name [] - can be omitted Log out: The remote interactive login (session) is terminated by the command exit. Examples of use: $ ssh wolf01.ncbr.muni.cz $ ssh wolf01 who the command to be executed; if not specified, the command line is made available in interactive mode C2110 UNIX and programming Lesson 1 / Module 4 -12Initial Remote Login [kulhanek@pes ~]$ ssh skirit.ics.muni.cz The authenticity of host 'skirit.ics.muni.cz (2001:718:ff01:1:216:3eff:fe20:382)' can't be established. ECDSA key fingerprint is SHA256:Splg9bGTNCeVSLE0E4tB30pcLS80sWuv0ezHrH1p0xE. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'skirit.ics.muni.cz' (ECDSA) to the list of known hosts. [kulhanek@skirit ~]$ When logging in for the first time, it is necessary to confirm the authenticity of the machine we are logging to. In a trusted network, we can accept the fingerprint without verification. However, it is a good idea to verify the machine's fingerprint in an independent way (for example, by sending a thumbprint by mail from the remote machine administrator) in an insecure environment. This is protection against MITM (Man-in-the-middle) attack. Note: On a WOLF cluster, all computers are verified against each other, so this confirmation is not required. C2110 UNIX and programming Lesson 1 / Module 4 -13Remote Login wolf03 wolf04 wolf05wolf02 wolf06 wolf07 wolf08 wolf23 Using the command ssh, it is possible to do nested remote login. ssh wolf07 ssh wolf02 ssh wolf03 ssh wolf03 With each new level of remote login overhead grows, therefore, if possible, we will use the most direct remote login. Nested remote login must be used to access computers on non-public networks (e.g., supercomputers in IT4I). (details in supercomputing C2115). C2110 UNIX and programming Lesson 1 / Module 4 -14WOLF Cluster - Where to login? wolf wolf03 wolf23wolf02 wolfsr university network workstations (computing nodes) server / front node 0.18 1.18 2.11 wolf32 wolf40wolf31wolf30 0.18 wolf01 switch computing nodes wolflr 0.57 Full machine names: wolf02.ncbr.muni.cz wolf03.ncbr.muni.cz …. wolf23.ncbr.muni.cz Short machine names (only within the WOLF cluster): wolf02 wolf03 …. wolf23 C2110 UNIX and programming Lesson 1 / Module 4 -15Exercise 1 1. Remotely login onto the workstation wolf02.ncbr.muni.cz • From MS Windows (any version) use Putty (see separate presentation) • From Linux or macOS, use the command ssh 2. Verify the remote workstation name using the command: hostname 3. Print the full computer name using: hostname -f 4. Print your login name: whoami 5. List the logged users: w or who or last 6. List the contents of your home directory: ls 7. Print the path to your home directory: pwd 8. From the node wolf02 log on to the node wolf10 via the command ssh. 9. Repeat tasks 2 through 7 on node wolf10. 10. Log out from the wolf10 node: exit 11. From the node wolf02 run the command hostname remotely on the node wolf16. 12. From the node wolf02 run the command ls remotely on the node wolf16. 13. Log out from the node wolf02: exit C2110 UNIX and programming Lesson 1 / Module 4 -16- wolf10 Exercise 2 1. Open two terminal sessions on the workstation wolf02.ncbr.muni.cz 2. Enter commands from a previous exercise (e.g. last, w, etc.). 3. Sign out. 1. Open two terminal sessions, one on the workstation wolf02.ncbr.muni.cz and the other on wolf10.ncbr.muni.cz 2. Enter commands from a previous exercise (e.g. last, w, etc.). 3. Sign out. wolf02wolf02 wolf02 wolf02 wolf02 wolf10 your computer your computer