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

Similar documents
Unix Basics. Benjamin S. Skrainka Harris School of Public Policy University of Chicago. July 19, 2012

Perl and R Scripting for Biologists

Introduction to Linux

CS Fundamentals of Programming II Fall Very Basic UNIX

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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: What is Unix?

Introduction to Linux

Introduction to Linux

Introduction to the Linux Command Line

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

CS CS Tutorial 2 2 Winter 2018

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

CISC 220 fall 2011, set 1: Linux basics

Introduction to Linux Workshop 1

Part 1: Basic Commands/U3li3es

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

INTRODUCTION TO BIOINFORMATICS

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

CS197U: A Hands on Introduction to Unix

A Brief Introduction to Unix

Files and Directories

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

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction of Linux

Outline. Structure of a UNIX command

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

commandname flags arguments

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

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

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

Unix Basics. Systems Programming Concepts

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

Scripting Languages Course 1. Diana Trandabăț

The Linux Command Line & Shell Scripting

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Chapter-3. Introduction to Unix: Fundamental Commands

Essential Linux Shell Commands

Unix Workshop Aug 2014

Introduction To. Barry Grant

Week 2 Lecture 3. Unix

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

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

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

Introduction to Supercomputing

AN INTRODUCTION TO UNIX

Analytical Processing of Data of statistical genetics research in UNIX like Systems

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

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

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

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

Introduction to Linux

Mills HPC Tutorial Series. Linux Basics I

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Unix Tutorial Haverford Astronomy 2014/2015

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

CS197U: A Hands on Introduction to Unix

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

Introduction to the Linux Command Line January Presentation Topics

C++ Programming on Linux

Chapter 1 - Introduction. September 8, 2016

Unix Introduction to UNIX

UNIX Essentials Featuring Solaris 10 Op System

Introduction to Linux Environment. Yun-Wen Chen

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

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 UNIX I: Command Line 1 / 21

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

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

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

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

Introduction To Linux. Rob Thomas - ACRC

Version Control with Git

Introduction to UNIX Command Line

The Unix Shell & Shell Scripts

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

Chap2: Operating-System Structures

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Linux Essentials Objectives Topics:

Shell Programming Systems Skills in C and Unix

CS370 Operating Systems

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

Parallel Programming Pre-Assignment. Setting up the Software Environment

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

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

Getting started with Hugs on Linux

Open Source Computational Fluid Dynamics

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

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

COMS 6100 Class Notes 3

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

Computer Systems and Architecture

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

Lab 2: Linux/Unix shell

Transcription:

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

Overview We cover basic Unix survival skills: Why you need some Unix in your life How to get some Unix in your life Basic commands (Free) tools you can t live without

Why you need some Unix in your life Unix/Linux will make you more productive: Simple yet powerful commands Command line or GUI interface Access to vast amounts of Open Source or free software Forgiving programming environment Exceptionally robust architecture The lingua franca for scientific and high throughput computing

Design Philosophy The core of Unix s design philosophy is: Acommand/programshoulddoonethingonly,butdoitwell Commands should be easy to string together to perform more complex operations Smaller kernel than Windows Greater reliability and extensibility Better performance

How to get some Unix in your life There are several ways to get some Unix: PC hardware: OS/X Download cygwin (www.cygwin.com) Install Linux Can dual-boot Linux and Windows Ubuntu is a popular distribution Has Unix-style kernel underneath user interface Install XCode (developer.apple.com) Install MacPorts (www.macports.org) Install desired packages with port command Use a virtual machine: VMWare Fusion, Parallels, VirtualBox (Free)

Overview Let s look at the basic survival skills needed on Unix: Getting Help Configuration Navigation Editing

Help To get help: Use GUI help command, if supported Google Use the man command: man man man ls man -k edit Navigation: space, /, f, b,... O Reilly books (www.ora.com)

Conventions There are a couple conventions to be aware of: Special characters in filenames: Dotfiles: * Greedy matching of all characters in a name ~ Your login directory (cd without arguments goes to ~ ) Used for configuration Invisible unless you use ls -a.bashrc,.profile,.login, and application-specific files The place to define your own commands with alias Environment variables specify configuration information, too: PATH LD_LIBRARY_PATH

