Introduction to UNIX - Tokyo Institute of Technology to UNIX Ver. TSUBAME3 Tokyo Institute of...

87
Tokyo Institute of Technology Global Scientific Information and Computing Center Introduction to UNIX Ver. TSUBAME3

Transcript of Introduction to UNIX - Tokyo Institute of Technology to UNIX Ver. TSUBAME3 Tokyo Institute of...

Tokyo Institute of Technology Global Scientific Information and Computing Center

Introduction to UNIX

Ver. TSUBAME3

Tokyo Institute of Technology Global Scientific Information and Computing Center

Contents • Overview of TSUBAME3 • Introduction of UNIX • File operation • Various commands • Program execution • User environment • Representative services of UNIX

Tokyo Institute of Technology Global Scientific Information and Computing Center

Overview of TSUBAME3 • What is TSUBAME3? • System architecture of TSUBAME3 • System details • ISV applications • Service contents • Usage of compute node • TSUBAME3’s home page

TSUBAME is the abbreviation of Tokyo-tech Supercomputer and UBiquitously Accessible Mass-storage Environment

which was selected through public invitation.

Tokyo Institute of Technology Global Scientific Information and Computing Center

What is TSUBAME3? • The Green Supercomputer of No. 1 Green 500 list introduced at

the Tokyo Institute of Technology's International Information Center on August 1, 2017.

• Total theoretical computational performance: 12.15 PFLOPS (5.7 [email protected])

• Total main storage capacity: 135 TiB (72 [email protected]) • Magnetic disk capacity: 15.9PB (7.13 [email protected]) • Network: High speed network of 100 Gbps realized through

Omni-Path

Tokyo Institute of Technology Global Scientific Information and Computing Center

System architecture of TSUBAME3

Tokyo Institute of Technology Global Scientific Information and Computing Center

System details (1) • Compute node SGI ICE XA 540 nodes (1408 [email protected])

Compute node - 540 nodes

Configuration (per node)

CPU Intel Xeon E5-2680 v4 2.4GHz× 2CPU # of

cores/threads 14 cores / 28 threads × 2CPU Memory size 256GiB

GPU NVIDIA TESLA P100 for NVlink-Optimized Servers ×4

SSD 2TB Interconnect Intel Omni-Path HFI 100Gbps ×4

Tokyo Institute of Technology Global Scientific Information and Computing Center

System details (2) • Storage

• Software – SUSE Linux Enterprise Server 12 SP2 – ISV applications (see other pages)

Usage Mount Capacity File system Home directory /home 40TB GPFS+cNFS Shared application /apps

High speed storage area 1 /gs/hs0 4.8PB Lustre High speed storage area 2 /gs/hs1 4.8PB Lustre High speed storage area 3 /gs/hs2 4.8PB Lustre

Local scratch area /scr 1.9TB per node

xfs(SSD)

Tokyo Institute of Technology Global Scientific Information and Computing Center

ISV applications (1) • ANSYS • Fluent • ABAQUS • ABACUS CAE • Marc & Mentat / Dytran • Nastran • Patran • Gaussian • GaussView • AMBER • Materials Studio • Discovery Studio • Mathematica

• Maple • AVS/Express • AVS/Express PCE • LS-DYNA • LS-PrePost • COMSOL • Schrodinger • MATLAB • Allinea Forge • Intel Compiler • PGI Compiler

Environment of The applications shown above is loaded/purged by module command.

*Newly introduced software in T3

Tokyo Institute of Technology Global Scientific Information and Computing Center

ISV applications (2) • T3 have more applications and functions comparing with T2.5. • Overall the number of licenses has decreased, so please avoid

occupancy them for a long time. • Application usage will be charged in the future. • Under consideration of a system to purchase additional

licenses by billing revenue to promote fair use. • In order to use an application which is not introduced in

TSUBAME 3.0, it is possible to refer to the license server introduced inside the university (laboratory etc.)

Tokyo Institute of Technology Global Scientific Information and Computing Center

Service contents • Use of compute node

– SGI ICE XA - 540 nodes Refer to another page for an example of using compute nodes

• Use of storage – home directory (up to 25GB per user)

• home directory for each user is located in /home/[0-9]/username. • Accessible from all machines of system

– High-speed storage area • Group disk area composed of Lustre file system • Refer to "TSUBAME portal User's Guide" for the purchase of group disks.

– Scratch area • Local scratch area

– Local scratch area composed of SSD • Shared scratch area

– Shared file system bundling local scratch areas – accessible only when using resource type F (f_node)

Tokyo Institute of Technology Global Scientific Information and Computing Center

Usage of compute node (1) • Logging into a login node (SSH key authentication)

– TSUBAME has two login nodes, login0 and login1. – Execute the ssh command to access to login.t3.gsic.titech.ac.jp in a terminal,

such as a PC in your lab. – Then automatically log in to one of the login nodes by load balancing

[NOTE] Not permitted to log in to a interactive node directly.

Don’t run a heavy process in login node. Necessary to create a SSH key pair and upload the public key of it to

TSUBAME3 portal in advance. (Refer to “TSUBAME3.0 Portal User’s Guide”)

Terminal login0

login1 login.t3.gsic.titech.ac.jp

load balancing SSH

