Skip to content
Atlas Hoster
SSH and advanced tasks

Basic Linux commands and absolute paths for your hosting

Updated on 18 November 2026Checked on GNU Coreutils 9.12, Linux man pages (chmod, path_resolution) and cPanel & WHM documentation (versions 126 and later) on 11 November 2026

On a hosting account, a terminal lets you handle your files with typed commands instead of clicks. A handful of commands and a clear idea of what a path is are enough to find your way around.

Before you start

  • You need command-line access to your hosting: see Log in to your hosting over SSH. Not every hosting plan opens this access: cPanel states that "not all hosting providers allow shell access".
  • The commands below are standard Linux commands (GNU Coreutils), the same on most servers. Replace username with your cPanel username.
  • Nothing can be undone on the command line: a deletion does not send the file to a trash folder. Make a backup before changing or deleting many files.

Understand paths

A path says where a file or folder is.

  • An absolute path starts with / (the root of the system) and describes the whole route. It always points to the same place, wherever you type it. Example: /home/username/public_html/index.html.
  • A relative path does not start with /: it starts from the folder you are in. If you are in /home/username, public_html/index.html points to the same file.
  • . is the current folder, . its parent folder, and ~ your home folder.

On a cPanel hosting account, the cPanel documentation describes an account like this:

  • your home directory is the account's main folder, /home/username;
  • the web root is public_html, that is /home/username/public_html: your website's files live there;
  • an additional FTP account is limited to a subfolder of /home/username/ (see Create additional FTP accounts).

Absolute paths matter in scripts, scheduled tasks and configuration files: a program started automatically is not in the folder you think it is.

Steps

Open your session (see the article on SSH login). Type each line below, then press Enter.

  1. Find out where you are: pwd prints the absolute path of the current folder.
  2. List a folder's content: ls. Two useful options: ls -l (one line per item, with permissions, size and date) and ls -a (also shows hidden files, whose name starts with a dot, like .htaccess). Combine them: ls -la.
  3. Change folder: cd public_html (relative path) or cd /home/username/public_html (absolute path). cd . goes up one level; cd alone (or cd ~) takes you back to your home folder.
  4. Create a folder: mkdir new-folder.
  5. Create an empty file: touch file.txt.
  6. Copy: cp source.txt copy.txt. For a folder and its content, add -r: cp -r folder folder-copy. The -i option asks before overwriting a file.
  7. Move or rename: mv old.txt new.txt renames; mv file.txt folder/ moves.
  8. Read a file: cat file.txt prints all of it; tail -n 50 file.log prints only its last 50 lines (handy for an error log).
  9. Delete: rm file.txt deletes a file; rm -r folder deletes a folder and everything in it. The -i option asks for confirmation for each item.
  10. Check sizes: du -sh folder prints a folder's total size in a readable unit (-s: one total; -h: KB, MB, GB). du -sh * gives the size of each item in the current folder.
  11. Change a file's permissions: chmod 644 file.txt sets the permissions as a number. Each digit stands, in order, for the owner, the group and others. By default, cPanel's File Manager uses 0644 for a file.

Expected result

You can tell where you are (pwd), move around your folders (ls, cd), create, copy, move and delete items, measure what takes up space (du -sh) and write the absolute path of a file, for example /home/username/public_html/index.html.

If something goes wrong

  • "No such file or directory": the path is wrong. Check the spelling (Linux is case sensitive) and the current folder with pwd.
  • "Permission denied": your account may not read or write there. Stay in your home folder (/home/username): your files are yours there.
  • "command not found": the command is misspelled, or not available in your environment. On shared hosting, access is sometimes restricted to a limited ("jailed") shell, and some commands may be missing.
  • A file does not show in ls: its name may start with a dot. Use ls -a.
  • A site stops working after a chmod: put the usual permissions back (0644 for a file) or restore the backup.

FAQ

What is the difference between an absolute and a relative path?

An absolute path starts with / and begins at the root of the system (/home/username/public_html). A relative path starts from the folder you are in. In a script or a scheduled task, prefer the absolute path.

What is my site's absolute path on cPanel hosting?

According to the cPanel documentation, it is the public_html web root in your home directory: /home/username/public_html, where username is your cPanel username. An additional domain can have another folder: cPanel's Domains page shows each domain's document root.

Can I recover a file deleted with rm?

Not from a trash folder: rm does not use one. If a backup exists, restore it. In cPanel's File Manager, however, deleting first moves the item to the Trash folder (see Use cPanel's File Manager).

Do I need to learn the terminal to manage my site?

No. cPanel's File Manager covers uploading, copying, editing and deleting files from your browser. The terminal helps to automate, to go faster on large volumes or to read logs.

Need full access to your server? Discover our virtual private servers (VPS).

SSH and advanced tasksAll guides