some nix commands (from MT)
=========================================================================================|
This is a list of Common commands that can be run from root / SSH access.
I. Basic Commands
A. Retrieve Plesk Admin Password
cat /etc/psa/.psa.shadow
B. Change Directory (cd) *
cd /path/to/directory/
C. Listing Files/SubFolders (ls) *
ls -alh (files and subfolders listed with perms in human-readable sizes)
D. Checking Processes
ps -a top -c (process viewer - Ctrl+C to exit)
ps -auxf (process list)
E. Start/Stop Services
/etc/init.d/
F. Check Bean Counters (hard and soft limits, failcounts, etc.)
cat /proc/user_beancounters
II. File System Commands (df & du are (dv)-only commands)
A. Check Total Disk Usage
df (gives physical disk usage report with % used)
B. List Files/Folders +Sizes (du)
du (lists all filesizes. takes a LONG time, dont run this)
1. du -sh * (lists all the subfolders/sizes in a dir)
C. Remove/Delete Files (rm /path/to/filename.htm) -DANGER- always verify *
1. rm -vf (force-deletes file. Dont run unless you know EXACTLY what you're doing)
2. rm -vrf (force deletes folder and all subfolders and files)
D. Copy Files (cp) *
cp filename.abc /new/path/filename.abc.123
E. Move Files (mv) *
mv filename.abc /new/path/filename.abc.123
F. Create Empty File (touch) *
touch filename.123
III. File Permissions and Ownership (dv)+(ss)
A. Change Permissions of files (chmod) *
chmod 000 filename.abc (defaults are usually 755 for folders, 644 for files)
1. Numbers correspond to users. 1st=Owner; 2nd=Group; 3rd=Other
(-rwxrwxwrx = 777, -rwxr-xr-x = 755, -rw-r--r-- = 644, etc.)
7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied
B. Change Ownership of files (chmown) *
chown user:group filename.abc (you can see user and group w/ ls -alh)
Anytime a user creates a file, the Ownership of the file matches that user. In Plesk,
every domain that has hosting has a different user. So if you are copying files from
one domain to another, you must remember to change ownership.
IV. Checking Log Files (dv)
Log files can tell you alot about whats going on on a (dv). You can use the command:
'tail -n 100' before the logfile name to list the last 100 entries of the logfile.
Here are some of the most common:
A. Main Error Log
/var/log/messages
B. Apache Error Log
1. /var/log/httpd/error_log (main)
2. /home/httpd/vhosts/domain.com/statistics/logs/error_log (per-domain)
(May also be: /var/www/vhosts on newer dvs)
C. MySQL Logs
/var/log/mysqld.log
D. Mail Logs
/user/local/psa/var/log/maillog
**Common issues to look out for in log files**
-The main error log will not always give you all the information you want for a svc.
You may see alot of failed SSH and FTP connections, that is generally normal.
-Keep an eye out for MaxClients errors in the Apache logs if a customer is complaining
of Apache dying alot. You can check the internal KB for raising MaxClients settings.
-If a customer does not set up Log Rotation for a domain under Plesk, then Log Files
will build up and may take up alot of unneeded space. You can usually delete old log
files in Plesk, and change the Log Rotation to Daily instead of by size.
-MailLogs can show you if a customer is spamming, or if mail is coming in or out.
-MySQL Logs should be able to show you general MySQL errors such as bad connections,
or corrupted tables. Check the Int. KB for the 'myisamchk -r' repair table command.
V. Advanced Commands
A. Find. You can do alot with find. for now lets find all files over 10MB.
find . -size '+10000k' -exec ls -Shl {} ;
B. Grep. Another handy tool to get specific information
cat file | grep blah (only lists the information where the word blah is found)
C. Less/More
less filename.abc (displays the content of a file. arrows to scroll, 'q' to quit.)
more == same thing basically.
You can use the '| more' command to scroll through something page or line at a time.
'tail -n 1000 /var/log/httpd/error_log | more'
D. VI. Vi is a basic text editor. Careful what keys you hit while in vi.
vi /path/to/filename.abc
i = INSERT mode. Hit 'i' when you are ready to type in some junk.
leave INSERT mode by hitting the 'Esc' key.
:q = Quit without saving. (Make sure your not in INSERT mode)
:wq = Write file and Quit (Save).