How to check the bash shell version
Answer:
To check the current bash shell version
# bash -version
GNU bash, version 3.2.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to check the bash shell version
Answer:
To check the current bash shell version
# bash -version
GNU bash, version 3.2.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
How to remove install CPAN modules?
Answer:
1. Copy the script below, e.g. remove_module.pl
#!/usr/bin/perl -w
use ExtUtils::Packlist;
use ExtUtils::Installed;
$ARGV[0] or die "Usage: $0 Module::Name\n";
my $module = $ARGV[0];
my $inst = ExtUtils::Installed->new();
foreach my $item (sort($inst->files($module))) {
print "Removing $item\n";
unlink $item;
}
my $packfile = $inst->packlist($module)->packlist_file();
print "Removing $packfile\n";
unlink $packfile;
2. Execute the script to remove module, e.g. MongoDB
# perl remove_module.pl MondoDB
Install Perl module from CPAN even tests failed
Answer:
To install Perl module from CPAN even tests failed, try the following:
e.g. Assume to install the MongoDB module
# sudo cpan -fi MongoDB
How to sort a file by n-column
Answer:
Suppose you have a CSV file:
1,c
2,d
3,a
How do you sort by the 2nd column?
Here is the command you need:
# sort -k2 input.txt -t ','
where -t ',' mean the comma separator, and -k2 mean the 2nd column.
Change MySQL replication master host
Answer:
To change the MySQL replication master host from a MySQL slave, follow the steps below.
1. Copy current master bin log file name and position
mysql> STOP SLAVE;
mysql> SHOW SLAVE STATUS\G
You will find something like the following...
Master_Log_File: mysql-bin.000081
Read_Master_Log_Pos: 3684056824
2. Change to new master using command
mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.2', MASTER_LOG_FILE='mysql-bin.000081', MASTER_LOG_POS=3684056824;
mysql> START SLAVE;