Workbook 5 - Part 2 The Linux Filesystem RH030 Linux Computing Essentials.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

RH030 Linux Computing Essentials
การใช้ระบบปฏิบัติการ UNIX พื้นฐาน บทที่ 4 File Manipulation วิบูลย์ วราสิทธิชัย นักวิชาการคอมพิวเตอร์ ศูนย์คอมพิวเตอร์ ม. สงขลานครินทร์ เวอร์ชั่น 1 วันที่
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.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Linux+ Guide to Linux Certification, Second Edition
Lesson 22 – Introduction to Linux Systems Administration.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
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
Linux+ Guide to Linux Certification Chapter 12 Compression, System Backup, and Software Installation.
Linux+ Guide to Linux Certification, Third Edition Chapter 11 Compression, System Backup, and Software Installation.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Linux Commands LINUX COMMANDS.
Chapter 11 Compression, System Backup, and Software Installation.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
Linux+ Guide to Linux Certification
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
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.
Offline File Storage. Module 12 Offline File Storage ♦ Introduction Backup is usually done by first collecting all the data in a single archive file,
Lesson 11-Locating, Printing, and Archiving User Files.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Linux Operations and Administration
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Thirteen Compression, System Back-Up, and Software Installation.
Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Chapter 5 File Management File Overview.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
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.
Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System.
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 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
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.
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.
Linux Commands C151 Multi-User Operating Systems.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
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.
Linux+ Guide to Linux Certification, Second Edition
Agenda The Linux File System (chapter 4 in text) Setting Access Permissions Directory vs File Permissions chmod Utility Symbolic Method Absolute Method.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
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.
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.
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
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.
Linux Filesystem Management
Introduction to Unix – CS 21
Linux file system "On a UNIX system, everything is a file;
C151 Multi-User Operating Systems
Operation System Program 4
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
Linux Commands LINUX COMMANDS.
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
January 26th, 2004 Class Meeting 2
Presentation transcript:

Workbook 5 - Part 2 The Linux Filesystem RH030 Linux Computing Essentials

Linux+ Guide to Linux Certification, 2e 2 Objectives chapter Last week we looked at: How the linux filesystem works  Filesystem structures dentries, inodes, data blocks  ls -i  ls –s  Linking items – hard & soft links  ln  ln –s  Recognising the types of items found in the filesystem regular files, directories, and symbolic links. block and character device nodes.  mount  df

Linux+ Guide to Linux Certification, 2e 3 Objectives chapter  THIS WEEK  Searching for files and directories  Compressing Items  Archiving Items

Linux+ Guide to Linux Certification, 2e 4 Command Covered  Review - locating information about files and directories whereis, which, whatis,  Searching for files and directories locate, find  Compressing Items gzip bzip2  Archiving Items tar

Linux+ Guide to Linux Certification, 2e 5 Files and Directories You can locate information about files using various commands.  Such as locate, whereis, which, whatis and find which command:  Used only on executable files  Lists the directory location on the system where the executable file is located.  Searches through the System Variable $PATH to see if this location is on it.  $PATH allows executable files to be run without specifying absolute or relative path whereis command:  Used to locate the binary, source and man pages for a command. whatis command:  Display’s 1 st line of the man pages

Linux+ Guide to Linux Certification, 2e 6 Locating the pathnames of items in FSH. You can use any “text” to display any items which match to anything on any of the systems pathnames. locate :  Will search for anything within the system FSH pathname structure Search identifies and displays all FSH pathnames which match to the text. Shortcut to the slocate command Uses an indexed database of all files on system As the Information returned may not fit on screen it is commonly used the less / more commonds

Linux+ Guide to Linux Certification, 2e 7 find command It is one of the commands that everyone should master especially system administrators.  The first, and most obvious, use is find's ability to locate old, big, or unused files, or files that you just forgot where they are.  The other important characteristic is find's ability to automatically travel recursively down through subdirectories.  There are only a few unix commands which can be given a directory name and will automatically search down the directory pathname tree structure, searching each subdirectories. The commands chmod, chgrp, rm, ls and cp will do it as well. But only if the -r or -R option is specified. But the find command does this automatically.

