The “File System” Under UNIX, (almost) everything is a “file”: –Normal files –Directories –Hardware –Sockets –Pipes Things that are not files: –Users –Groups.

Slides:



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

UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Introduction to UNIX CSE 2031 Fall May 2015.
Chapter 8 Files and User Information Utilities. Logical Partitions referred to as file systems like a drive in windows world $ df (display filesystems)
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Redirection & Pipes Understanding UNIX Input and Output.
User Accounts and Permissions Chapter IV / Part II.
UNIX Utilities Software Tools. Slide 2 Getting Started on UNIX The machines in CS Lab2 are named csl2wk01 through csl2wk41. csl2wk01 means “CSLab2, workstation#1”
The Unix Shell. Operating System shell The shell is a command interpreter It forms the interface between a user and the operating system When you log.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
Intermediate Unix Presented July 29 th, 2001 by: “Robin” R. Battey Evgeny Roubinchtein with tips,
Linux File Security. What is Permission ? Specifies what right are granting to users to access the resources available in the computer. So that important.
Introduction to Linux and Shell Scripting Jacob Chan.
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.
Chapter 4: UNIX File Processing Input and Output.
Introduction to UNIX/Linux Exercises Dan Stanzione.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Linux in More Detail Shirley Moore CPS5401 August 29,
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Agenda Basic Shell Operations Standard Input / Output / Error Redirection of Standard Input / Output / Error ( >, >>,
BIF703 stdin, stdout, stderr Redirection. stdin, stdout, stderr Recall the Unix philosophy “do one thing well”. Unix has over one thousand commands (utilities)
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.
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer,
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
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.
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
EMT 2390L Lecture 5 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Chapter Four I/O Redirection1 System Programming Shell Operators.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Learning Unix/Linux Based on slides from: Eric Bishop.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Unix Basics.
System Programming and administration CS 308
Some Linux Commands.
Shell Script Assignment 1.
stdin, stdout, stderr Redirection
Unix Operating System (Week Two)
Advanced GNU/Linux Command Line By: - Mohammed El-Sayed.
CSE 303 Concepts and Tools for Software Development
Basic UNIX OLC Training.
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Introduction to Computer Organization & Systems
More advanced BASH usage
Lecture 4 Redirecting standard I/O & Pipes
CSC 4630 Meeting 4 January 29, 2007.
Presentation transcript:

The “File System” Under UNIX, (almost) everything is a “file”: –Normal files –Directories –Hardware –Sockets –Pipes Things that are not files: –Users –Groups –Processes

File Permissions Every file has three access levels: –user(the user owner of the file) –group(the group owner of the file) –other(everyone else) At each level, there are three access types: –read(looking at the contents) –write(altering the contents) –execute(executing the contents)

Ownership Files have two owners –Every file has exactly one user owner –Every file has exactly one group owner Everyone is a user –Users are in at least one group Processes have owners, too (known as an “id”) –Every process has exactly one user id –Every process has at least on group id Users and groups are really just numbers with names –Every username is mapped to a single numeric “uid” –Every groupname is mapped to a single numeric “gid”

Who am I? Commands that tell you who you are: –whoami displays your username –id displays your username and groups Commands that tell you who others are: –finger [ ] displays info for –id [ ] displays info for Commands that change who you are: –su “switch user” to –login login as a different user

Changing Permissions The “change mode” command: chmod [,…] string of: u, g, o, a (user, group, other, all) one of +, -, = (gets, loses, equals) string of: r, w, x, s, t, u, g, o (read, write, execute, set-id, text, same as user, same as group, same as other), Examples: chmod u+rwx,go-w foobar chmod g=u,+t temp/ chmod u=rwx,g=rwxs,o= shared/

What is input/output redirection? Normally, a program’s standard output is displayed on user’s terminal, and its standard input comes from the keyboard. Redirecting the output of a program means asking the shell to put the program’s output ( stdout [C++’s cout ]) into a file. Redirecting the input of a program means asking the shell to feed a file as the program’s standard input ( stdin [C++’s cin ]). Note: redirection works with files.

How to redirect program’s output? To redirect just the standard output: > Example: ls –l > root-folders

> vs. >> Both > and >> will create the output file, if it doesn’t already exist If the file does exist, then: –Using > to redirect output will overwrite the output file: ls > newlisting printenv > my_environment –Using >> to redirect output will append to the output file cat ch1 ch2 ch3 > book cat ch4 ch5 ch6 >> book

Why redirect program’s input? To run the program repeatedly with the same (or similar input) Having the program read from standard input may make the program simpler to write.

How to redirect program’s input? Simple! Example sort < my_grades.txt head < really_long_book.txt

Piping Piping is connecting programs together by using the output of one program as the input to the next. Syntax: | | … | A simple example (view a sorted file-listing a page at a time): ls | sort | less Note: piping deals with the input/output of programs (that is, stdin, stdout, stderr )

Why piping? Because “the whole is bigger than the sum of its parts. By combining Unix utilities in a pipeline, you can build tools “on-the-fly” as you need them.

Piping examples How many.c files are in this directory? ls *.c | wc –l What files were modified most recently? ls –t | head What processes am I running? ps auxw | grep Redirection and piping used together –Sort –r < root-folders | more