Introduction to the Linux Command Line for High-Performance Computing Dr. Charles J Antonelli LSAIT ARS October, 2014.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Introduction to UNIX CSE 2031 Fall May 2015.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
Introduction to Linux and Shell Scripting Jacob Chan.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Introduction to UNIX/Linux Exercises Dan Stanzione.
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
1 Intro to Linux - getting around HPC systems Himanshu Chhetri.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Introduction to the Linux Command Line for High-Performance Computing Dr. Charles J Antonelli LSAIT ARS May, 2014.
Introduction to Programming Using C An Introduction to Operating Systems.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
The Unix File sytem. Introduction Tree structure …
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Overview of Linux Fall 2016 Dr. Donghyun Kim
GRID COMPUTING.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
CS1010: Intro Workshop.
Web Programming Essentials:
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
C151 Multi-User Operating Systems
Introduction to Linux Dr Karina Kubiak - Ossowska
The Linux Operating System
CSE 374 Programming Concepts & Tools
Tutorial of Unix Command & shell scriptS 5027
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
College of Engineering
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Andy Wang Object Oriented Programming in C++ COP 3330
CSE 303 Concepts and Tools for Software Development
Linux Commands LINUX COMMANDS.
Working in The IITJ HPC System
Presentation transcript:

Introduction to the Linux Command Line for High-Performance Computing Dr. Charles J Antonelli LSAIT ARS October, 2014

Roadmap Linux overview The command shell Navigating the filesystem Basic commands & wildcarding Shell redirection & pipelining Editing text files PermissionsProcesses 10/14cja 20142

Poll How many here to learn the command line For HPC, specifically Flux, work? For other computing cluster work? For desktops/other Linux/Unix/Mac OS X? Other? 10/14cja 20143

Course Text William E Shotts, Jr., “The Linux Command Line: A Complete Introduction,” No Starch Press, January Download Creative Commons Licensed version athttp://downloads.sourceforge.net/project/linuxcomma nd/TLCL/13.07/TLCL pdf. nd/TLCL/13.07/TLCL pdfhttp://downloads.sourceforge.net/project/linuxcomma nd/TLCL/13.07/TLCL pdf 10/14cja 20144

Linux Overview 10/14cja 20145

A compute node 12 Intel cores 48 GB RAM Local disk Network 10/14cja 20146

10/14 cja 20147

The command shell 10/14cja 20148

The command line A basic way of interacting with a Linux system Execute commands Create files and directories Edit file content Access the web Copy files to and from other hosts Run HPC jobs … do things you can’t do from the conventional point- and-click Graphical User Interface (GUI) 10/14cja 20149

Why command line? 1.Linux was designed for the command line 2.You can create new Linux commands using the command line, without programming 3.Many systems provide only the command line, or poorly support a GUI interface Such as most HPC systems Such as most HPC systems 4.Many things can be accomplished only through the command line Much systems administration & troubleshooting Much systems administration & troubleshooting 5.You want to be cool 10/14cja

The command shell The command shell is an application that reads command lines from the keyboard and passes them to the Linux operating system to be executed When you login to a remote Linux system using a tool like ssh, you will automatically be connected to a shell On your desktop, laptop, or tablet, you may have to find and execute a terminal emulator application to bring up a shell in a window 10/14cja

The command shell 10/14 cja

Types of shells Standard Linux shell (used in this course) bash“Bourne-again” shell Other shells shBourne shell, original AT&T Unix shell csh“C shell”, common on older Unix systems tcsh“Enhanced C shell”, better version of csh What shell am I using? echo $SHELL 10/14cja

Connecting via ssh Terminal emulators Linux and Mac OS X Start Terminal Use ssh command Windows U-M PuTTY/WinSCP (U-M Blue Disc) PuTTY SSH Secure Shell (deprecated) 10/14cja

Lab 0 Task: Start a local shell on Mac OS X 1.Login to Mac OS X with your uniqname and Kerberos password 2.If there is a Terminal icon in the Dock, double-click it Otherwise: a.Bring up a Finder window: Click on the desktop, type Command-N b.Start the Terminal Application: In the Finder window, click on Applications on the left, scroll down on the right until you find the Utilities folder, double-click on the Utilities folder, scroll down on the right until you find the Terminal application, double-click it 3.This creates a Terminal window with a shell running inside it 4.From a Terminal window, Command-N will start a new Terminal 10/14cja

Lab 0 10/14cja

The shell prompt The “~$ “ is the shell prompt This means the shell is waiting for you to type something Format can vary, usually ends with “$”, “%” or “#” If $ or %, you have a normal shell This shell has your privileges If #, you have a so-called “root shell” This shell has administrator privileges You can do a great deal of irreversible damage You can do a great deal of irreversible damage 10/14cja

