cd command with examples in Linux / Unix
cd command is used to change directory in Linux / Unix environment. The abbreviation of “cd” is “Change Directory”. It is the most basic and important command in linux / Unix command prompt environment. OK lets see some example about cd command.
How to go to your home directory with cd command
Use pwd(present working directory) command to to verify that you are in your home directory.
Use pwd(present working directory) command to verify that you are in your home directory.
How to go to your previously working directory
The “cd -” command will fetch the input directory from “echo $OLDPWD” variable and use it if you give “cd -”
How to use relative and absolute path with cd command
I will give you some basic tips about relative and absolute path. we will see deep about it in a separate blog later. Relative path always starts with “/” and absolute path always starts with “..” symbol. Relative path should be a full path but absolute path can start from any where in between.
Consider that you are in your home directory right now. If you want to go to http configuration files location “/etc/httpd/conf” use absolute path
If you want to go to “/etc” two steps backward use relative path righ from there
That’s it you have successfully switch over in to folder “/etc”
Cd command with wild card example
Suppose consider that you want to go to folder “/etc/samba” folder so i am going to use cd command with wild card. Press “Tab” after giving below command for auto complete.
The below command will take you to /etc/httpd/conf/ folder. Press “Tab” after giving below command for auto complete.