Get a free website with any plan

See how
LINUX AND SSH

Moving around the server with cd and pwd

Last updated

IN SHORT

On Flashcloud servers, Linux navigation relies on two SSH commands: cd moves between directories and pwd prints your current location. Running pwd before modifying or deleting files confirms your exact path, ensuring commands target the right directory rather than the wrong part of the filesystem.

Two commands cover most of your movement on a Linux server over SSH: cd (change directory) takes you somewhere, and pwd (print working directory) tells you where you ended up. If a command is failing because you're "in the wrong place," these two fix it faster than anything else.

Run pwd first whenever you're unsure. It prints the full absolute path of your current location, like /home/username/public_html. Then use cd to move.

The basics

The essential forms of cd:

  • cd foldername, moves into a subfolder of where you are now (relative path)
  • cd /full/path/here, jumps straight to an absolute path from anywhere
  • cd .., moves up one level to the parent directory
  • cd ../.., moves up two levels
  • cd with no argument, or cd ~, takes you back to your home directory
  • cd -, jumps back to the previous directory you were in

Tab completion is your friend here. Type the first few letters of a folder name and hit Tab. If there's only one match, the shell fills it in. If there are several, hit Tab twice to list them. This also saves you from typos in long paths.

A typical sequence

pwd
cd public_html
ls
cd wp-content/plugins
pwd

That last pwd confirms you actually landed where you meant to, which matters once you start running commands that touch files, since a command like rm or a WordPress CLI operation runs against whatever directory you're currently in.

Relative vs absolute paths

A relative path is written from your current location: cd logs only works if a logs folder exists right where you are. An absolute path always starts with / and works no matter where you currently are: cd /home/username/logs gets you there from anywhere in the filesystem.

When you're not sure which to use, absolute paths are safer, especially in scripts or cron jobs, since they don't depend on the working directory the command happened to start in.

Where you land on shared and WordPress hosting

On shared and WordPress hosting, SSH access drops you into your account's home directory, and your site files live under public_html (or a subfolder of it, for addon domains). You're scoped to your own account: you can move freely within your home directory, but you don't have root access and can't cd into other customers' spaces or most system directories. On most hosting accounts, the rest of the server is something we manage for you, so you'll mainly be working inside your own home directory tree: public_html, logs, and wherever your application stores uploads or config.

Where you land on a VPS

A VPS is different: you get broader SSH access to the server, so cd can take you further across the filesystem, including system directories like /etc, /var, and /usr. That's the point of a VPS: more control, and more responsibility for what you change. With that access there's less of a permission wall stopping you from cd-ing into a directory you shouldn't be touching, so double-check pwd before running anything destructive, and be careful with commands that operate on "everything in the current directory."

A few habits worth building

  • Run pwd before any command that deletes, moves, or overwrites files in bulk.
  • Use ls right after cd to confirm the folder has what you expect before you act on it.
  • Favor absolute paths in scripts and cron jobs so they behave the same regardless of where they're triggered from.
  • On a VPS, get in the habit of checking pwd before running anything with elevated privileges, since a mistake there can affect the whole server, not just your account.

If you're on shared or WordPress hosting and can't cd into a directory you believe should be accessible, or you're seeing permission errors that don't match what you expect, open a ticket from Support in the portal. A real person can check the account's file ownership and permissions directly.

Common questions

How do I check which folder I am currently in?

Run the pwd command. The shell prints your full absolute path, like /home/username/public_html, so you can confirm your location before running commands that touch files.

How do I get back to my home directory?

Run cd with no arguments or type cd ~. If you want to return to the folder you were in immediately before your last move, run cd - instead.

Why am I blocked from opening system folders on shared hosting?

Shared and WordPress hosting accounts do not include root access. Your SSH access stays inside your personal home directory tree, while Flashcloud manages system directories and other account spaces for you.

Should I use relative or absolute paths?

Use absolute paths whenever possible, especially in scripts and cron jobs. Absolute paths start with a slash and work from anywhere, while relative paths fail if you are not already in the parent folder.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.