Tokyo Institute of Technology Global Scientific Information and Computing Center

Usage of compute node (2) Every job must run on some of the 540 compute nodes. Impossible for an user to specify a compute host • Interactive job execution (for small to medium scale)

– Execute qrsh, the command for starting an interactive session, on a login node, then automatically login to an interactive node.

$ qrsh -l resource_type -l reserve_time -g TSUBAME_group

– Run program on the interactive node $ ./a.out

• Batch job submission (for medium to large scale) – Execute qsub, the command for submitting a job, on a login node.

$ qsub -l resource_type -l reserve_time -g TSUBAME_group batch_script.sh

A various resource type is selectable. → Refer to TSUBAME3 User’s Guide.

Tokyo Institute of Technology Global Scientific Information and Computing Center

TSUBAME3’s home page (1) http://www.t3.gsic.titech.ac.jp/

Click to move to the page in English

Tokyo Institute of Technology Global Scientific Information and Computing Center

TSUBAME3’s home page (2) • The top page informs failure events, maintenance schedule and so

on. Please check periodically.

• Be sure to read user’s guides before using TSUBAME3. – Users guides

http://www.t3.gsic.titech.ac.jp/manuals http://www.t3.gsic.titech.ac.jp/docs/TSUBAME3.0_Users_Guide_en.pdf http://www.t3.gsic.titech.ac.jp/docs/TSUBAME3.0_Portal_Users_Guide.pdf (in Japanese)

• If any question appears, please check the following pages first. – FAQ

http://www.t3.gsic.titech.ac.jp/en/faq – Known issues

http://www.t3.gsic.titech.ac.jp/node/17 (In Japanese) • If it cannot solve the problems referring the above links, please

contact us through the link below. – Contact

http://www.t3.gsic.titech.ac.jp/en/contact

Tokyo Institute of Technology Global Scientific Information and Computing Center

Introduction of UNIX • Outline of UNIX • Login locally • Terminal • Use of terminal on Windows/Mac • Remote login • SSH authentication • Login to TSUBAME • Logout

Tokyo Institute of Technology Global Scientific Information and Computing Center

Outline of UNIX • UNIX has mainly two lines of System V and BSD. • Linux is compatible with UNIX. • UNIX is a multitasking/multiuser Operating System. • User Authentication

– Checking which user you are – Checking whether the user is valid

login name / password

Tokyo Institute of Technology Global Scientific Information and Computing Center

Login locally • At the time to login, which user you are, and whether the user

name is valid is judged. • Login name and password are required to log in UNIX system.

It becomes available after the required items are authenticated.

Welcome to ______-000 Login name : ______ Password : ______

Tokyo Institute of Technology Global Scientific Information and Computing Center

Terminal • Using a standard terminal on UNIX.

GSIC@t3support2:~

[GSIC@t3support2 ~]$

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Use of terminal on Windows

• There are various terminal emulators for Windows. – Cygwin, PuTTY, Rlogin as Representative.

• Example: Cygwin

– Operation of two-button mouse for Windows (with a wheel) • Gently press the wheel to click the middle button • Rotate the wheel to scroll the screen • Usage example for showing Menu

– Press Ctrl + middle button to display the Menu. • Usage example for copy & paste

– Select the area with left click to copy (color inversion) – Click the middle button (paste)

• In case of using an application in graphical user interface, it is

necessary to install/run an X Window System on the same machine the terminal emulator you use.

Tokyo Institute of Technology Global Scientific Information and Computing Center

Use of terminal on Mac • Applications >Utilities >Terminal.app

GSIC― -bash ― 80x24

t3support :~ GSIC$

~―bash

Applications

Utilities

Terminal

Tokyo Institute of Technology Global Scientific Information and Computing Center

Remote login • Using a host at remote location from a local host • Commands are telnet, rlogin, ssh and so on. • In TSUBAME, SSH public key authentication, a highly secure

method, is adopted. Terminal

[GSIC@t3support2 ~]$ ssh login.t3.gsic.titech.ac.jp -l GSIC -i ~/.ssh/ecdsa Last login: Tue Oct 3 09:26:54 2017 from 131.112.3.100 GSIC@login0:~> GSIC@login0:~> top GSIC@login0:~> exit logout Connection to login0.t3.gsic.titech.ac.jp closed. [GSIC@t3support2 ~]$

Authentication

Remote operation Logout from the remote host

Tokyo Institute of Technology Global Scientific Information and Computing Center

SSH key authentication The authentication system using a pair of keys, called public key and private key • Advantage

– Only accessible from the machine which have the key = High security

• Disadvantage – It’s a little hard for configure and management

[NOTE] Never let the private key leak out.

Key pair

Priv key

Pub key

Registered Pub key

Request to conn.

Registration in adv.

Encryption Composite

Hash

Random seed

Hash Authentication

Tokyo Institute of Technology Global Scientific Information and Computing Center

SSH key generation Refer to the following links for generating a key pair and register the public key to TSUBAME3. http://www.t3.gsic.titech.ac.jp/en/node/79 http://www.t3.gsic.titech.ac.jp/node/37

Tokyo Institute of Technology Global Scientific Information and Computing Center

Login to TSUBAME3 • A symbol such as “%”, “$” and “>”. It is called prompt. • Enter a command on this line. • Input ssh command on a prompt for remotely login to

