It doesn’t matter if you are a beginner, intermediate, or advanced Linux user. This Basic command you should know.
Just bookmark this page because you require this command to work for daily use.
Let’s start the Basic command journey
1. pwd Command
We use the pwd command when we want to know the name of the current working directory.
[email protected]:~$ pwd
When you pass the pwd command in the terminal, you will get the full path of the current working directory.
It will always start from the forward Slash (/) after that directory name.
2. cd Command
When you want to navigate or switch back to another directory or folder, we use the cd command, and the cd command stands for Change Directory.
[email protected]:~$ cd /DirectoryName
How to use the CD command? For example, I want to go inside the Download folder, and I have checked my current working directory using the pwd command. From that, I know my current directory is ???/home/trendoceans???.
So, what I need to do go inside the download folder. I’ll type ???cd /Downloads???, and now I’m inside the Download folder.
[email protected]:- $ cd Downloads
If the current working directory is ???/usr/share???, I need to go to the download folder for that type the command.
[email protected]:/usr/share$ cd /home/trendoceans/Downloads/
Now verify the current Directory using pwd command.
[email protected]:~/Downloads$ pwd
It will only go to the next directory if the directory is present and type the correct directory name; otherwise, you will get an error.
I’ll provide you useful shortcuts that you can use while working on directories.
[cd or cd ???]:- If you want directly jump to the home folder, then simply type cd or cd – and you will back to your home directory. It doesn’t matter what your current directory is. There are many shortcuts to go back to the home directory.
[cd..]:- When you want to go back one step to the previous directory, then pass command cd??? you will back to the last directory.
[cd-]:-If you want to go back to the last working directory, then type command cd-.
To get more information about cd command pass man cd in terminal.