Change Directory (
To change your working directory, use the
cd command. To do this, type
cd followed by the pathname of the desired working directory. A pathname is the route we take along the branches of the tree to get to the directory we want. Pathnames can be specified in one of two different ways;
- Absolute pathnames
- Relative pathnames
An absolute pathname begins with the root directory and follows the tree branch by branch until the path to the desired directory or file is completed. For example, there is a directory on your system in which most of your system's programs are installed. The pathname of the directory is /usr/bin. This means from the root directory (represented by the leading slash in the pathname) there is a directory called "usr" which contains a directory called "bin".
[robin@pc-name] $ cd /usr/bin [robin@pc-name bin] $ pwd /usr/bin [robin@pc-name bin] $ ls ....... listing of many files ....
Now we can see that we have changed the current working directory to /usr/bin and that it is full of files. Notice how the shell prompt has changed? As a convenience, it is usually set up to automatically display the name of the working directory.
Where an absolute pathname starts from the root directory and leads to its destination, a relative pathname starts from the working directory.
[robin@pc-name usr] $ pwd /usr [robin@pc-name usr] $ cd bin [robin@pc-name bin] $ pwd /usr/bin
Now we have changed the working directory from /usr to /usr/bin.
Some special symbols represent relative positions in the file system tree. These special symbols are
. (dot) and
.. (dot dot).
.symbol refers to the working directory.
..symbol refers to the working directory's parent directory.
~symbol refers to the user home directory.
-symbol refers to the previous working directory.
Navigating Up (
Once inside a directory, it can be useful to be able to navigate back up a directory. One way to do this would be to call
cd giving it the full path to the directory you want to go. Another way to accomplish the task of moving up to the parenet
directory is to use the special path
$ cd ..
cd to navigate to
.. will navigate to the parent directory of the current directory.
Navigating to the Home Directory
When you are in a directory and want to navigate back to your home directory, you can call
cd without any argument.
$ cd $ pwd /Users/robin
Alternative, you can
$ cd ~
Summary of the helpful shortcuts
| ||Changes the working directory to your home directory.|
|Changes the working directory to your home directory.|
|Changes the working directory to the previous working directory.|
|Changes the working directory to the home directory of user_name. For example, |
- Dependency injection
- Directives and Pipes
- Data binding
- HTTP Get vs. Post
- Node.js is everywhere
- MongoDB root user
- Prefer Async Script Loading
- Components, Bootstrap and DOM
- What is HEAD in git?
- Show the changes in Git.
- What is AngularJS 2?
- Confidence Interval for a Population Mean
- Accuracy vs. Precision
- Sampling Distribution
- Working with the Normal Distribution
- Standardized score - Z score
- Evaluating the Normal Distribution
- What is Nodejs? Advantages and disadvantage?
- How do I debug Nodejs applications?
- Sync directory search using fs.readdirSync