How to navigate back to the previous directory in Ubuntu?

You can use the following command to go back to the previous directory while working in the Ubuntu terminal:

Use the command `cd ..`.

This command will switch to the parent directory of the current directory. For example, if your current working directory is “/home/user/Documents,” executing the “cd ..” command will switch you to the “/home/user” directory.

   cd ..

2. Utilize the `cd -` command:

This command will switch to the previous working directory. It will remember the directory you were in before and switch back to it when needed.

   cd -

If you are in the `/home/user/Documents` directory, then switch to the `/var/www` directory, and execute the `cd -` command again, you will return to the `/home/user/Documents` directory.

广告
Closing in 10 seconds
bannerAds