Introduction – You need to use the cd command to move from your present directory to another directory. You must have execute or search permission in the specified directory. This page shows basic examples of how to change directory on Linux using the cd command.
How to change directory in Linux
The procedure changes a directory or folder in Linux as follows:
- Let us change to your home directory in Linux, run: cd
- If you want to change to the /etc/security/ directory on Linux, execute: cd /etc/security/
- Want to go up one level of the directory tree in Linux? Try: cd ..
Let us see some examples and usage in details.
Changes the current directory in Linux
Let us change the current working directory to the home (login) directory in Linux, run:
To print the current working directory, use the pwd command:
Next change to an arbitrary directory named /etc/ufw/, type:
At this stage, you may want to list the directory contents. Hence, try the ls command:
Say you need to go down one level of the directory tree (say you want to change to the applications.d), run:
How do I go back to my home folder or directory in Linux?
Simply type any one of the following command:
How to change a folder in Linux
Get list of directories only in the current directory using the following:
ls -d */
Once you know the directory names, change it as per your needs:
To move back to a parent directory directory, type:
Linux change directory and symbolic links
One can force symbolic links to be followed. The syntax is:
cd -L dir1
cd -L link2
To use the physical directory structure without following symbolic links:
cd -P link2
This page explained the cd command that allows you to change directories. For more info type the following command at the terminal: