Get 30% off your WordPress Hosting with code WPSAVE10. Launch Faster. Save More!
  • 00 Days
  • 00 Hours
  • 00 Minutes
  • 00 Seconds

Basic UNIX commands and utilities - SIRSTEVEHQ CP

When managing your SIRSTEVEHQ CP web hosting, you may wish to enable SSH access for one or more of your packages.

Enabling SSH access will give you easier management of your package(s), as you'll be able to use UNIX commands and utilities to carry out tasks and activities.

Here's a list and explanation of some basic commands:

ls – 'ls' (list) is perhaps one of the more commonly used commands. It will list all of the files in the current working directory (the directory the user is currently-in).

[sirstevehq@localhost Public]$ ls
Documents  Music  Pictures
[sirstevehq@localhost Public]$ ls -lah
total 20K
drwxr-xr-x.  5 sirstevehq sirstevehq 4.0K Jan  6 10:03 .
drwx------. 28 sirstevehq sirstevehq 4.0K Jan  6 10:00 ..
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Documents
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Music
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Pictures
[sirstevehq@localhost Public]$

-lah - this series of letters changes the appearance of the output: 'l' means in the long list format (so it's ordered and more readable), 'a' means all files/directories (don't ignore hidden files that begin with a '.') and 'h' means to print sizes of files/directories in a human readable format, e.g., 1.0K, 234M, 3.5G instead of the exact number of bytes.

pwd – the 'pwd' command (print working directory), will output/write the full path of the current working directory.

[sirstevehq@localhost home]$ pwd
/home
[sirstevehq@localhost home]$

cd – 'cd' (change directory) allows a user to move from one directory to another.

[sirstevehq@localhost ~]$ cd Documents/
[sirstevehq@localhost Documents]$

mv – 'mv' (move) lets you move files and directories from one location to another.

[sirstevehq@localhost Public]$ ls -lah
total 20K
drwxr-xr-x.  5 sirstevehq sirstevehq 4.0K Jan  6 10:06 .
drwx------. 28 sirstevehq sirstevehq 4.0K Jan  6 10:00 ..
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Documents
-rw-rw-r--.  1 sirstevehq sirstevehq 0 Jan  6 10:06 foo.txt
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Music
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Pictures
[sirstevehq@localhost Public]$ mv foo.txt Documents/
[sirstevehq@localhost Public]$ cd Documents/
[sirstevehq@localhost Documents]$ ls -lah
total 8.0K
drwxrwxr-x. 2 sirstevehq sirstevehq 4.0K Jan  6 10:07 .
drwxr-xr-x. 5 sirstevehq sirstevehq 4.0K Jan  6 10:07 ..
-rw-rw-r--. 1 sirstevehq sirstevehq 0 Jan  6 10:06 foo.txt
[sirstevehq@localhost Documents]$

cp – 'cp' (copy) will allow a user to copy files and directories from one location to another.

[sirstevehq@localhost Documents]$ ls -lah
total 12K
drwxrwxr-x. 2 sirstevehq sirstevehq 4.0K Jan  6 10:09 .
drwxr-xr-x. 6 sirstevehq sirstevehq 4.0K Jan  6 10:11 ..
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:09 foo.txt
[sirstevehq@localhost Documents]$ cp foo.txt foo2.txt
[sirstevehq@localhost Documents]$ ls -lah
total 16K
drwxrwxr-x. 2 sirstevehq sirstevehq 4.0K Jan  6 10:14 .
drwxr-xr-x. 6 sirstevehq sirstevehq 4.0K Jan  6 10:11 ..
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:14 foo2.txt
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:09 foo.txt
[sirstevehq@localhost Documents]$ 

rm – 'rm' (remove) allows the removal of many types of objects, such as, files, directories, and symbolic links.

[sirstevehq@localhost Documents]$ ls -lah
total 12K
drwxrwxr-x. 2 sirstevehq sirstevehq 4.0K Jan  6 10:14 .
drwxr-xr-x. 6 sirstevehq sirstevehq 4.0K Jan  6 10:11 ..
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:14 foo2.txt
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:09 foo.txt
[sirstevehq@localhost Documents]$ rm foo.txt foo2.txt
[sirstevehq@localhost Documents]$ ls -lah
total 16K
drwxrwxr-x. 2 sirstevehq sirstevehq 4.0K Jan  6 10:16 .
drwxr-xr-x. 6 sirstevehq sirstevehq 4.0K Jan  6 10:11 ..
-rw-rw-r--. 1 sirstevehq sirstevehq 12 Jan  6 10:09 foo.txt
[sirstevehq@localhost Documents]$ 

man – the 'man' (manual) command can be used to display the documentation/manual page(s) for command line tools.

[sirstevehq@localhost ~]$ man grep

mkdir – 'mkdir' (make directory) can be used to create a directory.

[sirstevehq@localhost Public]$ ls -lah
total 20K
drwxr-xr-x.  5 sirstevehq sirstevehq 4.0K Jan  6 10:07 .
drwx------. 28 sirstevehq sirstevehq 4.0K Jan  6 10:09 ..
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:09 Documents
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Music
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Pictures
[sirstevehq@localhost Public]$ mkdir Downloads
[sirstevehq@localhost Public]$ ls -lah
total 24K
drwxr-xr-x.  6 sirstevehq sirstevehq 4.0K Jan  6 10:11 .
drwx------. 28 sirstevehq sirstevehq 4.0K Jan  6 10:09 ..
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:09 Documents
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:11 Downloads
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Music
drwxrwxr-x.  2 sirstevehq sirstevehq 4.0K Jan  6 10:03 Pictures
[sirstevehq@localhost Public]$

grep – 'grep' (global regular expression print) is a useful command line tool that allows you to search for patterns, and their corresponding lines, in the input file(s) specified.

[sirstevehq@localhost Documents]$ grep -n Test foo.txt 
1:Test.
[sirstevehq@localhost Documents]$

du – 'du' will show the disk usage of the files and directories in the directory specified (if a directory is not specified, the current working directory will be used).

[sirstevehq@localhost Public]$ du -sh Documents/
8.0K    Documents/
[sirstevehq@localhost Public]$
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I connect a website via SSH? - SIRSTEVEHQ CP

SSH, or ‘Secure Shell’, is a method of remotely accessing and managing your site files, as well...

How do I import a .sql file via the command-line? - SIRSTEVEHQ CP

If you've set up SSH access for a package then you can use one of two methods to import a MySQL...

How do I connect to SSH using 2FA? - SIRSTEVEHQ CP

It's only recommend that you connect to your package via SSH if you're familiar with the command...

How do I run Composer via SSH? - SIRSTEVEHQ CP

At SIRSTEVEHQ we run multiple different versions of PHP. On our SSH servers, the execution of...

Is Git supported on your hosting platform?

The short answer is yes. We offer Shared Web Hosting with Git, WordPress hosting with Git and...