Directories and navigation

tree

  • text based tree display.
    storage drives
    parsed into cylinders, heads, sectors (CHS).
    broken into 'partitions' for better management.
    newer, smarter drives use logical block addressing (LBA) to simplify access.
    partitions
    each partition numbers its own sectors starting from LBA 0.
    each partition contains its own file-system.
    different partitions may contain different types of file-systems.
    Unix type partitions - one primary feature is the inode table
    inode
  • member of a type of database, the inode table.
  • each Unix-style partition on a drive has its own inode table
  • each created file is assigned to a single inode entry
  • inode contains info about ownership, permissions, file type, size,
    and location of storage sectors (LBAs) on storage device.
  • does NOT contain a file's name.
  • directory
  • is a special purpose file
  • contain filenames and inode numbers of files being listed.
  • multiple filenames may reference a specific inode on a particular partition.
  • directory must be readable to list filenames stored.
  • directory must be executable to retrieve the inode info of a file.
  • current working directory
  • default directory used when using a relative path to specify a target file.
  • or when referencing a file with out any additional path information.

  • pwd
  • command that prints the current working directory
  • echo $PWD prints the current working directory
  • pwd is both a built-in bash command and a separate program - /bin/pwd.
  • $PWD is built-in bash variable.

  • Special file names
    Two filenames that always exist in all directory listings.
    . - dot, refers to current directory.
    .. - double dot, refers to parent directory.
    . and .. are relative filenames
    . and .. act as links in a doubly linked list
    . and .. in root, /, link to root itself.
    $HOME - bash variable set on login to your home directory.
    ~ (tilde_) - bash symbolic reference to $HOME.
    ~ - quoting the tilde will denature it. (stops working)
       $ echo ~
    
       /home/hopper/berezin
    

    Paths - relative and absolute

    relative
    location of file determined starting from current directory.
    absolute
    filename preceded by full path starting from / (root)
    command interpreter can always find the root directory.
      /home/hopper/berezin/bin/pingit


    cd directory
  • change-directory - changes the current working directory to one specified in command line argument.
  • shell built-in
  • directory has to be a valid directory name for which user has permission to access.
  • cd, by itself, resets current directory to home directory.

  • Creating and removing new directories.

    Note : Unix is case sensitive so Dir and dir are 2 different files.

  • mkdir mydir - makes a directory of specified name. Some Options :
  • rmdir mydir[s] - removes a directory of specified name. Some Options :