The cd command

Yaser Rahmati | یاسر رحمتی

The cd command is used to change the current working directory (i.e., in which the current user is working). The "cd" stands for "change directory" and it is one of the most frequently used commands in the Linux terminal.

Examples of uses:

  • Change the current working directory:

[root@academy /]# cd /tmp
  • Change the current working directory to the home directory:

[root@academy tmp]# cd ~
[root@academy ~]#
  • Change to the previous directory:

[root@academy tmp]# cd ~
[root@academy ~]# cd -
/tmp
[root@academy tmp]#
  • Change the current working directory to the system's root directory:

[root@academy tmp]# cd /
[root@academy /]#

Quick Tips

  • Adding a .. as a directory will allow you to move "up" from a folder:

[root@academy /]# cd /tmp/F1
[root@academy F1]# cd ..
[root@academy tmp]# cd ..
[root@academy /]#
  • This can also be done multiple times! For example, to move up three folders:

[root@academy /]# cd /tmp/F1/F2
[root@academy F2]# cd ../../..
[root@academy /]#

Syntax:

cd [OPTIONS] directory

Additional Flags and Their Functionalities:

Last updated