Linux+ Guide to Linux Certification, 2e 8 Syntax of the ‘Find Command’ find [starting pathname] [search criteria] [filename] [action] [starting pathname]  The first argument of the find command is the location from which to start the search  This pathname tells the command in which directory to start searching.  In the starting pathname you can make use of any of any of the relative symbol characters using relative addressing.  Such as ~... [search criteria]  The search criteria options after the starting pathname always start with a minus sign, and give the criteria for the actual search. [filename]  The filename is the item or items which will be searched for. [action]  Optional action which you want to execute on the items you find.

Linux+ Guide to Linux Certification, 2e 9 Using search criteria You can nominate different search criteria to be used during the search  Such as can use the find command with “ –name “ to create a search which will list all files which start with the word chapter*. find ~ -name “chapter*?” OR find ~ -type d “bean??” Common criteria used with find command

Linux+ Guide to Linux Certification, 2e 10 Combining search criteria Creating multiple search criteria in one search. example 1  1 st – it searchs for items that end in name = “*chapter”  2 nd – further filters the search to find only files NOT directories find ~ - name “*chapter” - type f -group 100 example 2 The –not is a negative statement to tell NOT to look group 100. find ~ - name “*chapter” - type f - not -group 100 example 3 The 2>/dev/null serves to "throw away" complaints about directories which you do not have permissions to access. find /etc -size +200k 2>/dev/null

Linux+ Guide to Linux Certification, 2e 11 Examples A simple example of find is using it to list the names of all of the files in the nominated directory and all it’s subdirectories. This is done with the simple command find. –name ‘*’ find ~ -name beans find ~ -name “bean??” find /usr/local -name share -type d find /etc -name fstab -type f find /home –type d –user root find. -name “*backups” -type d -user 504 find ~ -name “*chapter” -type f -group 100

Linux+ Guide to Linux Certification, 2e 12 Using -exec to execute actions -exec, and its close cousin -ok.  The -exec mechanism is powerful: rather than just printing the names of matching files, secondary commands can be run.  But using the -exec is awkward because the syntax for specifying the command to run is tricky. Syntax rules  The secondary command should be written after the -exec switch,  using a literal { } as a placeholder for the file name.  The command should be terminated with a literal ;  But as the ; has special significance to the shell, it must be "escaped" by a precending \. An example will help clarify the syntax. find /etc -size +200k -exec cp { } /tmp/big \;

Linux+ Guide to Linux Certification, 2e 13 SUMMARY OF SEARCH / LOCATE COMMANDS locate command: Searches FSH pathname structure for anything which matchs. whatis command: Display’s 1 st line of the man pages whereis command: Used to locate the binary, source & man pages for a command. which command:  Used only on executable files  Lists the directory location on the system where the executable file is located.  Searches through the System Variable $PATH to see if this location is on it.  $PATH allows executable files to be run without specifying absolute or relative path find command:  Used to locate particular items.  Able to modify searchs with use of selected criteria.  Able to recursively search thru nominated sections of FSH  Able to execute an action on located items.

Linux+ Guide to Linux Certification, 2e 14 Next Chapter 6 Understanding compressed files  Creating compressed files  Viewing compressed files  Extracting compress files Chapter 7 Working with archived or backup files  Creating backup files  Viewing backup files  Extracting backup files

Linux+ Guide to Linux Certification, 2e 15 Why use Compression? Why do we use compression utilities?  Because the Internet only uses compressed files.  Files which are backed up onto another media using a backup utility are also commonly compressed to save space.  Tape devices are the default medium used for archives Two most common compression utilities: gzip Bzip2  Many compression utilities are available for Linux systems.  Each uses a different compression algorithm  That produces a different compression ratio.

Linux+ Guide to Linux Certification, 2e 16 The gzip utility gzip command:  A GNU utility  Most commonly utility used to compress files.  Used frequently utility for compressed files on the internet.  Adds the.gz filename extension by default  - l Used to display the level of compression achieved.  - v Used to display the level of compression achieved and display a list of the items which have been compressed. gunzip command:  Used to decompress.gz files

Linux+ Guide to Linux Certification, 2e 17 The bzip2 Utility bzip2 command: Adds the.bz2 filename extension by default Not as commonly used but still used a lot on the internet. Because it t ypically yields better compression than gzip. Used to compress files only Cannot compress a directory full of files bunzip2 command:  Used to decompress files compressed via bzip2

Linux+ Guide to Linux Certification, 2e 18 How compression works List the file to see the original size $ ls -l bin.file -rw-r--r-- 1 user2 staff Mar 22 09:17 bin.file Compress the file $ gzip -l bin.file bin.file: compression: 53.81% -- replaced with bin.file.gz List the file to see compressed size $ ls -l bin.file.gz -rw-r--r-- 1 user2 staff Mar 22 09:17 bin.file.gz Uncompress the file and list again $ gunzip -l bin.file.gz bin.file.gz: -- replaced with bin.file $ ls -l bin.file -rw-r--r-- 1 user2 staff Mar 22 09:17 bin.file

Linux+ Guide to Linux Certification, 2e 19 Archiving files to create System Backups Backups:  The Process whereby files are copied to an archive file.  The actual backup copies of directories & files are called archives.  Typically created by a backup utility. Performing System Backups:  You should always backup any important system configuration files.  Plus the user files from their home directories.  Also possibly files used by system services, as well. Media:  They can be created on various media.  They can be created in various locations.  Default media has been tape.  But most popular media now is hardrives, CD’s & DVD’s Several backup utilities available:  tar, cpio, dump/restore, burning software

Linux+ Guide to Linux Certification, 2e 20 tar archive files (tarballs) The tar ( “Tape Archive” ) command It is still one of the oldest & most commonly used backup utilities. It allows for the backing up of multiple files or directories in the file system. It makes a single archive file out of the input files it backed up for extraction later. Used extensively for files on the internet  These compressed archived files are called tarballs.  You should always add a.tar filename extension to identify it as a tarfile.  Files are not automatically compressed as they are archived.  Adding a – z will compresses them with gzip.  It adds the.tar.gz filename extension or.tgz filename extension

Linux+ Guide to Linux Certification, 2e 21 The tar utility options The tar syntax tar function modifier destination.tar sourcefiles

Linux+ Guide to Linux Certification, 2e 22 Maintaining Context By default it always will change the ownership to who ever runs the command and reset the items with default permissions. Using – p stops this. It will keep existing ownership and group attributes And stop it striping the ACL’s so it ignores umask and keeps the existing permissions tar cvfp net.tar /etc/sysconfig/networking Maintaining Pathnames By default it always stores items using a relative pathname. Using – P stops this. It stop it striping the leading “/” from the existing pathname. tar cvfP net.tar /etc/sysconfig/networking

Linux+ Guide to Linux Certification, 2e 23 Maintaining Pathnames & Context By default it always stores items using a relative pathname. Adding a – P stops this. Sit sop it striping the leading “/” from the pathname. tar cvfP net.tar /etc/sysconfig/networking Establishing Context.  the -C switch can also be used to help establish or maintain context of multiple items in the filesystem. By changing directory before the archive is constructed. tar cvf net.tar -C /etc/sysconfig file1 file 2 -C /var/logs file 1 file 2

Linux+ Guide to Linux Certification, 2e 24 The tar ( Tape Archive) utility Can create archive in a file on a filesystem or directly onto a device. Defaults to tapedrive unless told to output to file onto a harddrive.  You use – f to modify this default and use another device such as the hardrive. Table 12-4: Common tape device files

Linux+ Guide to Linux Certification, 2e 25 Options used with the tar utility Table 12-5: Common options used with the tar utility

Linux+ Guide to Linux Certification, 2e 26 Options used with the tar utility Table 12-5 (continued): Common options used with the tar utility

Linux+ Guide to Linux Certification, 2e archive a file $ tar cvf dir1files.tar dir1 2. list contents $ tar tvf dir1files.tar 3. remove dir1 and verify $ rm -r dir1 $ ls 4. extract the archived dir1 to your current directory $ tar xvf dir1files.tar Example 1

Linux+ Guide to Linux Certification, 2e compress & archive a file $ tar cvfz dir1files.tar dir1 2. list contents $ tar tvfz dir1files.tar 3. remove dir1 and verify $ rm -r dir1 $ ls 4. extract the archived dir1 to your current directory $ tar xvfz dir1files.tar Example 2

Linux+ Guide to Linux Certification, 2e 29 Workbook5 - Command Summary ls – n –i –s stats ln –s mount umount mkfs df locate, which, whereis, whatis find gzip bzip2 tar