Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, April 26, 2010

Handy Locations

Password File

/etc/passwd

Log Files

/var/log/

Installing Stuff

/usr/src is where you do work such as installing packages

Plesk Backups

/var/lib/psa/dumps/1/

Plesk Logs

/usr/local/psa/admin/logs

Saturday, April 24, 2010

find all files over a certain size

cd /
find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' |sort -n | mail -s "files over 10000k" cschwieterman@xxxxxxxxxxxxx.com

cd /
find / -type f -size +50000k -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' |sort -n


Change the 10000k or 50000k to the size you need.

Tuesday, April 20, 2010

Custom Commands

Here is a list of custom commands I usually create on linux based systems.

htr is a custom command that will restart apache
echo "service httpd restart" > /usr/bin/htr ; chmod 700 /usr/bin/htr

awstats is a custom command that will update ALL STATS for all sites that have a config file
echo "/usr/local/awstats/tools/awstats_updateall.pl now" > /usr/bin/awstats ; chmod 700 /usr/bin/awstats

mail-ps is a custom command to mail the current process list to statusupdate@xxxxxxx.net
echo "ps auxw | mail -s \"Server: Current Processes\" statusupdate@xxxxxxx.net" > /usr/bin/mail-ps ; chmod 700 /usr/bin/mail-ps

mail-netstat is a custom command to mail the current open port list to statusupdate@xxxxxxx.net
echo "netstat -nape | mail -s \"Server: Current Active Internet Connections\" statusupdate@xxxxxxx.net" > /usr/bin/mail-netstat ; chmod 700 /usr/bin/mail-netstat

Saturday, April 17, 2010

Change Permissions of files (chmod)

Here's another from my scrap notes.

chmod 000 filename.abc

(defaults are usually 755 for folders, 644 for files)

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

Friday, April 16, 2010

qmail

Flush the queue and send all mail

killall -ALRM qmail-send

I use this every now and then on my failover mail queue.

Thursday, April 15, 2010

Common MySQL Commands

From root command prompt

Mysql Prompt: mysql -uadmin -p`cat /etc/psa/.psa.shadow`

Cool commands:
show variables like 'have_query_cache';
show variables like 'query%';
SHOW STATUS LIKE 'Qcache%';


FLUSH QUERY CACHE - defrag
RESET QUERY CACHE - empty


MySQL Start
/etc/init.d/mysqld start

To update mysql root password:

mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

Wednesday, April 14, 2010

Common Linux Commands I Use

Processes

To view current processes running on the system use the following commands:

ps auxw # USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ps auxw | grep | sort –n

Netstat

To view open connections and ports use netstat.

Netstat –nape

Outputting to Null

> /dev/null

TAR

To tar a file:

tar -cf nameOfTar.tar Folder1 Folder2

To untar a file

tar -xvf nameOfTar.tar

To untar a gzip file

tar -zxvf nameOfTar.tar.gz

Touch

A simple command that can create a file quickly

touch /var/log/somelogname.log
chmod 700 /var/log/somelogname.log
echo “this is a log file” > /var/log/somelogname.log
cat /var/log/somelogname.log


HTTPD Restart

/etc/init.d/httpd restart


Server Version

cat /etc/redhat*

CentOS release 4.5 (Final)


2)On SUSE Linux,
$cat /etc/SuSE-release


Top

Top displays a lot of system information in real time. CPU/memory/etc. It is a resource hog though.

top

Free Memory

free –m // memory


FTP

ftp server.com

use ftp -i server.com to remove confirmations. For example, downloading multiple files requires the use of mget *.*. Without logging in with -i it will force you to acknowledge the download of each file.

Reboot

shutdown -r now is reboot

Nice

Usage: nice [OPTION] [COMMAND [ARG]...]
Run COMMAND with an adjusted scheduling priority.
With no COMMAND, print the current scheduling priority. ADJUST is 10
by default. Range goes from -20 (highest priority) to 19 (lowest).

-n, --adjustment=ADJUST increment priority by ADJUST first
--help display this help and exit
--version output version information and exit

Example:
cd /; nice -n 15 /usr/bin/clamscan -r | mail -s "Server: AV Scan Results" chad@xxxxxxxxxxxx.com


Display resources

cat /proc/user_beancounters

egrep "failcnt|numiptent" /proc/user_beancounters

httpd configtest

/etc/init.d/httpd configtest