> For the complete documentation index, see [llms.txt](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/popd.md).

# popd

## popd

Sure, I can help you with that.

The `popd` command in Linux is used to move to the previous directory in the directory stack. This command is used to manipulate the directory stack, which is a list of recently accessed directories. You can use the `pushd` command to add a directory to the stack and the `popd` command to remove a directory from the stack.

The syntax for the `popd` command is as follows:

```
popd
```

This command moves to the previous directory in the directory stack.

Here is an example of how to use the `popd` command:

```
$ cd /home/user
$ pwd
/home/user
$ pushd /tmp
$ pwd
/tmp
$ popd
$ pwd
/home/user
```

In the first command, the current directory is moved to /home/user. The next command outputs the path of the current directory. The next command adds the /tmp directory to the stack. The next command moves the current directory to /tmp. The next command removes the directory from the stack. The next command outputs the path of the current directory.

The `popd` command is a useful tool for manipulating the directory stack.

## help

```
popd: popd [-n] [+N | -N]
    Remove directories from stack.
    
    Removes entries from the directory stack.  With no arguments, removes
    the top directory from the stack, and changes to the new top directory.
    
    Options:
      -n        Suppresses the normal change of directory when removing
                directories from the stack, so only the stack is manipulated.
    
    Arguments:
      +N        Removes the Nth entry counting from the left of the list
                shown by `dirs', starting with zero.  For example: `popd +0'
                removes the first directory, `popd +1' the second.
    
      -N        Removes the Nth entry counting from the right of the list
                shown by `dirs', starting with zero.  For example: `popd -0'
                removes the last directory, `popd -1' the next to last.
    
    The `dirs' builtin displays the directory stack.
    
    Exit Status:
    Returns success unless an invalid argument is supplied or the directory
    change fails.
```
