Essential Linux Administration Commands for Database and Web Services
MySQL Command Line Error Recovery
When executing multi-line statements in the MySQL command-line interface, an error in a preceding line can be frustrating. Use the \c command to cancel the current input and return to the "mysql->" prompt.
Tomcat Service Management
Navigate to the Tomcat bin directory first: cd /usr/local/tomcat/bin
- Start service:
./startup.sh - Stop service:
./shutdown.sh
Verifying Tomcat Shutdown
Check for remaining Java processes: ps -ef|grep java
root 7010 1 0 Apr19 ? 00:30:30 [java] <defunct>
The presence of a defunct process indicates successful shutdown.
Real-time Tomcat Log Monitoring
- Navigate to logs directory:
cd tomcat/logs - Monitor output:
tail -f catalina.out - Exit with
Ctrl+c
Resolving Tomcat Memory Issues
For OutOfMemoryError exceptions, modify /bin/catalina.sh by adding these JVM options before the "Using CATALINA_BASE" echo statement:
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=256m -XX:PermSize=512m -XX:MaxPermSize=512m"
Vim Editor Essentials
Editing files: vi /usr/local/mytxt
- Enter insert mode with
i - Exit insert mode with
Esc - Save and quit:
:wqfollowed by Enter
Linux Firewall Management
Persistent settings (survive reboot):
- Enable:
chkconfig iptables on - Disable:
chkconfig iptables off
Immediate settings (reset on reboot):
- Enable:
service iptables start - Disable:
service iptables stop - Check status:
service iptables status
Individual Port Configuration
- Open port:
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT - Save configuration:
/etc/rc.d/init.d/iptables save - Restart service:
/etc/init.d/iptables restart - Verify opening:
/sbin/iptables -L -n
SELinux Management
Check status: /usr/sbin/sestatus -v or getenforce
Temporary disable: setenforce 0
Permanent disable: Edit /etc/selinux/config, change SELINUX=enforcing to SELINUX=disabled, then reboot.
MySQL Administration Commands
Connection: mysql -hlocalhost -uroot -p -P3306
Password modification:
mysql -uroot -p
mysql> use mysql;
mysql> update user set authentication_string=password('newpass') where user='root';
mysql> flush privileges;
mysql> exit;
Basic operations:
show databases;use database_name;show tables;quit;create database new_db;
MySQL Case Sensitivity Configuration
Add to /etc/my.cnf under [mysqld] section:
lower_case_table_names=1
Values: 0 = case-sensitive, 1 = case-insensitive. Restart MySQL after change.
MySQL Character Encoding
Check encoding: show variables like 'character%';
Configure UTF-8 in /etc/my.cnf:
[client]
default_character_set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8
MySQL Status Monitoring
Display runtime information: STATUS;
MySQL Backup Procedures
For automated backup strategies, see separate documentation on Linux MySQL backup automation.