Directories and navigation

tree
text based tree display.
-a lists all files including .[hidden]
-l follows symbolic links
- 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.
- filename by itself
- commands look in current directory only.
- ./filename1
- look only in current directory
- usually same as just filename
- may be required by some commands when used as an argument
- may be required if file being invoked as a command
- ./dirA/filename1
- look for directory "dirA" in current directory,
then look in that directory for target file.
- ../filename
- look in parent of current directory for target file.
- ../dir2/filename1
- goes up 1 level then down into dir2 to look for filename1
- Note directory permissions can block path access.
- 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.
Filename used must not already exist in current directory
User must have write and execute permissions to parent directory, directory
new directory will be listed in.
Some Options :
- -m mode - sets permissions, overrides defaults.
- mkdir -m 700 newdir
- mkdir -m u=rwx,g=,o= newdir
- -p - makes parent directories as needed and don't exist.
rmdir mydir[s]
- removes a directory of specified name.
Directory file must be empty
User must have write and execute permissions to parent directory
Some Options :
- -p - remove directory and it's listed parent.
All directories in path must be empty.
- rmdir -p Temp/Bob
- rmdir Temp/Bob Temp # without option, two steps.