In unix like systems what is the difference between a
home directory and
working directory ?
A home directory is where you start when you open a shell. The working directory is where you are right now. You can usually go directly to the home directory with the command
The home directory is a directory associated with a user name in the system's user account database. It's the 6th field in the entry returned by
When you log in, the
That directory is usually owned and writable by the corresponding user, and it's typically where applications store the user settings and where the user stores his files.
The kernel has no notion of what a user name or home directory is. The home directory is entirely a user-space concept.
On the other hand, the working directory is an attribute of each process. It can be changed with the
The working directory is inherited upon a fork and preserved upon execution of a command. For instance,
When a user logs in, the working directory of the first process that is run under his name is set to his home directory, and as a result, unless anything changes it, every process started under that login session will have the home directory as the current working directory.
shells don't start in the home directory, they start wherever the current directory was when they were executed, though shells started by a terminal emulator itself started by a window manager itself started by the login manager will likely start in the home directory since there's no reason why the window manager or terminal emulator would change their working directory.