To change the current working directory in a Linux terminal, you can use the cd
command. For example, to navigate to the /home/user
directory, you can use the following command:
cd /home/user
To navigate to a subdirectory within the current directory, you can specify the subdirectory name after the cd
command. For example, to navigate to the documents
subdirectory within the current directory, you can use the following command:
cd documents
You can also use the cd
command with the ..
notation to navigate to the parent directory of the current directory. For example, to navigate to the parent directory of the current directory, you can use the following command:
cd ..
You can use the cd
command with the -
notation to switch back to the previous directory. For example, to switch back to the directory you were in before the current directory, you can use the following command:
cd -
You can also use the cd
command with the ~
notation to navigate to your home directory. For example, to navigate to your home directory, you can use the following command:
cd ~
You can use the pwd
command to print the current working directory. This can be helpful for verifying that you are in the expected directory.
pwd
You can use the ls
command to list the contents of the current directory. This can be helpful for identifying the subdirectories and files within the current directory.
ls