Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions

Preview:

Citation preview

Session 2Wharton Summer Tech Camp

Basic Unix

Agenda

• Cover basic UNIX commands and useful functions

UNIX

• Operating System• AT&T – Bell Lab 1969 • Ken Thompson, Dennis Ritchie,

Brian Kernighan, etc (picture: Ken Thompson and Dennis Ritchie standing)

• Linux, Mac OSX descended from Unix

• For Windows, Unix-like environment can be achieved by– Just Logging into

Unix.wharton.upenn.edu OR– Install cygwin www.cygwin.com/

Wharton Grid

Unix Prompt

• [leedok@hpc-login2 ~]$

user name network node hostname

Current Directory name

(~ means home)

Unix Shell

• Unix Shell: A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems. (WIKI)

• Basically, a translator between unix OS (kernel) and user, delivering commands.

• There are many varieties: bash, tcsh, csh, ksh• Bash is the most popular

Information look up

• Manual page: “man [command]” “man man”• Google everything! • Stackoverflow.com

Command Structure

• [Command] [Options] [Argument]• ls –l directory

• Directory structure separated by “/”• /home/opim/leedok• Important Startup File: ~/.bash_profile

Command for listing

directory contents

Command for listing

directory contents

Directory name. By default, if you don’t specify, it’s current

working directory “.”

Control-key commands

• ctrl-c– interrupts a running program

• ctrl-z –suspends a running program –(use the fg command to continue the

program)

Directory Navigation

• ls - list content of a directory• pwd – print working directory• cd – change directory• mv – move file or rename• cp - create a copy of a file• rm – remove a file• mkdir – create a new directory• rmdir – remove a directory

Some other commands• who - list who is on system• echo, printf – display a message• script - log all interaction in a file• clear - clear the screen• cat, more, less – file perusal• du – file info• chmod – change permission• find:

– By Name: find . –name \*.ado– By Type: find . –type d (directory)– Etc

Pipes and Redirects

• > - Redirect output from a command to a file on disk.• >> - Append output from a command to an existing file on

disk.• < - Read a command's input from a disk file, rather than the

user.• | - Pass the output of one command to another for further

processing.

• Date > date.txt• Date >> date.txt• who | cut -f1 -d" " | sort -u

Bit more advanced commands

• grep – match string patterns (search)

• sed, awk – find and replace (text manipulation)

Lab session

1. Do some exercise posted “practice.sh”2. Do Unix tutorial if you are new to it

http://www.ee.surrey.ac.uk/Teaching/Unix/

1: Log into unix account if you have one Ssh uname@unix.wharton.upenn.edu2: If you have Mac OS, just open up the “Terminal”3: If you have Linux, you probably know this 4: if you have Windows, download terminal applications (e.g., putty, secureCRT etc)

For the next session

• Download and install Canopy – packaged python

• https://www.enthought.com/products/canopy/academic/

• People with EDU email gets it for free