How to get out of /opt folder using cmd line?

I typed cd /opt to get into the opt folder. What command should I write to get out of it? cd.. doesn't work

2

4 Answers

You can not get "out" of a folder.

Well, you can, but only by changing to a different directory.

In the terminal, you always have a current working directory. The cd command changes this working directory to the specified one.

Running the cd command without any arguments brings you back to the default working directory, which is your home directory /home/USERNAME (or short ~).

So probably you just want to go back to the default working directory by simply typing cd.


However, if by "get out of a folder" you meant to go to the directory one level above in the hierarchy (e.g. from /usr/bin to /usr or from /opt to /), this can be achieved by changing to the special directory .. which always represents the directory a level above.

Note that unlike in Windows/DOS, you may not leave the space between cd and .. out!

cd ..
2

cd - will return you to directory where you were before entering /opt

1

cd and then the name of the directory that you want, for example

cd /etc 

for /etc or just cd to go to your home directory.

cd 

Looks like you need a space between the "cd" and the ".." in order to go back to the directory above.

To list files and folders

ls

To step into a folder:

cd foldername

To one step back:

cd ..

To home:

cd

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like