|
UsefulLinux
A list of useful Linux commands.
Phase-Support Filter filesls -allh | grep Oct | awk {'print $9'} | xargs fileMirror an MP3 sitewget -dc -np -H --mirror -UMSIE6 -Amp3 URL Archive a filestar -cf backup.tar file1.txt file2.txt file3.txt
Search messages log for named on a certain datecat /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 NTPyum -y install ntp chkconfig ntpd on ntpdate uk.pool.ntp.org /etc/init.d/ntpd start bash: vzctl: command not foundexport PATH=$PATH:/usr/sbin:/sbin Setup latest imagickcvs -d :pserver:cvsread@cvs.php.net/repository checkout pecl/imagick && cd pecl/imagick && phpize && ./configure Find the distrocat /etc/redhat-release Count lines in all php files in a dirfind . -name "*.php" | xargs wc -l Shows hard drives in Megs and Gigsdf -h Find out which users are taking up space usedu -sh /home/* Find ftp passwordsfind '/home/' -type f -name '*' -size -10000k -exec grep -i -e 'ftp\:\/\/.*\:.*\@.*' {} \;Find out info about hardwareapt-get install dmidecode dmidecode | more cat /proc/cpuinfo cat /proc/meminfo df -h Finds .htaccess that have errordocument 401 in themfind /home/ -type f -name '.htaccess' -exec grep "ErrorDocument 401" {} \; -printConfig the firewall from an interfacesystem-config-securitylevel Watch your messages constantlytail -f /var/log/messages Set HOSTNAMEnano /etc/sysconfig/network Configure networksystem-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 commandlineusermod -p `mkpasswd -H md5 password` #requires: apt-get install whois (for mkpasswd) Watch the httpd/monitor apachecd /proc;watch " ls -al */cwd|grep public_html" Monitor apache httpd logstail -f /usr/local/apache/logs/error_log tail -f /usr/local/apache/logs/access_log tail -f /usr/local/apache/logs/* Show all processesThis command will show all active processes in a tree view: ps auxfc netstat1. 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 | sort4. 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 -nMySQL TopQuick and dirty: watch mysqladmin proc Full featured (if installed): mytop Also see |
► Sign in to add a comment