Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Similar documents
Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Introduction: What is Unix?

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Lab Working with Linux Command Line

Linux Command Line Primer. By: Scott Marshall

Introduction to the UNIX command line

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Computer Systems and Architecture

Computer Systems and Architecture

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Unix: Fundamental Commands

Introduction to UNIX command-line

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Introduction to Linux Workshop 1

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

5/20/2007. Touring Essential Programs

Introduction to the Linux Command Line

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

LOG ON TO LINUX AND LOG OFF

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Perl and R Scripting for Biologists

Command Line Interface The basics

CSCI 2132 Software Development. Lecture 4: Files and Directories

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

User Guide Version 2.0

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Arkansas High Performance Computing Center at the University of Arkansas

Scripting Languages Course 1. Diana Trandabăț

Linux Systems Administration Getting Started with Linux

COMS 6100 Class Notes 3

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Week 2 Lecture 3. Unix

The Unix Shell & Shell Scripts

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

A Brief Introduction to Unix

Introduction to Linux

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Operating System Interaction via bash

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Lab 2: Linux/Unix shell

Basic Linux Command Line Interface Guide

Introduction to Supercomputing

CISC 220 fall 2011, set 1: Linux basics

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction to Linux. Fundamentals of Computer Science

The Shell. EOAS Software Carpentry Workshop. September 20th, 2016

Mills HPC Tutorial Series. Linux Basics I

Session 1: Accessing MUGrid and Command Line Basics

Chapter 4. Unix Tutorial. Unix Shell

Getting Started With UNIX Lab Exercises

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Linux at the Command Line Don Johnson of BU IS&T

Linux & Shell Programming 2014

A Brief Introduction to the Linux Shell for Data Science

Introduction to Linux for BlueBEAR. January

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

COSC UNIX. Textbook. Grading Scheme

An Introduction to Cluster Computing Using Newton

Introduction of Linux

Unix Tutorial Haverford Astronomy 2014/2015

Chap2: Operating-System Structures

Basic Linux Command Line Interface Guide

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

LING 408/508: Computational Techniques for Linguists. Lecture 5

Introduction to Unix and Linux. Workshop 1: Directories and Files

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Files and Directories

Linux Tutorial. Ken-ichi Nomura. 3 rd Magics Materials Software Workshop. Gaithersburg Marriott Washingtonian Center November 11-13, 2018

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Linux Shell Script. J. K. Mandal

Files

CS197U: A Hands on Introduction to Unix

Introduction to Linux

Introduction to Linux

Introduction to UNIX command-line II

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Using Linux as a Virtual Machine

Linux Command Line Interface. December 27, 2017

Introduction to Linux

Practical Session 0 Introduction to Linux

Introduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018

CS Fundamentals of Programming II Fall Very Basic UNIX

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Welcome to Linux. Lecture 1.1

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CENG393 Computer Networks Labwork 1

Transcription:

Introduction to Linux Part 1 Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

ssh Login or Interactive Node kingspeak.chpc.utah.edu Batch queue system kp001 kp002. kpxxx

FastX https://www.chpc.utah.edu/documentation/software/fa stx2.php Remote graphical sessions in much more efficient and effective way than simple X forwarding Persistence - can be disconnected from without closing the session, allowing users to resume their sessions from other devices. Licensed by CHPC Desktop clients exist for windows, mac, and linux Web based client option Server installed on all CHPC interactive nodes and the frisco nodes.

Windows alternatives to FastX Need ssh client PuTTY http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html XShell http://www.netsarang.com/download/down_xsh.html For X applications also need X-forwarding tool Xming (use Mesa version as needed for some apps) http://www.straightrunning.com/xmingnotes/ Make sure X forwarding enabled in your ssh client

Linux or Mac Desktop Just need to open up a terminal or console When running applications with graphical interfaces, use ssh -Y

Getting Started - Login Download and install FastX if you like (required on windows unless you already have PuTTY or Xshell installed) If you have a CHPC account: ssh unid@linuxclass.chpc.utah.edu If not get a username and password: ssh userxx@linuxclass.chpc.utah.edu

Shell Basics A Shell is a program that is the interface between you and the operating system (OS e.g, linux) Command line interface CLI versus a GUI or a graphical user interface Type commands on command line, send command by pressing enter, then the computer reads and executes the command and returns the results (NOTE not all commands have output!) When commands are done they return to the PROMPT (more on prompts later) Commands can take flags that modify their behaviour - flags are formed with (dash) and letter Commands can also sometimes require an argument this defines the item upon which the command acts

Additional Shell Basics Linux is case sensitive! We will focus on two basic shells - slightly different command syntax - csh/tcsh - sh/bash (Bourne, Bourne again) While many shell commands are the same between shell types there are syntax and behaviour differences Your account comes with a script that is executed upon login that sets a basic environment for your shell To check which shell you are using: echo $SHELL Note $SHELL is an environmental variable more on these later To change shell for the session - enter name of shell you want at the prompt and hit enter

Other Useful Items Up/down arrows go through past commands history provides list of all recent commands; can! followed by number from history list will put that command at the prompt Tab completion of commands, paths, filenames very useful Can edit previous commands up and down arrow to get to command; then right, left arrow then delete any characters and type in new at cursor; cntrl-a gets to front of command line, cntrl-e to end of command line

Directory Structure / --- refers to the root directory the top level directory that contains all other directories There is a tree directory structure levels are separated by / The home directory is used to refer to a user s base directory this is where you will be upon login If you have a CHPC account this is in /uufs/chpc.utah.edu/common/home/<yourusername> On linuxclass it will be /home/<yourusername> /path/from/root absolute path has leading / path/without/leading/slash relative path from current location. current directory.. parent directory (up one level)

Directory Structure At CHPC --- instead of /home we have /uufs/chpc.utah.edu/common/home under which we have all user directories

Login & Prompts When you first login you will see a prompt (the prompt is set by the login script) [u0028729@kingspeak1 ~]$ [userxx@linuxclass:~]$ When you first login, you will be in your home directory To see your username: whoami To see your current directory: pwd Shortcuts ~yourusername your home directory $HOME your home directory

Exercise Download and install FastX if you do not yet have it on your desktop. Login -- What is your shell? What is your username? What is the path of your current directory?

Basic Directory Commands ls list contents of a directory Flags to change output To see all flags ls --help man ls mkdir make directory (mkdir test) cd move to directory (cd test) cd without an argument moves you back to your home directory cd.. -- moves you up one level rmdir remove directory (rmdir test) more on this later

More on ls flags -l : long -a : All (including hidden files, also called dot files) -r : Reverse ordering while sorting -t : Timestamp

Files & Filenames Within directories you can have other directories and also files Filenames are often name.extension Files that start with a. are hidden or dot files Extensions are useful for telling you what type of file it is IF you follow the conventions (txt, pdf, jpg, etc) The extensions also are used by the OS The file command will tell you the file type Being careful with filenames can make your life easier some guidelines: Do not use white spaces or other special characters in names as you will have to handle these differently

Login Scripts & Environmental Variables In your home directory are a a number of dot files -.bashrc and.custom.sh,.tcshrc and.custom.csh Depending on your shell choice, the appropriate pairof these are executed during login. These set the environment (as environmental variables) needed for you to work on CHPC resources Commands to check your environment: env or printenv

cat display contents of file File commands more display contents of file with page breaks (next page with Space key) can also look at less head display top of file (default is 10 lines, change with -n) tail display end of file (default is 10 lines, change with -n) grep search for pattern in file (grep pattern test1) vi edit file (more on this later) cp copies file to a new name (cp file1 file2) mv renames file to a new file (mv old new) touch creates an empty file if file does not exist OR changes time stamp if it does (touch file) rm deletes file (rm file1) Note shells DO NOT have a trash bin; rm is final!

Wildcards more files can be specified via wildcards * - matches any number of letters including none? - matches any single character [] - encloses set of characters that can match the single given position - used within [] denotes range of characters Examples: *.csh, *.*sh, figure?.jpg, *.txt, figure[0-9].*

Exercise Make sure you are in your home directory and then make a directory called IntroLinux1 and change into this directory Look at the contents of one of MY directories: /uufs/chpc.utah.edu/common/home/u0028729/introlinux1 Copy over the contents of this directory into the directory you are in List contents of this directory see difference of a normal ls, ls l, ls ltr, and ls ltra See what output you get when you do a ls of: figure?.jpg, figure[0-9].* Make a new directory called Work inside of IntroLinux1 and copy all files with the txt extension from the IntroLinux1 directory to your new directory Open man page for some command (e.g. ls) and see what these flags do

Exercise If you are not already, move into your IntroLinux1 directory View script.slurm using cat, more, head and tail Vary number of lines viewed with head and tail Search for the string SBATCH in this file with grep Use the file command to tell you what the file type of ShellReference.pdf; copy this file to another filename, with a different extension and check the file type again

Command output redirection > redirect output to a file (instead of to screen) will create file if it does not exist; if it does it will overwrite the previous contents) cat file1.dat > file4.dat >> - append to a file cat file1.dat >> file3.dat - pipe redirect command output to another command head -10 list.txt tail -2

Exercise In the Work directory, combine the contents of geom1.txt and geom2.txt into one file named geom3.txt Using grep and the file states.dat create a file Mstates.dat with only the states that start with the letter M Create the same file content using head and tail

Shown with ls -l File Permissions User (u), group (g), other (o), all (a) Permissions are read (r), write (w), execute or search for a directory (x) chmod to change permissions of file or directory Format chmod g+x file Executable files (programs and scripts) must have executable permissions

Processes A Process is a running Linux program Each process has a PID (Process ID) ps reports a snapshot of current processes ps, ps x Display ALL of your processes ps ax Display ALL processes ps aux Display ALL processes (more detailed) ps auxw Display ALL processes (more detailed & unlimited width) ps efwww Also displays ALL processes

Some other useful commands wc e.g. wc -l file.txt Prints line (-l), word (-w), character (-m)or byte (-c) count of file cut e.g. cut -f 2 -d : file.txt Prints selected parts of lines from file to standard output (screen) du e.g. du hs Reports file space usage; -s give summary of total usage, -h gives it in human readable format of K, M, G df e.g. df h Reports file system disk space usage ln e.g. ln -s ~/bin/prog.exe prog1.exe create a link between files (-s symbolic) On your own Use and explore options of these commands

Have Questions? Anita: anita.orendt@utah.edu Wim: wim.cardoen@utah.edu CHPC has an issue tracking system: issues@chpc.utah.edu Slides and files ~u0028729/introlinux1 Some useful websites http://swcarpentry.github.io/shell-novice/ http://linuxcommand.org/