Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Similar documents
The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

Introduction: What is Unix?

Mills HPC Tutorial Series. Linux Basics I

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

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to Linux

Introduction to the Linux Command Line

Working with Basic Linux. Daniel Balagué

Week 2 Lecture 3. Unix

Introduction to UNIX. SURF Research Boot Camp April Jeroen Engelberts Consultant Supercomputing

Lab 2: Linux/Unix shell

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Introduction to the Linux Command Line January Presentation Topics

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

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

CISC 220 fall 2011, set 1: Linux basics

Unix Filesystem. January 26 th, 2004 Class Meeting 2

A Hands-On Tutorial: RNA Sequencing Using High-Performance Computing

The Unix Shell. Pipes and Filters

Introduction to Linux

Perl and R Scripting for Biologists

CS Fundamentals of Programming II Fall Very Basic UNIX

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

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

CSCI 2132 Software Development. Lecture 5: File Permissions

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

User Guide Version 2.0

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

commandname flags arguments

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Lab Working with Linux Command Line

Chapter 1 - Introduction. September 8, 2016

Files and Directories

Session 1: Accessing MUGrid and Command Line Basics

Linux Command Line Primer. By: Scott Marshall

Introduction To. Barry Grant

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

UNIX Essentials Featuring Solaris 10 Op System

Files

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Lec 1 add-on: Linux Intro

Computer Systems and Architecture

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

CS246 Spring14 Programming Paradigm Notes on Linux

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

Essential Linux Shell Commands

Useful Unix Commands Cheat Sheet

Linux/Cygwin Practice Computer Architecture

Introduction to Linux Workshop 1

System Administration

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

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.

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Operating Systems. Copyleft 2005, Binnur Kurt

Introduction of Linux

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

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

Introduction to UNIX command-line II

The Unix Shell & Shell Scripts

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

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.

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

Command-line interpreters

A Brief Introduction to Unix

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

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

Introduction to Linux

CS 300. Data Structures

CS CS Tutorial 2 2 Winter 2018

Introduction to the UNIX command line

CSE 390a Lecture 1. introduction to Linux/Unix environment

Std: XI CHAPTER-3 LINUX

Introduction to UNIX command-line

Unix basics exercise MBV-INFX410

Introduction to UNIX Command Line

Getting your department account

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

Commands are in black

Introduction to Linux and Cluster Computing Environments for Bioinformatics

Short Read Sequencing Analysis Workshop

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

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

Introduction to Linux Organizing Files

Operating systems fundamentals - B02

Introduction to Linux for BlueBEAR. January

AMS 200: Working on Linux/Unix Machines

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

CSE 391 Lecture 1. introduction to Linux/Unix environment

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

Unix Basics. Systems Programming Concepts

Unix. Examples: OS X and Ubuntu

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

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

AN INTRODUCTION TO UNIX

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Computer Systems and Architecture

EECS2301. Lab 1 Winter 2016

Transcription:

Basic UNIX commands HORT 59000 Lab 2 Instructor: Kranthi Varala

Client/Server architecture User1 User2 User3 Server (UNIX/ Web/ Database etc..) User4

High Performance Compute (HPC) cluster User1 Compute 1 Compute 2 User2 User3 User4 Head Node(s) User Login, Job scheduling, Connect to other machines, etc. DO NOT run jobs on the head node Compute 3 Compute 4 Compute 5 Compute 6.. Compute n Run jobs

Scholar : Our class server Sub- Cluster Number of Nodes Processors per Node Cores per Node Memory per Node Interconnect Head 7 A 8 Two 10-Core Intel CPUs Two 10-Core Intel CPUs 20 512-754 GB 20 64 GB 56 Gbps FDR Infiniband Scholar is a Linux cluster maintained by Purdue and is available for all computational classes. Secure Shell (SSH) protocol is the most common way to connect to remote UNIX/LINUX servers. The specific SSH client you use depends on your client (laptop) OS. Linux and MacOS have built-in clients. PuTTY is the most common client on Windows machines.

Today s pairs Pair #1 Pair #2 Pair #3 Pair #4 Pair #5 Pair #6 Pair #7 Pair #8 chandr95, hwillso hchikssa, ctraugh clark367, ingle0 cook311, flynn27 shailem, kriveraz rhiles, wang2852 ljessup, yang1511 rperon, tsuttiyu If your partner is missing, let me know and we ll adjust the pairs based on availability.

Using a compute node interactively 1. ssh <yourid>@scholar.rcac.purdue.edu Log in to the head node. 2. qsub -I -l nodes=1:ppn=1 -l walltime=02:00:00 Log in to the compute node to run jobs interactively.

ls on my scratch Contents of my scratch folder Metadata about the contents Contents of my scratch folder

Metadata on files and directories Metadata is information about the file that are not part of the contents of the file. Three main parts to it: Ownership and access permissions Size Timestamp

UNIX permissions Execute == x == 1 (Means traverse for directories) Write == w == 2 Read == r == 4 Common Permission settings Indicator Numeric code Read-only r-- 4 Read & execute r-x 5 Read & write rw- 6 Read, write, execute rwx 7???? 3

Ownership and Access Every file/directory has a defined owner, which is one user. Permissions Owner Group Owner controls who can access the file/directory by setting the permissions. Each user is a part of one or more groups. Each file belongs to one of the groups that the user belongs to.

UNIX permissions Permissions First character is - for a file and d for a directory. Characters 2-4 refer to permissions the owner sets for himself. Characters 5-7 are permissions for the group listed. Characters 8-10 are permissions for the world (i.e., every other user) Common Permission settings Indicator Numeric code Read-only r-- 4 Read & execute r-x 5 Read & write rw- 6 Read, write, execute rwx 7

