Linux Managing Files Ch7

  1. FHS
    Filesystem Hierarchy Standard (FHS)lShareable vs. Unshareable FilesStatic vs. Variable Files
  2. Shareable vs. Unshareable Files
    • Static vs. Variable Files
    • Shareable
    •    Static: /usr, /opt
    •    Variable /home, /var/mail
    • Unshareable
    •    Static /etc, /boot
    •    Variable /var/run, /var/lock
  3. configuration directory
    • executable directories
    • library director
    • Configuration directory - /etcl
    • Executable directories
    • –/sbin
    • –/bin
    • –/usr/sbin
    • Library directories
    • –Libraries - collections of programming functions
    • –/lib
    • –/usr/lib
    • –/usr/bin
  4. Run Level 3
    • If no GUI (i.e. Run Level 3)
    • –Use command-line shell commands
    • –Use wildcard characters to simplify tasks
  5. ls
    • “ls”   command (list)
    • –Many options (the examples below are all alphabetic)“
    • ls –l”  List long (include file type, permissions etc)
    • –Combine Options“
    • ls –la”  List long and include all directory entries
    • ls -lai
    • Display the contents the current working directory using long formatLists filenames/directory names, with permissions, date created, owner, file size, type of file“a” will list hidden files (files with a filename starting with a period)Also display i-node numbers
  6. touch
    • touch command
    • Used to create a new empty file
    • Can change the time stamp on an existing file
    • Example usage:
    • touch newfile.txt
    • “-c” option
    • –Don’t create a file if non exist
    • –Used to change the time stamps on existing files
    • “-d” option followed by date
    • –Set time/date to specific value
  7. cp
    • cp oldfile  newfile
    •       same location
    • cp oldfile  /otherdir
    •         new location/same name
    • cp oldfile  /otherdir/newfile
    •        new location/new name
  8. cp outfile.txt   ~/network
    • –If “network” is a directory, the results is a file call “outfile.txt” in the network directory
    • –If “network” is a file, then it will be replace with “outfile.txt”
    • –If “network” does not exist, the result is a new file
  9. cp options
    • “-i” interactive option
    •    –Cause cp to ask you before overwriting any existing file
    • “-p” preserve option
    •   –Preserve ownership
    • “-R” recursive copy
    •     –If you specify a directory of source of copy, the entire directory including subdirectories are copied
  10. mv oldfile  newfile
    • mv testfile ./newdir
    • mv testfile ./newdir/newname
    • mv oldfile  newfile
    •       rename a file
    • mv testfile ./newdir
    •      move a file to a new directory
    • mv testfile ./newdir/newname
    •      move with a new location/name
  11. Hard Links
    • Duplicate directory entry
    • Only the same filesystem
    • will have a number > 1 in the second column of ls -l output
    • Example usage:
    • ln origname  linkname
  12. Symbolic Links
    • (soft link)
    • A file that refers to another file by name
    • Can cross filesystems
    • will have a “l” as the file type
    • Example usage:
    • ln –s origname  linkname
  13. rm file1
    • m file1 file2
    • rm –r mydir
    • rm file1
    •     delete one file
    • rm file1 file2
    •     delete multiple files
    • rm –r mydi
    •      r  delete a directory and all contents
  14. Wildcards
    • –Sometimes called “globbing”
    • “?” (Question Mark)–Stands for a single character
    • “*” (Asterick)–Matches any character or set of characters, including no character
    • [ ] square brackets–Match any character in set–Specific a range of values [a-z]  (a to z)
  15. b\?\?k matches
    • b\*k matches
    • b[\a\o][\l\o]k matches
    • b\?\?k matches     “book”, “buck”, “beek” etc
    • b\*k matches     “book”, “buck”, “bk”, “bok”, “backtrack” etc
    • “b[ao][lo]k”   matches “book”, “balk”, but not “buck”
  16. mkdir newdir
    • mkdir newdir/dirone
    • mkdir –p newdir/dirone
    • mkdir newdir
    •    create a directory named “newdir”
    • mkdir newdir/dirone
    •   create a directory named “dirone”   in the directory “newdir”
    • mkdir –p newdir/dirone
    •   create a directory parent first then create the child directory
  17. rmdir dirone
    • rmdir –p newdir/dirone
    • rmdir –r dirone
    • rmdir dirone
    •   remove a directory named “dirone”
    • rmdir –p newdir/dirone
    •   remove a directory named “dirone”  first then remove parent
    • rmdir –r dirone
    •   remove a directory named “dirone”  and all files and subdirectories
  18. Deleting Directories
    • Use the “rmdir” command to delete a directory
    • Remember “r” option on “rmdir” command RecursiveCan be dangerous be careful
  19. /
    The root directory. All files appear in this directory or in subdirectories of it.
  20. /etc
    Holds system configuration files.
  21. /boot
    Holds important boot files, such as the Linux kernel, the initial RAM disk, and often boot-loader configuration files.
  22. /bin
    • /sbin
    • /bin
    • Holds program files that are critical for normal operation and that ordinary users may run.
    • /sbin
    • Holds program files that are critical for normal operation and that ordinary users seldom run.
  23. /lib
    • /lib
    • Holds libraries—code used by many other programs—that are critical for basic system operation.
  24. /usr
    Holds programs and data that are used in normal system operation but are not critical for a bare-bones boot of the system. This directory is split into subdirectories that mirror parts of the root organization—/usr/bin, /usr/sbin, /usr/lib, and so on.
  25. /home
    Holds users’ home directories. Separating this directory into its own low-level filesystem effectively isolates most user data from the OS, which can be useful if you want to reinstall the OS without losing user data.
  26. /root
    The root user’s home directory.
  27. /var
    Holds miscellaneous transient files, such as log files and print spool files. One subdirectory of /var, /var/tmp, deserves special mention. Like /tmp (described next), /var/tmp holds temporary files. These files should not be deleted when the computer reboots.
  28. /tmp
    Holds temporary files, often including temporary files created by user programs. Such files may theoretically be deleted when the computer reboots, although in practice many distributions don’t do this.
  29. /mnt
    The traditional mount point for removable media; sometimes split into subdirectories for each mounted filesystem.
  30. /media
    The new mount point for removable media; typically split into subdirectories for each mounted filesystem.
  31. /dev
    Holds device files, which provide low-level access to hardware.
  32. /run
    Holds information about the running system.
Author
slc53
ID
328232
Card Set
Linux Managing Files Ch7
Description
Linux Managing Files Ch7
Updated