How you can Use the CD Command in Linux

by | Oct 23, 2023 | Etcetera | 0 comments

The cd command, transient for “change checklist,” is without doubt one of the most fundamental and continuously used directions in Linux operating tactics. Its primary purpose is to navigate between different directories all over the file machine. By means of enabling consumers to easily switch from one folder to each different, the cd command plays the most important place in file keep an eye on and machine navigation. Listed here are numerous techniques the cd command can be used.

Commonplace syntax for cd command:

$ cd [DIRECTORY...]
1. Transfer to rapid dad or mum checklist
cd ..

This command will get your from provide checklist to an inventory previous to this.

Example:

$ pwd
/area/username/folder
$ cd ..
$ pwd
/area/username

In this example, the individual was initially throughout the /area/username/folder checklist and moved up to the /area/username checklist by the use of executing cd ...

2. Transfer to previous checklist
cd -

This command will return you to the checklist prior to the current. Bring to mind it since the once more button in your browser.

Example:

$ pwd
/area/username/folder1
$ cd /area/username/folder2
$ cd -
/area/username/folder1

In this example, the individual first navigates to /area/username/folder2 and then uses cd - to return to the previous checklist (/area/username/folder1), and the path to the previous checklist is printed to the terminal.

3. Transfer to accommodate checklist
cd ~

The cd ~ command will ship you once more to your home checklist, without reference to which checklist you’re this present day in.

See also  Perfect Signature Fonts for Emails and Paperwork

Example:

$ pwd
/area/username/folder
$ cd ~
$ pwd
/area/username

In this example, the individual was initially throughout the /area/username/folder checklist and moved to the individual’s area checklist, /area/username, by the use of executing cd ~.

4. Switch two directories up from provide location
cd ../../

Instead of doing cd .. two instances to transport up two directories prior to the current, you’ll use merely cd ../../ as an alternative.

Example:

$ pwd
/area/username/folder/subfolder
$ cd ../../
$ pwd
/area/username

In this example, the individual was initially throughout the /area/username/folder/subfolder checklist and moved up two levels to the /area/username checklist by the use of executing cd ../../.

5. Transfer to checklist with spaces in their determine
cd checklist determine with area

or

cd 'checklist determine with area'

To cd into directories with spaces in their determine, you’ll each add left-backlash () at the once more each word, or wrap the checklist determine with single quotes ('').

Example:

$ pwd
/area/username
$ ls
checklist determine with area  otherfolder
$ cd checklist determine with area
$ pwd
/area/username/checklist determine with area

In this example, the individual was initially throughout the /area/username checklist, then changed to the /area/username/checklist determine with area checklist the use of the cd command with appropriate backslashes to escape the spaces throughout the checklist determine.

Further Linux directions:
Record Operations rmdir · cd · pwd · exa · ls
Record Operations cat · cp · dd · much less · contact · ln · rename · extra · head
Record Gadget Operations chown · mkfs · find
Networking ping · curl · wget · iptables · mtr
Search and Text Processing to find · grep · sed · whatis · ripgrep · fd · tldr
Gadget Information and Regulate env · historical past · most sensible · who · htop · glances · lsof
Individual and Session Regulate display · su · sudo · open

The publish How you can Use the CD Command in Linux appeared first on Hongkiat.

See also  Laravel Eloquent Relationships: An Complex Information

WordPress Website Development

Supply: https://www.hongkiat.com/blog/linux-command-cd/

[ continue ]

WordPress Maintenance Plans | WordPress Hosting

read more

0 Comments

Submit a Comment

DON'T LET YOUR WEBSITE GET DESTROYED BY HACKERS!

Get your FREE copy of our Cyber Security for WordPress® whitepaper.

You'll also get exclusive access to discounts that are only found at the bottom of our WP CyberSec whitepaper.

You have Successfully Subscribed!