AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Linux cd command: switch between directories

PARTAGEZ

The cd command is particularly important, as it allows you to switch very quickly from one directory to another. This Linux command offers several useful functions.

Linux cd command: what is it?

The cd command can be used in all major Linux distributions, including Ubuntu. This is the fastest method for switch from one given directory or subdirectory to another. After failover, the current working directory becomes the specified destination. In Linux, « cd » stands for « change directory ». Most users primarily use this command when working with the shell. This command must respect upper and lower case letters. If you need to access your directory first, we recommend using the Linux find command.

How does the cd command work?

It is often necessary to switch from one directory to another when working in the shell. To do this, the cd command is the perfect tool. When typing, you can use relative paths which relate to the hierarchy of subdirectories and lead directly from your path to the upper path. It is also possible to opt for a absolute path, for immediate access to a destination that may be further away. The command is executed on the condition that the specified directory exists and that you have access rights to it. Otherwise, you receive an error message and remain in the previous working directory.

What does the cd command syntax look like?

Below is the general syntax of the Linux cd command:

$ cd [Option] [Répertoire]

shell

« cd » is the Linux command,  » [Option]  » denotes the possibility of further specification and  » [Répertoire] indicates the exact destination directory.

What are the cd command options?

Two options are available to you.

  • -L : under this option, the cd command follows the logical directory structure. This is the default.
  • -P: under this option, the command follows the physical directory structure instead.

Linux cd command: some examples

To better understand how the cd command works, we have prepared some simple examples for you. As you will soon see, this command is extremely convenient for your daily work, as it allows you to switch more easily from one directory to another.

With this command, you can immediately access your home directory.

This allows you direct access to the root directory.

This command gives you access to the subdirectory /usr/local.

With it, you can directly access your previous working directory.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact