systems admin troubleshooting

Server Troubleshooting

uptime
df -h
free -m
netstat -an
netstat -tlpn
ps wwauxf
uname -a
cat /proc/user_beancounters
top

Top Command

top – shows live system processes in a nice table, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn’t bogged down.
top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage

RAM Usage

free -m – shows memory info

Disk Space Usage

df -u – show disk space
df -h – show disk space
df -k – displays output in bytes
df -h – displays output in human readable form
df -T – display what type of file system
df -i – displays inodes

du – show directory space usage – show directory structure
du -sh *- shows a summary, in human-readable form, of total disk
du –max-depth=1 -h – space used in the current directory, including sub-directory – same thing, but for each file and directory. helpful when finding large files taking up space.
du -h –max-depth=1 – search folder size

Websites not loading after a Plesk Upgrade

ssh onto the server and type the following command
# cd /usr/local/psa/admin/bin
# ./nginxmng -d
# ./nginxmng -e
/usr/local/psa/admin/sbin/httpdmng –reconfigure-all

Inode Issues On Server

echo “Detailed Inode usage for: $(pwd)” ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf “$c\t\t- $d\n” ; done ; printf “Total: \t\t$(find $(pwd) | wc -l)\n”

cat /proc/user_beancounters –
updatedb – it scans the whole system and updates the mlocate.db database file.

date – show the current date and time
cal – show this month’s calendar
uptime – show current up time
w – display who is online
who  – username
pwd – shows the directory that you are in
whoami – who you are logged in as
finger user – display information about user
which – tells your where the program is installed
echo – displays content
echo “text content” | text “filename.ext” – will create a file and add text inside it
whereis – lets you know if you have a program installed
whatis – lets you know what a program does

sync; echo 3 > /proc/sys/vm/drop_caches/var/www/vhosts/domain.com/httpdocs/

User Admin

last – shows who logged in and when
last -20 – shows only the last 20 logins
last -20 -a – shows last 20 logins, with the hostname in the last field

w – shows who is currently logged in and where they are logged in from.
passwd – change root password

SSH Access

ssh user@<server ip address> – ssh into server
ssh user@hostname – ssh into server

Setting time via ssh

date -s “2 OCT 2006 18:00:00” – change date and time
date – check date and time
/var/log/sw-cp-server/error_log – error Log path

Test Apache Before Restart

/usr/sbin/apachectl configtest

Send a Test Email

mail -s “Test” ‘easyspacetesting@gmail.com’

Email Logs

cat /var/log/messages
zgrep “email address” “maillog”
cat /usr/local/psa/var/log/maillog

MySQL Logs

cat /var/log/mysql.log

Apache Error Logs

cat /var/log/httpd/error.log

ssh Access Logs

cat /var/log/secure

Plesk Access Logs

cat /var/log/sw-cp-server/error_log

Message Logs

cat /var/log/messages

http://kb.parallels.com/en/111283

Useful Bash Scripts for Linux System Administrator

touch sysinop.sh

chmod +x ./sysinop.sh

vi ./sysinop.sh

https://github.com/sathisharthar/Admin-Scripts/blob/master/sysinop