Guide to Parallel Operating Systems with Windows 7 and Linux Chapter 7 Files and File Attributes

Embed Size (px)

DESCRIPTION

Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files File: –Discrete set of information OS stores program modules in file systems Save documents under filenames for future use Section learning goals: –Recognizing the contents of files –Recognizing actions a given OS takes to open a file 3

Citation preview

Guide to Parallel Operating Systems with Windows 7 and Linux Chapter 7 Files and File Attributes Guide to Parallel Operating Systems with Windows 7 and Linux Objectives Describe the contents of files and identify the application that created a particular file Describe the use of file attributes Find files based on their name or content 2 Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files File: Discrete set of information OS stores program modules in file systems Save documents under filenames for future use Section learning goals: Recognizing the contents of files Recognizing actions a given OS takes to open a file 3 Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files in Windows 7 Filename: name plus . plus extension Example: default.htm Two types of extensions: Short extension is three characters (older convention) Long extension exceeds three characters Extensions indicate type of data stored in a file Windows 7 appends extension to filename prefix 4 Guide to Parallel Operating Systems with Windows 7 and Linux Viewing File Extensions in Windows 7 Windows tracks the extensions your PC uses Viewing registered file extensions: Click Start-> Control Panel -> click Default Programs, and then click Associate a file type or protocol with a program Example: MS WordPad documents have an extension of.rtf Administrative rights required to modify extensions 5 Guide to Parallel Operating Systems with Windows 7 and Linux6 Figure 7-1 File extensions in Windows 7 Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Viewing File Extensions in Windows 7 (continued) File associations Which icon appears for a file in Windows Explorer Which commands appear in a files shortcut menu Which application opens if a user double-clicks a file Icon appearance in Windows Explorer Eliminated feature: Displaying different icons for files based on file type 7 Guide to Parallel Operating Systems with Windows 7 and Linux Commands in a Files Shortcut Menu Right-click a file icon to view a shortcut menu Choices appearing on all file shortcut menus: Create a shortcut Delete a file Rename a file View file properties Some shortcut menu items are object specific: Example: Open and Print are used in MS WordPad Bold items identify default response to double-click 8 Guide to Parallel Operating Systems with Windows 7 and Linux9 Figure 7-2 Context menu Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Opening Applications Default response to double-clicking a file icon: Windows 7 opens file in associated application Example: response to double-clicking Homework.rtf OS opens the file In WordPad because: WordPad is associated with.rtf files Default action in Folder Options is defined as Open Changing the default program: Right-click the file icon, then click Open with From the dialog box that appears: Browse for program to use with the selected file type 10 Guide to Parallel Operating Systems with Windows 7 and Linux11 Figure 7-3 Open with dialog box showing default program for.rtf files Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Applications in Windows 7 Table 7-1: Lists common file extensions for business applications Table 7-2: Identifies the programming language for a particular source file Table 7-3: Lists some of the many Internet file extensions and formats you may encounter Table 7-4: Lists the files you are most likely to encounter 12 Guide to Parallel Operating Systems with Windows 7 and Linux13 Table 7-1 Common business applications and their file extensions Guide to Parallel Operating Systems with Windows 7 and Linux14 Table 7-2 Common programming source files Guide to Parallel Operating Systems with Windows 7 and Linux15 Table 7-3 Common Internet files Guide to Parallel Operating Systems with Windows 7 and Linux16 Table 7-4 Common Windows 7 files Guide to Parallel Operating Systems with Windows 7 and Linux Viewing the Contents of Text Files TYPE command: Displays contents of a text file line by line Example: TYPE Pgm1Data.txt MORE command: Displays text data files one screen at a time Example: TYPE Pgm1Data.txt | MORE Syntax: MORE [/E [/C] [/P] [/S] [/Tn] [n]] < drive:][path]filename MORE < Pgm1Data.txt : Displays contents of the Pgm1Data.txt file 17 Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files in Fedora 13 Fedora 13 and Windows 7 file similarities: Filenames may have extensions OS associations open files in usable formats Extension not required to open a file from the CLI Inode: Used to store applications files and directory attributes Does not contain file/directory name or actual data Filename does not require an extension When a file is created: It is assigned both a name and an inode number 18 Guide to Parallel Operating Systems with Windows 7 and Linux19 Table 7-5 Extensions for Fedora 13 compressed and archived files Contents of Files in Fedora 13 (continued) Guide to Parallel Operating Systems with Windows 7 and Linux20 Table 7-6 Extensions for Fedora 13 multimedia files Contents of Files in Fedora 13 (continued) Guide to Parallel Operating Systems with Windows 7 and Linux21 Table 7-7 Extensions for Fedora 13 system configuration and installation packaging files Contents of Files in Fedora 13 (continued) Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files in Fedora 13 (continued) 22 Table 7-8 Extensions for Fedora 13 programming files Guide to Parallel Operating Systems with Windows 7 and Linux Contents of Files in Fedora 13 (continued) ls command with the l option Determines file type ls l /dev | more: Lists files in the devices folder Syntax for the file command: file[filename(s)] file Pgm1Data : Examines a plain text file named Pgm1Data 23 Guide to Parallel Operating Systems with Windows 7 and Linux24 Figure 7-4 Listing Fedora 13 file types Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux25 Table 7-10 Fedora 13 file command types Contents of Files in Fedora 13 (continued) Guide to Parallel Operating Systems with Windows 7 and Linux Viewing Files in Fedora 13 Use cat command to view or concatenate files: Example: cat bsT Pgm1Data more command syntax: more [-dlfpcsu] [file...] Some more command options: -num : specifies screen size in lines (an integer value) -d : displays [Press h for instructions] -f : causes more to count logical lines (not folded) To display the contents of myfile: cat myfile more dfs red_canoe 26 Guide to Parallel Operating Systems with Windows 7 and Linux Using File Attributes File attributes: Labels describing and regulating files Associated with every file in Windows 7 Maintained by components in Windows 7 Windows 7 handles file attributes most of the time Users can also manipulate file attributes: Learning the technique will prove useful 27 Guide to Parallel Operating Systems with Windows 7 and Linux Using File Attributes in the Windows 7 CLI File attributes have binary values of 1 (on) or 0 (off) The four DOS file attributes are: Read-only: allows file viewing, but not modification Archive: set to on when file is created or modified System: marks a file as a system file (a warning) Hidden: hides a file from other commands 28 Guide to Parallel Operating Systems with Windows 7 and Linux Viewing DOS File Attributes View attributes and access methods with ATTRIB ATTRIB syntax: ATTRIB [drive:][path][filename][/S] [drive:][path][filename] : specifies file(s) to process /S : matches files in current folders and subfolders Similar to DIR command Wildcards must be used in ATTRIB command: Without wildcards, no files will match 29 Guide to Parallel Operating Systems with Windows 7 and Linux Viewing DOS File Attributes (continued) 30 Figure 7-8 Viewing DOS file attributes Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Setting DOS File Attributes ATTRIB: shows or changes DOS file attributes Syntax : ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename] [/S [/D]] + : sets an attribute - : clears an attribute R : read-only file attribute A : archive file attribute S : system file attribute H : hidden file attribute Example: ATTRIB +H Secret Hides the directory named Secret 31 Guide to Parallel Operating Systems with Windows 7 and Linux Using the DIR Command with File Attributes Use DIR to view filenames and specified attributes Syntax: DIR [drive:][path][filename] [/A[[:]attributes]] [drive:][path][filename]: specifies drive, directory, files /A : displays files with specified attributes Attributes : D,R, H, A, S, - (logical not prefix) 32 Guide to Parallel Operating Systems with Windows 7 and Linux Using the XCOPY Command with File Attributes XCOPY syntax: XCOPY source [destination] [/A | /M] [/H] [/R] [/K] Attribute options: /A : copies only files with the archive attribute set Used for differential backup as archive bit is not reset /M : copies files with archive bit set; turns off archive bit Used in incremental backup as archive bit is reset /H : copies hidden and system files /R : overwrites read-only files /K: copies attributes; read-only is typically reset 33 Guide to Parallel Operating Systems with Windows 7 and Linux Using the XCOPY Command with File Attributes 34 Figure 7-11 XCOPY command used with file attributes Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Using File Attributes in the Windows 7 GUI Additional attributes: Index, Compression, Encryption Applies to folders or files residing on an NTFS volume Index: File/Folder indexed by Indexing Service when bit is set Windows Indexing Service organizes files for search Index created by Windows 7 can be queried Compression: File or folder is compressed when bit is set Encryption: File or folder encrypted when bit is set 35 Guide to Parallel Operating Systems with Windows 7 and Linux36 Figure 7-12 Windows 7 advanced file attributes Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Using Compression in Windows 7 Compressing files: Decreases file size Reduces space that files use on your drives Compressing folders: Decreases space used by files stored in a folder Disadvantage of compression: Potential loss of performance 37 Guide to Parallel Operating Systems with Windows 7 and Linux Using Encryption in Windows 7 Encryption: restricts file viewing Users who may view (decrypt) encrypted files: Individual who encrypted the file Administrator (account has a global key) Encrypting File System (EFS) performs encryption: Installed automatically on Windows 7 38 Guide to Parallel Operating Systems with Windows 7 and Linux Using File Attributes in Fedora 13 lsattr : used to view attributes on extended file system Some attributes: a (no Access time): last access time not updated A (append only) Set for file: only allows append operations Set for directory: files may only be added to directory lsattr command syntax: lsattr [options] [file(s)] Some lsattr command options: -d : lists directories like other files -v : lists the files version/generation number 39 Guide to Parallel Operating Systems with Windows 7 and Linux Using the ls Command to Find Hidden Files ls command: Views filenames with specific file type attributes Syntax: ls [OPTION]... [FILE]... Some options: -a, --all : does not hide entries starting with . -l : uses a long listing format -p, --file-type : appends an indicator of /, or | to entries to indicate types of files 40 Guide to Parallel Operating Systems with Windows 7 and Linux41 Figure 7-14 Using the Fedora 13 ls command to show hidden files and file types Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Using Compression in Fedora 13 Compressing files: Decreases their size Reduces amount of space they use on drives Folder compression: Decreases amount of space used by all file gzip : Commonly used GNU compression utility By default: deletes ASCII file it compresses Command: basis for gunzip and zcat 42 Guide to Parallel Operating Systems with Windows 7 and Linux Using Compression in Fedora 13 (continued) zcat utility: Identical to using the gunzip c command Keeps the original filename and stamp Syntax: gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ filename... ] gunzip [ -acfhlLnNrtvV ] [-S suffix] [ filename... ] zcat [ -fhLV ] [ filename... ] 43 Guide to Parallel Operating Systems with Windows 7 and Linux Using Compression in Fedora 13 (continued) Some switches for gzip, gunzip, and zcat : -a ascii : converts end-of-line characters -c --stdout --to-stdout : writes output to standard output -L license : displays the license and quits Syntax to compress file: gzip myfile Syntax to decompress a file: gzip d myfile 44 Guide to Parallel Operating Systems with Windows 7 and Linux Using Compression in Fedora 13 (continued) gunzip myfile: decompresses a file zcat utility: Decompresses files created by gzip, zip zcat myfile: decompresses a file tar command: Works in conjunction with gzip Packages multiple files into one file Syntax: tar [flags] archive-file-name files-to-archive Some options: -c, --create, --delete, -r, --append, -t, --list, -u, --update 45 Guide to Parallel Operating Systems with Windows 7 and Linux Using Encryption in Fedora 13 Only user who encrypted file or an administrator can decrypt encrypted files gpg : Most popular encryption utility Syntax: gpg [--homedir name] [--options file] [options] command [args] Some options: -c : encrypts with a symmetric cipher --decrypt [file]: Decrypts file, writes it to standard output o, --output file : writes output to a file 46 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files Finding files in the Windows 7 CLI Searches are based on filenames or file contents Pattern-matching methods used in content searches Three commands used to search for files: DIR FIND FINDSTR 47 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the DIR Command DIR command supports wildcards Two wildcards used: question ( ? ), asterisk ( * ) Use ? to substitute for single unknown: Example: DIR ?.cpp Command applies in current directory Lists all files beginning with any letter and ending in.cpp Use * to substitute for multiple unknown characters A period extends search to include all file extensions Example: DIR h* Lists all files beginning with h in the current directory 48 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the DIR Command (continued) 49 Table 7-11 Multiple-character substitutions for searches Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the DIR Command (continued) 50 Table 7-12 Single-character substitutions for searches Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the FIND Command FIND syntax: FIND [/V] [/C] [/N] [/I] string [[drive:][path]filename[...]] /V : displays all lines without the specified string /C : displays the count of lines that contain the string /N : displays line numbers with the displayed lines /I : ignores the case of characters when searching Example: FIND /I "Good" *.* Redirection operators: for output Example: FIND /I "Football" FootballWinners.txt Finds all lines that contain Football in a file named Winners.txt 51 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the FINDSTR Command Use FINDSTR for more refined searches FINDSTR command syntax: FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/C:string] strings [[drive:][path]filename[...]] Some switches: /B : matches the pattern at the beginning of a line /I : specifies that the search is not case sensitive Example: FINDSTR /I "good fool" *.* Finds files containing good or fool 52 Book Title Finding Files with the FINDSTR Command 53 Figure 7-22 Finding files using the FINDSTR command Courtesy Course Technology/Cengage Learning Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files with the FINDSTR Command (continued) 54 Table 7-13 FINDSTR examples Guide to Parallel Operating Systems with Windows 7 and Linux Using the FINDSTR Command with Regular Expressions Regular expressions: specify patterns of text Notation uses metacharacters and literal characters Metacharacter: symbol with special meaning Examples: an operator or delimiter Literal character: characters with no special meaning Examples: letters and numbers Some examples of regular expressions: w.*ing : strings starting with w and ending with ing [ABX] : matches any occurrence of A, B, or C 55 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files in Windows 7 with Windows Search Windows Search: most direct way to locate a file All or partial name of file/folder can be used to search Using quotation marks with Windows Search To search on more than one word: Place the phrase in quotation marks Using wildcards with Windows Search Add asterisk (*) to a search term to: Represent an unknown string of letters or numbers Question mark (?): single character wildcard 56 Guide to Parallel Operating Systems with Windows 7 and Linux Finding Files in Windows 7 with Windows Search (continued) Using file sizes with Windows Search Keyword size : used when you know approximate size of file Example: resume size: thisweek, nextmonth, pastmonth, and comingyear To find a file created in 2010: Enter created: