Intermediate Linux
Total Page:16
File Type:pdf, Size:1020Kb
Intermediate Linux th st !!***May subroutine 30 mpi_utils_step_parallel_edge– 31 , 2016 implicit none integer ele, ierr do ele = 1, nfaces Lecturerscall mpi_isend(commvec(ele)%field1(commvec(ele)%out_i1, (in alphabetical order): & & commvec(ele)%out_j1, & Jaakko& Leinonen commvec(ele)%out_k1), & Tomasz& 1, commvec(ele)%mpi_type_out1,Malkiewicz & & commvec(ele)%to_id, commvec(ele)%to_id, & Thomas& MPI_COMM_WORLD, Zwinger send_reqs(ele), ierr) if(ierr /= MPI_SUCCESS) then call pio_abort(ierr) end if call mpi_isend(commvec(ele)%field2(commvec(ele)%out_i2, & & commvec(ele)%out_j2, & & commvec(ele)%out_k2), & & 1, commvec(ele)%mpi_type_out2, & & commvec(ele)%to_id, commvec(ele)%to_id+tag_offset, & & MPI_COMM_WORLD, send_reqs(nfaces+ele), ierr) if(ierr /= MPI_SUCCESS) then call pio_abort(ierr) end if end do #ifdef NONBLOCK do ele = 1, nfaces All material (C) 2016 by the authors. call mpi_irecv(commvec(ele)%field1(commvec(ele)%in_i1, & This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported & commvec(ele)%in_j1, & 1 License, http://creativecommons.org/licenses/by-nc-sa/3.0/ 2 & commvec(ele)%in_k1), & & 1, commvec(ele)%mpi_type_in1, & Program, May 30th 09:30 – 10:00 Morning coffee & registration 10:00 – 10:15 Introduction to the course (whereabouts, etc.) 10:15 – 10:45 Recapping Introduction to Linux (to refresh memory) 10:45 – 11:30 Basic concepts of shells 11:30 – 12:30 Lunch 12:30 – 14:30 Working with the Bash shell 14:30 – 15:00 Coffee 15:00 – 15:45 Bash job management and signals About This Course 15:45 – 16:30 Hands-on exercises & Troubleshooter: Interactive session to deal with open questions and specific problems 3 4 Program, May 31st How We Teach 09:00 – 10:00 Pipes, named pipes and redirecting All topics are presented with interactive demonstrations. 10:00 – 10:30 Coffee – Please, indicate immediately, if pace is too fast. We want to have 10:30 – 12:00 Shell commands and utilities everyone with us all the time. 12:00 – 13:00 Lunch Additionally, exercises to each of the sections will be provided. 13:00 – 14:00 Pattern matching and regular expressions 14:00 – 14:30 Coffee The Troubleshooter section is meant for personal interaction and is 14:30 – 15:00 Software and revision control (SVN & Git) (with a time-limit to 16:30 or 16:00) kept in an open end style. 15:00 – 16:00 Hands-on exercises & Troubleshooter: Interactive session to deal with open questions and specific problems 5 6 Around CSC Practicalities B1 (102,103) Kamppi Keep the name tag visible. B2 (194/5,503/4/… Pasila,… Lunch is served in the same building. – Room will be locked during lunch but lobby is open, use the lockers. Toilets are in the lobby. B2 Restaurant You are Network: here – Wi-Fi: eduroam, HAKA authentication (Training – Ethernet cables on the tables CSC room) – CSC-Guest accounts upon request B1 Transportation: – Bus stops to Kamppi/Center are located at the other side of the street (102, 103). – Bus stops to Center/Pasila are on this side, towards the bridge (194, 195, 503-6). Restaurant – To arrive at CSC the stops are at the same positions, just on opposite sides on the street. – If you came by car: parking is being monitored – ask for a temporary parking permit from the reception (tell which workshop you’re participating). Visiting outside: the doors by the reception desks are open. Username and password for workstations: given on-site. (K4 Salad bar) (THINK restaurant) 7 8 What Is a Shell? "A shell in computing provides a user interface for access to an operating system’s kernel services." (Wikipedia) Remote login: – Normally no GUI (Graphical User Interface) – Text shell: Terminal with a set of commands Different flavours: – bash (default), tcsh (old default), zsh, corn-shell, … The basics (recapping earlier course) 9 10 What Is a Command? Listing of Directories A command is a small program provided by the shell Print contents of a directory or information on a file The over-all structure of a command is: Detailed list of directory: command -option [optional input] $ ls –lthr /etc/ Example:”$” is not part of the command, but depicts the command prompt – -l displays additional information (detailed list in Windows) $ ls –lsh /etc/init.d (we will see later) – -h displays size in human readable format Case sensitive? Try: – -t orders by date (use -r to reverse order, i.e., oldest first) $ Ls –lsh /etc/init.d – -d keeps from going into sub-directories How to find a command? Only print directory/filenames matching a wildcard expression: $ apropos list $ ls -d /etc/*.d How to find all options? Only print directory/filenames with a 4 char suffix: $ man ls $ ls –l /etc/*.???? 11 12 Moving Around in Directories Creating and (Re-)Moving Directories Change directory: $ cd /etc/ Make a new directory: $ mkdir test1 Print work directory: $ pwd – Recursively: $ mkdir -p test2/anotherone Go to subdirectory: $ cd ./init.d Moving a directory: $ mv test2 test3 Relative path: $ cd ../ Removing a directory: $ rmdir test2/anotherone Absolute path: $ cd /etc/init.d – Recursively: $ rmdir -p test3/anotherone Combination: $ cd ../../usr Where is home: $ cd or cd ~/ 13 14 Creating/Copying/(Re-)Moving Files File Permissions Copy a file: $ cp mytest.txt othertest2.txt UNIX distinguishes between users, groups and others – Recursively: $ cp -r test test2 – Check your groups: $ groups Move a file (renaming): $ mv mytest.txt othertest3.txt Each user belongs to at least one group Remove file(s): $ rm –f mytest.txt To displays the attributes of a file or directory: – Recursively: $ rm –r test2 $ ls -l name -rw-r--r-- 1 userid groupid 0 Jan 29 11:04 name type group user others Size of file (usually in bytes) Number of references from file system r = read, w = write, x = execute The above configuration means: user can read + write, group and all others only read 15 16 File Permissions (cont'd) Finding Stuff Changing permissions with chmod: The hard way: cd yourself through the tree and ls $ ls -l lala The elegant way: -rw-r--r-- 1 userid groupid 0 Jan 29 11:04 lala $ find /etc -name "*.conf" -print $ chmod o-r,g+w,u+x lala $ ls –l lala – Finds all config files in the /etc tree -rwxrw---- 1 userid groupid 0 Jan 29 11:04 lala The alternative: $ chmod u-xrw lala $ locate *.conf $ less lala 17 18 Finding Stuff (cont'd) Managing Space Finding expressions inside files: How much space is left on my filesystem? – For instance, we want to know all files in the directory /etc/init.d that $ df -h contain keyword "network": Filesystem Size Used Avail Use% Mounted on /dev/sda5 22G 20G 903M 96% / $ grep network /etc/init.d/* /dev/sda1 447M 27M 396M 7% /boot .host:/ 12G 8.0G 4.1G 66% /mnt/hgfs – Or recursively: $ grep -r network /etc – Getting rid of noise: What are the sub-directories that consume the most disk-space? $ grep -r network /etc 2 >/dev/null $ du -sh ./* 1.4M bin Piping of output: 6.3M core 44K Desktop – Instead of re-directing into files, output can be piped in a chain of 696M Documents 1.2G Downloads commands: … $ grep –r network /etc 2> /dev/null| grep start| less 19 20 Login Remote Copying Only secure connections (no telnet, rlogin) are recommended scp is like cp, but used for remote transfer Quotes are Secure Shell (SSH): $ scp lala [email protected]:'$HOME' important here $ ssh [email protected] -X rsync works local as well as remotely and helps to keep two – Option -X tunnels the graphical output or alternatively -Y, e.g. (remote) directories in sync: $ ssh [email protected] -Y $ mv lala test $ rsync –avt test/ test2 – This syncs everything in test with test2 – Important: Do not drop trailing / – Remotely: $ rsync –avt test [email protected]:'$HOME' 21 22 (De-)compressing files Archives of Files GNU zip: Most common: tar (tape archive) – To inflate: – Take whole sub-tree and make a single compressed file $ gunzip hello-2.7.tar.gz $ tar cvzf myfirsttarfile.tar.gz /etc/init.d – To compress: . c create new archive $ gzip hello-2.7.tar . v be verbose BZIP (Bzip2): bzip2, bunzip2 . z gzip simultaneously ZIP: . f target file – To compress: $ zip myvar.zip myvariables.txt – Check contents (and simultaneously gunzip) $ tar tvzf hello-2.7.tar.gz – Listing: $ unzip –l myvar.zip – Unpack (and simultaneously gunzip): – To inflate: $ unzip myvar.zip $ tar xvzf hello-2.7.tar.gz 23 24 What is shell? Command interpreter between machine and human, a basic user interface to a computer running Unix Different flavors – bash – tcsh – zsh – corn-shell, … Basic concepts of shells 25 26 Shell vs Terminal / Console Shell concept A shell is a program which provides the traditional, text- Shell is mandatory by POSIX specification only user interface for Linux (and other Unix like systems) Reads in a typed command terminated by Enter and then parses it Shell’s primary function is to read commands that are typed into a console or terminal window and then execute them Commands may be built-ins or executable applications Commands may contain options and/or arguments Terminal - a wrapper program which runs a shell Console – special sort of terminal, used for direct communication at a low level with the operating system 27 28 Shell commands Commands cont. Structure of a command: A command is an instruction given by a user telling a computer to do something, e.g.: command -option [optional input] – run a single program – run a group of linked programs Examples: – whoami Commands are generally issued by typing them in at the command line and then pressing the ENTER key, which – ls –l passes them to the shell – file skype 29 30 Programs Bash Command-line programs De-facto standard shell on most Unix-like operating systems Examples: Can generally be found everywhere – gnuplot – cal GNU project's Bourne Again SHell Open source – Bash implements essentially the same grammar, parameter and – gimp variable expansion, redirection, and quoting as the Bourne Shell – gnumeric Closed source – Main differences between Bash and Bourne: – skype .