in Blog

Collection of useful command in centminmod

Centminmod - CentOS 7 Quick Commands
Commands for CentOS / centminmod / and other various items

##############################################
## CENTOS 7 COMMANDS
##############################################

Cron: checking log for what is running
# tail -f /var/log/cron

Empty Log or Any File
# truncate -s 0 /var/log/secure

Command Help
# systemctl --help

Load Average / Uptime
# cat /proc/loadavg
# uptime

Check on Service Status
# systemctl status nginx.service

Dump traffic on a network - when getting a DdoS attack
http://www.tcpdump.org/tcpdump_man.html
# tcpdump -w file.txt

List on running processes
# ps aux | less
# ps -U root -u root -N // see all process NOT as root
# ps -u vivek // see all processes of a specific user
# control + z to exit

Yum listing updates
# yum list mariadb* 
# yum list http*
# yum list php*
# yum list updates
# yum list gcc* g++* kernel* openssl*

CPU / Running Processes
# top

Current CentOS Release
# cat /etc/redhat-release

Get Free Memory Information & Get Swap Memory Information
# free -m
# smem -kpt
# smem -tuk

Get Disk / Filesystem Information
# df -h

Get CPU Information
# cat /proc/cpuinfo
# watch -n1 "lscpu | grep 'MHz' | awk '{print $1}'"

PHP List Modules / Module Information
# php -m
# php --ri mbstring  // mbstring
# php --ri memcache  // Memcache
# php --ri memcached  // Memcached
# php --ri redis  // Redis
# php --ri imagick  // imagick
# php --ri openssl  // openssl

Check listening Ports
# netstat -ntl

Check Cache
# ccache -s

List installed NGINX Modules
# ls -lah /usr/local/nginx/modules

Version Information (or -t)
# php -v
# mysql -v
# nginx -v

Changelog
# rpm -qa --changelog openssl | head -n8

To print a list of the messages in the queue, enter:
# exim -bp
# exim -Mrm {message-id}  // To remove a message from the queue

To remove all messages from the queue (two options)
# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
# exim -bp | exiqgrep -i | xargs exim -Mrm

Unpacking a tar.gz file w/ permissions intact
# tar -pczf name_of_your_archive.tar.gz /path/to/directory

PHPINFO File Location
Running the below will find the info file location.
You can delete the found file if you choose or password protect the file.
# ls -lah /usr/local/nginx/html | grep phpi

Speedtest
# nfsspeedtest -b 4k -s 128m
# nfsspeedtest -b 4k -s 128m -y
# nfsspeedtest -b 8k -s 128m -y
# nfsspeedtest -b 16k -s 128m -y

Hard Drive Information / Read Checking
# hdparm -I /dev/sda
# hdparm -Tt /dev/nvme0n1

Memory Information
# dmidecode -t memory

Motherboard Information
# dmidecode -t baseboard

Hard Drive SMART Information
# smartctl -data -A /dev/sda
# smartctl -data -A /dev/sdb


##############################################
## CENTOS OTHER STUFF
##############################################

### ADDING NEW IP ADDRESSES

Go to sysconfig
# nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

Add under IPADDR=

IPADDR1="10.0.0.121"
PREFIX1="24"
IPADDR2="10.0.0.122"
PREFIX2="24"

Restart Service
# systemctl restart network.service

### CHANGING HOSTNAME

# nano -w /etc/hostname (enter hostname and nothing else)
# service network restart

Check status of hostname
# hostnamectl status

Check status of Cron
# service crond status

Test SSL
# testssl https://keepass.info/update/version2x.txt.gz

##############################################
## CENTMINMOD COMMANDS
##############################################

Centmin Directory Shortcut
# cmdir

Site Status (Maintenance Mode)
# sitestatus on|off

Centmin Mod Quick Info
# cminfo

Centmin Release Version
# cat /etc/centminmod-release

Centmin Version History Log
# cat /etc/centminmod-versionlog

Lists all logs in date ascending order so latest log at bottom
# ls -lArt /root/centminlogs

Edit php.ini = phpedit ( /usr/local/lib/php.ini )
Edit my.cnf = mycnf ( /etc/my.cnf )
Edit php-fpm.conf = fpmconf ( /usr/local/etc/php-fpm.conf )
Edit nginx.conf = nginxconf ( /usr/local/nginx/conf/nginx.conf )
Edit (nginx) virtual.conf = vhostconf - only edits /usr/local/nginx/conf/conf.d/virtual.conf not the additional vhost domain.com.conf files added later
Edit (nginx) php.conf = phpinc ( /usr/local/nginx/conf/php.conf )
Edit (nginx) drop.conf = dropinc ( /usr/local/nginx/conf/drop.conf )
Edit (nginx) staticfiles.conf = statfilesinc ( /usr/local/nginx/conf/staticfiles.conf )
nginx stop/start/restart = ngxstop/ngxstart/ngxrestart
php-fpm stop/start/restart = fpmstop/fpmstart/fpmrestart
mysql stop/start/restart = mysqlstop/mysqlstart/mysqlrestart
nginx + php-fpm stop/start/restart = npstop/npstart/nprestart
memcached stop/start/restart =memcachedstop/memcachedstart/memcachedrestart
csf stop/start/restart = csfstop/csfstart/csfrestart

PageSpeed Options
# pscontrol handler  // edit pagespeedhandler.conf file
# pscontrol edit  // edit pagespeed.conf file
# pscontrol editstats  // edit pagespeedstatslog.conf file
# pscontrol on
# pscontrol off
# pscontrol statson  // turn on/off Pagespeed console pagespeedstatslog.conf file
# pscontrol statsoff  // turn on/off Pagespeed console pagespeedstatslog.conf file
# pscontrol admin  // access Pagespeed admin

PageSpeed Statistics
# localhost/ngx_pagespeed_statistics  // only ip 127.0.0.1 is allowed access

Adding PageSpeed Statistics to URL w/ IP
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }

PageSpeed Stats Command Line
# curl -s localhost/ngx_pagespeed_statistics
# curl -s localhost/pagespeed_global_admin/message_history or curl -s localhost/ngx_pagespeed_message


##############################################
## MYSQL COMMANDS
##############################################

MySQL Reference
How to Check and Repair MySQL Tables Using Mysqlcheck
Optimize All Tables # mysqlcheck -o --all-databases Optimize One Database # mysqlcheck -o <db_schema_name> Run mysqltuner in root folder # ./mysqltuner.pl Run mysqlreport in root folder # ./mysqlreport ############################################## ## LOG FILES ############################################## Nginx Log Files # tail -10 /usr/local/nginx/logs/[servername].access.log # tail -10 /usr/local/nginx/logs/[servername].error.log Domain Name Specific Log Files # tail -10 /home/nginx/domains/domainname.com/log/access.log # tail -10 /home/nginx/domains/domainname.com/log/error.log Other Specific Log Files # ls -lhrt /var/log PHP-FPM Log Files # tail -10 /var/log/php-fpm/www-error.log # tail -10 /var/log/php-fpm/www-php.error.log MariaDB Log Files # tail -10 /var/log/mysqld.log CSF Firewall Log Files # tail -10 /var/log/lfd.log Mail Log File # tail -10 /var/log/maillog Cron Job Log Files # tail -10 /var/log/cron Install Log Location > /root/centminlogs

Source : gist