Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology / File Naming Rules Relative vs Absolute pathnames mkdir,

Slides:



Advertisements
Similar presentations
Pre-Assessment Questions
Advertisements

The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
The UNIX File System CS465. File Systems What is a file system? A means of organizing information on the computer. A file system is a logical view, not.
Linux+ Guide to Linux Certification, Second Edition
UNIX Chapter 11 File Sharing Mr. Mohammad Smirat.
Chapter 5 Accessing Files and Directories. How Directories Get Created OS installation: usr, dev, etc, export, kernel and others places to store installation.
Linux Linux File System.
Guide To UNIX Using Linux Third Edition
File Management System The way a user or application may access files Programmer does not need to develop file management software You take files for granted.
UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.
Basic UNIX © McGraw Hill All rights reserved.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Guide To UNIX Using Linux Fourth Edition
Notes Assignment #1 is due next Friday by 11:59 pm via Test #1 will be held Thursday February 18 at the start of class (one period long) Format:
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Files & Directories Objectives –to be able to describe and use the Unix file system model and concepts Contents –directory structure –file system concepts.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
1Week 4 - Jan 31, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)
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.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Chapter Two Exploring the UNIX File System and File Security.
8-2 What is a program? What is a “Window Manager” ? What is a “GUI” ? How do you navigate the Unix directory tree? What is a wildcard? Readings: See CCSO’s.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Chapter 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
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
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Agenda The Linux File System (chapter 4 in text)
BIF713 File and Directory Management. File System A File System is a structure used to organize programs and data on a computer ’ s storage device Files.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Agenda The Linux File System (chapter 4 in text) Setting Access Permissions Directory vs File Permissions chmod Utility Symbolic Method Absolute Method.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system.
BIF703 File Permissions. As you recall from our previous notes, that Unix/Linux recognizes everything as a file: Regular files to store data, programs,
Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems.
Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:
Agenda The Linux File System (chapter 4 in text) Linking Files Hard Links / Symbolic Links Disk Storage Checking for Disk Space (df / du) Archiving (Backing.
CMSC 104, Version 9/011 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
Linux Filesystem Management
Agenda The Linux File System (chapter 4 in text)
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.
Lecture 2 Working with Files and Directories
BIF703 File Permissions.
Exploring the UNIX File System and File Security
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain.
The Linux Command Line Chapter 4
Operating Systems and Using Linux
Operating Systems and Using Linux
Agenda The Linux File System (chapter 4 in text)
Operating Systems and Using Linux
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
The Linux Command Line Chapter 4
Presentation transcript:

Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology / File Naming Rules Relative vs Absolute pathnames mkdir, mkdir -p, rmdir, rm -r ls, ls -a, ls -F, ls -l, ls -ld Setting Access Permissions chmod / umask Linking Files Hard Links / Symbolic Links

File System A File System is a structure used to organize programs and data on a computer’s storage device Linux (Unix) OS has a special file called a directory file used to store ordinary files as well as other “directories” Directories allow a computer’s file system to be better organized.

Hierarchical File System In the Linux (Unix) OS, the “root directory” / is the starting directory, and other “child directories”, “grandchild directories” …etc. are created The hierarchical structure resembles an “upside-down tree” root / homeetc abc12

Typical UNIX Directories / Root directory (ancestor to all directories) /homeUsed to store users’ home directories /usr/binCommon utilities (commands) for user /usr/sbinCommon utilities for user administration /etcGeneral System Admin. Files (eg passwd) /varDynamic files (log files) /tmpUser’s temporary file for programs /dev Device files (terminals, printers, etc…)

File Naming Rules The following rules apply to naming ordinary files or “directory files”: Some file systems restrict filename size to 14 characters, other file systems allow for 255 characters (best to select filename size of 14) Can use letters (upper & lower case), numbers, period, comma or underscore _ characters Upper case different than lower case Period at beginning of filename hides file

Pathnames A pathname is a listing of directories that will lead to a directory or a file. Examples: Directory pathname: /home/username/ics124/assignments File pathname: /home/username/ops224/assignments/assn1.txt

Absolute vs Relative Pathnames Absolute Pathname A pathname that begins from root. The pathname usually begins with a slash / or ~ eg. /home/msaul/ops224 ~/ics124/sample_tests (where ~ represents /home/username) Relative Pathname A pathname that is “relative” to the location of another directory

Relative Pathnames Rules: Relative pathname does NOT begin with a slash. Following symbols can be used:.. parent directory. current directory

Relative Pathnames Examples: Change to another directory branch from parent directory: cd../ops224 copy sample.c file from your professor’s directory to your current directory: cp /home/profid/oop244/sample.c.

Making Directories Building directories is similar in approach to building a house Begins from a foundation (eg home directory) Need to build in proper order (add on addition to house in right location) when building directories from different locations, must provide proper absolute or relative pathname!!

Where do we want to build directory? Want to build a directory called tmp that branches-off of your home directory Verify which directory you are located (either look at directory from command prompt or issue the command pwd Type mkdir tmp at the Unix prompt, followed by ENTER Always verify that directory has been created (e.g. use ls or ls -ld command)

Creating Parent Directories To create directory paths with parent directories that do not exist you can use the command mkdir -p pathname eg. Mkdir -p mur/dir1 (This would create the parent directory mur and then the child directory dir1)

Removing Directories Removing directories is reverse order of building directories Issue command rmdir Cannot remove directories containing files or other subdirectories (unless using rm -r) Need to “step-back” to at least parent directory to remove empty directory or related child, grandchild, etc… directories

Listing Directory Contents lsCompact listing on non-hidden files ls -aCompact listing of ALL files ls -lDetailed listing of non-hidden files ls -FDisplays symbols to mark directories and executable files ls -ldDetailed listing of specified directory ls -iDisplays i-node number (I.d. number of files)

Access Permissions Limiting unauthorized access to your directories and files is a very important concern for ALL Linux (Unix) users. Consequences of Unauthorized Access: Copying your assignments (cheating) Using your account for illegal activity Using your account to send obscene messages Tampering with files

File / Directory Permissions The Linux (Unix) OS can allow the user to specify read, write and execute permissions to the user, group or all others (UGO) for files. A user can also specify read, write and execute permissions for a directory. The execute permission for a directory allows the person to view files in that directory

chmod Command (Relative Method) Used to change the access permissions of a file or directory Format: chmod [option] [who] [operation] [permission] file chmod [option] [permission] file-list who relates to user (u), group (g) or all others (o) operation relates to adding (+), removing (-) or setting (=) permissions permissions are read (r), write (w) and execute (x)

chmod Command (Relative Method) Examples: Add Permission chmod g+rw file.name chmod o+x file.name Remove Permission chmod g-w file.name chmod a-w file.name(removes write for ugo) Set Permission chmod o=rx file.name chmod go=rx filename Note: you can use wildcard symbols (eg *) to match particular files

chmod Command (Absolute Method) You can use the chmod command with octal number to represent (in binary) a permission (1) or removal of a permission (0) for the file or directory This is referred to as an Absolute command, and many prefer this “short-cut” method to changing file / directory permissions

Relationship of a Binary to an Octal Number Notice the Pattern: Largest 3 digit binary is octal digit will represent a 3 digit binary number Highest Octal digit is 7 Therefore: = 7 8

Binary to Octal Relationship: OctalBinary Therefore: Octal number 755 is equal to: in binary This can be related to the permissions: r w x r - x r - x

chmod - Example (Absolute Method) Applying octal values of rwx use the absolute chmod command: chmod 777 filename- r w x r w x r w x chmod 755 filename - r w x r - x r - x chmod 711 filename- r w x - - x - - x chmod 644 filename- r w - r - - r - -

Practical Applications of chmod Command Pass-Through Permissions Pass-Through Permissions allow users to pass- through the home directories and other subdirectories until they reach a directory that provides read and execute permissions to read files. (pass-through permissions drwx--x--x) To deny any access other than yourself, you can remove pass-through permissions of your home directory (drwx------)

Practical Applications of chmod Command Linking & Sharing Files Set up directory and file permissions to allow users to modify a file or set up permissions of file to allow user to view, but not modify a file. Webpages Allow or deny other access to files. For example, use chmod command to allow group & others read and execute permissions to “pass-through” your directories.

Creating a Mask Are you tired of continually changing access permissions for newly-created files or directories? The umask command automatically sets the file permissions upon creation of the file. This process is useful, since user may sometimes forget to change the permissions of newly-created files or when they transfer files via the FTP application

umask Command Used to automatically establish file permission upon creation Format: umask [mask] where mask represents a 3-digit octal number regarding UGO and permissions to be assigned. Note: The rules vary between setting file masks and directory masks

Setting Directory Mask To change directory mask: Determine octal number that would set directory permission Subtract octal number 777 from octal number determined above to get result issue the command : umask [octal number] Note: should also be able to use “relative method” with umask command - may be easier

Setting Directory Mask Example: To set mask for newly-created directories to: r w x r - - r - - Determine octal number = 744 Subtract 777 from 744 = 033 Issue command umask 033 Issue command umask to verify change

Setting File Mask To change directory mask: Determine binary number that would set directory permission Subtract above binary number from and convert result to octal number to determine umask value issue the command : umask [octal number]

Setting File Mask - Example1 Example: To set mask for newly-created files to: r w - r - - r - - Convert to binary Subtract above from = (which is 022) issue umask 022 (enter umask to verify)

Setting File Mask - Example2 Example: To set mask for newly-created files to: r w x r - - r - - Convert to binary Subtract above from = (which is 022 octal) issue umask 022 (enter umask to verify) Cannot subtract 1 from 0

File Identification Files in UNIX and Linux contain contents (e.g. source code) but each file also contains information regarding the file itself. Each file is assigned a i-node number. To view i-node information, you can issue the UNIX command ls -i testfor chevy thefile Note that each file is unique since they have been assigned a different i-node number for identification.

Linking Files Since UNIX is a multi-user operating system, it makes sense to allow users to share files to collaborate on projects (such as programming projects, reports, etc.) In order to avoid duplication and inefficiency, it is better to provide links between files to give user illusion that what is edited on their file affects contents on other groups’ files.

Linking Files There are two major types of links: Hard Link: ln [existing_file] [linked_file] A directory entry containing the same “i-node number” of a file. All files have at least one hard- link - when removed, the link is removed Symbolic Link: ln -s [existing_file] [linked_file] A directory entry containing pathname to file (i.e. a pointer). Unlike hard links, i-node numbers can be different, but possess other useful features.

Linking Files Remember to set appropriate permissions for: your directories (such as pass-through permissions and permissions for appropriate directory) the file to link (which groups can modify the link file, which groups can view, but not modify file, and which groups are not permitted to modify or view linked file)

Hard Link Features Cannot make hard links to directories Cannot cross different file systems (since other file system may use i-node number for a already existing file…) User can allow access to file to link via directory access permissions and will still allow access if user later block group & other access. When “original file” that other user’s linked to is removed “linked file(s)’ will still exist.

Soft Link Features Can be used by users to link directories Can link across different file systems since they are considered to be “pointers” “Broken Links” can occur if original file is removed and link “points” to a file that does not exist.