Download presentation
Presentation is loading. Please wait.
Published byCharla Cameron Modified over 8 years ago
1
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright 2001-2003.
2
(C) Doug Bowman, Virginia Tech, 20012 UNIX filesystem The filesystem is your interface to physical storage (disks) on your machine storage on other machines output devices etc. Everything in UNIX is a file (programs, text, peripheral devices, terminals, …) There are no drive letters in UNIX! The filesystem provides a logical view of the storage devices
3
(C) Doug Bowman, Virginia Tech, 20013 Working directory The current directory in which you are working pwd command: outputs the absolute path (more on this later) of your working directory Unless you specify another directory, commands will assume you want to operate on the working directory
4
(C) Doug Bowman, Virginia Tech, 20014 Home directory A special place for each user to store personal files When you log in, your working directory will be set to your home directory Your home directory is represented by the symbol ~ (tilde) The home directory of “user1” is represented by ~user1
5
(C) Doug Bowman, Virginia Tech, 20015 UNIX file hierarchy Directories may contain plain files or other directories Leads to a tree structure for the filesystem Root directory: / No file extensions! / tmpusersbin user1user2 cs2204joketxt lab2txtlab1txt
6
(C) Doug Bowman, Virginia Tech, 20016 Some Standard Directories / - root directory /bin – Home of all binaries /dev – device directory /etc – host-specific files and directories /home – users home directories /home/grads/sgifford /lib – libraries for various languages /sbin – System administration utilities, tools,… /tmp – temporary files /var – Variable data that is changing
7
(C) Doug Bowman, Virginia Tech, 20017 Path names Separate directories by / Absolute path start at root and follow the tree e.g. /users/user1/joketxt e.g. ~user1/joketxt e.g. ~/joketxt / tmpusersbin user1user2 cs2204joketxt lab2txtlab1txt
8
(C) Doug Bowman, Virginia Tech, 20018 Path names (cont’d) Relative path start at working directory.. refers to level above;. refers to working dir. If /users/user1/cs2204 is working dir, these both refer to the same file:../joketxt../../user1/joketxt / tmpusersbin user1user2 cs2204joketxt lab2txtlab1txt
9
(C) Doug Bowman, Virginia Tech, 20019 Changing directories Change the working directory with the cd command cd Use absolute or relative path names cd without a path is equivalent to cd ~ e.g. cd../../user1/ e.g. cd /users/user1/
10
(C) Doug Bowman, Virginia Tech, 200110 Output of ls -lF total 4 lrwxr-xr-x 1 user1 user 18 Aug 28 13:41 home -> /usr/people/bowman/ -rw-r--r-- 1 user1 user 94 Aug 28 13:42 nothing.txt drwxr-xr-x 2 user1 user 9 Aug 28 13:40 test_dir/ We’ll keep coming back to this slide! File type PermissionsOwnerGroupModify dateFilename Size in bytes
11
(C) Doug Bowman, Virginia Tech, 200111 Types of files Plain ( - ) Most files Includes binary and text files Directory ( d ) A directory is actually a file Points to another set of files Link ( l ): A pointer to another file or directory Special: e.g. peripheral devices
12
(C) Doug Bowman, Virginia Tech, 200112 Special files Character special files keyboard, console, etc crw-rw---- 1 lp sys 6, 0 Dec 31 1969 lp0 Block special files cd-rom, disks, etc brw-rw---- 1 root floppy 2, 0 Dec 31 1969 lp0
13
(C) Doug Bowman, Virginia Tech, 200113 Creating, moving, renaming, copying, and removing files touch (create empty file) mv (rename) mv (move) mv (move & rename) cp [ | | ] (copy) rm [-i] (remove)
14
(C) Doug Bowman, Virginia Tech, 200114 Creating and removing directories mkdir Create a subdirectory of the current directory rmdir Remove a directory (only works for empty directories) rm –r Remove a directory and all of its contents, including subdirectories
15
(C) Doug Bowman, Virginia Tech, 200115 Creating links ln –s This command creates a symbolic link The file “link_name” will be a pointer to the “existing_file” which may be in another directory or even on another physical machine
16
(C) Doug Bowman, Virginia Tech, 200116 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) There are also various groups to which users can belong Groups may have different permissions than everyone else
17
(C) Doug Bowman, Virginia Tech, 200117 File permissions Permissions used to allow/disallow access to file/directory contents Read (r), write (w), and execute (x) For owner, group, and world (everyone) chmod chmod 700 filetxt chmod g+rw filetxt
18
(C) Doug Bowman, Virginia Tech, 200118 File modification date Last time the file was changed Useful information 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
(C) Doug Bowman, Virginia Tech, 200119 Looking at file contents cat “concatenate” output the contents of the file all at once more Output the contents of a file one screen at a time Allows forward and backward scroll and search
20
(C) Doug Bowman, Virginia Tech, 200120 Wildcards in file names All of the commands covered here that take file names as arguments can also use wildcards * for any string, e.g. *txt, obj*, a*.* ? for any character, e.g. doc? [] around a range of characters, e.g. [a-c]*
21
(C) Doug Bowman, Virginia Tech, 200121 Getting help on UNIX commands These notes only give you the tip of the iceberg for these basic commands man shows you all the documentation for a command apropos shows you all the commands with the keyword in their description
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.