mercredi 20 août 2014

MySQL Commands

1: Login

$ mysql -u user_name -p
Enter password:

2: Create a database

mysql> create database db_name;
Query OK, 1 row affected (0.00 sec)

3: Create a user

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

4: Grant the privileges to a user

GRANT ALL PRIVILEGES ON db_name . * TO 'newuser'@'localhost';
Here is a short list of other common possible permissions that users can enjoy.
  • ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
  • CREATE- allows them to create new tables or databases
  • DROP- allows them to them to delete tables or databases
  • DELETE- allows them to delete rows from tables
  • INSERT- allows them to insert rows into tables
  • SELECT- allows them to use the Select command to read through databases
  • UPDATE- allow them to update table rows
  • GRANT OPTION- allows them to grant or remove other users' privileges

5: Reload privileges (e.g., once you have finalized the permissions that you want to set up for your new users)

6: Revoke a permission

REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;

7: Delete a user

DROP USER ‘demo’@‘localhost’;

8: Delete a database

DROP DATABASE ‘demo’@‘localhost’;


lundi 18 août 2014


1: download Websvn

2: unpackage websvn and move it to the apache Web root folder, rename it to svn (e.g., /var/www/svn). Here, please remove the version number (after you unpackage it, you will get something like websvn3.2.6).

3: copy the configuration file

    $cd /var/www/websvn/include
    $sudo cp distconfig.php config.php

4: open and edit the config.php.

find the following lines:

    $config->addTemplatePath($locwebsvnreal.'/templates/calm/');     $config->addTemplatePath($locwebsvnreal.'/templates/BlueGrey/');     $config->addTemplatePath($locwebsvnreal.'/templates/Elegant/'); 

and add the following line to indicate the default template to use:


5: add the following lines just before the last lines: (the objective is to tell websvn where to get the data of svn)

    $config->parentPath("/media/datadrive/svn");     //you can have a parent path,     //or add another entry by using the following line:     //$config->addRepository("Empty Nest", "file:///media/datadrive/svn/emptynest");     $config->setEnscriptPath("/usr/bin");     $config->setSedPath("/bin");     $config->useEnscript();

6: now, when you open your browser, and go to:


you will be able to view svn directory.

7: However, everyone in the LAN can access to the content of svn by entering the above-mentioned URL address. The next step is to add authorization. First, create a pass word file.

    $touch /etc/apache2/dav_svn.passwd

Then, use the following command to create a user:

    $sudo htpasswd /etc/apache2/dav_svn.passwd user1    New password:     Re-type new password:     Adding password for user user1

8: Then, open the file etc/apache2/dav_svn.passwd, you can see some like this:


9: Of course, you can add more users by using the same command.

10: Then, open the apache configuration file:

    $sudo vim /etc/apache2/sites-enabled/000-default

then, add the following lines:

    <Location /svn>
            AuthType Basic
            AuthName "Subversion repository"
            AuthUserFile /etc/apache2/dav_svn.passwd
            Require valid-user

Save the file.

11: restart apache:

$sudo service apache2 restart
[sudo] password for wcg1sgh:
 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
                                                                         [ OK ]

12: Open the browser, and enter localhost/svn, and a username and password is demanded.


vendredi 15 août 2014

vendredi 1 août 2014

Setup Environment Variables for XRDP in UBUNTU

when you use a xrdp client to remotely login to a ubuntu machine, you can find that the environment variables configured in the host machine are not what you can see in xrdp client.

for example, execute the following commands on both host Ubuntu machine and xrdp client machine, repectively.

echo $PATH

you can see that in your xrdp client machine, the second command returns a blank line, and the PATH variable is not identical to the one you can see in host Ubuntu machine.


  1. open the xrdp file

    sudo vim /etc/xrdp/

    Then, you can see the last line is:

    . /etc/X11/Xsession
  2. add the environment setting to xrdp startup file

    Just before the last line, add the following line:

    . /etc/environment

    And save it. . /etc/environment document defines all customized environment variables, it content is like:


  3. Then, you can start your xrdp client to connect to this Ubuntu machine, then you will see that the PATH variable is the same as you can see in the host Ubuntu machine. However, the other variables are still not exported. To solve this problem, create another file /etc/environment.xrdp, its content is like:

    export JAVA_HOME="/usr/lib/jvm/jdk-1.8.0_11"
    export JRE_HOME="/usr/lib/jvm/jdk-1.8.0_11/jre"
    export CATALINA_HOME="/opt/tomcat/apache-tomcat-8.0.9"
    export AXIS2_HOME="/opt/axis2/axis2-1.6.2"

  4. reedit the file /etc/xrdp/, add the following line before the last line:

    . /etc/environment.xrdp

    save it.
  5. Run the xrdp client again, and you will see all the variables have been successfully imported.

The cause of this problem is that, when you login remotely to a Ubuntu server, the server will load automatically to ~/.profile or ~/.bashrc for the configuration of your environment. If some variables are commonly used by all the users, you can use the above mentioned solution to solve the problem. Otherwise, each user can also customize his/her own environment variable in ~/.profile or ~./bashrc file.