Skip to main content
FAQ

How to Go to Root Directory in Linux

Learn how to navigate to the root directory in Linux with a simple command. Understand the differences between / and /root, plus practical navigation tips for beginners.

Abhishek Prakash

Warp Terminal

Que: How do I go to the root directory in Linux command line?

The simple answer is, you type the cd command like this:

cd /

That will put you in the root directory, which is the starting point for the Linux directory structure.

Linux directory structure

If you want to go to the /root directory (i.e. home directory of the root user), you'll have to use:

cd /root

I know that a new Linux users can be confused with the notation of root directory (/) and the /root directory.

Understand the difference between / and /root

New Linux users often confuse two important concepts: the root directory (/) and the root user's home directory (/root). They sound similar but serve different purposes:

The root directory (/):

  • This is the primary directory that contains all other directories and files on your Linux system
  • It's the starting point of the filesystem hierarchy
  • All paths in Linux begin from this location
  • You can access it using cd / regardless of your current location

The root user's home directory (/root):

  • This is the home directory for the root user (the superuser with all the access)
  • It's located at /root (a directory inside the root directory)
  • Regular users may or may not have permission to access this directory

Learn more about the Linux directory structure in the GNU/Linux filesystem documentation.

💡
Navigating to the root directory doesn't require special privileges. A non-root user can also enter the root directory. However, modifying files there requires root permissions.

Understanding / as root directory vs directory separator

Forward slash used as root and as directory separator

The forward slash (/) in Linux serves dual purposes, which can be confusing for newcomers:

As the root directory:

  • When used alone or at the beginning of a path, it refers to the root directory
  • Example: cd / or cd /home/user

As a directory separator:

  • When used between directory names, it separates different levels in the path
  • Example: In /home/user/Documents, the slashes separate the directories

This dual usage is important to understand for proper navigation. When you see a path like /var/log/syslog:

  • The first / indicates we're starting from the root directory
  • The subsequent / characters are separators between directories
# Go to a directory using an absolute path (starting from root)
cd /var/log

# Go to a directory using a relative path (from current location)
cd Documents/Projects

💡Use special navigation shortcuts

Linux provides handy shortcuts for directory navigation:

cd /         # Go to root directory
cd ~         # Go to your home directory
cd -         # Go to previous directory
cd ..        # Go up one level
cd ../..     # Go up two levels

These shortcuts save time and make navigation more efficient.

Conclusion

Understanding how to navigate to and from the root directory is fundamental to working effectively in Linux. The root directory (/) serves as the foundation of your filesystem, distinct from the root user's home directory (/root).

By mastering the concepts of absolute vs relative paths and understanding the dual role of the forward slash, you'll be well-equipped to navigate your Linux system confidently.

Abhishek Prakash