Current Working Directory

Current Working Directory: pwd

Explaining the world:

  • Every process has a current working directory

  • ⟶ CWD is a process attribute (see Processes, Scheduling, Address Spaces for more about process attributes)

  • Shell is just an ordinary program ⟶ process

    A shell’s process ID
    $ echo $$
    121751
    
  • ⟶ shell has a CWD

  • Command: pwd (“print working directory”)

    $ pwd
    /home/jfasch
    

Changing The Current Working Directory: cd

  • Moving from where we are to there

    $ pwd
    /home/jfasch
    $ cd /etc/
    $ pwd
    /etc
    
  • Moving into my home directory

    $ pwd
    /etc
    $ cd
    $ pwd
    /home/jfasch
    
  • Same, but with more typing

    $ cd ~
    
  • Moving into someone else’s home directory

    $ cd ~someone-else
    $ pwd
    /home/someone-else
    
  • Moving back where I been last (where I came from): cd -

    $ cd ~someone-else
    $ pwd
    /home/someone-else
    $ cd -      # <-- back where I came from
    $ pwd
    /etc
    
  • Moving into parent directory

    $ cd ..
    
  • No-op nonsense

    $ cd .