I recently made the switch and started using Debian Linux. How do I change directory in Linux using the cd command? How can I change a directory or folder in Linux?
Introduction – You need to use the cd command to move from your present directory to another directory. You must have execute or search permission in the specified directory. This page shows basic examples of how to change directory on Linux using the cd command.
How to change directory in Linux
The procedure changes a directory or folder in Linux as follows:
Let us change to your home directory in Linux, run: cd
If you want to change to the /etc/security/ directory on Linux, execute: cd /etc/security/
Want to go up one level of the directory tree in Linux? Try: cd ..
Let us see some examples and usage in details.
Changes the current directory in Linux
Let us change the current working directory to the home (login) directory in Linux, run: cd To print the current working directory, use the pwd command: pwd Next change to an arbitrary directory named /etc/ufw/, type: cd /etc/ufw pwd At this stage, you may want to list the directory contents. Hence, try the ls command: ls ls -l Say you need to go down one level of the directory tree (say you want to change to the applications.d), run: cd applications.d pwd ls -l
How do I go back to my home folder or directory in Linux?
Simply type any one of the following command: cd OR cd ~ OR cd $HOME
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.