Change/Print Current Working Directory
cd command is used to move into another directory and make it the current working directory.
For example, to change the current directory from
birds, you would type:
animals directory should be one level up of birds directory (animals is the parent of birds).
To change current directory to root, home, parent directories, refer the below table.
parent(one level up)
cd ~ or cd
To change directory from
/usr/local/sharedirectory, you would type:
Suppose that you want to go to the Downloads directory from your current directory, and you know that the Downloads directory resides in the home directory, you type:
For Example, you are in the
/usr/local/sharedirectory, and you want to switch to the
/usr/local/src. You can do that by typing:
The current working directory is the directory where all the commands are being executed. To know your current directory, you can use the
pwd command which stands for Print Working Directory.
This will print the absolute path of the current directory as follows:
The name of the current working directory is the last directory in the absolute path. For example, in the above example,
dir2 is the current working directory.