Hidden files and directories Files or directories whose name starts with. are considered hidden so ls does not list them

Working with directories pwd -> lists the present working directory mkdir -> makes a new directory cd -> change directory rmdir -> remove directory Try using cd with path: cd /scratch/scholar/kvarala/idab cd./week1 cd../week2

File commands mv is the move command that moves a file. This command is also used for renaming files. rm is the remove command and will remove the file or empty directory listed as argument. cat is the concatenate command that joins the contents of all files given as arguments.

Exercises Basic commands

History: Keeping a record First let s make sure we keep a record of all the commands we use. In the Bash shell (your default shell on scholar) every command you enter is stored in memory while shell is active. When you quit the shell, this history is stored in a file called.bash_history that is in your home folder. Default size for history in memory and in the file is 1000 commands. You can recover your history of commands by typing: history in your command line.

Customizing your shell In the Bash shell, you can add aliases or modify PATH using the.bash_profile file. ~/.bash_profile is read every time a new shell is created. Create a new file called bash_profile.txt on your local computer and add the following two lines to it: alias ltr='ls -ltr alias scratch= cd /scratch/scholar/k/kvarala export PATH=$PATH:$HOME/bin Now copy this file to your home folder on Scholar using your SCP client.

Creating and working with directories cd /scratch/scholar/<yourid>/ mkdir Lab2_Exercises cd Lab2_Exercises

Copy file Copy file from /scratch/scholar/kvarala to your scratch: Absolute path cp /scratch/scholar/kvarala/idab/rcac_cluster_reference.pdf /scratch/scholar/<yourid>/lab2_exercises ls /scratch/scholar/<yourid>/lab2_exercises ls -l /scratch/scholar/<yourid>/lab2_exercises Relative path cd /scratch/scholar/<yourid>/lab2_exercises cp../kvarala/idab/rcac_cluster_reference.pdf. Now try the cp command with the -p switch

Move file Move file from your scratch to your home: Absolute path cd /scratch/scholar/<yourid>/lab2_exercises mv /scratch/scholar/<yourid>/lab2_exercises /rcac_cluster_reference.pdf /home/<yourid> ls -l /scratch/scholar/<yourid>/ ls -l /home/<yourid>/ Relative path cd /scratch/scholar/<yourid>/lab2_exercises mv rcac_cluster_reference.pdf ~/ mv ~/rcac_cluster_reference.pdf. ls -l /scratch/scholar/<yourid>/lab2_exercises ls -l /home/<yourid>/

Customizing your shell Now move the bash_profile.txt file in your home directory to.bash_profile mv bash_profile.txt ~/.bash_profile Type the command: ltr logout of the shell and log back in. Now, again type the command: ltr

Remove file Remove file from your scratch: Absolute path cp /scratch/scholar/<yourid>/lab2_exercises/ rcac_cluster_reference.pdf /scratch/scholar/<yourid>/temporary_copy ls -l /scratch/scholar/<yourid>/lab2_exercises rm /scratch/scholar/<yourid>/lab2_exercises/temporary_copy ls -l /scratch/scholar/<yourid>/ Relative path (be VERY careful) cd /scratch/scholar/<yourid>/ cp rcac_cluster_reference.pdf ~/temporary_copy rm ~/temporary_copy ls -l /home/<yourid>/

Viewing files cd /scratch/scholar/<yourid>/lab2_exercises cp -pr /scratch/scholar/kvarala/idab/week2/files. ls l cd Files cat Pasture.txt cat WoodPile.txt less North_of_Boston.txt quit less display with the q key head North_of_Boston.txt tail North_of_Boston.txt

Changing file permissions cd /scratch/scholar/<yourid>/lab2_exercises/files ls l Pasture.txt chmod 755 Pasture.txt ls l Pasture.txt chmod x Pasture.txt ls l Pasture.txt chmod 666 Pasture.txt ls l Pasture.txt chmod -w Pasture.txt ls l Pasture.txt

I/O streams Each command has 3 Input/Output streams: STDIN : Standard Input is the default stream that inputs data into a command. Example: keyboard, file etc. STDOUT : Standard Output is the default output stream of the command. Example: Terminal STDERR: Standard Error is where the errors from the program are displayed: Example: Terminal

Creating pipelines from commands The STDIN and STDOUT of each command can be redirected to combine programs together. For example, the STDOUT of one program can be sent to the STDIN of another program. STDIN and STDOUT streams can be redirected using the following symbols: 1. > 2. < 3.

Redirecting STDIN and STDOUT cat North_of_Boston.txt less Here, the STDOUT of cat is sent to the STDIN of less. cat Pasture.txt > New_Pasture.txt Here, the STDOUT of cat is sent to a new file called New_Pasture.txt less < New_Pasture.txt Here the file New_Pasture.txt is sent to the STDIN of less cat Pasture.txt WoodPile.txt >2Poems.txt

Capturing STDERR Errors from running commands are sent to STDERR. By default, STDERR is shown on your monitor. nonsense_command -bash: nonsense_command: command not found Here, the STDERR of nonsense_command is sent to the monitor nonsense_command 2>err.log Here the file STDERR of nonsense_command is sent to the file err.log

Try these on your own Try moving to these locations with the cd command: /home/<yourid> /scratch/scholar/kvarala/idab/ /usr/bin/ /root/ Create the following structure in your scratch Lecture1.pdf space: Week1 Lab1.pdf IDAB Lecture2.pdf Week2 Lab2.pdf Pasture.txt rcac_cluster_reference.pdf Files WoodPile.txt North_of_Boston.txt

Learning about UNIX commands which <cmd> Tells you the location of the command man <cmd> Displays the manual for the command <cmd> --help/-h Displays a short list of options for the command