TSUBAME3. GSIC@t3support2:~

[GSIC@t3support2 ~]$ ssh login.t3.gsic.titech.ac.jp -l GSIC -i ~/.ssh/ecdsa Last login: Tue Oct 3 09:26:54 2017 from 131.112.3.100 GSIC@login0:~> # The following command is also the same meaning. $ ssh [email protected] -i ~/.ssh/ecdsa

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Logout • To finish the work, perform logout operation. • Confirmation of machine being performed currently

– Arrangement of data – Confirmation of execution status (Check no program is running on the

terminal)

• Logout operation – Ctrl+d – logout – exit

Tokyo Institute of Technology Global Scientific Information and Computing Center

File operation • File operation • File system • Information display commands • file specification • Symbols • Special characters • File permission • Commands for file management • Different codes depending on OS • Compression and extraction

Tokyo Institute of Technology Global Scientific Information and Computing Center

File system • Represented in hierarchical structure • File management with directory • Ordinary file and special file

/

file_a

file_a FILE_A

directory_1

:Directory :File

Tokyo Institute of Technology Global Scientific Information and Computing Center

Information display commands • pwd

• ls [option] [file]

GSIC@t3support2:~

[GSIC@t3support2 ~]$ pwd /home/GSIC

File Edit View Help

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ls Desktop

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

File specification • The top of a hierarchical structure of a file system is called

“root”, represented as “/”. • How to access files

– Absolute specification: Full specification from the root (/) – Relative specification: Specifies the location from current location

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ls /home/GSIC Desktop [GSIC@t3support2 ~]$ ls ../GSIC Desktop

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Symbols • Command to confirm directory: pwd • Home directory: ~ • One directory up: ..

GSIC@t3support2:~

[GSIC@t3support2 ~]$ pwd /home/GSIC [GSIC@t3support2 ~]$ cd .. [GSIC@t3support2 home]$ cd ~ [GSIC@t3support2 ~]$

File Edit View Help

*Use . (dot) to represent the current directory (current position)

Tokyo Institute of Technology Global Scientific Information and Computing Center

Special characters

• Special characters representation can be used to specify file names.

* Although it is a very useful function, but it needs to be used carefully.

※Metacharacter Special characters are also known as metacharacters. Metacharacters are symbols which do not have any meaning itself, however these become meaningful as a whole when combined with other characters.

Metacharacter Function Usage * all character strings ls * ? one of any character ls ?

[character string] one of character strings ls bc [character1-character2]

one of the characters between character 1 and character 2 ls b[a-c]d

Tokyo Institute of Technology Global Scientific Information and Computing Center

File permission • ls –l

• Mode

GSIC@g3support2:~

[GSIC@t3support2 hogehoge]$ ls -l 合計 0 drwxrwxr-x. 2 GSIC users 6 10月 3 15:35 hoge -rw-rw-r--. 1 GSIC users 0 10月 3 15:35 hogedoc

File Edit View Help

Mode Owner Group Date File_name

File type d: directory l: link -: ordinary file

drwxrwxr-x

Owner’s permission Group’s permission

Other’s permission

Permission r: readable w: writable x: executable -: unauthorized

Tokyo Institute of Technology Global Scientific Information and Computing Center

Commands for file management • Make directory % mkdir aaa • Remove directory % rmdir aaa • Change file attribute % chmod 755 aaa

• Change owner # chown necapps aaa • Change group # chgrp procon aaa

*755 is called as bit representation, and it represents access rights for owner, group and others. 0 –-- unauthorized 1 --x executable 2 -w- writable 3 -wx 4 r-- readable 5 r-x 6 rw- 7 rwx (Operation of administrator is as follows)

Tokyo Institute of Technology Global Scientific Information and Computing Center

Different codes depending on OS • Line feed code in text file

– Unix/linux ¥n LF(line feed) – Macintosh ¥r CR(carriage return) – Win/Dos ¥r ¥n CRLF

• Display code for Japanese – Unix/Linux UTF-8/EUC – Macintosh/windows S-JIS

• Conversion through nkf command – nkf –w abc.txt > abcd.txt

Tokyo Institute of Technology Global Scientific Information and Computing Center

Compression and extraction • Compression

gzip atom45.tar → atom45.tar.gz zip atom45.zip atom45 → atom45.zip lha a text.lzh *.txt → text.lzh tar czvf atom45.tgz atom45 → atom45.tgz tar cjf smpl.tar.bz2 smpldir → smpl.tar.bz2 bzip2 sample.txt → sample.txt.bz2

• Extraction zcat atom45.tar.Z | tar -xvf - tar jxf sample.tar.bz2 gzip -d atom45.tar.gz → atom45.tar unzip book2nd.zip lha e text.lzh tar xzvf atom45.tgz bzip2 -d sample.txt.bz2 → sample.txt

Tokyo Institute of Technology Global Scientific Information and Computing Center

Various commands • Frequently used commands • Command operation • File operation command • Function of alias • Editor • Online manual • Command concatenation • Process and job

Tokyo Institute of Technology Global Scientific Information and Computing Center

Frequently used commands • ssh • exit • mkdir • rmdir • chmod • chown • chgrp • nkf • cd • cp • mv • rm • pwd

