Wednesday, 29 May 2013

Set FQDN on Debian

On Debin 9+ user

sudo hostnamectl set-hostname host.example.com

And to check:

hostnamectl





On Debian 8 and older

, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).
Caution: in the /etc/hosts file, the hostname and FQDN order must be respected.
~$ echo "my-computer" > /etc/hostname
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh
You can check the change with the following lines:
~$ hostname
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext

Friday, 1 February 2013

Execute a bash script on multiple folders


curdir=$(pwd)
for folder in /path/to/Files/*; do 
  [ -d $folder ] && cd "$folder" && bash /path/to/conv.sh
done
cd $curdir

Thursday, 3 January 2013

Force Chrome to render Google search in English


1. In Chrome, click the wrench icon. (upper-right)
2. Click 'Options' [This item is called 'Preferences' on Macs]
3. Under the 'Basic' tab, select 'Manage Search Engines' in the Search section
4. At the bottom of the list of search engines, you'll see three fields that allow you to add a new one. Add this info into the three fields in the correct order:
(You should paste this link without any breaks or spaces)
5. Hit 'Enter' and your search engine should be saved. Finally, hover your mouse pointer over the newly added Google entry to see a button that reads 'Make default' - select this in order to change your default Google search.
Close the preferences tab and test your new Google search by typing a search term into the Omnibox (Chrome's address and search bar).

Tuesday, 1 January 2013

Query cache check


mysql> show status like 'qc%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| Qcache_free_blocks | 3051 |
| Qcache_free_memory | 10365720 |
| Qcache_hits | 1650400 |
| Qcache_inserts | 757805 |
| Qcache_lowmem_prunes | 348499 |
| Qcache_not_cached | 9146 |
| Qcache_queries_in_cache | 10180 |
| Qcache_total_blocks | 24809 |
+-------------------------+----------+
8 rows in set (0.00 sec)
A couple important numbers from these values:
free space / free mem blocks = average free block size (in bytes)
10365720 / 3051 = 3398
used space / num queries in cache = average result size (in bytes)
(32 * 1024 * 1024 – 10365720) / 10180 = 2278


Saturday, 29 December 2012

POST using Curl , Python and Lynx


Source: 

Hemanth.HM 


Assume that you have a form , in the source look for something similar to :
input name="rid"  type="TEXT"
input name="submit" value="SUBMIT" type="SUBMIT" align="center"
Then , based on your needs select any of the methods to POST the data to the form and get the required results back
Using curl :
curl -s -d "rid=value%&submit=SUBMIT" <URL> > out.html


Using Python :
#!/usr/bin/env python
import urllib
# URL to post to
url = 'URL'
values = {'rid':    rid, 
            'submit': 'SUBMIT'}
 
html = urllib.urlopen(url, urllib.urlencode(values)).read()
print html



Using Lynx to dump data :
 curl -sd 'rid=1ap05cs013&submit=SUBMIT' <URL> | lynx -dump -nolist -stdin > out.html

Friday, 21 December 2012

my.cnf for large database + high end server


#
# The MySQL database server configuration file for Large innodb database.
# This is one of my better my.cnf

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]

user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
#skip-innodb
default-storage-engine=InnoDB
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#bind-address = 1.2.3.4
#
# * Fine Tuning
#
key_buffer = 192M
max_allowed_packet = 64M
thread_stack = 192K
thread_cache_size       = 64
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 800

interactive_timeout= 5
wait_timeout= 5

log-slow-queries = /var/log/mysql/slow_query.log
long_query_time = 10

table_cache            = 6048
thread_concurrency     = 22

join_buffer_size = 64M
sort_buffer_size = 16M
max_heap_table_size = 4412M
max_connect_errors = 10
tmp_table_size = 4412M




#*** MyISAM Specific options
key_buffer_size = 64M
read_buffer_size = 4M
read_rnd_buffer_size = 8M

myisam_sort_buffer_size = 128M
#myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G



#finally added
table_definition_cache = 2048


#default-storage-engine = innodb
innodb_buffer_pool_size = 10000M
innodb_log_file_size = 1500M
innodb_flush_method = O_DIRECT #O_DSYNC
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_additional_mem_pool_size = 20M

# num cpu's/cores *2 is a good base line for innodb_thread_concurrency
innodb_thread_concurrency = 16




#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size  = 128M
query_cache_min_res_unit = 1k

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

log_error                = /var/log/mysql/error.log

#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size         = 100M


[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

!includedir /etc/mysql/conf.d/


Saturday, 20 October 2012

drush functions


drush php-eval 'user_delete_cron();'  &&
drush php-eval 'dblog_cron();'  &&
drush php-eval 'filter_cron();'  &&
drush php-eval 'node_cron();'  &&
drush php-eval 'ping_cron();'  &&
drush php-eval 'poll_cron();'  &&
drush php-eval 'statistics_cron();'  &&
drush php-eval 'update_cron();'  &&
drush php-eval 'captcha_cron();'  &&
drush php-eval 'ctools_cron();'  &&
drush php-eval 'db_maintenance_cron();'  &&
drush php-eval 'googleanalytics_cron();'  &&
drush php-eval 'image_cron();'  &&
drush php-eval 'messaging_cron();'  &&
drush php-eval 'notifications_cron();'  &&
drush php-eval 'privatemsg_cron();'  &&
drush php-eval 'scheduler_cron();'  &&
drush php-eval 'session_expire_cron();'  &&
drush php-eval 'spam_cron();'  &&
drush php-eval 'user_stats_cron();'  &&
drush php-eval 'votingapi_cron();
#drush php-eval 'system_cron();'  &&

Friday, 7 September 2012

Reset mysql forgotten password


First of all you will need to ensure that your database is stopped:
root@steve:~# /etc/init.d/mysql stop
Now you should start up the database in the background, via the mysqld_safe command:
root@steve:~# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 6702
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started
Here you can see the new job (number "1") has started and the server is running with the process ID (PID) of 6702.
Now that the server is running with the --skip-grant-tables flag you can connect to it without a password and complete the job:
root@steve:~$ mysql --user=root mysql
Enter password:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> exit
Bye

Source

Friday, 31 August 2012

apache downloads php in the browser

I see this problem in Debian 6. To fix just add the missing library:

apt-get install libapache2-mod-php5

and restart apache.

Monday, 30 July 2012

Grant mysql permission

CREATE DATABASE mydb;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mydb.* TO 'myuser'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mydb.* TO 'myuser'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
quit;