Navigate command line structure in SSH
In our previous article, we showed you how to login to your server via SSH. If you're following along our tutorial, the next item to learn is how to navigate around the file system. This is the same whether you are using a shared, VPS, or Dedicated account.
Using SSH with your files
The following article will help you with navigating through your files using SSH. The secure shell interface (SSH) uses a command line interface that allows you type commands to manipulate and view your server files.
cPanel username: user5
What directory am I working in?
When you first log in via SSH, you will be placed in your home folder. For our user, it is /home/user5. Further on in this page, you'll change directories. If you ever need to determine which directory you are currently in, use the pwd command. The pwd command will print the working directory:
firstname.lastname@example.org [~]# pwd
What is in this directory?
Now that you know which directory you are in, you may want to know what files and folders and in this directory. You can use the ls command to list the directory contents:
email@example.com [~]# ls
./ ../ .bash_logout .bash_profile .bashrc .contactemail .dns .gemrc .htpasswds/ etc/ mail/ perl5/ public_ftp/ public_html/ tmp/ www@
The results above are simply a listing of files and folders in your current account. Many times you'll need more information than this. For example, you may need to see file sizes or permissions. You can add the -alh flags to:
- a - do not ignore entries starting with . (hidden files, such as .htaccess)
- l - use a long listing format (shows additional information such as filesizes and permissions)
- h - when using -l (described immediately above), prints file sizes in human readable format (e.g., 1K 234M 2G)
firstname.lastname@example.org [~]# ls -alh
drwx--x--x 9 user5 user5 4.0K Dec 5 11:23 ./
drwx--x--x 36 root root 4.0K Dec 5 11:15 ../
-rw-r--r-- 1 user5 user5 24 Dec 5 11:15 .bash_logout
-rw-r--r-- 1 user5 user5 191 Dec 5 11:15 .bash_profile
-rw-r--r-- 1 user5 user5 124 Dec 5 11:15 .bashrc
-rw------- 1 user5 user5 18 Dec 5 11:15 .contactemail
-rw-r--r-- 1 user5 user5 20 Dec 5 12:27 .dns
-rw-r--r-- 1 user5 user5 147 Dec 5 11:15 .gemrc
drwxr-x--- 2 user5 nobody 4.0K Dec 5 11:15 .htpasswds/
drwxr-x--- 2 user5 mail 4.0K Dec 5 11:15 etc/
drwxr-x--- 8 user5 user5 4.0K Dec 5 11:15 mail/
drwxr-xr-x 2 user5 user5 4.0K Dec 5 11:23 perl5/
drwxr-xr-x 3 user5 user5 4.0K Dec 5 11:15 public_ftp/
drwxr-x--- 3 user5 nobody 4.0K Dec 5 11:15 public_html/
drwxr-xr-x 2 user5 user5 4.0K Dec 5 11:15 tmp/
lrwxrwxrwx 1 user5 user5 11 Dec 5 11:15 www -> public_html/
How can I navigate to another directory?
Using the cd command, you can change directories. For example, if we want to navigate to the public_html folder, you can issue this command:
email@example.com [~]# cd public_html/
To confirm you are in this directory, you can use pwd to print the directory you are currently in:
firstname.lastname@example.org [~/public_html]# pwd
How can I go back one directory?
We were previously at /home/user5 and we changed to our /home/user5/public_html folder. If we want to go up one level, i.e back to our /home/user5 folder, you can use cd ..
email@example.com [~/public_html]# cd ..
We can confirm where we're at by printing the directory we're currently in:
firstname.lastname@example.org [~]# pwd
Learn more about SSH Hosting
You are NOT logged in. You can still browse our Support Center.
To participate within our Community Support Forum: