Introduction to UNIX (part 2) CSE 2031 Fall 2010 113 March 2016.

Slides:



Advertisements
Similar presentations
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Advertisements

Introduction to UNIX CSE 2031 Fall May 2015.
7 Searching and Regular Expressions (Regex) Mauro Jaskelioff.
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
File Security. Viewing Permissions ls –l Permission Values.
CS 497C – Introduction to UNIX Lecture 20: - The Shell Chin-Chih Chang
The UNIX Shells 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell.
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.
Linux File Security. What is Permission ? Specifies what right are granting to users to access the resources available in the computer. So that important.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Shell Script Examples.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
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”
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
Writing Shell Scripts ─ part 1 CSE 2031 Fall September 2015.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Unix Shells Based on Glass & Abels’ Book CS240 Computer Science II.
An Introduction to Unix Shell Scripting
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
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.
LIN Unix Lecture 3 Hana Filip. LIN UNIX Resources UNIX Tutorials UNIX help for.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Scripting Languages Course 2 Diana Trandab ă ț Master in Computational Linguistics - 1 st year
CS465 - UNIX The Bourne Shell.
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.
I/O Redirection and Regular Expressions February 9 th, 2004 Class Meeting 4.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
I/O Redirection & Regular Expressions CS 2204 Class meeting 4 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
CIT 140: Introduction to ITSlide #1 CIT 140: Introduction to IT Shell Programming.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Introduction to Unix (CA263) Quotes By Tariq Ibn Aziz.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Introduction to Unix (CA263) Command File By Tariq Ibn Aziz.
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.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Writing Shell Scripts ─ part 1
Prepared by: Eng. Maryam Adel Abdel-Hady
The UNIX Shell Learning Objectives:
Writing Shell Scripts ─ part 3
Writing Shell Scripts ─ part 3
Using Linux Commands Lab 3.
UNIX Reference Sheets CSE 2031 Fall 2010.
Writing Shell Scripts ─ part 1
Writing Shell Scripts ─ part 1
CSE 303 Concepts and Tools for Software Development
Shell Control Structures
Shell Control Structures
Chapter 3 The UNIX Shells
Introduction to UNIX (part 2)
CSC 4630 Meeting 4 January 29, 2007.
Introduction to UNIX (part 2)
Introduction to UNIX (part 2)
Introduction to UNIX EECS July 2019.
Presentation transcript:

Introduction to UNIX (part 2) CSE 2031 Fall March 2016

Command Terminators Command terminator: new line or ; % date; who Another command terminator: & % nedit lab9.c&  Tells the shell not to wait for the command to complete.  Used for a long-running command “in the background” while you continue to use the xterm for other commands. 2

Command Terminators (cont.) Use parentheses to group commands % ( sleep 5; date ) & date 14929# process ID of long-running command Tue Nov 9 14:06:15 EST 2010# output of 2 nd date % Tue Nov 9 14:06:20 EST 2010# output of 1 st date The precedence of | is higher than that of ; % date; who | wc -l % (date; who) | wc -l 3

tee command tee copies its input to a file as well as to standard output (or to a pipe). % date | tee date.out Tue Nov 9 13:51:22 EST 2010 % cat date.out Tue Nov 9 13:51:22 EST 2010 % date | tee date.out | wc % cat date.out Tue Nov 9 13:52:49 EST

Comments If a shell word begins with #, the rest of the line is ignored. Similar to // in Java. % echo Hello #world Hello % echo Hello#world Hello#world 5

Metacharacters Most commonly used: * Search the current directory for file names in which any strings occurs in the position of * % echo *# same effect as % ls * To protect metacharacters from being interpreted: enclose them in single quotes. % echo ‘***’ *** 6

Metacharacters (cont.) Or to put a backslash \ in front of each character: % echo \*\*\* *** Double quotes can also be used to protect metacharacters, but … The shell will interpret $, \ and `…` inside the double quotes. So don’t use double quotes unless you intend some processing of the quoted string (see slide 10). 7

Quotes Quotes do not have to surround the whole argument. % echo x’*’y# same as echo ‘x*y’ x*y What’s the difference between these two commands? % ls x*y % ls ‘x*y’ 8

Program Output as Arguments To use the output of a command X as the argument of another command Y, enclose X in back quotes: `X` % echo `date` Tue Nov 9 13:11:03 EST 2010 % date# same effect as above Tue Nov 9 13:11:15 EST 2010 % echo date date % wc `ls *` % wc *# same as above 9

Program Output as Arguments (2) Single quotes vs. double quotes: % echo The time now is `date` The time now is Tue Nov 9 13:11:03 EST 2010 % echo "The time now is `date`" The time now is Tue Nov 9 13:11:15 EST 2010 % echo 'The time now is `date`' The time now is `date` 10

Program Output as Arguments (3) % pwd /cs/home % ls | wc –l 26 % echo You have `ls | wc –l` files in the `pwd` directory You have 26 files in the /cs/home directory 11

File/Directory Permissions 12

Example indigo 354 % ls -l total 284 drwxr-xr-x 2 utn faculty 4096 Oct 29 21:35 Asg1/ drwx utn faculty 4096 Sep 19 13:37 Misc/ drwxr-xr-x 3 utn faculty 4096 Nov 7 15:37 Notes/ drwxr-x utn utn 4096 Nov 11 13:27 Posted_Labs/ drwxr-xr-x 5 utn faculty 4096 Nov 7 15:38 Weekly_Labs/ -rw-r--r-- 1 utn faculty 2003 Sep 9 14:10 grade.html -rw-r--r-- 1 utn faculty 4815 Oct 25 20:06 index.html -rw-r--r-- 1 utn faculty 2363 Oct 17 13:35 midterm.html -rw-r--r-- 1 utn faculty 4116 Nov 7 15:44 news.html -rw-r--r-- 1 utn faculty Sep 30 17:13 schedule.pdf -rw-r--r-- 1 utn faculty 4736 Nov 7 15:51 weekly_labs.html 13

chmod Command chmod who+permissions filename # or dirname chmod who-permissions filename # or dirname Examples: chmod u+x my_script# make file executable chmod a+r index.html# for web pages chmod a+rx Notes# for web pages chmod a-rx Notes chmod a-r index.html 14

chmod with Binary Numbers chmod u+x my_script chmod a+r index.html chmod a+rx Notes chmod a-rx Notes chmod a-r index.html chmod 700 my_script chmod 644 index.html chmod 755 Notes chmod 700 Notes chmod 750 Notes chmod 600 index.html chmod 640 index.html 15

chgrp Command chgrp grp_name filename # or dirname Examples: chgrp submit asg1 chgrp labtest lab9 To display the group(s) a user belongs to, use id command: % id cse12345 uid=12695(cse12345) gid=10000(ugrad) groups=10000(ugrad) 16

Next time … Writing shell scripts Reading for this lecture:  3.1 to 3.5, UNIX book  chmod tutorial: 17