The UNIX File System. The UNIX File A file is a container for storing information and data. Filename limited to 255 characters. Can’t contain / or NULL.

Slides:



Advertisements
Similar presentations
Pre-Assessment Questions
Advertisements

CS 497C – Introduction to UNIX Lecture 11: - The File System Chin-Chih Chang
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.
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.
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.
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.
Lesson 22 – Introduction to Linux Systems Administration.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 15: - File Attributes Chin-Chih Chang
Linux Linux File System.
CS 497C – Introduction to UNIX Lecture 16: - File Attributes Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
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.
Getting Started with Linux Linux System Administration Permissions.
Linux Commands LINUX COMMANDS.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
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”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
2 Manual & Filestore. Introduction Using the manual The UNIX filestore File permissions.
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.
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
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.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Chapter Two Exploring the UNIX File System and File Security.
Chapter 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
Chapter 4 The File Structure. Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links.
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
PacNOG 6: Nadi, Fiji UNIX ™/ /Linux Permissions Hervey Allen Network Startup Resource Center.
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2007 by the Trustees of Indiana University except as noted.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Λειτουργικά Συστήματα – 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.
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
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.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
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.
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.
Learning basic Unix command It 325 operating system.
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
Linux Filesystem Management
Introduction to Unix – CS 21
Linux 101 Training Module Linux Basics.
Linux file system "On a UNIX system, everything is a file;
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
Lecture 2 Working with Files and Directories
C151 Multi-User Operating Systems
Exploring the UNIX File System and File Security
Security and File Permission
Module 6 Working with Files and Directories
Software I: Utilities and Internals
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
Presentation transcript:

The UNIX File System

The UNIX File A file is a container for storing information and data. Filename limited to 255 characters. Can’t contain / or NULL character. Avoid $, ‘, ?, -, “ in the filename. Extensions are optional. Filenames are case-sensitive; chap and Chap are two different filenames because c and C have different ASCII codes. Group of filenames held together in a directory. Directory contains the name of the file (name and size are not stored in the file itself). Both files and directories are subject to access control.

File Types Ordinary or regular file: Contains data. This file can be a text file (program sources, configuration files). binary file (executables, graphic and multimedia files). Directory: Contains the filename and a number (inode number). Device file: Contains no data whatsoever. Symbolic link: Contains the location of another file.

/ bindevhomelibtmpetcsbinusrvar dskfd0pr1 austinjulie binlibsbinlocal progs login.sql.profile root Typical File Hierarchy in UNIX

The Hierarchical Structure of the File System A single hierarchical structure that contains all files. Top signified by root (/). Existence of a parent-child relationship. Parent of any file must be a directory. Files accessed with pathnames (e.g., /etc/passwd ).

What Goes Where (Usually) / the root (comparable in Windows to c:\) / bin commonly used binaries (programs) /sbin superuser programs /usr user-related commands (and random stuff) /usr/include header files for C programs /usr/share/man manual pages /lib libraries of reused files (for programmers) /dev device files /home traditionally, where user accounts are stored /etc startup and configuration files /var traditionally, where mailboxes are stored /tmp temporary files

Some Important File-Related Commands in UNIX cd – change directory mkdir – make a directory rmdir – delete a directory ls – list files in a directory pwd – print the working directory dos2unix (unix2dos) – convert between dos & unix chown ( chgrp ) – change ownership of file cp – copy a file mv – move (rename) a file rm – delete a file cat – display a file more ( less ) – page a file lp ( lpr ) – print a file od – octal dump a file tar ( gzip. zip ) – compress and/or archive files find – locate files chmod – change file permissions

Navigating the UNIX Directory Structure You are always located at one location in the tree cd changes your current directory –cd / moves you to the root directory –cd without any arguments moves you to your home directory Special notation for navigating directories: –. means the current directory e.g. cd./progs –.. means the parent directory of the current directory e.g. cd../brother/progs –~ means your home directory e.g., cd ~/myprogs You can “stack” this notation e.g., cd../..

Two Types of Pathnames Absolute Pathname: Specifies location with reference to the file system root e.g., cat /etc/passwd good for configuration files and command not in your PATH Relative Pathname: Specifies location with reference to the user’s current location e.g., cd../include good for files that are impossible/ inconvenient to access in an absolute manner Both commands and filename arguments can be represented in either form.

The Home Directory Directory where user is placed on login. Determined by sixth field in /etc/passwd file: romeo:x:500:100:romeo vincent:/home/romeo:/bin/bash Can also be referred to by the environment variable $HOME e.g., cat $HOME/foo tilde expansion in most shells: ~ e.g., cat ~/foo cd command used without arguments returns user to home directory. user can create and remove files in their home directory but not in other directories.

Inodes (Index Nodes) System of organizing file attributes separately from file content. Lets files have multiple names. Files and directories are identified by a unique inode number. Inode number displayed by ls -i. Possible to consume all inodes even when there is adequate disk space.

