CS314 – Section 5 Recitation 1

Slides:



Advertisements
Similar presentations
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
Advertisements

Linux File & Folder permissions. File Permissions In Ubuntu, files and folders can be set up so that only specific users can view, modify, or run them.
Exploring the UNIX File System and File Security
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Linux Files. Files and directories As in Windows directories are structures which contain –Other directories –Files.
Unix Basics. Systems Programming: Unix Basics 2 Unix Basics  Unix directories  Important Unix file commands  File and Directory Access Rights through.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Linux File Security. What is Permission ? Specifies what right are granting to users to access the resources available in the computer. So that important.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Systems Programming Concepts
Review for Exam 1 Exam 1 on June 24 CSC 3320.
Learning basic Unix command IT 325 operating system.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
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”
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Unix Basics Chapter 4.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Linux+ Guide to Linux Certification, Second Edition
The UNIX development environment CS 400/600 – Data Structures.
Working with Linux Lab 1 1. Login and logout Account – username & password – Note: Linux is case-sensitive Administrator: username = root Logout: exit,
Chapter Two Exploring the UNIX File System and File Security.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Chapter Two Exploring the UNIX File System and File Security.
Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
40 Years and Still Rocking the Terminal!
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Linux Commands C151 Multi-User Operating Systems.
Revision: Absolute and relative paths. (root) staffusrbinstudetc ResearchTeachingPrivate pgugitmasters xxxgtrxxx CUA Coursework1.txt CUA xxx02uxxx04u.
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.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
File System Security ls -l. First Columm d = directory l = symbolic link b = block special file c = character special file p = fifo (or named pipe) special.
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.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
Learning basic Unix command It 325 operating system.
Dr. Sajib Datta Jan 16,  The website is up.  Course lectures will be uploaded there ◦ Check regularly for assignments and update.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Linux Shell. Outline Introduction to Linux Learning the Shell Writing Shell Scripts.
CS314 – Section 5 Recitation 2
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.
Linux Commands Workout 1
Prepared by: Eng. Maryam Adel Abdel-Hady
Linux 101 Training Module Linux Basics.
Lecture 2 Working with Files and Directories
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Useful Linux Commands.
BIF703 File Permissions.
Tutorial of Unix Command & shell scriptS 5027
Introduction to UNIX.
Using Linux Commands Lab 3.
Exploring the UNIX File System and File Security
Security and File Permission
UNIX Reference Sheets CSE 2031 Fall 2010.
In the last class,. ls –l command. seven fields
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
January 26th, 2004 Class Meeting 2
Presentation transcript:

CS314 – Section 5 Recitation 1 Long Zhao (lz311@rutgers.edu) Basic Linux Command Rewrite System Regular Expressions Introduction Attendance Homework

Linux command List files and directories ls List the files in the working directory ls /bin List the files in the /bin directory (or any other directory you care to specify) ls -l List the files in the working directory in long format ls -l /etc /bin List the files in the /bin directory and the /etc directory in long format ls -la .. List all files (even ones with names beginning with a period character, which are normally hidden) in the parent of the working directory in long format Get your ilab account

pwd: Get current working directory cd: Change working directory Navigation: pwd: Get current working directory cd: Change working directory File/directory manipulation: cp: Copy file/directory cp file1 file2 Copies the contents of file1 into file2. cp -i file1 file2 If file2 exists, user is prompted before it is overwritten. cp file1 dir1 Copy the contents of file1 (into a file named file1) inside dir1. cp -R dir1 dir2 Copy contents of dir1. If dir2 does not exist, it is created. Otherwise, it creates a directory named dir1 within directory dir2. mv: move or rename file/directory mv file1 file2 If file2 does not exist, file1 is renamed file2. If file2 exists, its contents are replaced with the contents of file1. mv dir1 dir2 If dir2 does not exist, then dir1 is renamed dir2. If dir2 exists, the directory dir1 is created within directory dir2. mv file1 dir1 file1 is moved to directory dir1. dir1 must exist. mkdir: create directory rm: delete file/directory (-r)

Permission: chmod: change the permissions of a file or directory $ ls -l /bin/bash => -rwxr-xr-x 1 root root 316848 Jan 20 2017 /bin/bash The file "/bin/bash" is owned by user "root" The superuser has the right to read, write, and execute this file The file is owned by the group "root" Members of the group "root" can also read and execute this file Everybody else can read and execute this file chmod: change the permissions of a file or directory chmod xyz some_file ; xyz is a 3-digit octal number, e.g: rwx = 111 in binary = 7 rw- = 110 in binary = 6 r-x = 101 in binary = 5 r-- = 100 in binary = 4 chown: change file ownership chown [new_user] file_name You must be superuser (su) to change owner. chgrp: change group ownership

Compile C program with GCC: Create (text) file: touch filename cat filename ; CTRL-D to end editing Use ‘>’ to create a text file from any command Use editor: nano, vi, etc. less filename: display content of text file Compile C program with GCC: There are 3 source files: “myprint.c” includes “myprint.h”; “main.c” includes “myprint.h” $gcc -c main.c myprint.c main.o myprint.o $gcc main.o myprint.o -o exe_file

Rewrite system $ 0 1 1 0 1 # Rules: rule 1 : $ 1 => 1 & rule 5 : $ # => A rule 6 : & # => B Rewrite: $01101# 0$1101# by rule 2 01&101# by rule 1 011$01# by rule 3 0110$1# by rule 2 01101&# by rule 1 01101B by rule 6

