Knowledgebase: Using Shell (SSH)
What are some basic commands that are available via SSH?
Posted by Pacific Host, Last modified by Pacific Host on 04 December 2011 05:09 PM

ln (redirecting file access)
Type ln -s fred.html index.html to redirect all file accesses from index.html to the file fred.html.

passwd (changing your password)
Type passwd to change your password. You may also use Brain to change your password.

zip/unzip
Type zip to zip files and unzip to unzip files. This program is compatible with the zip program for DOS. For example:

zip myzip file1 file2 file3

This puts the files file1, file2, and file3 into a new zip archive called myzip.zip. On the other hand, if you had the archive myzip.zip and wanted to get back the files:

unzip myzip

Typing zip or unzip by itself will give you a usage summary, showing nearly all the options availible.

du (disk usage)
The Unix command

du -s directory
shows how much disk space is used by a directory and everything below it. While we work on creating the complicated command needed to automatically check all the directories you are associated with, you can find out how much space is in use by the WWW files for a domain with

du -s /home/domain/www
If you don't have anything much in your home directory or mail spool, this comes close to the total space you have in use. (You would know if you did have other things in your home directory, and could use du -s $HOME to check on that.)

locate (find files)
The normal Unix methods of locating files have one thing in common, they are slower than molasses on a winter night in Alaska. So instead, we use a powerful program called locate. Type locate file_name and the server will immediately locate all files that contain the file_name. (Provided such files have been on the machine at least one day.)

lynx (browsing WWW)
If you, for one reason or another, don't have a better WWW browser availible and want to see a page (maybe you just edited it, or you want to check this manual while on-line) type lynx URL to view the URL. (For example, lynx http://www.GracefulWeb.com/.) This simple browser of course can't show you graphics, and is bewildered by tables, but otherwise will show you what you need to see.

pwd Shows the full path of the current directory
ls Lists all the files in the current directory
ls -al Lists all files and information
ls –alR Lists all files and information in all subdirectories
ls -alR | more Same as ls –alR, pausing when screen becomes full
ls -alR > filename.txt Same as ls –alR, outputs the results to a file
ls *.html Lists all files ending with .html
cd [directory name] Changes to a new directory
cd .. Changes to directory above current one
clear Clears the screen
vdir Gives a more detailed listing than the "ls" command
exit Log off your shell

mv [old filename] [new filename] Move/rename a file
cp [filename] [new filename] Copies a file
rm [filename] Deletes a file
rm * Deletes all files in current directory
rm *.html Deletes all files ending in .html

mkdir [directory name] Creates a new directory
ls -d */ Lists all directories within current directory
cp -r [directory] [new directory] Copies a directory and all files/directories in it

find . -name [filename] -print Searches for a file starting with current directory
grep [text] [filename] Searches for text within a file

File permissions:
0 = --- No permission
1 = --X Execute only
2 = -W- Write only
3 = -WX Write and execute
4 = R-- Read only
5 = R-X Read and execute
6 = RW- Read and write
7 = RWX Read, write and execute

chmod 604 [filename] Minimum permissions for HTML file
chmod 705 [directory name] Minimum permissions for directories
chmod 755 [filename] Minimum permissions for scripts & programs
chmod 606 [filename] Permissions for data files used by scripts
chmod 703 [directory name] Write-only permissions for public FTP uploading


Some commands that you will need are printed at the bottom of the screen. The keys to press are presented as '^X'. This long-standing shorthand in the computer world means the same as Control-X, in other words, hold down the Control or Ctrl key on your keyboard and type an 'x'.

(0 vote(s))
Helpful
Not helpful

Comments (0)