Monday, April 29, 2013

[Ubuntu] Wireless stop working after upgrade

If wireless fail to work after upgrade, be sure to use lspci | grep network to look for your wireless device and include this info when you post online for help.

If you're using Broadcom BCM4312 (full name: "Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01)") same as mine, then you probably could easily fix by installing the following:
sudo apt-get install firmware-b43-installer b43-fwcutter
or try another one if the above doesn't work:
sudo apt-get install broadcom-sta-common
You're adviced to reboot your system, but before that you may try:

  1. off & on your wireless device, it may work straight away without system reboot.
  2. run command modprobe b43

If you choose to reboot and the wireless device doesn't start, try modprobe b43. To autoload the device at startup, edit /etc/modules, add "b43" to the list. That should load it during startup.

Good luck!

Sunday, March 24, 2013

[Ubuntu] iNotify-Tools: The Realtime File Monitoring Tool

I have been searching for a good real time file monitoring tools to save time on checking what directories or files has been updated by my colleagues. It seems the iNotify-Tools that built into Linux kernel has gained a lot of recommendation, and even IBM has an article on their website address for this little tool.

To setup inotify is fairly simple:
  1. apt-get install inotify-tools
  2. after install, it comes with two module:
    • inotifywait - it runs and keep monitor for changes happen in the target folder/file, and the results can be output to an external file.
    • inotifywatch - it outputs a summary count of the events received on each file or directory.
  3. We will use inotifywait to monitor our folder and output a text file in the same folder.
inotifywait /targetFolder -mr -e create,delete,move --timefmt "%D_%a_%H:%M" --format "%T | %w%f | %e" -o /targetFolder/FolderReport.txt --exclude "FolderReport.txt"
  • "-m" is used to continuously monitor the target. Without this, by default it will exit after the first event occurs.
  • "-e" is to specify the event that we want to monitor. Full list can be viewed by execute inotifywait -h
  • "--timefmt" is used to add date and time to the log. By default the result doesn't has such info.
  • "--format" has to be specified if --timefmt is used. %T is the time, %w is the path of the folder being monitored, %f is the file name and %e is the event (action done to the folder/file). We can add any words in between the parameter, and it will be output as well. For example, %w the folder is %f %e will output = "/home/tecsun/folder the folder is TestFolder CREATE,ISDIR. (blue is the output specified by parameter) 
  • "-o" is to output the result to file (else it would display on the terminal)
  • "--exclude" is to exclude the result file being monitored, especially when modify event is triggered, so it won't get into infinity loops.
There is one more tools namely iwatch, which is based on inotify, would allow sending of email when event being triggered. Another one which I have not tested is gamin, if anyone of you happen to test this, please let me know how it works.

Thursday, February 28, 2013

[Ubuntu] Xrdp password failed after user password changed

If the password of users has been changed, Xrdp service must be restarted to reflect the changes made. Else, it would give an error of either "password failed" or "login error".

To restart xrdp service, simply type this command in terminal:
/etc/init.d/xrdp restart


After that you should be able to login from remote connection.

Saturday, February 23, 2013

[Ubuntu] Temporarily / Permanently Mount Cifs Network Shares

It is strange that Ubuntu 12.10 doesn't come with cifs-utils installed. Whenever you try to mount a network folder via mount -t cifs -o username=user,password=pass //server-name/shared /mnt/shared, it will give you the following error message:

1:  mount: wrong fs type, bad option, bad superblock on //192.168.0.11/Dropbox,  
2:      missing codepage or helper program, or other error  
3:      (for several filesystems (e.g. nfs, cifs) you might  
4:      need a /sbin/mount.<type> helper program)  
5:      In some cases useful info is found in syslog - try  
6:      dmesg | tail or so  

Execute dmesg | tail will return the following result:

1:  [ 5537.959706] CIFS VFS: Connecting to DFS root not implemented yet  
2:  [ 5537.959815] CIFS VFS: cifs_mount failed w/return code = -22  

To solve this, simply apt-get install cifs-utils. After that run the same command again and you should be able to mount the network shared folder.

To permanently mount the shared folders, go to /etc/fstab, and add the following line:

1:  //server-name/shared     /mnt/shared     cifs     defaults,_netdev,credentials=/home/user/.smbcredentials     0     0  

_netdev parameter is being explained at the last section of this documentation, which in general mean connect only when network is available:
https://help.ubuntu.com/community/MountWindowsSharesPermanently

