Skip to content

Archive for

26
Jul

Log MySQL Queries

If you want to log MySQL Queries log in to your mysql client and run:

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| general_log      | ON                    |
| general_log_file | /var/db/mysql/machine.log |
+------------------+-----------------------+
2 rows in set (0.00 sec)
 
mysql>
mysql>
mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.00 sec)

Then to see the queries as soon as they run do tail on the log.

tail -f /var/db/mysql/machine.log

After you’ve seen the queries and you’ve completed the debug task it is a good practice do disable logging:

mysql> SET GLOBAL general_log = 'OFF';
Query OK, 0 rows affected (0.02 sec)
23
Jul

Check if a Service is Running Using Telnet and How to Quit Telnet Session

Telnet is not used that much anymore. To connect to a managed switch CLI this could be your only options. But then telnet has other use: you can check if a service run on a port on a remote machine.

For example to check if mysql server is running on a remote machine:

 # telnet 10.0.0.20 3306
Trying 10.0.0.20...
Connected to 10.0.0.20.
Escape character is '^]'.
J
5.6.36�-;#:<]A�w7HDZ{|{tV24mysql_native_password

To check if ssh is running on a remote machine:

 # telnet 10.0.0.20 22
Trying 10.0.0.20...
Connected to 10.0.0.20.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2
 
Protocol mismatch.
Connection closed by foreign host.

You should get some reply from the remote machine with a text.

If you get no reply that means either that the service is not running or the service is running on other port (in case of SSH) or that the remote machine’s firewall blocks the access from outside to that service.

Now, if you want to quit telnet you will notice Ctrl + C is not working.

In order to quit telnet press Ctrl + ] to get to telnet console then type: quit

14
Jul

Find Out the Version of Your Ubuntu Linux

To find out which version is the Ubuntu Linux installed on your machine you must use the lsb_release command:

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 17.04
Release:	17.04
Codename:	zesty