Introduction to Unix. University of Massachusetts Medical School. October, 2014

Similar documents
acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Computer Systems and Architecture

Computer Systems and Architecture

Perl and R Scripting for Biologists

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Chap2: Operating-System Structures

Working with Basic Linux. Daniel Balagué

Unix Essentials. BaRC Hot Topics Bioinformatics and Research Computing Whitehead Institute October 12 th

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

Getting started with Hugs on Linux

Introduction to Linux

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Getting started with Hugs on Linux

Introduction to UNIX Command Line

EE516: Embedded Software Project 1. Setting Up Environment for Projects

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

Introduction: What is Unix?

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to Linux

Chapter-3. Introduction to Unix: Fundamental Commands

Lab 1 Introduction to UNIX and C

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

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

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

The Linux Command Line & Shell Scripting

Unix. 1 tblgrant projects 0 Jun 17 15:40 doc1.txt. documents]$ touch doc2.txt documents]$ ls -l total 0

Introduction to the Linux Command Line

Exercise Sheet 2. (Classifications of Operating Systems)

CISC 220 fall 2011, set 1: Linux basics

Linux & Shell Programming 2014

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

Introduction to UNIX command-line

1Z Oracle Linux Fundamentals (Oracle Partner Network) Exam Summary Syllabus Questions

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

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

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

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

Introduction to Unix: Fundamental Commands

Introduction to Cygwin Operating Environment

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

CS Fundamentals of Programming II Fall Very Basic UNIX

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

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

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Mills HPC Tutorial Series. Linux Basics I

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

Unix Introduction to UNIX

Introduction to Linux

Short Read Sequencing Analysis Workshop

CS370 Operating Systems

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Introduction to Linux Basics

Introduction to UNIX/Linux

ScazLab. Linux Scripting. Core Skills That Every Roboticist Must Have. Alex Litoiu Thursday, November 14, 13

Operating Systems. Copyleft 2005, Binnur Kurt

An Introduction to Linux and Bowtie

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

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

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.

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Introduction to Linux Organizing Files

CS246 Spring14 Programming Paradigm Notes on Linux

Session 1: Accessing MUGrid and Command Line Basics

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

commandname flags arguments

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Introduction to Linux

Introduction to Linux Workshop 1

Exploring UNIX: Session 3

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Introduction to the shell Part II

Unix basics exercise MBV-INFX410

Linux Command Line Interface. December 27, 2017

Overview of Unix / Linux operating systems

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

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

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

EECS2301. Lab 1 Winter 2016

Introduction to UNIX I: Command Line 1 / 21

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

Introduction to Linux for BlueBEAR. January

Operating Systems, Unix Files and Commands SEEM

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

Introduction to the basics of UNIX

Unix Handouts. Shantanu N Kulkarni

Unix Tools / Command Line

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

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

Getting Started with UNIX

2 Lab 4. Unix Shell 2

Unix Basics. Benjamin S. Skrainka University College London. July 17, 2010

Transcription:

.. Introduction to Unix University of Massachusetts Medical School October, 2014

. DISCLAIMER For the sake of clarity, the concepts mentioned in these slides have been simplified significantly. Most of the command line tools and programs we explain have many more features that can t be found here. Unix command line tools are very well documented and their manual pages are freely available. These slides are prepared for the users of MGHPCC. MGHPCC system has features that don t exist in standard Unix systems such as loading modules. A rigorous treatment of topics on Unix and Bash can be found in various books in several levels.

. Some References 4 / 49 Unix: Unix in a Nutshell, Arnold Robbins, ISBN-13: 978-0596100292 Learning the bash Shell: Unix Shell Programming, Cameron Newham, ISBN-13: 978-0596009656 Umass High Perfotmance Computing: http://wiki.umassrc.org/ Bioinformatics: UCSC genome bioinformatics: https://genome.ucsc.edu/ Sam file format: samtools.github.io/hts-specs/samv1.pdf Samtools: http://samtools.sourceforge.net/ Bedtools: http://bedtools.readthedocs.org/en/latest/ bowtie2: http://bowtie-bio.sourceforge.net/bowtie2/manual.shtml tophat: http://ccb.jhu.edu/software/tophat/index.shtml

