The cd
command, brief for “alternate listing,” is among the maximum elementary and incessantly used instructions in Linux working techniques. Its number one objective is to navigate between other directories throughout the document gadget. Via enabling customers to simply transfer from one folder to every other, the cd
command performs an important position in document control and gadget navigation. Listed below are a number of tactics the cd
command can be utilized.
Common syntax for cd
command:
$ cd [DIRECTORY...]
1. Move to fast guardian listing
cd ..
This command gets your from present listing to a listing prior to this.
Instance:
$ pwd /house/username/folder $ cd .. $ pwd /house/username
On this instance, the person used to be to start with within the /house/username/folder
listing and moved as much as the /house/username
listing by means of executing cd ..
.
2. Move to earlier listing
cd -
This command will go back you to the listing prior to the present. Recall to mind it because the again button to your browser.
Instance:
$ pwd /house/username/folder1 $ cd /house/username/folder2 $ cd - /house/username/folder1
On this instance, the person first navigates to /house/username/folder2
after which makes use of cd -
to go back to the former listing (/house/username/folder1
), and the trail to the former listing is outlined to the terminal.
3. Move to house listing
cd ~
The cd ~
command will deliver you again to your house listing, irrespective of which listing you’re these days in.
Instance:
$ pwd /house/username/folder $ cd ~ $ pwd /house/username
On this instance, the person used to be to start with within the /house/username/folder
listing and moved to the person’s house listing, /house/username
, by means of executing cd ~
.
4. Transfer two directories up from present location
cd ../../
As a substitute of doing cd ..
two times to move up two directories prior to the present, you’ll use simply cd ../../
as a substitute.
Instance:
$ pwd /house/username/folder/subfolder $ cd ../../ $ pwd /house/username
On this instance, the person used to be to start with within the /house/username/folder/subfolder
listing and moved up two ranges to the /house/username
listing by means of executing cd ../../
.
5. Move to listing with areas of their identify
cd listing identify with house
or
cd 'listing identify with house'
To cd
into directories with areas of their identify, you’ll both upload left-backlash () on the again every phrase, or wrap the listing identify with unmarried quotes (
''
).
Instance:
$ pwd /house/username $ ls listing identify with house otherfolder $ cd listing identify with house $ pwd /house/username/listing identify with house
On this instance, the person used to be to start with within the /house/username
listing, then modified to the /house/username/listing identify with house
listing the usage of the cd
command with suitable backslashes to flee the areas within the listing identify.
Extra Linux instructions:
Listing Operations | rmdir · cd · pwd · exa · ls |
Report Operations | cat · cp · dd · much less · contact · ln · rename · extra · head |
Report Machine Operations | chown · mkfs · find |
Networking | ping · curl · wget · iptables · mtr |
Seek and Textual content Processing | to find · grep · sed · whatis · ripgrep · fd · tldr |
Machine Data and Control | env · historical past · most sensible · who · htop · glances · lsof |
Person and Consultation Control | display · su · sudo · open |
The submit How you can Use the CD Command in Linux seemed first on Hongkiat.
WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-cd/