Introduction to UNIX command-line

Similar documents
Introduction to UNIX command-line II

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

Using Linux as a Virtual Machine

Perl and R Scripting for Biologists

Computer Systems and Architecture

Computer Systems and Architecture

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

Introduction to Unix: Fundamental Commands

Useful Unix Commands Cheat Sheet

Introduction. File System. Note. Achtung!

Chapter-3. Introduction to Unix: Fundamental Commands

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

Files and Directories

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

Linux Command Line Primer. By: Scott Marshall

CSCI 2132 Software Development. Lecture 4: Files and Directories

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

Introduction to Linux. Roman Cheplyaka

Unix - Basics Course on Unix and Genomic Data Prague, January 2017

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

Week 2 Lecture 3. Unix

Introduction to UNIX/Linux

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

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

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

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

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.

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

Lab Working with Linux Command Line

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

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

Introduction to Linux Organizing Files

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.

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

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

The Linux Command Line & Shell Scripting

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

Introduction to Linux

Shell Programming Overview

Linux Essentials Objectives Topics:

Introduction to UNIX I: Command Line 1 / 21

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

Where can UNIX be used? Getting to the terminal. Where are you? most important/useful commands & examples. Real Unix computers

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

Mills HPC Tutorial Series. Linux Basics I

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

A Brief Introduction to the Linux Shell for Data Science

CS197U: A Hands on Introduction to Unix

CSCI 2132 Software Development. Lecture 5: File Permissions

CS 460 Linux Tutorial

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.

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

Introduction of Linux

Introduction to the Linux Command Line

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

No Food or Drink in this room. Logon to Windows machine

Arkansas High Performance Computing Center at the University of Arkansas

Introduction to Linux

Introduction: What is Unix?

Working with Basic Linux. Daniel Balagué

Commands are in black

Introduction to Linux

Introduction to Linux

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

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

Basic Linux Commands. Srihari Kalgi M.Tech, CSE (KReSIT), IIT Bombay. May 5, 2009

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

Recap From Last Time:

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

BGGN 213 Working with UNIX Barry Grant

Research. We make it happen. Unix Basics. User Support Group help-line: personal:

CS197U: A Hands on Introduction to Unix

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

A Brief Introduction to Unix

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

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

COMS 6100 Class Notes 3

Introduction to the shell Part II

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

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

Introduction To Linux. Rob Thomas - ACRC

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

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

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

Tutorial-1b: The Linux CLI

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

An Introduction to Cluster Computing Using Newton

Introduction to Linux Basics

INTRODUCTION TO LINUX

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

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

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Chapter 4. Unix Tutorial. Unix Shell

Introduction to Linux/Unix. Xiaoge Wang, ICER Jan. 14, 2016

Operating Systems. Copyleft 2005, Binnur Kurt

Transcription:

Introduction to UNIX command-line Boyce Thompson Institute March 17, 2015 Lukas Mueller & Noe Fernandez

Class Content Terminal file system navigation Wildcards, shortcuts and special characters File permissions Compression UNIX commands Networking UNIX commands Basic NGS file formats Text files manipulation commands Command-line pipelines Introduction to bash scripts

What is a virtual machine?

What is a terminal?

Origins of Linux. The UNIX operating system

Why use command-line? Most software for biological data analysis is used through UNIX command-line terminal Most of the servers for biological data analysis use Linux as operative system Data analysis on calculation servers are much faster since we can use more CPUs and RAM than in a PC (e.g.: Boyce servers has 64 cores and 1TB RAM) Large NGS data files can not be opened or loaded in most of GUI-based software and web sites Compression commands are useful, since NGS large data files usually are stored and shared as compressed files

File system navigation UNIX Command-Line Cheat Sheet BTI-SGN Bioinformatics Course 2014 File system commands Download the cheat sheet from: http://www.slideshare.net/nofernndezpozo/unix-command-sheet2014 https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf File system Commands ls lists directories and files ls -a lists all files including hidden files ls -lh formatted list including more data ls -t lists sorted by date pwd returns path to working directory cd dir changes directory cd.. goes to parent directory cd / goes to root directory cd goes to home directory touch file_name creates en empty file cp file file_copy copy a file cp -r copy files contained in directories rm file deletes a file rm -r dir deletes a directory and its files mv file1 file2 moves or renames a file mkdir dir_name creates a directory rmdir dir_name deletes a directory locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Compression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files command > file command >> file cat file Text handling commands saves STDOUT in a file appends STDOUT in a file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta head file head -n 5 file tail file tail -n 5 file less file less -N file less -S file grep pattern file concatenates all fasta files in the current directory prints first lines from a file prints first five lines from a file prints last lines from a file prints last five lines from a file view a file includes line numbers wraps long lines Prints lines matching a pattern grep -c pattern file counts lines matching a pattern cut -f 1,3 file sort file sort -u file uniq -c file wc file paste file1 file2 paste -d, sed wget URL ssh user@server scp apt-get install retrieves data from selected columns in a tab-delimited file sorts lines from a file sorts and return unique lines filters adjacent repeated lines counts lines, words and bytes concatenates the lines of input files concatenates the lines of input files by commas transforms text Networking Commands download a file from an URL connects to a server copy files between computers installs applications in linux

File system navigation File Browser Terminal =

Home and Root directories Home directory /home/bioinfo /home/noe /home/noe/desktop Root directory /bin, /lib, /usr code and code libraries /var logs and other data /home user directories /tmp temporary files /etc configuration information /proc special file system in Linux

Anatomy of a UNIX command grep -c -A 3 --ignore-case file.txt command option with argument option (long form) argument Simple option flag (short form) print grep manual man grep

ls, cd and pwd to navigate the file system where am I? pwd how to change current directory cd what files and directories are in my current directory? ls return current work directory pwd

ls lists directories and files list directories and files in current directory list all directories and files, including hidden files ls ls -a ls -l -h list in long format human readable ls -l -h -t ls -lhs size sorted time sorted

ls lists directories and files owner user owner group permissions links # size date File name group user other d rwx r-x r-x d Directory - Regular file r readable w writable x executable or searchable - not rwx

Wildcards, history and some shortcuts ls *txt list all txt files in current directory ls P*s list files starting with P and ending with s, e.g.: Pictures, Photos, Programs... Use up and down arrows to navigate the command history ctrl-c ctrl-a ctrl-e ctrl-r stop process go to begin of line go to end of line search in command history

Escaping special characters! @ $ ^ & * ~?. / [ ] < > \ ` " ;# ( ) ls my_folder list a folder ls my\ folder list a folder containing a space Tip: file names in lower case and with underscores instead of spaces Use tab key to autocomplete names

cd changes directory changes directory to Desktop goes to parent directory Use tab key to autocomplete names cd Desktop cd.. cd / cd cd - goes to root directory goes to home directory goes to previous directory

Absolute and relative paths list files in Desktop using an absolute path ls /home/user/desktop ls Desktop/ ls ~/Desktop list files in Desktop using your home as a reference list files in Documents using a relative path (from your home: /home/bioinfo)

Absolute and relative paths Absolute paths do not depend on where you are ls /home/bioinfo/desktop ls ~/Desktop ~/ is equivalent to /home/bioinfo/

Absolute and relative paths goes to Desktop from when you are in your home (/home/bioinfo) cd Desktop/ ls../documents list files from Documents when you are in Desktop

Create, copy, move and delete files creates an empty file called tmp_file.txt copies tmp_file.txt in file_copy.txt Tip: file names in lower case and with underscores instead of spaces touch tmp_file.txt cp tmp_file.txt file_copy.txt mv file1.txt file2.txt moves or rename a file rm file.txt deletes file.txt

Locate a file Locate the path for the file unix_class_file_samples.zip locate unix_class_file_samples.zip locate unix_class Locate the path for all the files containing unix_class

Create, copy and delete directories creates an empty directory called dir_name deletes dir_name directory if it is empty mkdir dir_name rmdir dir_name rm -r dir_name delete dir_name and its files cp -r dir_name dir_copy copy dir_name and its files in a new folder

Compression commands Compression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files groups and compress files tar -zcvf file.tar.gz f1 f2 tar -zxvf file.tar.gz decompress and ungroup a tar.gz file ls ls -a ls -lh ls -t pwd cd dir cd.. cd / cd touch file_name cp file file_copy cp -r rm file rm -r dir mv file1 file2 mkdir dir_name rmdir dir_name File system Commands lists directories and files lists all files including hidden files formatted list including more data lists sorted by date returns path to working directory changes directory goes to parent directory goes to root directory goes to home directory creates en empty file copy a file copy files contained in directories deletes a file deletes a directory and its files moves or renames a file creates a directory deletes a directory locate file_name searches a file man command top df -h gzip/zip shows commands manual shows process activity shows disk space info Compression commands compress a file gunzip/unzip decompress a file tar -cvf tar -xvf tar -zcvf tar -zxvf UNIX Command-Line Cheat Sheet groups files ungroups files groups and gzip files gunzip and ungroups files BTI-SGN Bioinformatics Course 2014 command > file command >> file cat file Text handling commands saves STDOUT in a file appends STDOUT in a file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta head file head -n 5 file tail file tail -n 5 file less file less -N file less -S file grep pattern file concatenates all fasta files in the current directory prints first lines from a file prints first five lines from a file prints last lines from a file prints last five lines from a file view a file includes line numbers wraps long lines Prints lines matching a pattern grep -c pattern file counts lines matching a pattern cut -f 1,3 file sort file sort -u file uniq -c file wc file paste file1 file2 paste -d, sed wget URL ssh user@server scp apt-get install retrieves data from selected columns in a tab-delimited file sorts lines from a file sorts and return unique lines filters adjacent repeated lines counts lines, words and bytes concatenates the lines of input files concatenates the lines of input files by commas transforms text Networking Commands download a file from an URL connects to a server copy files between computers installs applications in linux files, directories or wildcards

Compression commands compress file f1.txt in f1.txt.gz compress files f1 and f2 in file.zip gzip f1.txt zip file.zip f1 f2 unzip file.zip decompress file.zip gunzip file.gz decompress file.gz

Networking Commands UNIX Command-Line Cheat Sheet BTI-SGN Bioinformatics Course 2014 Networking commands File system Commands ls lists directories and files ls -a lists all files including hidden files ls -lh formatted list including more data ls -t lists sorted by date pwd returns path to working directory cd dir changes directory cd.. goes to parent directory cd / goes to root directory cd goes to home directory touch file_name creates en empty file cp file file_copy copy a file cp -r copy files contained in directories rm file deletes a file rm -r dir deletes a directory and its files mv file1 file2 moves or renames a file mkdir dir_name creates a directory rmdir dir_name deletes a directory locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Compression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files command > file command >> file cat file Text handling commands saves STDOUT in a file appends STDOUT in a file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta head file head -n 5 file tail file tail -n 5 file less file less -N file less -S file grep pattern file concatenates all fasta files in the current directory prints first lines from a file prints first five lines from a file prints last lines from a file prints last five lines from a file view a file includes line numbers wraps long lines Prints lines matching a pattern grep -c pattern file counts lines matching a pattern cut -f 1,3 file sort file sort -u file uniq -c file wc file paste file1 file2 paste -d, sed wget URL ssh user@server scp apt-get install retrieves data from selected columns in a tab-delimited file sorts lines from a file sorts and return unique lines filters adjacent repeated lines counts lines, words and bytes concatenates the lines of input files concatenates the lines of input files by commas transforms text Networking Commands download a file from an URL connects to a server copy files between computers installs applications in linux

Networking Commands connects your terminal to your account in a server downloads the UNIX command line cheat sheet PDF file ssh user_name@server_adress wget http://btiplantbioinfocourse.files.wordpress.com/2014/01/unix_command_sheet_2014.pdf scp noe@boyce.sgn.cornell.edu:/home/noe/file.txt. copy file.txt from your home in the server to the current directory in your computer Tip: use the command pwd to get the path for cp and scp

Networking Commands connects my terminal to my account Boyce, the BTI server copy the folder dir and all its files and subdirectories to my home in the server ssh noe@boyce.sgn.cornell.edu scp -r dir/ noe@boyce.sgn.cornell.edu: scp file.txt noe@boyce.sgn.cornell.edu: copy file.txt from the current directory in my computer to my home in the server

Useful commands in the server df -h shows disk space information top display and update sorted information about processes

Top displays and update sorted information about processes q quit u user (top -u user) M sort by memory usage

Commands to install software aptitude search blast sudo aptitude install blast2 sudo apt-get install pbzip2 installs pbzip2 in your computer call the command with super user permissions

Exercises 1. Go to your Desktop directory using the command cd 2. Use the command touch to create a file called: Do not Use special characters in file names!.txt 3. Use the command rm to delete that file 4. Use the command mkdir to create a folder called unix_data in your desktop 5. Copy the file unix_class_file_samples.zip from your folder Data, in your home, to the folder unix_data, in your desktop 6. Uncompress the file unix_class_file_samples.zip in /home/bioinfo/desktop/unix_data 7. Use the command rm with the option -r to remove the _MACOSX folder 8. Use the command wget to download the UNIX command line cheat sheet PDF from: https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf