1 / 20

Unix Filesystem

Unix Filesystem. January 26 th , 2004 Class Meeting 2. * Notes adapted by Christian Allgood from previous work by other members of the CS faculty at Virginia Tech. Unix Filesystem. The filesystem is your interface to: physical storage (disks) on your machine storage on other machines

betancourt
Download Presentation

Unix Filesystem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix Filesystem January 26th, 2004 Class Meeting 2 * Notes adapted by Christian Allgood from previous work by other members of the CS faculty at Virginia Tech

  2. Unix Filesystem • The filesystem is your interface to: • physical storage (disks) on your machine • storage on other machines • output devices • Everything in Unix is a file (programs, textfiles, peripheral devices, terminals) • There are no drive letters in Unix – the filesystem is a logical view of the storage devices

  3. Working Directory • Working Directory – the current directory in which you are located • pwd (print working directory) command outputs the absolute path (more later) of your working directory • Unless you specify another directory, commands will assume that you want to operate on the working directory

  4. Home Directory • Directory for users to store personal files • At login, your working directory will be set to your home directory • The path (more later) to your home directory can be referred to by the ~ (tilde) symbol • The home directory of “user1” is represented by ~user1

  5. Unix File Hierarchy • Root Directory: / • Directories may contain plain files or other directories • Result is a tree structure for the filesystem • Unix does not recognize any special filename extensions / bin home etc user1 user2 textfile cs2204 lab1txt lab2txt

  6. Unix Paths • Separate directories by / • Absolute Path • start at root and follow the tree • Example: • /home/user1/textfile • ~users1/textfile • ~/textfile / bin home etc user1 user2 textfile cs2204 lab1txt lab2txt

  7. Unix Paths (cont) • Relative Path • start at working directory • . . – level above • . – working directory / bin home etc user1 user2 textfile cs2204 lab1txt lab2txt

  8. Some Standard Directories • / - root directory • /bin – standard commands and utilities • /dev – block and character device directory • /etc – host-specific configuration files and directories • /home – users directory • /lib – library directory • /sbin – system commands and utilities (needed to boot) • /tmp – temporary files • /usr – most user utilities and applications • /var – files that vary as the system runs (logs, spools)

  9. Changing Directories • cd – changes the working directory • cd <directory_path> • can use absolute or relative path names • cd without any arguments is the same as: cd ~ • Examples: • cd /home/user1 • cd ../../user1

  10. Output of ls -lF lrwxrwxrwx 1 callgood Grads 20 Jan 24 20:16 home -> /home/grads/callgood/ -rw-r--r-- 1 callgood Grads 392419 Sep 22 10:07 atoll.jpg drwxr--r-- 2 callgood Grads 64 Jan 24 18:33 cs2204/ • We’ll keep coming back to this slide permissions user group modified date filename file type size

  11. Types of Files • Plain ( - ) • Most files, binary or text • Directory ( d ) • Directory is actually a file • Points to another set of files • Link ( l ) • Pointer to another file or directory • Special • b – block device (disks, CD-ROM) • c – character device (keyboard, joystick)

  12. Manipulating Files • touch <file> • create a new file or change last modified date • mv <file1> <file2> • rename file1 as file2 • mv <file1> <dir> • move file1 into the dir directory • mv <file1> <dir/file2> • move file1 into dir and rename as file2 • cp <file1> [<file2>|<dir>|<dir/file2>] • copy file with new name, into directory, or both • rm [-i] <file(s)> • remove file or list of files

  13. Creating and Removing Directories • mkdir <directory_name> • create a subdirectory of the current directory • rmdir <directory_name> • remove directory • only works for empty directories • rm -r <directory_name> • remove directory and all of its contents, including subdirectories

  14. Creating Links • ln -s <existing_file> <link_name> • creates a symbolic link • link_name will be a pointer to existing_file which may be in another directory or even on another physical machine

  15. File Ownership • Each file has a single owner • chown command can be used to change the owner; usually only root user can use this command • Users can also belong to various groups • Groups may have different permissions than everyone else

  16. File Permissions • Permissions are used to allow or disallow access to files or directories • Three types of permission: • Read ( r ) • Write ( w ) • Execute ( x ) • Permission exists on three levels: • User ( u ) • Group ( g ) • World ( o )

  17. File Permissions (cont) • chmod <mode> <file(s)> • chmod 700 textfile • chmod g+rw textfile r w xuser r w xgroup r w xworld ugo +/- rwx

  18. File Modification Date • Last time a file was changed • Useful when . . . • there are many copies of a file • many users are working on a file • touch command can be used to update the modification date to the current date (or to create a file if it doesn’t exist)

  19. Looking at File Contents • cat <filename(s)> • short for concatenate • output the contents of the file all at once • more <filename(s)> • output the contents of the file one screen at a time • allows forward and backward search

  20. Getting Help on Unix Commands • man <command_name> • shows all of the documentation for a command (more-style output) • apropos <keyword> • shows you all of the commands with the specified keyword in their description

More Related