C2110 UNIX and programming 2nd lesson -1C2110 UNIX and programming Petr Kulhánek, Jakub Štěpán kulhanek@chemi.muni.cz National Centre for Biomolecular Research, Faculty of Science Masaryk University, Kotlářská 2, CZ-61137 Brno CZ.1.07/2.2.00/15.0233 3.lekce C2110 UNIX and programming 2nd lesson -2- Contents  Scientific-technical applications • Module  Remote file transfer • scp, wget  Remote graphical applications • Display export  Virtualization • What is virtualization, typical usage, hypervisor overview • MS Windows in VirtualBox, instalation of Ubuntu OS  MS Windows as client • Putty, WinSCP • Text file transfer C2110 UNIX and programming 2nd lesson -3- Scientific-technical applications  module C2110 UNIX and programming 2nd lesson -4Scientific – technical applications Available modules list: $ module $ module versions vmd Available versions of module: Module activation: $ module add vmd Running application from module vmd $ vmd Scientific-technical applications are installed in multiple versions (application version, compilation type, parallel version), these are available through module system. Before running application, particular module has to be activated. $ module add vmd:1.9.0 Module version is separated by colon Activates default version C2110 UNIX and programming 2nd lesson -5- Exercise 1. List all applications accessible in module system. 2. Which versions are accessible for module vmd and nemesis. 3. Activate module vmd version 1.9.0 and run program vmd. 4. Activate module nemesis in default version and run program nemesis. C2110 UNIX and programming 2nd lesson -6Remote file transfer  scp  wget C2110 UNIX and programming 2nd lesson -7Remote copy $ scp [-r] source destination Usage examples: Syntax: [] – maybe omitted Source and destination can be file or directory. In case of directory copy option –r (recursive) has to be used. Remote source or destination is identified by machine hostname separated by colon. [user@]hostname:[path/]file $ scp pokus.txt wolf01.wolf.inet:/scratch/kulhanek $ scp wolf01.wolf.inet:/scratch/kulhanek/pokus.txt . For remote copy there is command scp. C2110 UNIX and programming 2nd lesson -8Web file download For file download from web command wget can be used. Remote machines has to provide files using protocol ftp, http or https. $ wget [-O output_name] url url (uniform resource locator) www file identification Usage examples: $ wget http://www.rcsb.org/pdb/files/1SS9.pdb PDB structure code Upper case O C2110 UNIX and programming 2nd lesson -9Remote graphical applications  Display export C2110 UNIX and programming 2nd lesson -10Running remote GUI application Graphical applications can be run directly in X11 environment (graphical terminal) or with display export to remote desktop X11 environment. Direct run Display export wolf01 Application wolf01 Application wolf01 wolf02 C2110 UNIX and programming 2nd lesson -11Display export Application wolf01 wolf02 Command ssh sets all necessities for display export automatically if option -X (uppercase X) is used. [wolf01] $ ssh -X wolf02 [wolf02] $ ./my_application Option -x (lowercase x) disables export. Display export can be done also manually, by setting variable DISPLAY and correct calls of commands xhost and xauth. C2110 UNIX and programming 2nd lesson -12- Exercise 1. Log to machine of your colleague using command ssh. Check your login mutually (command w or who). 2. Create subdirectory pdb in directory /scratch/your_login 3. Download structure 1SS9 from PDB database using command wget and save it as test.pdb. 4. Open structure in program vmd. Check, that your application runs on remote machine (ps -e). Check that application of your colleague runs on your machine (ps –u his_login). 5. Create subdirectory structures in directory /scratch/your_login 6. Copy file 1SS9.pdb to your machine using command scp to directory /scratch/your_login/structures 7. Open structure in program vmd on your machine. Compare program qualitatively response (speed) for remote and local running. Work in pairs. C2110 UNIX and programming 2nd lesson -13- Virtualization  What is virtualization?  Typical usage  Hypervisor overview  MS Windows in VirtualBox  Ubuntu OS installation C2110 UNIX and programming 2nd lesson -14Virtualization – Hypervisor Hardware Host OS Hypervisor OS 1 OS 2 OS 3 Virtualization are procedures and techniques, that enables to approach computer hardware in different way, then they physically exist. Virtualization can be done on different levels, from whole computer (virtual machine), to particular hardware devices (virtual processors, memory etc.) or only software environment (virtualization of operating system). source: www.wikipedia.org Hypervisor – virtual machine manager Host OS (in virtual machine) C2110 UNIX and programming 2nd lesson -15Virtualization advantages • On one physical machine, there may run multiple virtual machines (each with different operating system). • Physical hardware performance can be used more efficiently (lower costs). • Easier backup. Virtual machine state maybe saved as snapshots, these can be used to restore original state. • Teleport. Virtual machines can be transferred in between two physical machines with minimal stop time. Appropriate for hardware updates. • Easier testing of OS. C2110 UNIX and programming 2nd lesson -16Virtualization tools overview VirtualBox www.virtualbox.org supported host OS: MS Windows, Mac OS X, Linux Licence: freeware + proprietary extension for non-commerce usage KVM Linux kernel part Supported host OS: Linux Support programs: virt-manager, qemu Licence: freeware VMWare http://www.vmware.com/ Supported host OS: MS Windows, Linux Licence: commerce C2110 UNIX and programming 2nd lesson -17MS Windows on WOLF cluster Running MS Windows XP in virtual machine (hypervisor VirtualBox) $ /win/win C2110 UNIX and programming 2nd lesson -18Virtual machine control Full screen on / off switch Host = (right Ctrl key) (MS Windows and Linuxem) How to input Ctrl+Alt+Del C2110 UNIX and programming 2nd lesson -19Virtual machine switch off Correct switch off way Wrong switch off C2110 UNIX and programming 2nd lesson -20- Exercise 1. Run virtual machine with MS Windows XP (command /win/win). 2. Open Internet Explorer in virtual machine and find keyword Hypervisor in Wikipedia. 3. On host OS monitor hypervisor using command top. 4. Pause virtual machine. 5. Resume virtual machine. 6. Finish virtual machine. C2110 UNIX and programming 2nd lesson -21Ubuntu 12.04 LTS installation Install program VirtualBox (http://www.virtualbox.org). Download installation image of OS Ubuntu as iso format: http://www.ubuntu.com/ Ubuntu 12.04 LTS (Ubuntu Desktop) Create virtual machine in VirtualBoxu manager: Choose OS Linux and Ubuntu version. Other settings can be left on default values. First virtual machine run: First run prompts for install media input. We attach iso image as installation media (icon on right and select downloaded iso image) System install Then follow installation wizard hints. Homework. C2110 UNIX and programming 2nd lesson -22MS Windows as client  Putty  WinSCP  Text file transfer C2110 UNIX and programming 2nd lesson -23MS Windows as client – overview Login to Linuxu from MS Windows (text terminal)  putty www.chiark.greenend.org.uk/~sgtatham/putty  ssh from Cygwin environment; www.cygwin.com File transfer between Linuxem and MS Windows  WinSCP www.winscp.com, twin-panel file manager  scp from Cygwin environment; Display export from Linuxu to MS Windows (X11 server)  cygwin www.cygwin.com  Xming http://sourceforge.net/projects/xming/ Login from Linuxu to MS Windows (remote desktop)  rdesktop C2110 UNIX and programming 2nd lesson -24- Putty Putty http://www.chiark.greenend.org.uk/~sgtatham/putty/ Implementation of SSH (Secure Shell) for Windows, Putty enables remote connection to SSH servers (machines supporting ssh protocol and login – unix/linux type). C2110 UNIX and programming 2nd lesson -25Putty – settings wolf.ncbr.muni.cz Remote machine address Backspace key interpretation. C2110 UNIX and programming 2nd lesson -26Putty – settings II Unix compatible mouse select / paste system. Non-proportional font (all symbols have same width) C2110 UNIX and programming 2nd lesson -27- WinSCP WinSCP http://winscp.net/eng/docs/lang:cs Program for file transfer between MS Windows and computers supporting SFTP or SCP protocols (unix and linux type). Local machine Remote machine C2110 UNIX and programming 2nd lesson -28Text files MS Win  Linux Text files created in MS Windows and Linuxem are not totally compatible, Each OS uses different coding of line end. Linux: \n (line feed 0x0A) MS Windows: \r+\n (carriage return 0x0D, line feed 0x0A) For file conversion one can use programs d2u and u2d (on cluster WOLF). 1) Activation of cats module $ module add cats 2) Conversion MS Windows => Linux $ d2u file.com 3) Conversion Linux => MS Windows $ u2d file.log C2110 UNIX and programming 2nd lesson -29- Exercise 1. Run virtual machine with MS Windows XP (/win/win). 2. Run application Putty. 3. Using terminal Putty log on machine wolf.ncbr.muni.cz. 4. Monitor who has logged on wolf.ncbr.muni.cz. 5. In terminal Putty try running application vmd. Why does it fail to run? 6. Run application WinSCP. 7. Download file 1SS9.pdb to virtual machine. Open file in program Notepad. Is content shown correctly? 8. Correct line end coding in file 1SS9.pdb and open file again in virtual machine program Notepad.