Category Archives: debian, linux, computing

Disable MySQL server from auto start in Debian

systemctl list-units | grep mysql # check for mysql unit name
systemctl disable mysql.service # or whatever you find at prev step

or

systemctl list-units | grep mariadb
systemctl disable mariadb.service

To show the Linux system name

To show the linux system name, version number, etc.

Debian:$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.6 (stretch)
Release:	9.6
Codename:	stretch

Redhat:$ lsb_release -a
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	RedHatEnterpriseServer
Description:	Red Hat Enterprise Linux Server release 6.10 (Santiago)
Release:	6.10
Codename:	Santiago

Enable Port Forwarding in Windows 7

When working from home, I need to access the company network using a VPN software which works on Windows only.  However, all my tools are in Linux, thus working in Windows (dual-boot) or in a Windows virtual machine is very tedious and inefficient.

The solution is to create a Windows virtual machine.  Use it to run the VPN software.  Then, my linux OS will connect to the virtual machine and go into the office network via the VPN connection created by the virtual machine.  This is how to do it:

  1. Create a virtual machine with Windows 7 (I’m using Virtual-box).
  2. Create two network adapters for the virtual machine.  The first one uses NAT.  The second one uses Host-only Adapter.  To configure a Host-only Adapter, you will have to create a Host-only Network in the virtual-box (File > Preferences > Network > Host-only Network).
  3. Start up Windows 7 virtual machine.  Make sure VPN is working fine (can connect to the office network from within the Windows 7 virtual machine).
  4. Make sure the second adapter can be reached from the host Linux OS.  You can simply ping the IP address of the second adapter from the host Linux OS.  You will have to disabled the firewall in the Windows 7 virtual machine.

Now is the port forwarding.  Click the Windows start button and type cmd.  Right-click on the search result and choose Run as administrator.  In the command prompt, type the following command:

netsh interface portproxy add v4tov4 listenaddress=x.x.x.x listenport=xx connectaddress=x.x.x.x connectport=xx

My Windows 7 virtual machine has its 2nd network adapter configured with the IP address 192.168.56.101.  I would like to connect to my office server with IP address  10.1.69.83.  The office server is listening at port 22 (SSH).  My final command becomes:
netsh interface portproxy add v4tov4 listenaddress=192.168.56.101 listenport=22 connectaddress=10.1.69.83 connectport=22

The listenport=22 can be set to any other number as long as you specify it when connecting from your Linux OS to the Windows virtual machine like the following:

ssh -oPort=<listenport> user@192.168.56.101

The effect is like running the following command

ssh -oPort=<connectport> user@10.1.69.83

from the Windows 7 virtual machine.

To show all port forwarding configurations:

netsh interface portproxy show all

To clear all port forwarding settings:

netsh interface portproxy reset

If the forwarding does not work, you may want to clear all settings and re-add them.

More info here: http://woshub.com/port-forwarding-in-windows/

END.

Setup A Wifi Router using a Laptop Running Windows 7

In work, I need to connect to LAN using Windows OS (running some CISCO NAC software).  However, all developers are using Linux laptops.  Running virtual machines in Linux with Windows 7 OS, failed to connect to the LAN with the CISCO NAC software.  So I tried to set up a Windows 7 laptop which can connect to the LAN (with this CISCO NAC software), and turn the laptop wifi into hosted mode, so that all Linux laptop can connect to it and use the LAN interface to access the network.  Initially, I set up the ad-hoc network, but no machines (linux and windows) can connect to it.  Android cannot even see it.  Then I read about the the windows miniport setup, which is able to turn the laptop wifi into an access point with hosted mode instead of just an ad-hoc network.  This is great for it should work with all laptops as well as android phones.  This is how to do it:

Step 1: Press start and type cmd and right click on it click on “Run as Administrator”
Step 2: Type netsh wlan stop hostednetwork and press enter.
Step 3: Type netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD keyUsage=persistent and press enter.
Step 4: Type netsh wlan start hostednetwork and press enter.

That’s it!  You can now scan the network with laptop or android phones and connect to it.  To share the network, modify the properties of the LAN interface to allow internet sharing through the newly created miniport adapter.

Details explanation can be found here: http://forum.xda-developers.com/galaxy-s2/general/guide-alternate-to-ad-hoc-wi-fi-network-t1924911

In one of the setup, the network is created, devices are able to connect to the network but IP addresses cannot be obtained (stuck at obtaining IP addresses…).  To fix it, modify the miniport adapter properties by removing all ticks except the TCP/IPv4.  Then, repeat step 1 to step 4.

More posts here: http://superuser.com/questions/339448/windows-7-hosted-network and here: http://mintywhite.com/windows-7/set-windows-7-wifi-hotspot-quick-tip/

