2018-11-12 09:08:27 +00:00
|
|
|
---
|
|
|
|
layout: page
|
2018-11-14 13:28:12 +00:00
|
|
|
category-page: fs
|
|
|
|
category-title: FileSystem
|
2018-11-12 09:35:55 +00:00
|
|
|
tags: change directory
|
2018-11-14 21:15:38 +00:00
|
|
|
author: Alessandro Marinelli
|
2018-11-12 09:35:55 +00:00
|
|
|
title: cd
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/fs/absolute.html
|
2018-11-19 14:57:49 +00:00
|
|
|
next-page: pages/fs/cp.html
|
2018-11-12 09:08:27 +00:00
|
|
|
---
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
<!-- Co-authored with Mirko Ponzio -->
|
|
|
|
|
2018-11-12 09:08:27 +00:00
|
|
|
<p>
|
2018-11-18 20:44:36 +00:00
|
|
|
The <code>cd</code> command is used to change the working directory<br/>
|
|
|
|
The name stands for <i>Change Directory</i>.<br/>
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
The default cd command syntax is:
|
2018-11-18 20:44:36 +00:00
|
|
|
</p>
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
<pre>
|
|
|
|
cd [flags] [path]
|
|
|
|
</pre>
|
|
|
|
|
2018-11-18 20:44:36 +00:00
|
|
|
<p>
|
2018-11-14 21:15:38 +00:00
|
|
|
Where [flags] are the cd flags, read below for more info,and [path] is the
|
2018-11-18 20:44:36 +00:00
|
|
|
path (absolute or relative), of the directory which we want to make as working directory.
|
|
|
|
</p>
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
<h3>Change the working directory</h3>
|
2018-11-18 20:44:36 +00:00
|
|
|
<p>
|
|
|
|
Let's see how to use the command <code>cd</code> in order to change the working directory:
|
|
|
|
</p>
|
2018-11-12 09:08:27 +00:00
|
|
|
|
2018-11-14 21:15:38 +00:00
|
|
|
<pre>
|
|
|
|
pwd
|
|
|
|
~
|
|
|
|
cd Desktop/multimedia
|
|
|
|
pwd
|
|
|
|
~/Desktop/multimedia
|
|
|
|
</pre>
|
2018-11-12 09:08:27 +00:00
|
|
|
|
2018-11-18 20:44:36 +00:00
|
|
|
<p>
|
2018-11-14 21:15:38 +00:00
|
|
|
As you can see, we changed the working directory from ~ (which stands for HOME),
|
|
|
|
to "multimedia". Now our Shell will work on the directory "multimedia"
|
2018-11-18 20:44:36 +00:00
|
|
|
until a new <code>cd</code> will occour.</p>
|
2018-11-12 09:08:27 +00:00
|
|
|
|
2018-11-18 20:44:36 +00:00
|
|
|
<p>
|
|
|
|
<b>Notice:</b> If you want to move to a directory which is not contained in the
|
2018-11-14 21:15:38 +00:00
|
|
|
current working directory, you <u>MUST</u> use the absolute path.
|
|
|
|
</p>
|