User Tools

Site Tools


products:ict:linux:basic_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
products:ict:linux:basic_commands [2023/05/12 11:50] wikiadminproducts:ict:linux:basic_commands [2023/08/26 13:31] (current) wikiadmin
Line 29: Line 29:
  
 On a side note, Linux’s shell is case sensitive. So, you have to type the name’s directory exactly as it is. On a side note, Linux’s shell is case sensitive. So, you have to type the name’s directory exactly as it is.
 +
 +The `cd` command in Linux is used to change the current working directory in the terminal. It allows you to navigate the file system and switch between different directories. Here's a detailed tutorial on how to use the `cd` command:
 +
 +### Basic Usage:
 +To use the `cd` command, open your terminal and follow these steps:
 +
 +1. **Open the Terminal:** You can usually find the terminal application in the Applications menu or by searching for it.
 +
 +2. **View Current Directory:** When you open the terminal, you are in a specific directory. You can see the current directory's path in the terminal prompt. For instance, if the prompt shows something like:
 +   
 +   ```
 +   user@hostname:~/Documents$
 +   ```
 +
 +   The `~/Documents` part indicates that you're currently in the `Documents` directory within your home directory.
 +
 +3. **Changing Directory:** To change to a different directory, type `cd` followed by the path to the directory you want to navigate to. For example, if you want to move to the `Downloads` directory:
 +
 +   ```bash
 +   cd Downloads
 +   ```
 +
 +   If the directory name has spaces, enclose it in quotes:
 +
 +   ```bash
 +   cd "My Documents"
 +   ```
 +
 +### Directory Paths:
 +There are several ways to specify the directory path with the `cd` command:
 +
 +- **Absolute Path:** An absolute path starts from the root directory (`/`). For example:
 +
 +  ```bash
 +  cd /home/user/Documents
 +  ```
 +
 +- **Relative Path:** A relative path starts from the current directory. For example, if you are in the `/home/user` directory:
 +
 +  ```bash
 +  cd Documents
 +  ```
 +
 +  This takes you to `/home/user/Documents`.
 +
 +- **Parent Directory (..):** You can use `..` to refer to the parent directory. For example, if you're in `/home/user/Documents`, you can use:
 +
 +  ```bash
 +  cd ..
 +  ```
 +
 +  This moves you up to `/home/user`.
 +
 +- **Home Directory (~):** The tilde (`~`) symbol represents your home directory. For example:
 +
 +  ```bash
 +  cd ~/Downloads
 +  ```
 +
 +  This takes you to `/home/user/Downloads`.
 +
 +### Special Directories:
 +There are a few special directory shortcuts you can use with `cd`:
 +
 +- **`-`:** Use a single hyphen (`-`) to switch to the previous directory you were in.
 +
 +- **`.`:** A single dot (`.`) represents the current directory. This is often used when you want to refer to the current directory explicitly.
 +
 +### Tips and Shortcuts:
 +- Pressing the `Tab` key while typing a directory name auto-completes it. This is useful when dealing with long directory names.
 +
 +- You can use the `Tab` key twice to see a list of available options if the directory name is ambiguous.
 +
 +- The `cd` command without any arguments takes you to your home directory.
 +
 +### Examples:
 +Here are a few more examples of using the `cd` command:
 +
 +1. Move to the parent directory:
 +   ```bash
 +   cd ..
 +   ```
 +
 +2. Move to the root directory:
 +   ```bash
 +   cd /
 +   ```
 +
 +3. Move to a directory with spaces:
 +   ```bash
 +   cd "My Documents"
 +   ```
 +
 +4. Move to a subdirectory within the current directory:
 +   ```bash
 +   cd Subfolder
 +   ```
 +
 +5. Go back to the previous directory:
 +   ```bash
 +   cd -
 +   ```
 +
 +Remember that the `cd` command only changes the current working directory within the terminal session. It doesn't affect other open terminal sessions or your file system outside of the terminal.
 +
 +
  
 **ls command** **ls command**
products/ict/linux/basic_commands.1683874212.txt.gz · Last modified: 2023/05/12 11:50 by wikiadmin