How to change directory in Linux terminal

My Dell Laptop came preinstalled with Ubuntu Linux, and I am a new Linux desktop user. How do I change directories in the Linux terminal?

Introduction – On Linux the cd command allows you to change directories when using the terminal application. This page shows how to change directory in Linux terminal using the cd command.

How to change directory in Linux terminal

  1. To return to the home directory immediately, use cd ~ OR cd
  2. To change into the root directory of Linux file system, use cd /.
  3. To go into the root user directory, run cd /root/ as root user.
  4. To navigate up one directory level up, use cd ..
  5. To go back to the previous directory, use cd -

Let us see all examples and usage for terminal in details.

How to use the Linux command line to change directory or folder

The directory in which the user is currently working is called the current working directory (CDW).

How to print the current working directory in Linux

To display the name of the current/working directory, type the following pwd command:

cd command in Linux termianl

The syntax is:
cd ..
cd /path/to/dir

When cd command used without stipulating any directory name, cd command returns to the home directory. Let us change the directory to /usr/sbin/, run:
cd /usr/sbin/
Verify it:
Want to list the files in the /usb/sbin/ directory? Try the ls command:
ls -l

Let us go back to user’s home directory, run:
Again verify it:

Absolute vs Relative pathname

The cd command changes the current directory when a directory name provided by the user. The name can be written as an absolute pathname (e.g. cd /etc/httpd/) or as local pathname relative to the root directory (e.g. cd conf.d/). For example:
cd /etc/httpd/
cd conf.d/

The absolute vs. relative pathname for cd command in Linux

Understanding . and .. directories

On Linux the current directory is represented by a single dot (.) and two consecutive dots represent its parent directory (..). Thus, to change to the parent of the current directory, run cd ... For example:
cd ..

How can I return directly to my home directory when using the Linux terminal?

cd ~
cd $HOME

How do I change directories in the Linux terminal and return to the previous directory?

Simply pass the - option to the cd:
cd -
Verify it:

A note about symbolic links and cd command

The -P option instructs cd to use the physical directory structure instead of following symbolic links:
cd -P LinkDir

The -L option forces cd to follow symbolic links:
cd -L LinkDir

Linux cd command cheat sheet

Command Description
cd Returns you to your login directory
cd ~ Also returns you to your login directory
cd - Returns you to your previous working directory
cd / Takes you to the entire system's root directory.
cd /root Takes you to the home directory of the root user. You must be the root user to access this directory.
cd /home Takes you to the home directory, where user login directories are usually stored
cd .. Takes you to the directory one level up.
cd ~tom Takes you to tom's home directory, if tom user has granted you permission
cd /path/to/dir/ Take you to the /path/to/dir/ directory
cd dir* Use a wildcard to change the directory name


The cd command is used to change the current directory in both Linux and other Unix-like systems.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • San Jan 14, 2013 @ 12:22

    excellent. very useful.

    • Martina Jun 1, 2014 @ 1:58

      +1 from Argentina.

      • Krishna Kumar Oct 23, 2015 @ 23:12

        ++1 from India.

        • 🐧 Vivek Gite Oct 28, 2017 @ 1:06

          Thank you for the kind words. I am closing comments as I do not want to create a big chain. I appreciate all of posts.

  • CarolCC Dec 3, 2020 @ 21:19

    How do I do: ls sdb
    to list all the files on my sdb drive?

    • 🐧 Vivek Gite Dec 4, 2020 @ 18:13

      You need to use the find command:

      sudo find / -ls 
      sudo find / -ls | more
      ## only files ##
      sudo find / -type f -ls 
      ## only dirs ##
      sudo find / -type d -ls 
  • Marcel Feb 9, 2021 @ 11:41

    currently, my base is as below:

    (base) bmmb8@HQ1948155:/mnt/c/Users/bmmb8$

    I’m not sure how I ended up with this mnt/c/ as my default directory when opening up linux (currently using WSL2)

    What is this mnt? Can I change this?


Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @