Monday, January 31, 2011

/bin/bash^M: bad interpreter: No such file or directory

-bash: ./2_genDB.sh: /bin/bash^M: bad interpreter: No such file or directory

Here is the solution:
http://www.linuxforums.org/forum/red-hat-fedora-linux/65469-bad-interpreter-no-such-file-directory.html

Quote:
#!/usr/bin/perl

die "Usage: $0 < files >\n" unless @ARGV;

for $file (@ARGV)
{
open IN, $file or die "$0: Cannot open $file for input!\n";

my @lines = <IN>;

close IN;
open OUT, "> $file" or die "$0: Cannot open $file for output!\n";

s/\r$// for @lines;
print OUT for @lines;
}

Save this file as fix_m.pl

run perl fix_m.pl yourshell.sh

check linux shell version

gregg@server:/opt/de$ echo $SHELL
/bin/bash

mysqldump no data , mysqldump a table with data

1, Dump whole DB schema
$ mysqldump --no-data -u mysqluser -pMysql_DB_PW api > api.mysql

2, Dump a table data from DB
$ mysqldump  -u mysqluser -pMysql_DB_PW  api_DB a_table  > db_table.mysql

Monday, January 24, 2011

enable htaccess

Need to update  #AllowOverride None to AllowOverride AuthConfig

<Directory "/var/www/html">

    Options Indexes FollowSymLinks

    #AllowOverride None
    AllowOverride AuthConfig

    Order allow,deny
    Allow from all


</Directory>

Sunday, January 23, 2011

mysql regular express

Tel phone number 555-555-5555

SELECT * FROM phone WHERE pnumber  REGEXP '[0-9]{3}-[0-9]{3}-[0-9]{4}';


CAS number 
SELECT * FROM products WHERE cas REGEXP '[0-9]{2,7}-[0-9]{1,2}-[0-9]{1}';


Friday, January 21, 2011

sudo: no valid sudoers sources found, quitting - ubuntu

Issue:

When I tried to add a new user into sudoer file  /etc/sudoers, I need to chmod sudoers
chmod +w /etc/sudoers
Then, system gave this error:
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

Solution:
Enter Ubuntu recovery mode to change /etc/sudoers to 0440

enter ubuntu recovery mode in vm

press 'shift' when reboot the ubuntu in VM