credentials and /home/user/.smbcredentials is a file created to store the username and password for the remote login, so that we don't put these sensitive info at risk because the /etc/fstab can be viewed by every users on the system. DO NOT forget to set the file permission for the .smbcredentials:

1:  chmod 600 /home/user/.smbcredentials  

Now enjoy working with your network shares!

If you would like to read on, the following articles is good to go:
  1. https://help.ubuntu.com/community/Samba/SambaClientGuide
  2. https://wiki.ubuntu.com/MountWindowsSharesPermanently
  3. https://help.ubuntu.com/community/MountWindowsSharesPermanently




Friday, February 22, 2013

[Ubuntu] Oracle Java 7 Runtime Installation Error

First, I didn't not use manual method for the installation. Instead, I used the PPA method which discussed under here:
http://www.ubuntugeek.com/how-to-install-oracle-java-7-in-ubuntu-12-04.html

However, the installation halted in half way due to my HDD running out of space.

After cleaning up the space and re-run with:
apt-get install -f

It keeps giving me this error:
 Setting up oracle-java7-installer (7u15-0~webupd8~1) ...  
 Installing from local file /var/cache/oracle-jdk7-installer/jdk-7u15-linux-x64.tar.gz  
 Removing outdated cached downloads...  t
 mv: cannot move `jdk1.7.0_15' to `java-7-oracle/jdk1.7.0_15': Directory not empty  
 dpkg: error processing oracle-java7-installer (--configure):  
  subprocess installed post-installation script returned error exit status 1  
 Errors were encountered while processing:  
  oracle-java7-installer  

And this error has disabled Synaptic Package Manager from function properly.

Tried a few solutions but to no avail:
  • apt-get purge
    - cannot be run
  • apt-get autoremove
    - cannot be run
  • dpkg --remove --force-remove-reinstreq oracle-java7-installer
  • http://www.khattam.info/solved-subprocess-pre-removal-script-returned-error-exit-status-2-error-2009-08-04.html - This is a great article suggesting a few solutions, big thanks to the author. It may help you to solve Java7 installation problem, give it a try. Especially the step 6, it has successfully remove the oracle-java7-installer and get apt-get work again, but that does not install Java 7 which is our initial intention. Read on...
  • Remove the installer file located in /var/cache/oracle-jdk7-installer, then re-download & run the installer... cannot resolve the problem as well
And what did the magic is... delete the directory 'jdk1.7.0 15' located inside the 'java-7-oracle', then re-run the installer apt-get install -f. Voila! The installation should complete without any more hassle.

What happened?

The 'jdk1.7.0 15' & 'java-7-oracle/jdk1.7.0 15' are actually located in /var/cache, but for some reason the 'jdk1.7.0 15' is already exist in 'java-7-oracle' folder. When the installer try to copy it into the parent folder, it cannot overwrite it, suggested by the error message 'Directory not empty'.

Somehow, this cannot be solved by changing the directory write permission, so delete the directory has become the immediate working method.

[Ubuntu] How to configure Smartmontools to send email report

There are a few steps-by-steps tutorial to teach you how to configure Smartmontools to email report to you when drives failed. But to get it works is may not be as simple as complete the steps written.

Especially for Ubuntu users, most of you that encountered this problem may have followed the instruction here:
https://help.ubuntu.com/community/Smartmontools

The documentation is very good indeed and it explains almost everything. However, it forgot to mention that if you are not sending email to root account, you are actually sending email externally and the mail simply may not work on that.

How to tackle this has been documented here:
https://wiki.archlinux.org/index.php/S.M.A.R.T.
*Despite it is for Arch Linux, but it works fine to configure Ubuntu.

Basically, you would have to configure ssmtp or any other MTA (Mail Transport Agent) so that Ubuntu can use it to send email to you.

The setup is rather simple, you can get guidance from:
https://wiki.archlinux.org/index.php/SSMTP

I hope this post will help any of you solve this issue quickly, need not to be like me wasting few hours to searching for solution just to get this simple function work.

Sunday, February 17, 2013

How to deal with space in file path?

In modern computing, we are not restricted to use file/folder name with space between each words. This tends to create trouble if we want to mount the path in /etc/fstab

The solution to this is to add "\040" where the space is. For example:
//192.168.0.2/Shared Folder
has to be written as
//192.168.0.2/Shared\040Folder