--- layout: page category-page: fs category-title: FileSystem tags: change directory author: Mirko Ponzio title: cd ---

In the operative system Unix and Unix-like, and in general in the system POSIX, cd (change directory) is an internal command of shell that change the corrent directory.

The command is only an internal command of shell, it can't be an external program, because one process can modified only the own corrent directory and not that of other processes. So the Shell has to implement this function autonomously. La new setting of the corrent directory it has been inherited from the started programs.

After the change of the directory, the variable pwd it is automatically updated with the pathname of the new directory.



Some usefull command for CD

sintax of cd

La sintassi generale di cd è la seguente: cd [opzioni] [--] [dir] Il parametro facoltativo dir indica la nuova directory corrente. Se non è specificato, viene usato al suo posto il valore della variabile d'ambiente HOME, che normalmente indica la home directory dell'utente. Se invece è un trattino ("-"), allora viene usata la directory corrente precedente. Se il parametro dir è un pathname relativo che non ha come primo elemento "." o "..", allora esso viene unito a ciascuna delle directory elencate nella variabile d'ambiente CDPATH: se il risultato corrisponde ad una directory esistente, allora essa diviene la nuova directory corrente. Altrimenti dir viene considerato relativo alla directory corrente. Il doppio trattino -- (facoltativo) indica che i parametri successivi non sono da considerarsi opzioni.