15
Session 2 Wharton Summer Tech Camp Basic Unix

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

Embed Size (px)

Citation preview

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

Session 2Wharton Summer Tech Camp

Basic Unix

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

Agenda

• Cover basic UNIX commands and useful functions

Page 3: Session 2 Wharton 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/

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

Wharton Grid

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

Unix Prompt

• [leedok@hpc-login2 ~]$

user name network node hostname

Current Directory name

(~ means home)

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

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

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

Information look up

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

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

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 “.”

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

Control-key commands

• ctrl-c– interrupts a running program

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

program)

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

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

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

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

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

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

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

Bit more advanced commands

• grep – match string patterns (search)

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

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

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 [email protected]: 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)

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

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