Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Bootcamps Get Certified Upgrade Teachers Spaces Bootcamps
   ❮   
     ❯   

Bashcd - Change Directory


Using thecd Command

Thecd command is used to change the current working directory in the terminal.


Basic Usage

To change to a specific directory, usecd directory_name:

Example

cd my_directory

Options Overview

Thecd command supports several useful options for navigating directories:

  • cd ..: Move up one directory level
  • cd ~: Change to the home directory
  • cd -: Switch to the previous directory
  • cd /: Change to the root directory

cd .. Option: Move Up One Directory Level

Thecd .. command lets you go to the folder above your current one.

It's useful when you need to go to the parent folder.

Example

cd ..


cd ~ Option: Change to Home Directory

Thecd ~ command takes you to your home directory, which is the default directory for your user account.

This option is useful when you need to return to your starting point after navigating through various directories.

Example

cd ~

cd - Option: Switch to Previous Directory

Thecd - command switches your working directory to the previous one you were in.

This option is useful for toggling between two directories without needing to type their full paths repeatedly.

Example

cd -

cd / Option: Change to Root Directory

Thecd / command takes you to the root directory of the file system.

This option is useful when you need to access system-wide files or directories.

Example

cd /

Combining Options

Thecd command itself does not support combining options, but you can use it in conjunction with other commands to enhance navigation efficiency.

For example, usingcd withls can quickly show you the contents of a directory you navigate to:

Example: Change and List

cd my_directory && lscopy_of_my_file.txt  Cosmere_RPG_Beta_Rules_Preview.pdfimages/  my_file.txt  myfolder/  report.csv  voiceover.wav



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2026 Movatter.jp