Typing into the shell Basic input line editing commands Backspace erases previous character Left and right arrow move insertion point on the line Control-U erases the line so you can start over Enter executes the line you typed Control-C interrupts whatever command you started and returns you to the shell prompt (usually) Up and down arrow will access your command history Type “ exit ” without the quotes to exit the shell Click the red "close" icon at the top of the Terminal window to close it 10/14cja

Lab 1 Task: Enter some basic commands ~$ date ~$ id ~$ ps ~$ df -kh ~$ who ~$ top# type Control-C to exit 10/14cja

Interlude: Flux 10/14cja

Flux Flux is a university-wide shared computational discovery / high-performance computing service. Interdisciplinary Provided by Advanced Research Computing at U-M (ARC) Operated by CAEN HPC Hardware procurement, software licensing, billing support by U-M ITS Used across campus Collaborative since 2010 Advanced Research Computing at U-M (ARC) College of Engineering’s IT Group (CAEN) Information and Technology Services Medical School College of Literature, Science, and the Arts School of Information 10/14 cja

The Flux cluster … 10/14cja

A Flux node 12 Intel cores 48 GB RAM Local disk Network 10/14cja

Logging in to Flux ssh flux-login.engin.umich.edu MToken (or Software Token) required You will be randomly connected a Flux login node Currently flux-login1 or flux-login2 Firewalls restrict access to flux-login. To connect successfully, either Physically connect your ssh client platform to the U-M campus wired or MWireless network, or Use VPN software on your client platform, or Use ssh to login to an ITS login node (login.itd.umich.edu), and ssh to flux-login from there 10/14cja

A shell on a login node Now you have a shell on the login node Your shell prompt has changed to something like [flux-login1 ~]$ Try those simple commands here! Flux is for HPC work The login nodes are reserved for copying data, editing and compiling programs and scripts, and short test runs For HPC computation, you should run on the compute nodes A batch job will always run on the compute nodes An interactive batch job will get you a shell on a compute node 10/14cja

A shell on a compute node Getting a shell on a compute node Enter this command on the login node: [flux-login1 ~] $ ~cja/hpc100/getshell After a short delay, you’ll get an interactive shell: qsub: waiting for job nyx.engin.umich.edu to start qsub: job nyx.engin.umich.edu ready [nyx5509 ~]$ You can type commands into this shell for all of our in-class experiments Type “exit” to exit this shell After two hours, your interactive shell will be killed 10/14cja

Navigating the filesystem 10/14cja

Linux Filesystem Concepts Files are stored in a directory Directories may contain other directories as well as files A hierarchy of these directories is called a directory tree A directory tree (a connected graph with no cycles) has a single topmost root directory A directory tree rooted at the system root directory “ / ” is called a filesystem 10/14cja

10/14 cja

Linux Filesystem Concepts A file is accessed using its path name Absolute path name /dir1/dir2/…/dirn/filename/usr/X11R6/bin Relative path name current-working-directory/filenamebin Every shell maintains a notion of a current working directory Initialized at login to your home directory Changed via cd command Two special directories. refers to the current directory.. refers to the current directory’s parent directory 10/14cja

Basic commands 10/14cja

Prerequisites Some fundamental commands: ~$ file file# what kind of file is file? ~$ cat file# display contents of text file ~$ less file# paginate text file ~$ man command# get info about command Exercise: figure out how to make the date command display the date in Coordinated Universal Time (UTC) 10/14cja

Lab 2 Task: navigate the file system Commands: ~$ cd # make your home directory the current working directory ~$ pwd# print working directory ~$ mkdir foo# create directory foo ~$ cd foo# cd to the foo directory ~$ mkdir bar# create directory bar ~$ cd..# cd back to the foo directory ~$ tree# display foo’s directory tree 10/14cja

Navigating the filesystem Some fundamental commands: ~$ pwd# print working directory ~$ cd dir# make dir the current working directory ~$ cd # cd to your home dir ~$ cd ~cja# cd to cja’s home dir ~$ mkdir dir# create directory dir ~$ rmdir dir# remove (empty) directory dir ~$ tree# display dir tree 10/14cja

Listing info on files ls – list information about files ~$ ls # list contents of cur dir ~$ ls dir# list contents of dir ~$ ls –l# list details of files in cur dir including access, owner & group, size, and last-modified time ~$ ls –t# list newest files first ~$ ls –R dir# list all files in tree dir ~$ ls –lt dir# options can be combined 10/14cja

Working with files These commands manipulate files ~$ mv foo bar# rename file foo to bar ~$ cp foo bar# copy file foo to bar ~$ cp –r dir1 dir2# copy dir tree dir1 to dir2 ~$ cp f1 f2 dir# copy f1 and f2 to directory dir ~$ mkdir dir# create empty directory dir ~$ rmdir dir# remove empty directory dir ~$ rm file# remove file file ~$ rm –r dir# remove directory tree dir 10/14cja

Lab 3 Exercise: Create a directory named tutorial in your home directory. In that directory, create a directory named sample and a directory named test. Create a file named msg in directory test that contains a copy of the file /etc/motd. Extra credit: Make the last-modified time of your copy identical to that of /etc/motd. Hint: look at the options of the copy command 10/14cja

Compressing and archiving These commands compress and archive files ~$ gzip foo# compress foo to foo.gz ~$ gunzip foo# uncompress foo.gz to foo ~$ bzip2 foo# better compress foo to foo.bz2 ~$ bunzip2 foo# uncompress foo.bz2 to foo ~$ tar cf foo.tar bar# archive subtree bar in file foo.tar ~$ tar xf foo.tar# restore archive from file foo.tar ~$ tar zcf foo.tgz bar # archive and compress ~$ tar jcf foo.tjz bar # archive and compress better 10/14cja

Wildcards The shell accepts wildcarded arguments This is also called "shell globbing" Wildcards: ?Matches a single character *Matches zero or more characters [chars]Matches any of the chars [c 1 -c 2 ]Matches chars ‘c 1 ’ through ‘c 2 ’ [^chars]Matches any but the chars ~$ ls foo.?# match files named foo.x, where x is any character ~$ echo *.[cs]# echo files that end in.c or.s ~$ mv [o-z]* save# move files starting with o through z to directory save ~$ echo [^A-Z]?# ??? 10/14cja

Shell redirection & pipelining 10/14cja

Shell redirection A Linux command can have its inputs and outputs redirected ~$ ls >foo# put list of files in current directory into file foo ~$ ls >>bar# add list of files in current directory to end of file foo ~$ sort <bar# sort lines from file bar ~$ sort <<EOF # sort lines entered at keyboard whiskey bravo tango EOF ~$ wc -l ~/mycounts # count number of lines from file /etc/motd and put result in file mycounts in my home directory 10/14cja

More Linux commands More useful Linux tool commands ~$ grep string # show lines of input containing string ~$ tail# show last few lines of input ~$ head# show first few lines of input ~$ sort# sort the input 10/14cja

Shell pipelining A Linux command can have its output connected to the input of another Linux command ~$ ls | wc –l# count files in current directory ~$ last | grep reboot# when did we reboot? Exercise: How many people are running MATLAB on your compute node? 10/14cja

Editing text files 10/14cja

Editing text files Simple editor nano or pico "What you see is what you get” editor Simple to learn if you want to get started quickly Supported editors vi or vim emacs Powerful but more complex If you have time and inclination to become proficient, spend time here 10/14cja

Text files Watch out for source code or data files written on Windows systems Use these tools to analyze and convert source files to Linux format file dos2unix 10/14cja

Permissions 10/14cja

File Permissions Three permission bits, aka mode bits Files: Read, Write, Execute Directories: List, Modify, Search Three user classes User (File Owner), File Group, Other man chmod 10/14cja

File Permissions, examples -rw cja lsait 40 Oct 1 12:03 foo.bz2 file read and write rights for the owner, no access for anyone else chmod u=rw,g=r,o= file -rw-r----- cja lsait 40 Oct 1 12:03 foo.bz2 file read and write rights for the owner, read for members of the lsait group, no access and for others drwxr-x--x cja lsait 4096 Oct 1 12:15 bar list, modify, and search for the owner, list and search for group, and execute only for others 10/14cja

Processes 10/14cja

Processes On Linux, every program runs in a process You can examine these processes man ps ps ps ax top 10/14cja

Processes You can signal a running process To stop it, or "kill" it man kill 10/14cja

Any Questions? Charles J. Antonelli LSAIT Advocacy and Research Support /14cja

References William E Shotts, Jr., “The Linux Command Line: A Complete Introduction,” No Starch Press, January Download Creative Commons Licensed version athttp://downloads.sourceforge.net/project/linuxcommand/TLCL/13.07/TLCL pdf. Licensed /14cja

Extra Task: compile and execute simple programs on the Flux compute node Copy sample code to your login directory: cd cp ~brockp/cac-intro-code.tar.gz. tar -xvzf cac-intro-code.tar.gz cd./cac-intro-code Examine, compile & execute helloworld.f90: ifort -O3 -ipo -no-prec-div -xHost -o f90hello helloworld.f90./f90hello Examine, compile & execute helloworld.c: icc -O3 -ipo -no-prec-div -xHost -o chello helloworld.c./chello Examine, compile & execute MPI parallel code: mpicc -O3 -ipo -no-prec-div -xHost -o c_ex01 c_ex01.c mpirun -np 2./c_ex01 10/14cja