Presentation is loading. Please wait.

Presentation is loading. Please wait.

January 26th, 2004 Class Meeting 2

Similar presentations


Presentation on theme: "January 26th, 2004 Class Meeting 2"— Presentation transcript:

1 January 26th, 2004 Class Meeting 2
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 / bin home etc user1 user2 textfile cs2204 lab1txt
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 Example: / bin home
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 / bin home etc user1 user2 textfile
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 We’ll keep coming back to this slide
lrwxrwxrwx 1 callgood Grads 20 Jan 24 20:16 home -> /home/grads/callgood/ -rw-r--r-- 1 callgood Grads 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 ( - ) Directory ( d ) Link ( l ) Special
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> mv <file1> <file2>
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 x user r w x group r w x world 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


Download ppt "January 26th, 2004 Class Meeting 2"

Similar presentations


Ads by Google