Introduction to UNIX (part 2)

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.
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.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
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.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
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.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
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.
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.
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 ?
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
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
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)
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.
Introduction to UNIX (part 2) CSE 2031 Fall March 2016.
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).
Learning Unix/Linux Based on slides from: Eric Bishop.
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.
Introduction to Shells
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Writing Shell Scripts ─ part 1
Prepared by: Eng. Maryam Adel Abdel-Hady
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
The UNIX Shell Learning Objectives:
Lecture 2 Working with Files and Directories
Some Linux Commands.
CSE 303 Concepts and Tools for Software Development
Writing Shell Scripts ─ part 3
Writing Shell Scripts ─ part 3
Basic UNIX OLC Training.
Introduction to UNIX.
Using Linux Commands Lab 3.
Pepper (Help from Dr. Robert Siegfried)
Security and File Permission
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
Linux Commands LINUX COMMANDS.
Introduction to UNIX (part 2)
CSC 4630 Meeting 4 January 29, 2007.
Introduction to UNIX (part 2)
Introduction to UNIX EECS July 2019.
BASIC FILE ATTRIBUTES.
January 26th, 2004 Class Meeting 2
Presentation transcript:

Introduction to UNIX (part 2) EECS 2031 30 June 2019

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.

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 2nd date % Tue Nov 9 14:06:20 EST 2010 # output of 1st date The precedence of | is higher than that of ; % date; who | wc -l % (date; who) | wc -l sleep: SUFFIX may be "s" for seconds (the default), "m" for minutes, "h" for hours, or "d" for days. ls –FC -F Flags filenames. -C Displays files in a columnar format (default)

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

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 ‘***’ ***

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).

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’

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

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`

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

File/Directory Permissions

Example indigo 354 % ls -l total 284 drwxr-xr-x 2 utn faculty 4096 Oct 29 21:35 Asg1/ drwx------ 2 utn faculty 4096 Sep 19 13:37 Misc/ drwxr-xr-x 3 utn faculty 4096 Nov 7 15:37 Notes/ drwxr-x--- 10 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 112755 Sep 30 17:13 schedule.pdf -rw-r--r-- 1 utn faculty 4736 Nov 7 15:51 weekly_labs.html

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 o-rx Notes chmod o-r index.html

chmod with Binary Numbers chmod u+x my_script chmod a+r index.html chmod a+rx Notes chmod go-rx Notes chmod o-rx Notes chmod go-r index.html chmod o-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

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

Next lecture Writing shell scripts Reading for this lecture: 3.1 to 3.5, UNIX book chmod tutorial: http://catcode.com/teachmod/