• ls • vi • emacs • view • tail • cat, more, less • find • file • grep • diff, sdiff • man

Tokyo Institute of Technology Global Scientific Information and Computing Center

Command operation Usage • Execute a command without any option • Execute a command with options or arguments • It is possible to combine multiple commands.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ls Desktop [GSIC@t3support2 ~]$ [GSIC@t3support2 ~]$ ls –l drwxr-xr-x 2 GSIC users 512 Sep 13 10:15 Desktop [GSIC@t3support2 ~]$ [GSIC@t3support2 ~]$ cal 10 2017 October 2017 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Commands for file operation • cd

change direction

• cp copy copy a file or a directory

• mv move move a file or a directory

• rm remove remove a file or a directory

*In cp, mv, rm commands, users are prompted for confirmation by –i option. *There is no command to restore the files that were removed once.

GSIC@t3support2:~

[GSIC@t3support2 hogehoge]$ ls hoge hogedoc [GSIC@t3support2 hogehoge]$ cd hoge [GSIC@t3support2 hoge]$ ls cast dust host [GSIC@t3support2 hoge]$ cp cast fast [GSIC@t3support2 hoge]$ ls cast dust fast host [GSIC@t3support2 hoge]$ mv host test [GSIC@t3support2 hoge]$ ls cast dust fast test [GSIC@t3support2 hoge]$ rm dust [GSIC@t3support2 hoge]$ ls cast fast test

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Function of alias • Adding alias to frequently used command or command line. • alias can also be used as command. • Command to set alias is called alias. • Command to remove alias definition is called unalias.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ cat .bashrc # rm option alias rm='rm -i'

File Edit View Help

By writing this way in .bashrc, loss of file by mistake can be prevented. By mistake, if space is given such as rm a *, then all files that have string "a" will be deleted. By setting the alias, users are prompted for confirmation before removing by -i option.

Tokyo Institute of Technology Global Scientific Information and Computing Center

vi editor An editor necessarily installed in UNIX machine

Insert mode by i or a Standby mode by Esc key Delete one character by x, delete one line by dd Save and exit editor by :wq Wipe out all edits and quit by :q! Undo the last change to the file by u At the time standby mode, move using h, j, k, l, which is the function of ←, ↓, ↑, →, respectively.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ vi hogedoc ~ ~ ~ ~ ~ “hogedoc” 0L, 0C 0,0-1 全て

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

view command • Editor commands similar to vi editor can be used. • Open editor in read-only mode. • Use to check the contents of file.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ view hogedoc ~ ~ ~ ~ ~ “hogedoc” [readonly] 0L,

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

tail command • Displays last part of output to standard output

It is useful to output the calculation result to a file and periodically check the progress with the tail command. Please don’t run text output and tail commands successively through a program. (in order not to increase the load on the machine)

GSIC@t3support2:~

[GSIC@t3support2 ~]$ tail -5 /usr/share/doc/python-2.7.5/LICENSE FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

cat, more, less commands • Using cat to view the content of a file • Using more/less to output the large size files in page The contents of a file are displayed in page units. page feed is done with the space key.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ more /usr/share/doc/python-2.7.5/LICENSE A. HISTORY OF THE SOFTWARE ========================== Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) in Reston, Virginia where he released several versions of the --続ける--(29%)

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

find command • find is the command for get a file location.

→ It is convenient to use when you know part of file name or file name. → It is impossible to search within a directory without execution rights.

• There are whereis and which as similar commands GSIC@t3support2:~

[GSIC@t3support2 ~]$ find . -name hoge –print ./hoge [GSIC@t3support2 ~]$ which python /usr/bin/python [GSIC@t3support2 ~]$ whereis python python: /usr/bin/python /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python3.4-config /usr/bin/python3.4m-config /usr/lib/python3.4 /usr/lib/python2.7 /usr/lib64/python3.4 /usr/lib64/python /usr/lib64/python2.7 /usr/include/python3.4m /usr/include/python2.7 /usr/include/python /usr/share/man/man1/python.1.gz

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

file command • Checks file type. * Do not trust entirely because sometimes it is wrongly judged.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ file hoge hoge: directory [GSIC@t3support2 ~]$cd hoge [GSIC@t3support2 hoge]$ file hogedoc hogedoc: empty [GSIC@t3support2 hoge]$ file hogedoc2 hogedoc: ASCII text

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

grep command • Searches the character string in file

• Convenient to search strings in standard output (with pipe) It is useful if this command is executed before performing character string search such as vi editor and more command.

GSIC@t3support2:~

[GSIC@t3support2 examples]$ grep mpi *.c connectivity_c.c:#include <mpi.h> hello_c.c:#include "mpi.h“ [GSIC@t3support2 examples]$ grep mpi *.c connectivity_c.c:#include <mpi.h> connectivity_c.c: MPI_Status status; (略) hello_c.c:#include "mpi.h“ hello_c.c: char version[MPI_MAX_LIBRARY_VERSION_STRING]; (略) [GSIC@t3support2 hoge]$ grep -i mpi *.c | more (略)

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

diff command Displays the differences between two files.

diff

sdiff

GSIC@t3support2:~