Sending Emails from Solaris to External Email Addresses

There are many cronjobs running on the servers I maintained.  Each cronjob creates output which needs to be sent to the external email addresses.  However, none of the cronjob mails were received by the external email accounts.  I guess the servers were not setup correctly.  I run the mail program from the terminal and got a bounced email with the following content:

The original message was received at Fri, 20 May 2016 12:02:03 +0800 (MYT)
from localhost [127.0.0.1]

   ----- The following addresses had permanent fatal errors -----
<user@company.com>

   ----- Transcript of session follows -----
550 5.1.2 <user@compay.com>... Host unknown (Name server: mailhost.xxx.com: host not found)

The configured STMP server is mailhost.xxx.com but this host name is not valid.  I’m not sure how to modify the SMTP server configured, but I do know the IP address of the SMTP server.  So, I add the following line to the /etc/hosts file:

xxx.xxx.xxx.xxx    mailhost.xxx.com

Then, all emails can now be sent to external email accounts successfully.

Debian Jessie: Disable NVIDIA discrete graphic card in a NVIDIA Optimus laptop

Disabling NVIDIA discrete graphic card on a laptop running Debian Jessie is the same (in concept) compare to Debian Wheezy, however, the steps are a bit different.

1. First of all, install the bbswitch kernel module.

 # aptitude install bbswitch-dkms

2. Load the module.

 # modprobe bbswitch

3. Check the status of the NVIDIA graphic card (running or not).

 # cat /proc/acpi/bbswitch
0000:01:00.0 ON  <-- The card is running

4. Disable the card.

 # tee /proc/acpi/bbswitch <<<OFF

5. Check the status of the card again.

 # cat /proc/acpi/bbswitch
0000:01:00.0 OFF  <-- The card is no longer in use

6. To disable the graphic card at boot.

# echo "bbswitch" >> /etc/modules-load.d/bbswitch.conf
# echo "options bbswitch load_state=0" >> /etc/modprobe.d/bbswitch.conf
# update-initramfs -u

See the project website for more info regarding the module: https://github.com/Bumblebee-Project/bbswitch

To see the battery consumption of your laptop (remember to remove the power cord).

awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now

Debian Wheezy – Mate Desktop 1.8.1- Lowering The Volume Into Mute But Cannot Unmute By Increasing The Volume

Since the installation of Wheezy, I’ve been struggling to find a good and reliable desktop environment.  From Gnome 3 to XFCE to LXDE and back to XFCE.  Still, some of the things just didn’t work as I wanted it to be.  A few weeks ago I learnt that Debian’s Wheeze-backports have provided the Mate Desktop package.  It’s a fork from Gnome 2 which is the best Linux desktop environment I’ve ever used, so I decided to give it a try (I did try Mint Linux with Mate desktop for a short while quite some time ago).  It’s been a few weeks using the Mate desktop and I’m very happy with it except one thing: the sound will be muted when lowering the volume to 0% but it won’t be unmuted by increasing the volume.  I’ll have to fire up the “Sound Preferences” to unmute the audio device.  After some googling, the solution is easy:

aptitude install mate-media-pulse mate-settings-daemon-pulse

The two packages will replace the mate-media-gstreamer and mate-settings-daemon-gstreamer installed.

See here for a discussion of the issue: http://askubuntu.com/questions/118675/mute-key-mutes-alsa-and-pulseaudio-but-unmutes-only-alsa

Downgrade a debian package

Recently, I updated my iceweasel to version 24.4.0esr-1~deb7u2 which breaks the GWT browser plug-in. I need to downgrade it to a version which works with the plug-in.

First, I’ll need to install a tool which allows me to list out all available versions of a package:

# aptitude install apt-show-versions

Next, find out what versions of iceweasel are available:

# apt-show-versions --package=iceweasel --allversions

Finally, install the older version:

# apt-get install iceweasel=17.0.10esr-1~deb7u1

Done.

Creating a ISO file from CD/DVD

Find the block size:

$ isoinfo -d -i /dev/cdrom
CD-ROM is in ISO 9660 format
System id: 
Volume id: NEW
Volume set id: UNDEFINED
Publisher id: 
Data preparer id: 
Application id: NERO BURNING ROM
Copyright File id: 
Abstract File id: 
Bibliographic File id: 
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 2073648
NO Joliet present
**BAD RRVERSION (0)
NO Rock Ridge present

Create the ISO file:

$ dd if=/dev/cdrom bs=2048 of=video.iso

Setting up iceweasel in Wheezy (Debian)

To enable flash plugin:

aptitude install flashplugin-nonfree

To enable java plugin:

aptitude install icedtea-7-plugin