Introduction to UNIX A User’s Perspective: Day 3: Advanced Commands & vi.

Slides:



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

PacNOG 6: Nadi, Fiji Using Commands in Linux Hervey Allen Network Startup Resource Center.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.
Introduction to UNIX GPS Processing and Analysis with GAMIT/GLOBK/TRACK T. Herring, R. King. M. Floyd – MIT UNAVCO, Boulder - July 8-12, 2013 Directory.
“Linux at the Command Line” Don Johnson of BU IS&T.
Introduction to Linux and Shell Scripting Jacob Chan.
Shell Script Examples.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
1. This presentation covers :  User Interface Administration  Files System and Services Management 2.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Advanced File Processing
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
CENT 305 Information Systems Security Linux Introduction.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
Grades Please hand in your homework Quizzes coming back today Current grade on back with missing assignments Anything missing can be turned in late There.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Third Edition
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
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.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 11: Shell.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Using Commands Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
Using Commands Unix / Linux Preparation Course May 6, 2012 Serrekunda, The Gambia.
Unix Shell Basics Edited from Greg Wilson's "Software Carpentry"
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.
Lecture One. Objective: Provide description of the Command-Line Editor of Linux operating system. Enable students to understand the practical side of.
40 Years and Still Rocking the Terminal!
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
Using the “CLI” Unix / Linux Preparation Course June 9, 2013 Lusaka, Zambia.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Unix Advanced Shells Chapter 10. Unix Shells u Command Line Interpreter –once logged in, login gives control to a shell –it prompts for input, then parses,
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
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.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Comp 145 – Introduction to UNIX $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 UNIX Processes.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Chapter 11 Command-Line Master Class
Shell Environments.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Introduction to Linux Week 0 - Thursday.
John Carelli, Instructor Kutztown University
Guide To UNIX Using Linux Third Edition
Tutorial of Unix Command & shell scriptS 5027
Linux Shell Script Programming
A shell is a user interface.
Presentation transcript:

Introduction to UNIX A User’s Perspective: Day 3: Advanced Commands & vi

What We Will Cover Today Shell customizations File operation commands The UNIX search utility vi Shell script basics

Clean Up: Standard Error Redirecting standard error – 2> = redirect standard error Let’s redo the link example seen yesterday – cat file 2> errors – cat index.html 2> errors

BASH! User friendly & Free Want to switch – $ bash Easy to navigate and edit at command-line – Let’s see…

Bash Tip 1 History recall – The up/down arrow Korn Shell equivalent – $ set –o vi Let’s you use vi control keys at the command-line

Bash Tip 2 Tab completion – Hitting the tab key will attempt to complete file name from the current directory – Example $ cd $ cd pu (hit the tab key)

Bash Tip 3 Remembering your history – Attempts to auto complete commands previously entered – Start with CTRL-R – Start typing Try ls -al

Bash Customization Ideas Make you life easier Examples: – $ alias procs=‘echo “Number of processes are: ”;ps | wc –l’ Issue the command ‘procs’ – $ procs – $ alias ll=‘ls –al’ – $alias l=‘ls’ These can be placed in your.profile so they are always available

Understanding Your Environment env – Values that follow you when you change shells set – Values set when you enter a shell – Lost when leave that shell

File Operations join grep diff cmp dircmp split sed

join cd cp –p /u/ux101is1/jointest*. sort –k 1 jointest1 > jtest1s sort –k 1 jointest2 > jtest2s join jtest1s jtest2s – What are the issues? – What are possible resolutions?

grep cd grep your_user_name /etc/passwd – What did you find? grep –i Filter * – What did you find? – What is the problem?

diff cd diff jtest1s jtest2s

cmp & dircmp cmp file1 file2 – cmp jtest1s jtest2s dircmp directory1 directory2 – dircmp -ds public_html public_html/test > dircmp.txt

split Example – $ split -l 1 jtest1s student – $ ls –al – $ cat student*

sed Example: – cd – cp -p jtest1s sedtest – $ cat sedtest – $ sed -e 's/mark/mike/g' sedtest > sedtest1 – $ cat sedtest1

Subshells No change to your current shell state – ( some commands ) – Example 1: $ ( date; who ) > whowhen.txt – Example 2: $ cd $ pwd $ ( cd pub*; pwd ) $ pwd – Implications?

The UNIX Search Tool find – Very versatile – Built in command handling – Extremely extensible – Can be used to search by any file characteristic

Advanced find Example 1: – find /u/msaba/public_html -type f -print | grep refs

Advanced find Example 2: – find /u/msaba/public_html -type f -print | grep refs 2> errors

Advanced find Example 3: – find /u/msaba/public_html -type f -print 2> errors | grep refs

Advanced find Example 4: – find. -name "*" -exec grep -i "ocks" {} /dev/null \;

find: Directory Tree Mapping Show the directory hierarchy of /tmp – $ find /tmp –type f –o –print – $ find /tmp –type d –print

Making find More Efficient A better way of invoking grep large number of files is: – $ find. -type f -print | xargs grep ocks – $ find. -type f -print 2> errors | xargs grep ocks 2>> errors This results in far fewer invocations of grep – Runs faster – Less system load

vi – The Only Editor You Need Why learn vi? – You don’t always have a GUI interface – It’s on every UNIX system – It’s powerful – Try it, you’ll like it!

Let’s Edit Something To create a new file – # vi new_file_name – # vi To open a file for editing – # vi existing_file_name

Additional Modes for Starting vi vi –r file – Recover the last saved version after a crash (rare) vi –R file – Read-Only vi +n file – Open with cursor at line number n vi file1 file2 file3 – Open multiple files, move between using :n

A Cool Feature of vi :r – Reads into the current file the contents of a file :r file – OR – The output of a command :r !command

Shell Scripts The first line: – #!/usr/bash The rest of the file: – Standard command sequences

A shell Script Example cd public_html vi bash.script – #!/usr/bash – cp –p /u/ux101fa*/ jointest* /u/ux101fa*/ public_html – sort -k 1 jointest1 > autojtest1s – sort -k 1 jointest2 > autojtest2s – join autojtest1s autojtest2s $. bash.script

What Should You Know? How to Log on and off of a UNIX system Be familiar with UNIX shells Be familiar with the UNIX file system UNIX Paths, ownership and permissions Use UNIX commands Use vi Write a basic shell script

Question? Anyone… anyone?

THANK YOU FOR ATTENDING Please fill out the Evaluation Form before leaving.