JREAM
4/14/2012 - 3:54 AM

Linux Commands CentOS

Linux Commands CentOS

Find
-----------------------
$ find / -name filename
$ grep pattern file
$ grep -r pattern dir
$ locate file
$ find / -type f -mmin 10 (Find Files modified Less than 10 Mins Old)

List Files
-----------------------
$ ls -A (Show hidden files)
$ ls -sh (List file sizes)
$ ls -lt (Show permissions)
$ ls -lt | grep anything (Look for file with specific name)

List Only Directories
-----------------------
$ find . -maxdepth 1 -type d -ls
$ ls -l | grep "^d"

Output to a File
-----------------------
$ command > filename

Compare File Difference
-----------------------
$ diff file1 file2

Word Count
-----------------------
wc filename
wc -l filename1 filename2


Edit Ip Tables
-----------------------
/etc/sysconfig/iptables

Auto start service
-----------------------
chkconfig httpd on


Edit Crontab with Nano
-----------------------
env EDITOR=nano crontab -e $ crontab -l (Show entries)
Check crontab $ tail - f /var/log/cron


Daily MySQL Backup
-----------------------
0 6 * * * mysqldump -u dbuser-pPASSWORDATTACHEDHERE dbname > /tmp/db_export_`date +%H%M%S`.sql

MySQL Import
-----------------------
mysql dbname -u root -p7027 -e 'source filename.sql'


Restarting Daemons
-----------------------
/etc/init.d/service 
/etc/init.d/httpd restart

File Locations
-----------------------
/etc/httpd/conf/httpd.conf
/etc/php.ini
/etc/my.cnf
/etc/postfix/main.cf
/etc/dovecot/dovecot.conf 
/etc/sysconfig/iptables 
/etc/ssh/sshd_config

Rsync
-----------------------
$ rsync -avz --include=.* --rsh="ssh -l username " /home/jesse.txt www1:/home/edumart/dog/

PHP / Apache Error Log
-----------------------
/var/log/httpd/error_log