File Attributes Stored in Inode Type: Whether ordinary, directory, device, etc. Permissions: Determines who can read, write or execute a file. Links: Number of names a file can have. A program can be designed to behave differently depending on the name by which it is invoked. Owner: A file is owned by a user, by default, its creator. The owner can change many file attributes and set the permissions. Group Owner: The group which owns the file. Owner belongs to this group. File Size: Number of bytes of data contained. File Time Stamps: Date and time of last modification Date and time of last access

Users and File Permission Types A file has three types of permissions: read, write and execute. read: file can be read, but not modified write: file may also be modified execute: file may be run (as in a program file) Available to three categories of users: user, group and the world. user: the creator of the file (also called the owner) group: a set of users grouped together world: everyone else not in group Only file owner or superuser (su) can change file permissions.

Look at the Output of ls -l - rwxrwxrwx -rwx File Type OwnerGroupWorld - = ordinary file d = directory ls –l -rw-rw-r-- 1 bournique instructors 143 Sep 1 08:45 grades permissions linksowner group owner size last mod filename

What Permissions Mean on a Directory Read: User can get a listing of that directory using, e.g., ls Write: Users can create/ remove files in the directory. Execute (or search permission): Users can pass through the directory to search for filenames. Desirable permission setting for directories: 755 or rwxr-xr-x

How a Directory Influences File Permissions Examining only the user category File Directory Significance r--r--r-- rwxr-xr-x A write-protected file; can’t be modified but can be removed. rw-r--r-- r-xr-xr-x A write-protected directory; file can’t be removed but can be modified. r--r--r-- r-xr-xr-x A write-protected file and directory; file can’t be modified or removed. rw-r--r-- rwxr-xr-x Normal setting; file can be modified and removed. rw-r--r-- rw-r-xr-x File can’t be removed even though directory is writable. (An unusual setting) How a Directory Influences File Permissions Examining only the user category File Directory Significance r--r--r-- rwxr-xr-x A write-protected file; can’t be modified but can be removed. rw-r--r-- r-xr-xr-x A write-protected directory; file can’t be removed but can be modified. r--r--r-- r-xr-xr-x A write-protected file and directory; file can’t be modified or removed. rw-r--r-- rwxr-xr-x Normal setting; file can be modified and removed. rw-r--r-- rw-r-xr-x File can’t be removed even though directory is writable. (An unusual setting)

Changing Permissions With chmod General Form : chmod Example: chmod a-x testFile (relative change) u = user g = group o = other a = all + (add) - (remove) = (set) r = read w = write x = execute

More chmod Examples Set read and write access for all chmod a=rw Add executable access for others chmod o+x Remove all access for owner chmod u-rwx Set read, write & execute access for all chmod a=rwx 777 permissions (absolute permission change) o Octal Representation of - rwxrwxrwx o Three binary digits or bits corresponds to one octal digit: Read=4, Write=2 Execute=1 i.e., rwx=4+2+1 = 7 chmod 750 same as chmod u=rwx,g=rx,o=

The User Mask Command, umask Reassigns default file and directory permissions. Default permissions before applying mask are completely insecure: 666 for files and 777 for directories System wide default changed by umask (a shell builtin). umask statement placed in a startup script (typically, the file /etc/profile). 022 is a good umask value which mean 644 for files and 755 for directories.

Links (also Called Hard Links) Mechanism by which a file is allowed to have multiple names. Linked filenames share inode but have separate directory entries. Each link increments link count in inode by 1 and adds an entry to the directory. File considered to be deleted and inode freed only when link count drops to 0. Linked filenames equivalent in all respects.

Advantages/ Disadvantages of Hard Links Advantages Backup: Prevention from accidental deletion. Allows the same file to be executed as two similar but separate programs. Disadvantages Can’t link directories Can’t link across file systems

Symbolic Links (also Called Symlinks) Separate file type (identified by l in listing) and having its own inode. Contains the pathname of another file or directory. Can link directories (unlike hard links). Can link across file systems. Link and file pointed to are not equivalent (they have different inode numbers). Dangling symlinks are possible if you remove original file.

File Ownership and Group Ownership chown - Change the ownership of a file (restricted to su on BSD- based systems) Example: $ su Password: ****** # chown rick grades chgrp – Change the group owner of a file (if you’re not a member of the group, only su can change on BSD UNIX) Example: $ chgrp csinstructors grades Superuser can do both actions with just chown. Example: chown rick:csinstructors grades

Locating Files with find find recursively finds files in a directory tree and takes an action. General form: find Some Examples: find / -name csgrades –print Starting at root, look for the file(s) csgrades and display them on screen. find. –atime +365 –ls Starting in current directory, look for all files more 365 days without access and list them.