2018-10-12 04:30:38 +05:30 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Bash cd
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Bash command: cd
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								**Change Directory** to the path specified, for example `cd projects` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-15 13:55:31 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Usage
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bash
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								cd [dir]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 04:30:38 +05:30 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-15 13:55:31 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								There are a few really helpful arguments to help with this:
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 04:30:38 +05:30 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								-  `.`  refers to the current directory, such as `./projects`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `..`  can be used to move up one folder, use `cd ..` , and can be combined to move up multiple levels `../../my_folder`  
						 
					
						
							
								
									
										
										
										
											2018-10-30 08:21:41 +05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `-`  takes you back to the previous directory you were working on. For example, `cd -`  
						 
					
						
							
								
									
										
										
										
											2018-10-12 04:30:38 +05:30 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								-  `/`  is the root of your system to reach core folders, such as `system` , `users` , etc. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `~`  is the home directory, usually the path `/users/username` . Move back to folders referenced relative to this path by including it at the start of your path, for example `~/projects` . 
						 
					
						
							
								
									
										
										
										
											2018-10-19 20:40:55 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `-`  can be used to move to the previous directory. For example, you are in `/A` , then cd to `/B` , use `cd -`  and you are back to `/A`  
						 
					
						
							
								
									
										
										
										
											2019-01-15 15:58:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `~[number]`  will cd to that entry from the output of `dirs`  directories can be pushed or popped to the 'dirs' stack using `pushd`  and `popd`  respectively. 
						 
					
						
							
								
									
										
										
										
											2019-01-15 23:21:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  Typing only `cd`  will move to the home directory works same as `cd ~` .  `cd $HOME`  will also move to the home directory. 
						 
					
						
							
								
									
										
										
										
											2018-10-29 19:13:18 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  Typing 'pwd' will show you which directory you are currently working in. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-15 13:55:31 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Example
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Change directory to `projects`  folder:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bash
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								cd projects
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 04:30:38 +05:30 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								### More Information:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  [Wikipedia ](https://en.wikipedia.org/wiki/Cd_(command ))