260 likes | 376 Vues
Learn about filenames, paths, directory operations, and access permissions in Linux/Unix systems. Explore absolute and relative paths, standard directories, file manipulation, and changing access permissions with practical examples. Understand how to create, copy, move, and delete directories and files, and manage user access with read, write, and execute permissions. Instructor: Bo Sheng.
E N D
Lecture 5: File Systems (ch 4) IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Outline • Filename and paths • Directory operations • Access permissions
Filenames and Paths • Absolute path name • ls /home/it244/it244 • ls /home/it244/it244/ /home/it244/it244/hello Path Filename
Filenames and Paths • Absolute path name
Filenames and Paths • Absolute path name • ~ represents “home directory” • ls ~ =ls /home/your username • cd ~ • pwd • ls ~it244 =ls /home/it244
Filenames and Paths • Relative path name • cd /home/it244 • ls it244 /home/it244/it244/hello Path Filename
Filenames and Paths • Relative path name • . : Current directory • .. :Parent directory • ls –la • ls . • ls .. • cd .. • cd ../..
Filenames and Paths • Relative path name
Filenames and Paths • Standard directories (Pg95~98)
Directory Operations • Create a directory • mkdir book • ls -l • ls book • ls ./book • cd book • ls ../book
Directory Operations • Delete a directory (when it’s empty) • cd .. • rmdir book • Example • mkdir book • cd book • echo “this is a book” > book1 • cd .. • rmdir book (not empty)
Directory Operations • Example • rm book/book1 • rmdir book • Delete directories by rm • mkdir book • rm book • rm –r book (cautious)
Directory Operations • Example • mkdir book • cd book • mkdir novel • cd .. • rmdir book • cd book/novel • rmdir .
Directory Operations • Copy and move files to directories • cd ../.. • cp hello book • ls book • mv welcome linux book • ls • ls book
Directory Operations • Copy and move files to directories • mv book newbook • mv newbook book • ls • mkdirnewbook • mv book newbook
Directory Operations • Copy and move files to directories • mv newbook/book book • cp book newbook ??? • cp –r book newbook • lsnewbook
Access Permissions • Three types of users • Owner • Group member • Others • Three access permissions • Read • Write • Execute
Access Permissions • Change access permissions (chmod) • Symbolic arguments • a (all), u (owner), g (group), o (others) • r (read), w (write), x (execute) • + / - • chmoda+w book1 • chmod go-rw book1
Access Permissions • Change access permissions (chmod) • Numeric arguments -rw-r--r-- 644 -rwxr-xr-x 755
Access Permissions • Change access permissions (chmod) • Numeric arguments • chmod 644 book1 • chmod 755 book1
Access Permissions • Example • Read permission • chmod a-r hello • cat hello • chmoda+r hello • cat hello
Access Permissions • Example • Read permission • chmod a-r book • ls book • ls book/book1 • chmoda+r book
Access Permissions • Example • Write permission • chmod a-w hello • echo hi>hello • rm hello • chmoda+w hello • rm hello
Access Permissions • Example • Write permission • cd book • chmod a-w . • chmoda+rw book1 • echo hi>book2 (create a file) • mv book1 book2 (rename a file) • rm book1 (delete a file) • chmoda+w .
Access Permissions • Example • Execute permission (directory) • Determine if the files are searchable • chmod a-x book • ls book • ls book/book1 • cd book • chmoda+x book Why?