[GSIC@t3support2 ~]$ diff hello_c.c hello_cxx.cc 18,20c18,20 < MPI_Init(&argc, &argv); < MPI_Comm_rank(MPI_COMM_WORLD, &rank); < MPI_Comm_size(MPI_COMM_WORLD, &size); --- > MPI::Init(); > rank = MPI::COMM_WORLD.Get_rank(); > size = MPI::COMM_WORLD.Get_size();

File Edit View Help

GSIC@t3support2:~

[GSIC@t3support2 ~]$ sdiff hello_c.c hello_cxx.cc MPI_Init(&argc, &argv); | MPI::Init(); MPI_Comm_rank(MPI_COMM_WORLD, &rank); | rank = MPI::COMM_WORLD.Get_rank(); MPI_Comm_size(MPI_COMM_WORLD, &size); | size = MPI::COMM_WORLD.Get_size(); MPI_Get_library_version(version, &len); MPI_Get_library_version(version, &len);

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Online manual • man command name/file name • man -k keyword

POSIX [Portable Operating System Interface for UNIX] A set of standard operating system interfaces based on the UNIX, specified by IEEE. (extracted from e-word)

GSIC@t3support2:~

[GSIC@t3support2 examples]$ man ls Man: find all matching manual pages (set MAN_POSIXLY_CORRECT to avoid this) * ls (1) ls (1p) Man: What manual page do you want? Man: NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION 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.

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Command concatenation Process can be executed collectively as program by combining commands. • Connect command by semicolon (;) • Connect command by pipe (|) • Write the output of the command to file • Input file in command • Shell Programming

Tokyo Institute of Technology Global Scientific Information and Computing Center

Semicolon • Connects multiple commands by semicolon (grouping) • After execution of command 1, command 2 and command 3

are executed in sequence.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ uname;arch;hostname Linux x86_64 t3support2

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Pipe • | Example: Transfer the standard output obtained with cat to grep

GSIC@t3support2:~

[GSIC@t3support2 ~]$ cat /usr/mpi/gcc/openmpi-1.10.4/include/mpi.h | grep INDEX #define MPI_T_ERR_INVALID_INDEX 57 MPI_COMBINER_INDEXED, MPI_COMBINER_HINDEXED_INTEGER, MPI_COMBINER_HINDEXED, MPI_COMBINER_INDEXED_BLOCK, MPI_COMBINER_HINDEXED_BLOCK

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Redirection • > Create the stdout obtained with ls to ls.txt. • >> Append the stdout obtained with ls to ls.txt.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ls Desktop hoge [GSIC@t3support2 ~]$ ls > ls.txt [GSIC@t3support2 ~]$ cat ls.txt Desktop hoge [GSIC@t3support2 ~]$ ls >> ls.txt [GSIC@t3support2 ~]$ cat ls.txt Desktop hoge Desktop hoge ls.txt

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Here document • Transfer data from standard output to command (program)

– Input from file

– Input from standard input

GSIC@t3support2:~

[GSIC@t3support2 ~]$ a.out < input.dat

File Edit View Help

GSIC@t3support2:~

[GSIC@t3support2 ~]$ a.out << EndOfFile 100 EndOfFile $

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Background execution • Command (program) which takes longer time in execution • In order to do another task on the same terminal after starting

a program. → Execute the program as a background job

• To execute command, add “&” at the end of command.

GSIC@t3support2:~

[GSIC@t3support2 ~]$ find . –name xinit –print & [1] 53254

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Process • Process is execution unit of processing on OS

– The following example shows three processes running.

GSIC@t3support2:~

GSICUSER00@r6i3n2:~> top PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 354797 hpe_use+ 20 0 49.897g 456836 408116 R 14.286 0.173 0:02.09 pmemd.cuda.MPI 354798 hpe_use+ 20 0 49.897g 453680 407172 R 14.286 0.172 0:02.08 pmemd.cuda.MPI 3207 hpe_use+ 20 0 425428 60592 1356 S 2.640 0.092 30:26.49 a.out

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Job • A job is a shell execution unit that combines commands /

programs – Even when a command is connected by a pipe or the like, it is called a

job. – jobs command to check running jobs with jobs command

GSIC@t3support2:~

[GSIC@t3support2 ~]$ sleep 30 & [1] 3423 [GSIC@t3support2 ~]$ jobs [1]+ Running sleep 30 & [GSIC@t3support2 ~]$

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Exercise • Let's use the commands that have learned so far.

cd mkdir lesson cd lesson cp /gs/hs0/soudan/UNIX/* ./ cp sample.sh sample.txt file sample.txt vi sample.txt

• Please edit somewhere appropriately in a file with vi

:wq (save and quit) diff sample.sh sample.txt sdiff sample.sh sample.txt

Tokyo Institute of Technology Global Scientific Information and Computing Center

Program execution • module command to set environment • Compilation • Linking library • Manuals for compiling • Executing a program • Runtime environment • Program Execution • Batch job • Resource types • Tool utilization • Process information gathering commands

Tokyo Institute of Technology Global Scientific Information and Computing Center

module command to set environment

• Read the execution environment of the application you want to use with the module command. It needs to be done before executing the application.

• Example (Intel Compiler): $ module load intel

• The following command to browse configurable modules $ module avail

• Depending on the module, it may be necessary to load related modules. For example, since the gromacs module depends on the intel-mpi module, loading of both modules is necessary.

• When the module command itself does not work, run $ . /etc/profile.d/modules.sh

Tokyo Institute of Technology Global Scientific Information and Computing Center

Compilation • Available compilers

Compiler name GNU PGI Intel

FORTRAN gfortran pgfortran ifort

C/C++ gcc/g++ pgc/pgc++ icc/icpc

MPI ○ ○ ○

openMP -fopenmp -mp -qopenmp

Auto-parallel - -Mconcur -parallel

High speed option - -fastsse -fast

-fast -Ofast

Version 4.8.5 17.5-0 16.0.4.258 17.0.4.196

Tokyo Institute of Technology Global Scientific Information and Computing Center

Compilation (Basic formats) • Example 1. C program “pi.c”

$ gcc pi.c or $ icc pi.c $pgcc pi.c

• Example 2. Explicit specification of execution object file $ gcc -o addition addition.c

• Example 3. Specification of a library (openMP) $ g++ thred.c –pthread

• 例4. In the case of "sample.f" using MPI and OpenMP $ mpifort –openmp -o sample sample.f

Tokyo Institute of Technology Global Scientific Information and Computing Center

Linking library • Specifying library name in option while linking

→ Search and link to archive files • Linking lib***.a library

→ specify after -l option like -l***

• Example 1. Link “libm.a” to fortran, C program $ ifort sample.f –lm $ icc sample.c –lm

• Example 2. link libblas.a located in specific location $ ifort sample.f –L~/BLAS/lib -lblas

• Example 3. link numerical computing library $ module load intel $ ifort -o sample -fast sample.f wclock.o -lmkl_blacs_lp64 -L$MKLROOT/lib/intel64/lib/intel64

Tokyo Institute of Technology Global Scientific Information and Computing Center

Manuals for compiling • DocumentsManuals for compiling • provided by developers

– INTEL https://www.xlsoft.com/jp/products/intel/tech/documents.html?tab=1#doc-psxe – PGI http://www.softek.co.jp/SPG/Pgi/document.html

Tokyo Institute of Technology Global Scientific Information and Computing Center

Runtime environment • JOB submission

– A resource type is shared by multiple users (except for f_node). CPU, memory, etc. are secured for each resource type, but the scratch area is shared. – Utilization of group disks Home directory capacity is only 25 GB.

Tokyo Institute of Technology Global Scientific Information and Computing Center

Program Execution (confirmation) • Example 1. Execute Fortran program "sample" with 1 CPU

$ ./sample

• Example 2. Execution of MPI execution file "sample" with 2 CPU

$ mpirun -np 2 ./sample

• Example 3. Execution of OpenMP execution file "sample" with 2 CPU

$ export OMP_NUM_THREADS=2 $ ./sample

• Example 4. Execution of pthread execution file "sample" with 2 CPU

$ export NCPUS=2 $ ./sample

Tokyo Institute of Technology Global Scientific Information and Computing Center

Batch job • Univa Grid Engine (UGE) is installed as job scheduler.

Compute node Login node Admin node

Tokyo Institute of Technology Global Scientific Information and Computing Center

Resource types • There are six resource types. SSH connection is available only

for f_node. • Combination of resource types is impossible. • Up to 72 same resource types can be run within 24 hours.

*Unlike in T2.5, not specifying a queue but specifying a resource type.

Resource initial Resource type # of CPU Memory (GB) # of GPU

F f_node 28 240 4 H h_node 14 120 2 Q q_node 7 60 1 C1 s_core 1 7.5 0 C4 q_core 4 30 0 G1 s_gpu 2 15 1

Tokyo Institute of Technology Global Scientific Information and Computing Center

Program Execution(Shell creation) • Creation of job script for executing in batch Refer to TSUBAME3.0 User’s Guide. http://www.t3.gsic.titech.ac.jp/docs/TSUBAME3.0_Users_Guide_en.html

#!/bin/bash #$ -p -5 #$ -cwd #$ -N parallel_test_job #$ -l f_node=2 #$ -l h_rt=0:10:0 . /etc/profile.d/modules.sh module load openmpi ./a.out

Tokyo Institute of Technology Global Scientific Information and Computing Center

Program Execution (Batch execution) • qsub -l resource_type -l reserve_time -g TSUBAME_group file.sh Refer to TSUBAME3.0 User’s Guide. http://www.t3.gsic.titech.ac.jp/docs/TSUBAME3.0_Users_Guide_en.html

※Unlike T2.5, run this command without specifying any options about resources.

GSIC@t3support2:~

[GSICUSE@t3support2 ~]$ qsub –g sample.sh #For trial, submit a job without –g option. Note that the limitation to a job execution is within 10min and 2 nodes. [GSICUSE@t3support2 ~]$ qsub sample.sh #Interactive execution using f_node as resource type [GSICUSE@t3support2 ~]$ qrsh –g GSIC –l f_node=1 –l h_rt=8:00:0

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Confirmation of batch queues • Confirm that the job(s) has been submitted with qstat.

• Delete the running job with qdel

GSIC@t3support2:~

GSICUSER00@login0:~> qstat job-ID prior name user state submit/start at queue jclass slots ja-task-ID ---------------------------------------------------------------------------------------------------- 93501 0.55500 PDF GSICUSER00 r 10/04/2017 07:39:58 all.q@r2i4n6 56 93578 0.55500 QRLOGIN GSICUSER00 r 10/04/2017 11:39:58 all.q@r6i3n2 28

File Edit View Help

GSIC@t3support2:~

GSICUSER00@login0:~> qdel 93578 GSICUSER00@login0:~> qstat GSICUSER00@login0:~>

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

The size of a running program • Command to measure the memory size of running programs ps aux, top *Press q key to stop top command.

GSIC@t3support2:~

GSICUSER00@r6i3n2:~> ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND GSICUSER00 354797 13.2 0.1 52321684 490304 pts/1 Rl 13:19 0:02 pmemd.cuda.MPI GSICUSER00 354798 13.2 0.1 52321348 487148 pts/1 Rl 13:19 0:02 pmemd.cuda.MPI GSICUSER00@r6i3n2:~> top PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 354797 hpe_use+ 20 0 49.897g 456836 408116 R 14.286 0.173 0:02.09 pmemd.cuda.MPI 354798 hpe_use+ 20 0 49.897g 453680 407172 R 14.286 0.172 0:02.08 pmemd.cuda.MPI

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Force stop a program • Confirm the process ID of a running program.

Use either ps or top command. (the example is shown below.)

• Execute kill command to stop the process.

GSIC@t3support2:~

GSICUSER00@r6i3n2:~> ps aux | grep GSICUSER00 354797 13.2 0.1 52321684 490304 pts/1 Rl 13:19 0:02 pmemd.cuda.MPI -O -i input -p top -o test 354798 13.2 0.1 52321348 487148 pts/1 Rl 13:19 0:02 pmemd.cuda.MPI -O -i input -p top -o test GSICUSER00@r6i3n2:~> top 354797 hpe_use+ 20 0 49.897g 456836 408116 R 14.286 0.173 0:02.09 pmemd.cuda.MPI 354798 hpe_use+ 20 0 49.897g 453680 407172 R 14.286 0.172 0:02.08 pmemd.cuda.MPI

File Edit View Help

GSIC@t3support2:~

GSICUSER00@r6i3n2:~> kill 354797 354798 #If it was not killed, use -9 option. GSICUSER00@r6i3n2:~> kill -9 354797 354798

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Process information gathering commands (1)

• Display the users logging in -> who command • Display status of the users logging in -> w command

GSIC@t3support2:~

[GSICUSE@t3support2 ~]$ who GSIC pts/5 2017-09-06 10:52 (:1) GSIC pts/6 2017-09-06 11:22 (:1) TEST pts/2 2017-09-07 10:05 (192.168.111.63) GSICUSE pts/7 2017-10-03 12:30 (:2) GSICUSE pts/3 2017-10-04 12:37 (192.168.111.63) [GSICUSE@t3support2 ~]$ w 12:39:20 up 51 days, 3:29, 12 users, load average: 1.00, 1.01, 1.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT GSIC pts/5 :1 0611月10 ?xdm? 22days 22.80s gdm-session-worker GSIC pts/6 :1 0611月10 41days 0.25s 10:00 /usr/libexec/ TEST pts/2 192.168.111.63 06 9月17 4days 1.26s 1.26s -bash GSICUSE pts/7 :2 火12 24:09m 0.05s 0.05s bash GSICUSE pts/3 192.168.111.62 12:37 0.00s 0.04s 0.00s w

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Process information gathering commands (2)

• Display the status of a node -> top command

• Display running processes -> ps command

GSIC@t3support2:~

[GSIC@t3support2 ~]$ top Tasks: 784 total, 1 running, 781 sleeping, 2 stopped, 0 zombie %Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem: 26377451+total, 14203016 used, 24957150+free, 3352 buffers KiB Swap: 0 total, 0 used, 0 free. 10473748 cached Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 225488 root 20 0 371260 20796 4816 S 2.990 0.008 118:58.30 nv-hostengine 1111 root 20 0 110076 66204 61604 S 0.332 0.025 0:19.26 systemd-journal

File Edit View Help

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ps aux [GSIC@t3support2 ~]$ ps aux | grep ps aux | grep 1111 root 1111 0.0 0.0 110076 66224 ? Ss Sep28 0:19 /usr/lib/systemd/systemd-journald GSIC 352412 0.0 0.0 10540 1640 pts/0 S+ 12:29 0:00 grep --color=auto 1111

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

User environment • Shell • Environment variables • HISTSIZE shell variable • PATH variable • TCP/IP

Tokyo Institute of Technology Global Scientific Information and Computing Center

Shell • Environment where a command can be executed is called shell. • Environment can be changed according to user’s preference. • The major compatible shells which TSUBAME3 supports, which

available with chsh command, are as follows: – /bin/bash – /bin/csh – /bin/sh – /bin/ksh – /bin/tcsh – /bin/zsh

• Specify full path of the shell to use as follows. • Reflect the change is

– $ chsh /bin/tcsh

Tokyo Institute of Technology Global Scientific Information and Computing Center

Environment variables • Login shell is bash (chsh to change shell)

• The order of profiles (configuration files) read when logging in /etc/profile and /etc/bashrc ~/.bash_profile ~/.bash_login (if ~/.bash_profile is not exist)

• Editing the personal configuration file ~/.bashrc • PATH="/usr/games:$PATH“ • export PATH

• After editing, re-login or execute “source .bashrc” to reflect. • It is preferable to write alias here. • In case of editing files, check properly before updating. • Check in a new terminal.

Tokyo Institute of Technology Global Scientific Information and Computing Center

HISTSIZE shell variable • History function

– Stores a predetermined number of commands most recently. – It can be useful when executing the same (or similar) command. – The number of history to be stored can be set arbitrarily.

• Examples – $ export HISTSIZE=600 ⇒ History size will be set 500 – $ history 3 ⇒ Shows 3 items in history list

534 cd 535 ls 536 history 3

Tokyo Institute of Technology Global Scientific Information and Computing Center

PATH variable • Sets the location of command. • The setting sometimes needs to be modified for example when a

command or a program are installed or created by an individual.

※ If it is described in .bashrc, it will be always enabled.

GSIC@t3support2:~

[GSIC@t3support2 Program]$ ls a.out [GSIC@t3support2 Program]$ a.out If 'a.out' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf a.out [GSIC@t3support2 Program]$ PATH=$PATH:. [GSIC@t3support2 Program]$ a.out 14digit@M_PI=3.14159265358979 [GSIC@t3support2 Program]$

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

TCP/lP • Transmission Control Protocol and lnternet Protocol • Standard protocols to be used in internet and intranet.

– Invented in the process of developing a computer network in the experiment by the US Department of Defense that does not stop entirely even if partially destroyed by nuclear attacks.

• Protocol – A set of mutually determined agreements when computers

communicate with each other via a network.

Tokyo Institute of Technology Global Scientific Information and Computing Center

Main services of UNIX • Main services on UNIX • File transfer • File transfer examples (rsync/sftp/scp) • Example of ssh • Characteristics of X-window system • Client / Server ==== The following are not mentioned in this workshop === • E-mail • Web client • NIS (Network Information Service) • DNS (Domain Name System) • NFS (Network File System)

Tokyo Institute of Technology Global Scientific Information and Computing Center

File transfer • A system connected via a network is called a host in TCP/IP. • Between hosts, it is easy to transfer files of each other's hosts. • Commands for the function

– ftp, rcp, rsync, sftp, scp

• rsync, sftp, scp is available in TSUBAME3.

Tokyo Institute of Technology Global Scientific Information and Computing Center

Examples of rsync/sftp/scp GSIC@t3support2:~

#rsync [GSIC@t3support2 ~]$ rsync -av --progress -e "ssh -i .ssh/ecdsa -l GSICUSER00" login.t3.gsic.titech.ac.jp:/gs/hs0/soudan/UNIX/testfile ./ receiving incremental file list testfile 990 100% 966.80kB/s 0:00:00 (xfer#1, to-check=0/1) sent 42 bytes received 1078 bytes 2240.00 bytes/sec total size is 990 speedup is 0.88 [GSIC@t3support2 ~]$ #sftp [GSIC@t3support2 ~]$ sftp -i ~/.ssh/ecdsa [email protected] Connected to login.t3.gsic.titech.ac.jp. sftp> get /gs/hs0/soudan/UNIX/testfile Fetching /gs/hs0/soudan/UNIX/testfile to testfile /gs/hs0/soudan/UNIX/testfile sftp> exit #scp [GSIC@t3support2 ~]$ scp -i ~/.ssh/ecdsa [email protected]:/gs/hs0/soudan/UNIX/testfile . testfile

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Example of ssh • login to TSUBAME3 with login name (GSIC→GSCIUSER)

• login to TSUBAME3 as the same login name (GSCIUSER→GSCIUSER)

GSIC@t3support2:~

[GSIC@t3support2 ~]$ ssh login.t3.gsic.titech.ac.jp -l GSICUSER00 -i ~/.ssh/ecdsa Last login: Tue Oct 3 09:26:54 2017 from 131.112.3.100 GSICUSER00@login0:~> GSICUSER00@login0:~> top GSICUSER00@login0:~> exit

File Edit View Help

GSIC@t3support2:~

[GSICUSER00@t3support2 ~]$ ssh login.t3.gsic.titech.ac.jp -i ~/.ssh/ecdsa Last login: Tue Oct 4 09:26:54 2017 from 131.112.3.100 GSICUSER00@login0:~> GSICUSER00@login0:~> top GSICUSER00@login0:~> exit

File Edit View Help

Tokyo Institute of Technology Global Scientific Information and Computing Center

Characteristics of X-Window system • Used in various operating systems including UNIX. • Developed at US MIT • Hardware independent

– Standard loading in Linux/Mac – lots of software for Windows

• Cygwin • MobaXterm • PuTTY/Tera Term/RLogin+VcXsrv/Xming

Tokyo Institute of Technology Global Scientific Information and Computing Center

Client / Server • Running X-Window applications

→ Client program, server program

• X protocol, unique communication procedure → Data exchange between client/server

• Server side (Displayed side) Definition to allow display request from system % xhost +client_host_name • Client side (Displaying side) Specifies DISPLAY environment variables. % export DISPLAY=server_host_name