. What is an Operating System? 5 / 49 An operating system is a collection of software that manages system resources (such as memory, cpu(s), display and etc.) and provide applications a simpler interface to the system hardware.

. Operating System 6 / 49 Application Operating System Hardware CPU Memory Hard Disk...

. Unix 7 / 49 Developed in the 1960 s by Ken Thompson, Dennis Ritchie. It became very popular in the 70 s and 80 s.

"Contrary to popular belief, Unix is user friendly. It just happens to be very selective about who it decides to make friends with." anonymous 8 / 49

. Unix-like operating systems 9 / 49 Unix-like operating systems "behave" like the original Unix operating system and comply (at least partially) with POSIX (portable operating system interface) standards. Examples: Linux, OS X, Free BSD, Solaris, Hurd. Unix Unix-like Unix-clone

. What is a Terminal? 10 / 49 A terminal is a software that emulates a teletype writer terminal used in the early days of Unix.

. Unix Shell 11 / 49 User A shell is a software that runs inside a terminal and interprets and executes user commands. One of the most popular shells being used today is called BASH (Bourne Again Shell). It is also the default shell in the UMass HPC cluster, OS X and many Linux distributions. Shell Kernel

. Convention 12 / 49 $ denotes the Bash command line prompt. It is not meant to be typed. All Bash commands will appear in a gray box. $ bashcommand

. Hello Bash 13 / 49 We connect to MGHPCC server. $ ssh username@ghpcc06.umassrc.org

. Hello Bash 14 / 49 We connect to MGHPCC server. $ ssh username@ghpcc06.umassrc.org Let s verify that we are at the right place. $ hostname To print something on the screen, we use echo $ echo Hello World

. Navigating the Unix File System 15 / 49 / bin home etc media... user1 user2... script.sh Documents

. Exploring the Directories 16 / 49 Bash always has a working directory. To see the working directory, $ pwd

. Exploring the Directories 17 / 49 Bash always has a working directory. To see the working directory, $ pwd To see the contents of the working directory, $ ls

. Exploring the Directories 18 / 49 Bash always has a working directory. To see the working directory, $ pwd To see the contents of the working directory, $ ls To see the contents of a particular directory, provide the path of the directory. $ ls /bin displays th contents of the directory /bin

