1 / 75

Filesystem management

Filesystem management. Unit objectives Explain the function of the Filesystem Hierarchy Standard Find files, directories, and linked files Modify file and directory ownership Identify the default permissions and apply special permissions. Topic A:The filesystem hierarchy standard.

paulina
Download Presentation

Filesystem management

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. Filesystem management Unit objectives • Explain the function of the Filesystem Hierarchy Standard • Find files, directories, and linked files • Modify file and directory ownership • Identify the default permissions and apply special permissions

  2. Topic A:The filesystem hierarchy standard • 2.3 Create files and directories and modify files using the CLI commands • Creating Directories

  3. Filesystem Hierarchy Standard • Thousands of common files across Unix and Linux distributions • FHS • Outlines standard locations for files and directories • Gives software developers a consistent context regardless of the distribution • Helps users of one system work on another

  4. FHS directories continued

  5. FHS directories continued

  6. Managing files and directories • File Management Tasks • Create directories • Copy and move files • Delete files

  7. Managing files and directories • mkdir command • Create subdirectories • like windows folders • Takes arguments specifying the absolute or relative pathnames of the directories to create • Example • mkdir mysamples • Will create a directory called mysamples

  8. Managing files and directories • mv command • Moves a files from one directory to another • requires two arguments at a minimum • Source file/directory • Target file/directory • Example • mv project* proj_files • Move all files starting with project to the proj_files folder

  9. Managing files and directories • mv command • If target is directory • Source files moved to that directory • If target is existing filename and only one source file • Target file will be overwritten with source • If target is filename of non existent file • Source file is moved and renamed

  10. Managing files and directories, continued • cp command • Command used to create copies of files and directories • Two argurments • Source file/directory • Target file/directory

  11. Managing files and directories, continued • rm commands • Takes absolute or relative path • Can use wildcards • NO RECOVERY • User rm -r to remove all files in a directory • -r is recursive (searches through all subdirectories) • -f will force delete • rmdir command • Removes an EMPTY directory

  12. Activity A 2-5 A-2 Pg 4-6 Create directories A-3 pg 4-8 Move files A-4 pg 4-12 Copy files A-5 pg 4-14 rm and rmdir

  13. Any Questions?

  14. Which of the following commands will create the directory /home/gawd/tools/security regardless of the existence of its parent directories? A. md ­m /home/gawd/tools/security B. mkdir ­m /home/gawd/tools/security C. mkdir ­p /home/gawd/tools/security D. mkdir ­­makepath /home/gawd/tools/security

  15. Which of the following commands will create the directory /home/gawd/tools/security regardless of the existence of its parent directories? A. md ­m /home/gawd/tools/security B. mkdir ­m /home/gawd/tools/security C. mkdir ­p /home/gawd/tools/security D. mkdir ­­makepath /home/gawd/tools/security Answer: C

  16. Which of the following commands can be used to create new directories? A. rm B. ls C. mv D. mkdir

  17. Which of the following commands can be used to create new directories? A. rm B. ls C. mv D. mkdir Answer: D.

  18. Which of the following commands can be used to hide the file "help.new"? A. atrrib ­h help.new B. chmod 4000 help.new C. mv help.new .help.new D. cp help.new .help.new

  19. Which of the following commands can be used to hide the file "help.new"? A. atrrib ­h help.new B. chmod 4000 help.new C. mv help.new .help.new D. cp help.new .help.new Answer: C

  20. Topic B: Searching and linking files • 2.4 Execute content an directory searches using find and grep • Find • Create linked files using CLI commands

  21. Finding files • locate command • Fastest method to search for files • A shortcut to the slocate (or secure locate) command • Example • locate filename

  22. Finding files • find command • Used to find files using various criteria • Searches the directory tree recursively, starting from a certain directory, for files that meet criteria • Example • find /etc –name inittab • Find files names inittab in the etc directory

  23. Which command and PATH variable • which command • Used to locate files within directories listed in the PATH variable • PATH variable • Stores list of directories searched when commands are executed without an absolute or relative pathname

  24. Linking files • On a structural level, a filesystem has three main sections • The superblock • Number of inodes and data blocks • The inode table • Each inode desrcibes a file or directory and has unique inode number • Data blocks • Allocation units-actual storage locations on the HD • Only device files have no data blocks • Hard link, two files share the same data

  25. Linking files • Hard link, two files share the same data • File references the same inode and inode number • Must be in same filesystem

  26. Structure of hard linked files

  27. In command • ln (link) command • Used to create hard and symbolic links • two arguments • The existing file to hard-link • The target file that will be created as a hard link to the existing file • Will up the link count in ls –l by number of hard links

  28. In command • Example • ls –l of my directory -rw-r--r-- 1 epapates epapates 0 Feb 26 04:40 file1 -rwxrwxr-x 1 epapates users 548 Feb 26 03:59 Highland_Inn • Create linked file [epapates@localhost Unit_03]$ ln file1 file2 [epapates@localhost Unit_03]$ ls -l total 16 -rw-r--r-- 2 epapates epapates 0 Feb 26 04:40 file1 -rw-r--r-- 2 epapates epapates 0 Feb 26 04:40 file2 -rwxrwxr-x 1 epapates users 548 Feb 26 03:59 Highland_Inn • Link count went up!

  29. Linking files • Symbolic link • Different inode number • One file is pointer to other • Files have different sizes • Data blocks in symbolic file are only a pathname to target • When editing symbolic file, you are editing the original

  30. Structure of symbolically linked files

  31. Which of the following commands can be used to create a link to the file /home/joe/help in /tmp/help.old? A. ln ­s help help.old B. ln ­s /home/joe/help /tmp/help.old C. ln ­s /tmp/help.old /home/joe/help D. ln ­v /home/joe/help /tmp/help.old

  32. Which of the following commands can be used to create a link to the file /home/joe/help in /tmp/help.old? A. ln ­s help help.old B. ln ­s /home/joe/help /tmp/help.old C. ln ­s /tmp/help.old /home/joe/help D. ln ­v /home/joe/help /tmp/help.old Answer: B

  33. A Linux user wants to create a hard link named file2 in the current directory that points to /usr/var/file. Which of the following commands can be used? A. ln file2 /usr/var/file B. ln /usr/var/file file2 C. ln ­h file2 /usr/var/file D. ln ­h /usr/var/file file2

  34. A Linux user wants to create a hard link named file2 in the current directory that points to /usr/var/file. Which of the following commands can be used? A. ln file2 /usr/var/file B. ln /usr/var/file file2 C. ln ­h file2 /usr/var/file D. ln ­h /usr/var/file file2 Answer: B

  35. Topic C: File and directory permissions

  36. Usernames and group membership • Login identifies user by • Username • Group membership • Access to commands, files and directories are dependent on this information

  37. File and directory ownership • When a user creates a file or directory, that user’s name and primary group become the owner and group owner of the file • Primary group • Default group to which a user belongs • whoami • Show your username • groups • Shows group membership and primary group

  38. chown commands • chown (change owner) command • Used to change the owner and group owner of a file or directory • Two arguments • New owner • File or directory to change • -R option is recursive for subdirectories and files

  39. chgrp commands • chgrp (change group) command • Change the group owner of a file or directory • Takes two arguments at a minimum • The new group owner • The files or directories to change • Also can use the –R switch

  40. Managing file and directory permissions • Mode • The section of the inode that stores permissions • Divided into three sections based on the user(s) that receive(s) the permission to that file or directory • User (owner) permissions • Group (group owner) permissions • Other (everyone on the Linux system permissions

  41. Regular permissions • There are three regular permissions that you might assign to a user • Read • Write • Execute

  42. The structure of a mode

  43. Interpreting permissions

  44. chmod command • Used to change the mode (permissions) of a file or directory • Takes two arguments at a minimum • The first specifies criteria used to change permissions • The remaining arguments indicate the filenames to change

  45. Criteria used: chmod command

  46. Mode: numeric representation

  47. Numeric representations: permissions

  48. Topic D: Default and special permissions

  49. Default permissions • Umask • Used to alter the permissions on all new files and directories • Takes select default file and directory permissions away • Only applies to newly created files and directories • Never used to modify existing files or directories

  50. umask 022 calculation

More Related