Rewrite system $ 1 0 1 0 0 # Rules: rule 1 : $ 1 => 1 & rule 5 : $ # => A rule 6 : & # => B Rewrite: $10100# 1&0100# by rule 1 10&100# by rule 4 101$00# by rule 3 1010$0# by rule 2 10100$# by rule 2 10100A by rule 5

Rewrite system The final value produced by a rewrite system is called the normal form of the input. Does every rewrite system result in a normal form? If yes, why? If no, give an example. Can there be more than one possible result from a rewrite system, for the same input? If yes, give an example. If no, why?

Rewrite system $110# Rules: 1 ⇒ 11 0 ⇒ 00 The final value produced by a rewrite system is called the normal form of the input. Does every rewrite system result in a normal form? If yes, why? If no, give an example. $110# Rules: 1 ⇒ 11 0 ⇒ 00

Rewrite system $110# Rules: 11 ⇒ 0 10 ⇒ 1 Can there be more than one possible result from a rewrite system, for the same input? If yes, give an example. If no, why? $110# Rules: 11 ⇒ 0 10 ⇒ 1

Rewrite system What does the following rewrite system (the one from lecture 1) produce on input $0101# ? Construct a rewrite system to determine whether a binary number (e.g., $0101#) is even or odd. $1 ⇒ 1& $0 ⇒ 0$ &1 ⇒ 1$ &0 ⇒ 0& $# ⇒ A &# ⇒ B

Rewrite system What does the following rewrite system (the one from lecture 1) produce on input $0101# ? Rules: $1 ⇒ 1& $0 ⇒ 0$ &1 ⇒ 1$ &0 ⇒ 0& $# ⇒ A &# ⇒ B $0101# ⇒ 0$101# ($0 ⇒ 0$) 0$101# ⇒ 01&01# ($1 ⇒ 1&) 01&01# ⇒ 010&1# (&0 ⇒ 0&) 010&1# ⇒ 0101$# (&1 ⇒ 1$) 0101$# ⇒ 0101A ($# ⇒ A)

Rewrite system Construct a rewrite system to determine whether a binary number (e.g., $0101#) is even or odd. Rules: 1# ⇒ -O 0# ⇒ -E 1- ⇒ - 0- ⇒ - $- ⇒ ϵ $0101# ⇒ $010-O (1# ⇒ -O) $010-O ⇒ $01-O (0- ⇒ -) $01-O ⇒ $0-O (1- ⇒ -) $0-O ⇒ $-O (0- ⇒ -) $-O ⇒ O ($- ⇒ ϵ)

00# ⇒ 0# 10# ⇒ 0# 01# ⇒ 1# 11# ⇒ 1# $0# ⇒ E $1# ⇒ O Rewrite system Construct a rewrite system to determine whether a binary number (e.g., $0101#) is even or odd. Rules: 00# ⇒ 0# 10# ⇒ 0# 01# ⇒ 1# 11# ⇒ 1# $0# ⇒ E $1# ⇒ O $0101# ⇒ $011# (01# ⇒ 1#) $011# ⇒ $01# (11# ⇒ 1#) $01# ⇒ $1# (01# ⇒ 1#) $1# ⇒ O

Regular expressions Token: shortest string of characters with individual meaning. E.g. keywords, identifier, constant, operator, … Language has few to hundreds of tokens. C language: keyword (int, float, return), identifier (var1, func), constant (0x01, 0.01), operator (+, -, …) Regular expression: a pattern used to specify a set of strings required for a particular purpose.

Regular expressions (From Scott book) A regular expression is one of 1. A character 2. The empty string, denoted ϵ 3. Two regular expressions next to each other, meaning any string generated by the first one followed by (concatenated with) any string generated by the second one 4. Two regular expressions separated by a vertical bar ( | ), meaning any string generated by the first one or any string generated by the second one 5. A regular expression followed by a Kleene star, meaning the concatenation of zero or more strings generated by the expression in front of the star

Regex exercises Find regex representing the language Language Regex {0} {0,1} {0,01} {0, ϵ}{001} {1}*{10} {10,11,1100}*

Regex exercises Find regex representing the language Language Regex {0} {0,1} 0|1 {0,01} 0|01 {0, ϵ}{001} (0|ϵ)001 {1}*{10} 1*10 {10,11,1100}* (10|11|1100)*

Regex exercises Construct a regular expression for binary numbers of length two. Construct a regular expression for binary numbers with even length. Find regular expressions over {0, 1} that determine the language which consists of all strings with even number of 1s.

Regex exercises (0|1)(0|1) or (00|01|10|11) Construct a regular expression for binary numbers of length two. (0|1)(0|1) or (00|01|10|11)

Regex exercises ((0|1)(0|1))* or (00|01|10|11) * Construct a regular expression for binary numbers with even length. ((0|1)(0|1))* or (00|01|10|11) *

Regex exercises What would be the regular expression corresponding to the language which consists of all strings of 0s and 1s that have odd length?

Regex exercises What would be the regular expression corresponding to the language which consists of all strings of 0s and 1s that have odd length? Based on the previous example, we can add only 1 digit to the front or the end of the string. Thus, the regular expression can be (0|1)(00|01|10|11)* or (00|01|10|11)*(0|1).

Regex exercises (0*10*10*)* Find regular expressions over {0, 1} that determine the language which consists of all strings with even number of 1s. (0*10*10*)*

Regex exercises Find regular expressions over {0, 1} that determine the language which consists of all strings with odd number of 0s.

Regex exercises (1*01*)(1*01*01*)* Find regular expressions over {0, 1} that determine the language which consists of all strings with odd number of 0s. (1*01*)(1*01*01*)*