. Command Line Arguments 19 / 49 A program s execution and / or output format can be modified, according to our needs, by providing command line arguments. $ ls }{{} executable -lh }{{} argument 1 /bin }{{} argument 2

. More on ls 20 / 49 We can get more information about the files or directories by running ls with additional arguments. Compare $ ls with $ ls -l

21 / 49. A closer look at ls ls list the given directory contents. To see the complete list of options, $ man ls This will display the manual page of ls.

22 / 49. A closer look at ls ls list the given directory contents. To see the complete list of options, $ man ls This will display the manual page of ls. Some commonly used options are: -l : list contents in more detail -A : list all files in the direcory -h : when used with the -l option, prints file sizes in KB, MB, GB, and etc. to reduce the number of digits on the screen. These options can be grouped $ ls -lh

23 / 49 Let s first have some files and folders to experiment with. Upon success, you will see /home/user_name/bootcamp $ /tmp/bootcamp.pl

. Changing the working directory 24 / 49 First, we see the working directory $ pwd Now, lets change the directory to the bootcamp directory. $ cd ~/bootcamp We can verify the change by $ pwd

. Creating Directories 25 / 49 Note that $ mkdir directory_path $ mkdir /home/username/bootcamp/my_new_directory is the same as $ mkdir ~/bootcamp/my_new_directory

. Copying Files 26 / 49 $ cp sourcefile(s) destination_path Let s copy our sample files into the home folder. $ cp ~/bootcamp/transcriptomics.tar.gz ~/transcriptomics.tar.gz

. Copying Directories 27 / 49 $ cp source_directory destination_directory will not work in general. You need to provide the -r parameter. $ cp -r source_directory destination_directory Another useful option is -v which prints the files being copied. $ cp -rv source_directory destination_directory

. Moving Files 28 / 49 $ mv source_file destination_file

. Deleting Files 29 / 49 rm : Remove comand $ rm file_path To remove non-empty directories, use rm with the -r option. $ rm -r directory

. rm is a dangerous command 30 / 49 There is no undoing of rm! You may want to use it in the ineractive mode not to delete accidentally files $ rm -i file

. File Path 31 / 49 ~ : Home directory. : current directory.. : parent directory If a file path begins with /, then it is an absolute path. It doesn t depend on the current working directory. If a file path begins WITHOUT /, then it is a relative path. The path is defined according to the current directory. So, the path depends on the current working directory.

. Examples 32 / 49 /tmp/bootcamp/bootcamp.pl : Absolute path. bootcamp.pl : Relative path. This is the botcamp.pl file in the working directory.../bootcamp.pl : Relative path. This is the botcamp.pl file in the parent directory of the working directory. ~/bootcamp.pl : This is the file in the home directory of the current user.

. Files 33 / 49 Technically, every file is a binary file. Yet, it is common practice to group the files into two: Text Files : Contains only printable characters. Binary Files : Files that are not text files. Binary files are generally more compact and therefore smaller in size. They are read and processed by specific applications.

. Viewing text files 34 / 49 Text files are of extreme importance in bioinformatics. There are many tools to view and edit text files. less is a very useful program. $ less text_file For details read the manual page $ man less

. Editing Text Files 35 / 49 For a very simple text editor: $ nano vi and emacs are very powerful text editors with sophisticated features.

. File Permissions 36 / 49 Let s try to run a bash script. $./hello.sh Let s try another one $./other_hello.sh Why didn t this work?

. File Permissions 37 / 49 Let s try to spy on Manuel and see what he is up to. $ ls /home/mg44w

. File Permissions 38 / 49 Let s try to spy on Manuel and see what he is up to. $ ls /home/mg44w In Unix, users can only access (read, write or execute) files that they have permission to.

. Seeing File Permissions 39 / 49 A typical output of is $ ls -lh -rw-r r 1 ho86w moore 11M Nov 5 00:41 RPKM.csv -rwxrwxrwx 1 ho86w moore 143B Oct 27 02:53 my_script.sh drwxr-xr-x 21 ho86w moore 714B Jan 24 13:52 sam_files

40 / 49 r : read w : write x : execute rwx }{{} user r-x }{{} group r- - }{{} others User : Has read, write and execute access. Group : Has read and execute access but can t write to the file Others : Has only read access.

. Changing File Permissions 41 / 49 chmod: Change file mode bits. $ chmod filemode file To give only read access to other users, $ chmod o=r myscript.sh To give read and execution access together, $ chmod o=rx myscript.sh

. What is a Process? 42 / 49 A computer process is an instance of a program. It takes up space in the memory and its instructions are executed in the CPU.

. Processes 43 / 49 You can list your running processes $ ps -u username where username is your username. You can see them in more detail with the -F option $ ps -u username -F

. Terminating a process 44 / 49 You can terminate a process by $ kill -9 processid where processid is the process id that can be obtained by the ps command.

. Background Processes 45 / 49 To send a process to the background, first put the process on hold by pressing ctrl and z, and then send it to the background by $ bg You can check your processes by $ jobs To put a back to the foreground, first get the process id by and then $ jobs $ fg % processnumber

46 / 49 To start a process on the background, put & at the end of your command $ command &

. Working with Compressed Files 47 / 49 A common type of binary files is zipped files. We can save space by zipping text files. We use gzip to compress / decompress files tar to pack files into one file for archiving purposes. To compress a file $ gzip file To decompress, reads.fastq.gz, $ gzip -d reads.fastq.gz

. tar files 48 / 49 Say we collect our results on a project in one directory. We want to send this directory in an email attachment to a collaborator. How do we do that? / bin home etc media... user1 user2... script.sh Documents

. tar files 49 / 49 To pack a directory $ tar -cvf arcive.tar directory To pack a directory in a zipped tar file $ tar -czvf archive.tar.gz directory To get our directory back from the tar file $ tar -xvf archive.tar To get our directory back from the tar.gz file $ tar -xvzf archive.tar.gz