Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

NOTE: CentOS Enterprise Linux is built from the Red Hat Enterprise Linux source code. Other than logo and name changes CentOS Enterprise Linux is compatible with the equivalent Red Hat version. This document applies equally to both Red Hat and CentOS Enterprise Linux.

4.6. Leaving your Current Working Directory

To change directories from your current working directory, use the command cd.

cd /tmp/

The above command changes directories to the /tmp/ directory. The second word on the command line must be a path. It can either be relative or absolute, and can move one directory or many. If the cd command is entered at the shell prompt with no options or path specified, the default action is to move the user into their home directory. For example, user someone would be moved to the /home/someone/ directory.

The cd has many useful options. You can see all of these options by entering man cd at the shell prompt. The most commonly used options are listed below.

  • cd — Returns you to your login directory

  • cd - — Returns you to your previous working directory

  • cd ~ — Also returns you to your login directory

  • cd / — Takes you to the entire system's root directory.

  • cd /root — Takes you to the home directory of the root user. You must be the root user to access this directory.

  • cd /home — Takes you to the home directory, where user login directories are usually stored

  • cd .. — Takes you to the directory one level up.

  • cd ~otheruser — Takes you to otheruser's home directory, if otheruser has granted you permission.

Below are a few examples of the use of cd.

  • cd /dir1/dir2/ — Regardless of which directory you are in, this absolute path takes you directly to dir2, a subdirectory of /dir1/.

  • cd ../../dir2/dir3/ — This relative path takes you up two directories, then to dir2/, and finally into its subdirectory dir3/.

If you attempt to cd into a directory you do not have permission to access, you are denied permission to access that directory.

Denying access to the root and other users' accounts (or home directories) is one way your Red Hat Enterprise Linux system prevents accidental or malicious tampering. Refer to Section 4.11 Ownership and Permissions for more information.

 
 
  Published under the terms of the GNU General Public License Design by Interspire