Category Archives: Unix/Linux

Debian enable/disable services

Install rcconf if you don’t have it yet. rcconf is Debian’s runlevel configuration tool. It allows you to enable or disable the services from starting up automatically. Recently, I got annoyed by postgresql starting up at boot time, so this tool did the trick.

Source: http://www.cyberciti.biz/faq/howto-runlevel-configuration-tool-to-start-service/

Start emacs in terminal-mode

The first text-editor in Linux I ever used was pico. Then I was introduced to emacs and remained using for awhile. Nowadays, vi(m) is my favorite and default text editor of choice. Anyway, the main point of this post is to how to start emacs in terminal-mode instead of graphical mode.

    $ emacs -nw

That’s it. -nw actually does the trick.

Reference: How to get started…

Restore MySQL config file

I have installed mysql-server on my laptop running Debian back in awhile. For that reason, I forgot the root password. Just recently, I need to use MySQL server for one of my assignments. So, I was playing around in /etc/mysql/ directory hoping that I could get rid of the server and then reinstall it. The commands apt-get remove mysql-server didn’t seem to remove files/directories related to MySQL. Then, I decided to delete the /etc/mysql/ manually.

After I reinstalled mysql-server, a few config files ,contained in /etc/mysql direcotry, were never reinstalled. As always, I turned to Google for helps. With a few different combination of keywords, I found a solution to problem.

First, let’s completely remove mysql-server:

$ sudo apt-get remove --purge mysql-common
$ sudo apt-get remove mysql-server

Then reinstall mysql-server again:

$ sudo apt-get install mysql-common mysql-server

This time, I carefully chose a root password which was easy enough to remember. And voilla, it worked!

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.45-Debian_1-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Tomcat 6 on Debian Lenny

I need to install Tomcat 6 for a school assignment. I thought the installation process was easy as counting 123, but it turned out to be a few hours long of head scratching. Well, the first start is to setup a few environment variables as required by Tomcat:

CATALINA_BASE=/home/kenno/bin/apache-tomcat-6.0.13
CATALINA_HOME=/home/kenno/bin/apache-tomcat-6.0.13
export CATALINA_HOME;
export CATALINA_BASE# JAVA_HOME and Path to java, javac
JAVA_HOME=/usr/lib/j2sdk1.6-sun/bin
export JAVA_HOME;
export PATH=${JAVA_HOME}/bin:${PATH}:.

It can be stored in a setEnv.sh file, and run with source setEnv.sh to load those variables.

Then when I tried to run Tomcat with the following command, there was some error with the BASEDIR:

kenno@kampongcham:~$ $CATALINA_HOME/bin/startup.sh
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program

I wasted a few hours trying to search for solutions on Google, and as when I was about to temporarily give up for dinner, I found an unexpected answer from one of the blogs.

“I need to set all the shell scripts in $CATALINA_HOME/bin to be executable”

So let’s fix it:

kenno@kampongcham:~$ cd $CATALINA_HOME/bin
kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ chmod +x *.sh

Finally, it’s done. We can now run tomcat without any errors:

kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ ./startup.sh
Using CATALINA_BASE:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_HOME:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_TMPDIR: /home/kenno/bin/apache-tomcat-6.0.13/temp
Using JRE_HOME:       /usr/lib/j2sdk1.6-sun/bin

That’s it folks. When you setup Tomcat on your machine, make sure you specify the correct path to all the variables mentioned above.

Thanks to Michael for the solution: Tomcat 6 on OSX

Bash Command Shortcuts

How many times do you find yourself using arrow keys to scroll to the beginning or the end of line of the command line in bash terminal? Do you use backspace to delete every character of what you type to clear the command line? Well, if you answer “yes” to any of the two questions, continue reading.

I, myself, have been doing this a lot because I couldn’t remember the shortcut keys to do those tasks. So, I decided to write them here as a reference that could be referred to in the future. You can easily find the same or even thorough information on the web.

Useful Shortcut Keys
Key sequence What it does
Ctrl + U Delete to the end of line
Alt + D Delete to the end of current word
Alt + Backspace Delete to the start of current word
Ctrl + A Move to the start of line
Ctrl + E Move to the end of line
Ctrl + Left Arrow Move one word to the left
Ctrl + Left Arrow Move one word to the right

I hope those shortcuts could save you some time and the fingers from getting sore.

Follow

Get every new post delivered to your Inbox.