I just grabbed this from an old forum post of mine. It was originally written in 2002 or so, but I wanted to post it here as one of my reference items since this blog is where I come to find that stuff anyway.
This covers typical Linux commands used in web hosting.
Telnet vs. SSH
Telnet is an insecure way of accessing the server command line and is therefore not an option. SSH (Secure Shell) is a secure replacement for Telnet which gives the same type of access.
Accessing SSH
SSH can be accessed by an applet included in certain cPanel themes. It is preferable to access through an SSH program installed on your own computer.
Mac OSX users can open a terminal window and enter ssh -l username yourdomain.com
Useful commands
When using SSH you are accessing the server’s command line (Similar to MSDOS).
Here is a short list of commonly used commands:
(tip: when using Putty you can use the “right click” to copy and paste commands and information)
man
Display command manual (use: man [command])
To exit from the manual use the ‘q‘ key.
logout
Logout of SSH
exit
Logout of SSH
Ctrl + C
End current command
dir
Directory listing
ls
Better directory listing with more options (type “man ls” for more information. Note: The “l” is an “L”
ls -al is what I normally use.
cp source.file destination.file
Copies a file from one location to another
mv source.file destination.file
Moves a file from one location to another.
It copies it to the new location and deletes the original one
chmod
Changes the permissions on a file.
I prefer doing this through FTP and would recommend that for newbies as well.
chown
Changes the User and/or Group ownership for a file.
tar -cpzf filename.tar.gz
Tar (compress a number of files into one file) the current directory
Replace “filename” with an appropriate name.
tar -xzpf filename.tar.gz
Untar (uncompress a number of files out of one file) a file
Replace “filename” with the file’s name.
lynx
Lynx is a text based browser installed on the server that can be accessed via the command line or by cron.
cd /home/username
Navigate into a directory on the server (~ Navigate to your home directory, you can use “~” as part of the path: cd ~/public_html.
Replace “/home/username” with the appropriate directory.
whereis [function]
The easiest way to find the actual path to perl, sendmail, etc
Replace “[function]” with the function name e.g. “sendmail”.
rm
Remove/delete (use rm -r to delete recursive directories. Type “rm –help” for full help, there is no way to undelete)
top
List running processes and check server load (type h for help and q to exit the “top” display.
mysqldump -u[Username] -p[Password] [Database Name] < filename.sql
Dump a SQL file into a MySQL database. Note the “<”.
Replace “[Username]” with the database username (generally controlpaneluser_databaseuser). Replace “[Password]” with the database password and replace “[Database Name]” with the database name. Finally change “filename.sql” to the correct filename/location.
mysqldump -u[Username] -p[Password] [Database Name] > filename.sql
Dump a MySQL database to a SQL file. Note the “>”.
Replace “[Username]” with the database username (generally controlpaneluser_databaseuser). Replace “[Password]” with the database password and replace “[Database Name]” with the database name. Finally change “filename.sql” to the correct filename/location.
mkdir directory_name
Make directory
Replace “directory_name” with the directory you want to create’ name.
ln -s real/path [link name]
Create a symlink to a path
Replace “real/path” with the physical (real) path to the file. For example /home/user/downloads. Also replace “[link name]” with what you would like the symlink to be called. To remove the sym link use “rm [link name]“.
pico [filename]
Easy to use text editor to edit files
Replace “(filename)” with the filename to open e.g. “pico file.txt”
vi and vim are also available on many servers.
wget http://www.example.com
Wget can grab files from a web site or even the entire website in its directory structure and copy them to your server. Type man wget to see all of your options.
0 Response to “Linux Command Line – SSH and Telnet”