Archives October 2015

linux Execute shell script exception bad interpreter: No such file or directory

linux sh script exception /bin/sh^M:bad interpreter: No such file or directory

reason : This is caused by a different system encoding formats.

resolve : 1.Conversion at windows

        Use UltraEdit or EditPlus

        UltraEdit: File-->Conversions-->DOS-->UNIX

        EditPlus : Edit-->EOL Conversions-->Convert to UNIX Format


        2.Conversion with vi

        >vi filename

        :set ff or :set fileformat

        You can see ...

Continue reading

linux c library function to read binary file code

linux c library function to read binary file code

struct person
{
    int id;
    char name[20];
    int age;
    int sex;
    char tel[20];
};


int main(int arg, char *args[])
{
    FILE *p = fopen(args[1], "w");
    if (p == NULL)
    {
        printf("error is %s\n", strerror(errno));
    } else
    {
        printf("success\n");
        struct person man;
        memset(&man, 0 ...

Continue reading

Linux command history

[root@linux ~]# history [n]
[root@linux ~]# history [-c]
[root@linux ~]# history [-raw] histfiles

Parameters:

-n  :number, meaning ' the n command to list the most recent list ' means!

-c  :All the history in the current shell delete all content

-a  :Will be added into the history currently added instruction in histfiles, if not histfiles, then the ...

Continue reading

virtualenv -- python Virtual Environment

1. Installation pip

 pip install virtualenv

2. Creating a Virtual Environment

virtualenv envfolder(Virtual environment name)

3. Start Virtual Environment

After you create a successful, will generate the corresponding directory files in the current directory.

cd envfolder/

Then start

source ./bin/activate

4.Quit Virtual Environment

   deactivate

fedora mysql root Password Reset

1.Stop mysql service

[root@localhost han]#/etc/init.d/mysqld stop
Stop MySQL: [OK]

2.Start mysql service with the following command

[root@localhost han]#mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

(Prompt message: [root@localhost han]# nohup: ignoring input and redirecting stderr to stdout Starting mysqld daemon with databases from /var/lib/mysql)

3 ...

Continue reading

linux vps iptables Firewall configuration shell

#!/bin/bash
echo "clean all rules before"
iptables -F
iptables -X

echo "setting up default rules"
iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT

echo "allow local address"
iptables -A INPUT -i lo -p all -j ACCEPT

echo "allow now connection"
iptables -A INPUT -p all -m state --state ESTABLISHED,RELATED ...

Continue reading

CentOS yum upgrade Python 2.6 to 2.7

CentOS system comes python2.6.6 by yum upgrade to python2.7

1.Install Upgrade
wget http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm  
(x86_64) 
or
wget http://li.nux.ro/download/nux/dextop/el6/i386/nux-dextop-release-0-2.el6.nux.noarch.rpm 
(i386)
rpm -ivh nux-dextop-release-0-2.el6.nux.noarch.rpm ...

Continue reading

Daily archives

Next month

November 2015

Archives