Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleAnswer...


Code Block
languagebash
cd /stor/work/CBRS_unix
cd                          # Back home
cd -                        # Last directory (here /stor/work/CBRS_unix)
cd ~                        # And home again

The command prompt "follows you", displaying /stor/work/CBRS_unix when you're in that directory, and ~ when you're in your Home directory.

Relative pathname syntax

An absolute pathname lists all components of the full file system hierarchy that describes a file. Absolute paths always start with  / (the forward slash), which is the root of the file system hierarchy. For example /stor/work/CBRS_unix/unix/haiku.txt is an absolute path.

Rather than always typing a full pathname (that is, a pathname starting with the / root directory) an absolute pathname of where you want to go, you can specify a directory relative to where you are. This is where the special directory names . (single periodcurrent directory) and .. (double periodparent of current directory) come in handy.

...

Since we've seen that a goal of Unix is to type as little as possible, there are several metacharacters that serve as wildcards to represent sets of characters when typing file names. Using these metacharacters is called globbing (don't ask me why (smile)) and the pattern is called a glob.

  • asterisk ( * ) is the most common filename wildcard. It matches any length of any characters.
  • brackets ( [ ] ) match any character between the brackets.
    • and you can use a hyphen ( - ) to specify a range of characters (e.g. [A-G])
  • braces ( {  } ) enclose a list of comma-separated strings to match (e.g. {dog,pony})

...

  1. file permissions - a 10-character field
  2. number of sub-directories or symbolic linkscomponents associated with a directory - rarely important
  3. account name of the file owner
  4. Unix group associated with the file
  5. file size
  6. last modification month
  7. last modification day
  8. last modification year, or last modification hour/minute if within the last year
  9. file name

...

Permissions

File permissions ( and some information about the file type) are encoded in that 1st 10-character field. Permissions govern who can access a file, and what actions they are allowed.

  • character 1 describes the file type (d for directory, - for regular file, l for symbolic link)
  • the remaining 9 characters are 3 sets of 3-character designations
    • characters 2-4: what the owning user account can do
    • characters 5-7: what other members of the associated Unix group can do
    • characters 8-19: what other non-group members (everyone) can do

Each of the 3-character sets describes if read ( r ) write ( w or s ) and execute ( x or s ) actions are allowed, or not allowed ( - ).

  • read ( r ) access means file contents can be read, and copied
  • write ( w or s ) access means a file's contents can be changed, and directory contents can be modified (files added or deleted)
  • execute ( x or s )
    • for files, execute ( x ) means it is a program that can be called/executed (
      • e.g. /usr/bin/ls, the file that performs the ls command
      )
    • for directories, execute ( x ) means directory operations may be performed/executed
      • the directorycan be listed and changed into

...