Posts Tagged ‘working directory’

Working Directory

The Working Directory is the location of the directory that you are currently in. For example if you log into the system, it is designed so that you will begin in your home directory. For example, if your username was tom then your home directory by default would be /home/tom. When tom logs into the system it places him in the /home/tom directory, which is the current working directory. So if tom issues the command ls, then it will list the contents of /home/tom. If tom moves to the /usr directory by using the command cd /usr (which means change directories to /usr) then the current working directory is /usr Current working directory is the current directory that a command will interact with. Now, that does not mean that you have to be located in a directory to issue a command in the shell. Regardless of your current working directory you can use a command that interacts with any directory by using a path. For example, if you were located in the /home/tom directory you could list the contents of the /usr/share directory by using the path of that directory so the command would look like this:
ls /usr/share

One command that will verify your working directory is the command pwd, which stands for print working directory.

Moving Around in Directories

The cd command is the basic way to move around in the directory system. Cd followed by the directory location will move the users current working directory. For example,
cd /home

This command moves a user to the /home directory where all user directories are located. If the user fred wanted to move to their /home directory they would use:
cd /home/fred

There is a shortcut to moving to your home directory. The ~ is equivalent to the home directory. As a result fred can move to his home directory with this command:
cd ~

This makes it easier than typing the full path.


Get every new post delivered to your Inbox.

Join 55 other followers