My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UsefulLinux  
A list of useful Linux commands.
Phase-Support
Updated Mar 15, 2011 by nfhm2k

Filter files

ls -allh | grep Oct | awk {'print $9'} | xargs file

Mirror an MP3 site

wget -dc -np -H --mirror -UMSIE6 -Amp3 URL

Archive a files

tar -cf backup.tar file1.txt file2.txt file3.txt

Search messages log for named on a certain date

cat /var/log/messages | grep named | grep "Sep 26" | grep near

Upgrading PHP on CentOS

'''CentOS 4'''

cd
wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
yum --en=atomic update php

'''CentOS 5'''

cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
yum --en=c5-testing update php

Setup NTP

yum -y install ntp
chkconfig ntpd on
ntpdate uk.pool.ntp.org
/etc/init.d/ntpd start

bash: vzctl: command not found

export PATH=$PATH:/usr/sbin:/sbin

Setup latest imagick

cvs -d :pserver:cvsread@cvs.php.net/repository checkout pecl/imagick && cd pecl/imagick && phpize && ./configure

Find the distro

cat /etc/redhat-release

Count lines in all php files in a dir

find . -name "*.php" | xargs wc -l

Shows hard drives in Megs and Gigs

df -h

Find out which users are taking up space use

du -sh /home/*

Find ftp passwords

find '/home/' -type f -name '*' -size -10000k -exec grep -i -e 'ftp\:\/\/.*\:.*\@.*' {} \;

Find out info about hardware

apt-get install dmidecode
dmidecode | more
cat /proc/cpuinfo
cat /proc/meminfo
df -h

Finds .htaccess that have errordocument 401 in them

find /home/ -type f -name '.htaccess' -exec grep "ErrorDocument 401" {} \; -print

Config the firewall from an interface

system-config-securitylevel

Watch your messages constantly

tail -f /var/log/messages

Set HOSTNAME

nano /etc/sysconfig/network

Configure network

system-config-network

Port forwarding for VNC

/sbin/iptables -A PREROUTING -t nat -p tcp -d $NATIP --dport 5900 -m state --state NEW,ESTABLISHED,RELATED -j DNAT --to 192.168.0.2:5900

Port forwarding for HTTPD

/sbin/iptables -A PREROUTING -t nat -p tcp -d $NATIP --dport 81 -m state --state NEW,ESTABLISHED,RELATED -j DNAT --to 192.168.0.2:80

Startup

#chkconfig [--level <levels>] <name> <on|off|reset>
#eg: 
chkconfig --add pure-ftpd
chkconfig --level 345 pure-ftpd on

Change password via commandline

usermod -p `mkpasswd -H md5 password`
#requires: apt-get install whois (for mkpasswd)

Watch the httpd/monitor apache

cd /proc;watch " ls -al */cwd|grep public_html"

Monitor apache httpd logs

tail -f /usr/local/apache/logs/error_log
tail -f /usr/local/apache/logs/access_log
tail -f /usr/local/apache/logs/*

Show all processes

This command will show all active processes in a tree view:

ps auxfc

netstat

1. How to list the connections to port 80

netstat -alntp | grep :80

2. How to check the number of connections to port 80

netstat -alntp | grep :80 | wc -l

3. How to list the remote IPs connecting to your server on port 80

netstat -alntp | grep :80 | awk '{print $5}' | cut -d: -f1 | sort

4. How to list the uniq remote IPs and the number of connections from each IP

netstat -alntp | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

MySQL Top

Quick and dirty:

watch mysqladmin proc

Full featured (if installed):

mytop

Also see


Sign in to add a comment
Powered by Google Project Hosting