Basic UNIX Commands for StackCP SSH Management

Author:

Published:

Updated on August 15, 2024

Reading Time: 1 min read

When managing your web hosting with StackCP, enabling SSH access can greatly simplify the management of your packages. This guide provides an overview of essential UNIX commands and utilities to help you perform various tasks efficiently.

Common UNIX Commands: #

1. ls (List) The ls command lists all the files in the current working directory.

[StackCP@localhost Public]$ ls
Documents Music Pictures

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

  • -l for long listing format
  • -a to include hidden files
  • -h to show sizes in human-readable format

2. pwd (Print Working Directory) The pwd command displays the full path of the current working directory.

[StackCP@localhost home]$ pwd
/home

3. cd (Change Directory) The cd command allows you to navigate between directories.

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

4. mv (Move) The mv command moves files and directories from one location to another.

[StackCP@localhost Public]$ mv foo.txt Documents/
[StackCP@localhost Documents]$ ls -lah
total 8.0K
drwxrwxr-x. 2 StackCP StackCP 4.0K Jan 6 10:07 .
drwxr-xr-x. 5 StackCP StackCP 4.0K Jan 6 10:07 ..
-rw-rw-r–. 1 StackCP StackCP 0 Jan 6 10:06 foo.txt

5. cp (Copy) The cp command copies files and directories.

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

6. rm (Remove) The rm command deletes files and directories.

[StackCP@localhost Documents]$ rm foo.txt foo2.txt
[StackCP@localhost Documents]$ ls -lah
total 16K
drwxrwxr-x. 2 StackCP StackCP 4.0K Jan 6 10:16 .
drwxr-xr-x. 6 StackCP StackCP 4.0K Jan 6 10:11 ..

7. man (Manual) The man command displays the manual pages for command line tools.

[StackCP@localhost ~]$ man grep

8. mkdir (Make Directory) The mkdir command creates a new directory.

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

9. grep (Global Regular Expression Print) The grep command searches for patterns in the specified file(s).

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

10. du (Disk Usage) The du command shows the disk usage of files and directories.

[StackCP@localhost Public]$ du -sh Documents/
8.0K Documents/

Conclusion #

Familiarising yourself with these basic UNIX commands can significantly enhance your ability to manage and troubleshoot your StackCP hosting environment.