CSCI 2132 Software Development. Lecture 4: Files and Directories

Similar documents
Files and Directories

CSCI 2132 Software Development. Lecture 5: File Permissions

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

Files

CHAPTER 1 UNIX FOR NONPROGRAMMERS

5/8/2012. Creating and Changing Directories Chapter 7

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Commands are in black

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction: What is Unix?

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Chapter-3. Introduction to Unix: Fundamental Commands

Mills HPC Tutorial Series. Linux Basics I

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

commandname flags arguments

Perl and R Scripting for Biologists

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

The Unix Shell. Pipes and Filters

Introduction to Linux

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

A Brief Introduction to Unix

Introduction to Unix: Fundamental Commands

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Chapter 1 - Introduction. September 8, 2016

Overview of the UNIX File System. Navigating and Viewing Directories

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Introduction to Linux

Oxford University Computing Services. Getting Started with Unix

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

CSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions

Unix Shells and Other Basic Concepts

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Unix Workshop Aug 2014

Introduction to UNIX command-line

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Overview of the UNIX File System

Introduction to Linux Workshop 1

Std: XI CHAPTER-3 LINUX

CS246 Spring14 Programming Paradigm Notes on Linux

Session 1: Accessing MUGrid and Command Line Basics

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Linux Command Line Primer. By: Scott Marshall

Week 2 Lecture 3. Unix

Introduction to the UNIX command line

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

User Guide Version 2.0

CS4350 Unix Programming. Outline

Introduction to the Linux Command Line

Multiple Choice - 58 Questions - 10 of 15%

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

UNIX File Hierarchy: Structure and Commands

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

Lab Working with Linux Command Line

Lecture 2: The file system

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Introduction to Linux

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Introduction to Linux. Roman Cheplyaka

Getting started with Hugs on Linux

Operating Systems, Unix Files and Commands SEEM

CS CS Tutorial 2 2 Winter 2018

AN INTRODUCTION TO UNIX

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

The Unix Shell & Shell Scripts

Physics REU Unix Tutorial

Lec 1 add-on: Linux Intro

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

Short Read Sequencing Analysis Workshop

Scripting Languages Course 1. Diana Trandabăț

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

Computer Systems and Architecture

CS197U: A Hands on Introduction to Unix

CSE 391 Lecture 1. introduction to Linux/Unix environment

CS Fundamentals of Programming II Fall Very Basic UNIX

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems

Introduction to UNIX I: Command Line 1 / 21

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

Computer Systems and Architecture

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

SECTION -C. Getting Started with UNIX

Transcription:

CSCI 2132 Software Development Lecture 4: Files and Directories Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 12-Sep-2018 (4) CSCI 2132 1

Previous Lecture Some hardware concepts Main UNIX concepts, Shells Logging in, PuTTY Some basic utilities and commands date, clear, passwd, man Shell metacharacters cat example, file redirection Logging out 12-Sep-2018 (4) CSCI 2132 2

Files and Directories Many concepts in Unix are either a file or a process File is a stream of bytes Many devices and constructs are seen as files: regular files, stdin, stdout, stderr, keyboard, monitor, hard disk, CD/DVD,... File is a good example of abstraction File is described by a general interface 12-Sep-2018 (4) CSCI 2132 3

1. Regular files 2. Directory files Seven Types of Files 3. Buffered special files (block devices) 4. Unbuffered special files (character devices) 5. Symbolic links 6. Pipes (named pipes) 7. Sockets ls -l command reveals a file type: -, d, b, c, l, p, s Example: drwxr-xr-x 2 vlado csfac 4096 Sep 13 06:24 c -rw-r--r-- 1 vlado csfac 0 Sep 13 06:34 file 12-Sep-2018 (4) CSCI 2132 4

Navigating Directory Structure / users bin tmp etc var usr... faculty visitor vlado...... bin lib local... csci2132... lab1 HelloWorld.java HelloWorld.class 12-Sep-2018 (4) CSCI 2132 5

Some Notions in Directory Structure A tree with root directory (/) If a directory A contains directly directory B: A is parent directory of B B is subdirectory of A Each directory has two special directory entries: dot (.) the directory itself dot-dot (..) the parent directory 12-Sep-2018 (4) CSCI 2132 6

Each file has a name Pathname (Path) Files can have the same name if they are in different directories Example: see bin in the previous figure To distinguish files with the same name, we use pathnames Pathname (or path) is a sequence of directories, finishing with a file name Directories are separated using character slash (/) Example: /users/faculty/vlado/csci2132/lab1/helloworld.java 12-Sep-2018 (4) CSCI 2132 7

Two Kinds of Paths Absolute path starts from root (initial slash /), examples: /usr/bin /users/faculty/vlado/csci2132/lab1/helloworld.java Relative path starts from the current directory; examples (if the current directory is vlado ): csci2132 csci2132/lab1/helloworld.java./csci2132/lab1/helloworld.java../../visitor./a.out 12-Sep-2018 (4) CSCI 2132 8

Parts of Pathname Pathname: dirname and basename Example commands: $ basename /home/ed/file.txt file.txt $ basename /home/ed/file.txt.txt file $ dirname /home/ed/file.txt /home/ed Note: blue text above is system output and red text is our input; we will use $ or > as shell prompt. 12-Sep-2018 (4) CSCI 2132 9

Useful Commands related to Directories ls paths pwd cd path list directory contents print working directory change directory mkdir dirs make directory(ies) mkdir -p paths whole paths, no errors rmdir dirs remove empty directory(ies) mv path1 path2 move or rename directory or file mv -i path1 path2 prompt before overwrite rm paths remove files but can remove directories with option -r; useful to consider -f and -i tree paths note: not a standard Unix command 12-Sep-2018 (4) CSCI 2132 10

A Small Exercise Let us consider the following commands: $ pwd /home/ed $ mkdir tmp $ cd tmp $ mkdir a b c $ mkdir -p a/a1 a/a2/a21 a/a2/a22 $ cd a/a2/a22 What is our absolute current directory? What directory is..? Do the following directories exist and what are their absolute paths:..,../../b, and../../../c? 12-Sep-2018 (4) CSCI 2132 11

File Manipulation cat files showing textual file(s) content more files showing textual file content, paged head files showing textual file content, first part tail files showing textual file content, last part vi, emacs, pico, nano file editors wc files word count learn about -c, -w, and -l options of wc 12-Sep-2018 (4) CSCI 2132 12

File Permissions We will discuss the concepts of: users and groups different types of permissions on files 12-Sep-2018 (4) CSCI 2132 13

Users, Usernames and UserIDs Used to protect files and processes between different users Every user has a unique username, which is a text string Try command: whoami The system uses numeric userid, which we will call just userid (username is for string id) Try command: id -u 12-Sep-2018 (4) CSCI 2132 14

Groups Every UNIX user is a member of a group A user can be member of multiple groups, but one is effective for a process Each group has a unique groupname and groupid Command to list groups user is member of: groups Command for more complete information: id Each process, including shell, has one effective userid and groupid Each file is owned by one user and one group: file owner and file group 12-Sep-2018 (4) CSCI 2132 15

File Permissions Each file has 3 sets of permissions: file owner permissions (u) file group permissions, (but not the user), (g) permissions for others, (not user and not the group) (o) For each set, there are three true/false permissions: read (r) write (w) execute (x) What these permissions mean for regular files and directories? 12-Sep-2018 (4) CSCI 2132 16