Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Introduction to UNIX CSE 2031 Fall May 2015.
1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
CSE 303 Lecture 2 Introduction to bash shell
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.
Introduction to Linux/UNIX. History UNIX beginnings in 1969 (Linus Torvalds is born!) AT & T Bell Laboratories (Ken Thompson & Dennis Richie) Working.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Lecture 2 UNIX.  1999 Addison Wesley Longman4.2 Basics of Operating Systems.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
CS 2061 Shells Also known as: Unix Command Interpreter.
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Linux+ Guide to Linux Certification, Third Edition
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
1 UNIX essentials (hands-on) the directory tree running programs the shell → command line processing → special characters → command types → shell variables.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
Lecture 1: Introduction, Basic UNIX
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Lesson 8-Specifying Instructions to the Shell. Overview An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing.
Learning Unix/Linux Based on slides from: Eric Bishop.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
CSE 374 Programming Concepts & Tools
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Introduction to Linux Week 0 - Thursday.
Tutorial of Unix Command & shell scriptS 5027
Introduction to Linux/UNIX
Exploring Shell Commands, Streams, and Redirection
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Linux Shell Script Programming
Module 6 Working with Files and Directories
Linux Commands LINUX COMMANDS.
LPI Linux Certification
Presentation transcript:

Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques

Why are we here? What’s a computer Why do we run programs? What is needed to create a program?

Structure of a typical OS Applications Shell \ Kernel (OS) Hardware There are many standard applications: file system commands text editors compilers text processing

Logging In Create Acct Cluster PuTTY/SSH Log in Password

Home Directory The user’s personal directory. E.g., /home/kschmidt /home/vzaychik Location of many startup and customization files. E.g.:.vimrc.bashrc.bash_profile.forward.signature.plan.logout

Unix Filesystem Files Directories Other special files

The Filesystem (eg) / binetchome/tmpusr hollid2scullybinetc netprogunixXlswho

Pathnames Unique, on a given filesystem Absolute vs. relative./../ ~/

Pathname Examples / bin/etc/home/tmp/usr/ Hollid2/scully/bin/local/ netprogunix/Xlswho /usr/bin/ls Syllabus /home/hollid2/unix/Syllabus

Commands for Traversing Filesystem ls pwd cd rm cp mv mkdir rmdir

Viewing files cat less, more od Comparing files diff cmp

Copying, removing, linking rm – remove file mv – move (rename) file cp – copy file ln – create hard (inode) or soft (symbolic) links to a file touch – update file modification time, create an empty file if file doesn’t exist

Commands for directories mkdir make directory rmdir remove directory Directories can also be moved or renamed ( mv ), and copied ( cp –r )

Commands for Archiving tar – Tape Archive makes a large file from many files gzip, gunzip compression utility tar on Linux does compression with the z option: $ tar czf 571back.tgz CS571 $ tar xzf assn1.tgz

File Permissions Three types: readabbreviated r writeabbreviated w execute abbreviated x There are 3 sets of permission: 1. user 2. group 3. other (the world, everybody else)

ls -l and permissions -rwxrwxrwx User Group Others Type of file: - – plain file d – directory s – symbolic link

Bourne-again Shell (bash) Shells Startup Upon login (interactive), at the shell prompt customization files:  /etc/profile .bash_profile .bashrc

Command syntax First token is the “command” Come in 3 flavors: alias shell builtin External programs (utilities)  $PATH Use type

Command Options and Arguments command option(s) arguments Options (flags) Short Long Option args Arguments

man Pages man info

Some simple commands date – print current date who – print who is currently logged in finger usr – more information about usr ls -ao – lists (long) all files in a directory du -sh – disk usage summary, human readable quota

Standard I/O The shell establishes 3 I/O channels: stdin (0) stdout (1) stderr (2) These streams my be redirected to/from a file, or even another command

Basic control codes Ctrl-D (^D) set ignoreeof Ctrl-C (^C) Ctrl-U (^U) Ctrl-Z (^Z) Ctrl-L (^L)

Shell metacharacters Some characters have special meaning to the shell: I/O redirection | wildcards * ? [ ] others & ; $ ! \ ( ) space tab newline These must be escaped or quoted to inhibit special behavior

Shell Variables Values Assignment Reading

Shell maintains variables Some common ones: $PATH – list of directories to search for utilities $PS1 – Primary prompt $HOME – user’s home directory $USER – user’s login name $PWD – current working directory

set command (shell builtin) The set command with no parameters will print out a list of all the shell variables Sets options in the shell -o -noclobber -ignoreeof

Quoting Escape char Strong quoting Weak quoting

I/O Redirection > - output to a file (clobber) >> - append < - input from a file 2> - redirect stderr

Pipes – connecting processes A pipe is a holder for a stream of data. A pipe can be used to hold the output of one program and feed it to the input of another. prog1 prog2 STDOUT STDIN

filters Programs that read some input (but don’t change it), perform a simple transformation on it, and write some output (to stdout) Some common filters… wc – word count (line count, character count) tr – translate grep, egrep – search files using regular expressions sort – sorts files by line (lexically or numerically) cut – select portions of a line uniq – Removes identical adjacent lines head, tail – displays first (last) n lines of a file

The Unix Philosophy Stringing small utilities together with pipes and redirection to accomplish non-trivial tasks easily E.g., find the 3 largest subdirectories: $ du –sh * | sort –nr | head Files Zaychik 9472 tweedledee.tgz

pipes and combining filters Connect the output of one command to the input of another command to obtain a composition of filters who | wc -l ls | sort -f ls -s | sort -n ls -l | sort -nr -k4 ls -l | grep ‘^d’

Process Control Processes run in a subshell Subshells inherit exported variables Each process is has an ID (pid) and a parent (ppid) Use the ps utility to look at some processes: $ ps PID TTY TIME CMD 350 pts/4 00:00:00 bash pts/4 00:00:00 vim pts/4 00:00:00 ps

Job Control The shell allows you to manage jobs place jobs in the background move a job to the foreground suspend a job kill a job

Editors A text editor is used to create and modify text files. The most commonly used editors in the Unix community: vi (vim on Linux)  $ vimtutor emac  $ emacs  Then, hit ctrl-h t (that’s control-h, followed by ‘t’) You must learn at least one of these editors