Navigation Navigate by specifying filenames and directories (folders): cd dir change directory mkdir dir make directory rmdir dir remove directory rm file delete a file (N.B. there is no trash!) rm -rf * nuke everything make sure you really want to do this mv from to move/rename a file or directory ls [dir] list the contents of a directory pwd display current directory find traverse a directory tree, performing custom operations

History Unix has a sophisticated history facility: history list recent commands!n reexecute n-th command!cmd reexecute most recent command which started with string cmd ^P scroll backwards through history (can use arrow keys...)!cmd:p load most recent command starting with cmd onto command line (for editing or execution) More sophisticated manipulations are possible

Permissions Unix-style permissions are confusing to the uninitiated: % ls -la total 440 drwxr-xr-x 23 bss staff 782 24 Jul 22:05. drwxr-xr-x 11 bss staff 374 24 Jul 22:06.. drwxr-xr-x 8 bss staff 272 27 Jul 18:25.svn -rw-r--r--@ 1 bss staff 12655 24 Jul 22:06 BasicDriver.m -rw-r--r-- 1 bss staff 16128 24 Jul 21:54 BasicDriver.m~... [d -] directory or not [rwx] permissions are grouped according to social distance: user, group, andworld Specify r, w, and x (Octal: 4, 2, 1) chmod: use to change permissions: chmod 755 myfile.m

Looking at Stuff Unix has many handy commands for manipulating text files: less Page through a file grep Search for a token cat Concatenate files (or, dump them to the screen) head Cat the top of a file tail Cat the end of a file wc Display number of characters, words, and/or lines

Editing Traditional editors are: vi emacs Other options (if installed): nano jedit (Download from www.jedit.org)

Remote Login To connect to a remote machine use the secure shell protocol: Unix, Linux, or OS/X: Windows: ssh YourLoginName@htc.uni.edu Can also use sftp and scp Download PuTTY Create a connection via GUI May need to configure colors Used encryption to provide a secure connection Do not use rlogin, telnet, or ftp (unless anonymous) which are not secure!!!

Building More Complex Commands Unix provides tools to link atomic commands together into more complex commands: IO Redirection: >, <, < < Pipe: Shell scripts Regular Expressions Example: egrep -e ^[0-9]\{1,2\}[a-z] Data.txt sort > out.txt

GREs Most Unix tools support Generalized Regular Expressions: Powerful, compact, and often cryptic language for specifying patterns Permits sophisticated searching via egrep, vi, emacs Permits sophisticated editing via vi, emacs, sed, awk, perl, python, etc. Can capture parts of the pattern and manipulate Simple example to reverse columns separated by = : sed s/\(.*\)=\(.*\)/\2 = \1/ SomeFile.txt

Process Control Processes are organized in a hierarchical manner: Every process has a parent The parent forks and execs a child process Kill the parent, and all its children also die Reference with a Process ID Dead children are reaped...

Process Control Basic process control commands include: top List processes consuming most resources ps Get information about processes cmd & Run cmd in background process jobs List process running in background kill -9 PID Terminate a process kill %JobID Terminate using job ID xkill Terminate a process graphically users Who is logged in (variants: w and who) uptime How long since last reboot + load average

(Free) tools you can t live without Unix rules for data janitorial activities such as process text, extracting information from a stream of output, etc. Stream Editors: sed, awk, etc. Perl Python Eclipse (Photran, C/C++, Java) R Version control: svn or hg make

Listing 1: Text Extraction for NEOS Server: sed + bash #!/ b i n / bash INFILE=neosOutput. t x t for varname in V VK1 VK2 VK3 MIU HELPC HELPQ do sed n "/${varname}\[/,/;/p" $INFILE > out.${varname}. txt done

Listing 2: Text Extraction for NEOS Server: Python #! / usr / bin / env python import re import sys import string szinfile = sys.argv[ 1 ] szoutdir = sys. argv [ 2 ] vtokens = [ V, VK1, VK2, VK3, MIU ] # Load NEOS input file fin = open( szinfile ) vtext = fin. read ( ) fin. close () for sztoken in vtokens : pat = re. compile ( sztoken + " \[[^;] ;", re.dotall ) tgt = pat. search( vtext ) ixstart = tgt. start () ixend = tgt. end() f = open( szoutdir + / + sztoken +. out, w ) f.write( vtext[ ixstart:ixend ] ) f.close()