Summer Nights

Let's make the world a better place using digital technologies!

Solving: Samba not working in andLinux with domain users

If Samba share fails to mount during boot-up and you are a domain user, do the following:

  1. Edit /etc/smbpasswd
  2. Change the first line to username = <Domain>/<Username>. e.g., devel-net/andy
  3. The password in the second line should be the domain password

Now restart the andLinux service. The share should mount okay.

Continue Reading

Configure default command-line programs for Ubuntu

Use the following command to configure default command-line programs, e.g., pager, editor, ssh, etc.:

update-alternatives --all

For example:
update-alternatives --config editor
allows you to change the default editor nano in ubuntu, to e.g., emacs, if installed.

Continue Reading

Interactively customizing emacs

Execute the following command:
M - x customize <ENTER>
to customize emacs in a user-friendly way.

How to enable syntax-highlighting:

  1. Search for Faces group and press Enter on Go to Groupt.
  2. Next go to Font Lock group.
  3. Toggle Global Font Lock Mode to on to enable global syntax-highlighting.
  4. Use Save for Future Sessions to save the changes.
Continue Reading

Cygwin Installation

Step followed:

  1. Download and run Cygwin setup.
  2. Select Unix/Binary file types during installation.
  3. Select appropriate development packages, at least the gcc, make, automake, and autoconf.
  4. In Editors, choose emacs if you like to use it.
  5. Install ruby. You will need it for Terminator, a GPL terminal emulator.
  6. Complete the Cygwin installation. It will take some time until it downloads and installs the required packages.
  7. Go to My Computer -> right click -> Properties -> Advanced(tab) -> Environment Variables and create a new system-wide variable named “CYGWIN”. Give it the value “ntsec tty”. ntsec is for file permissions, and tty is needed for emacs to function properly.
  8. Edit the PATH variable in the Environment Variables and add “C:\Cygwin\bin”, assuming it is the correction Cygwin location.
  9. When you first get into the Cygwin, type the following commands to make appropriate passwd and group files:
    mkpasswd -l -c > /etc/passwd
    mkgroup -l -d > /etc/group
  10. Download and install Terminator. You have desktop icon as well but it does not work for me. So, if this is also the case for you, enter terminator at the command prompt. You shall have terminator running.

This installs a basic cygwin system with a decent terminal in the form of Terminator.

Continue Reading

Cygwin Installation: mkpasswd and mkgroup issue

You get this message when you start Cygwin:

Your group is currently “mkpasswd”. This indicates that
the /etc/passwd (and possibly /etc/group) files should be rebuilt.
See the man pages for mkpasswd and mkgroup then, for example, run
mkpasswd -l [-d] > /etc/passwd
mkgroup -l [-d] > /etc/group
Note that the -d switch is necessary for domain users.

Issue the following commands to fix it:

mkpasswd -l -c > /etc/passwd

mkgroup -l -d > /etc/group

It will create a local user based on the current logged on user. The groups will be fetched from the domain. For the local installation the “-d” option can be omitted from mkgroup command.

Thanks to sinewalker for this tip.

Continue Reading

Howto: Solving “Ubuntu Installation Left Messed-Up Bootloader”

Yesterday, I installed Ubuntu 8.04 to my second SATA II drive. I explicitly selected that grub be installed to second drive. After restarting, the computer failed to boot in both windows or linux and “GRUB” continued flooding on the screen. Here is how to solve this:

  1. Fix the XP boot record first: Boot with windows XP CD and when prompted press “R” to enter recovery console. Once in the console, enter:
    fixmbr
    to fix the master boot record of windows partition.
  2. Reboot the computer into windows and download the latest version of grub4dos. Do not be alarmed by the name, it is equally useful for XP NTFS partitions. Extract to a convenient location.
  3. In windows, go to Control Panel->System->Advanced->Startup and Recovery, click Settings
  4. In System Startup, click Edit
  5. Add the following line to the end of the opened (boot.ini) file:
    C:\grldr="Start GRUB4DOS"
    and save the file.
  6. Copy grldr to the same location where boot.ini is located. It is usually found in C: drive and is a hidden and system file. You need to make it visible using appropriate folder view options.
  7. Download and install Ext2IFS for windows. Run the program and map ext3 based Ubuntu partition into windows.
  8. Copy menu.lst from /boot/grub from the Ubuntu partition to the same location as windows boot.ini file.
  9. Open menu.lst in wordpad and edit the following lines to your need:
    title Ubuntu 8.04, kernel 2.6.24-16-generic
    root (hd1,0)
    It was hd0,0 and I had to make it hd1,0 to refer to the second harddisk. This should boot Ubuntu fine, but you may want to make other changes in menu.lst file to your needs. Save and close menu.lst file.
  10. Now reboot your computer, press F8 at reboot to get to OS choice menu. Select Start GRUB4DOS. Now you should see the usual grub menu. Select the first choice for Ubuntu and this should boot you in Ubuntu.
  11. If you are unable to get to grub menu after selecting Start GRUB4DOS from the menu, please check again the location of grldr and menu.lst files. You may try putting them in the C: root as well, if boot.ini location is different.
Continue Reading

SyncToy to Synchronize

If you want to regularly backup your data from one location/hard-disk to another location/hard-disk on your windows-based computer, then SyncToy is very good candidate to accomplish this. It is a small utility from Microsoft in which you can easily create folder-pairs to synchronize. A number of actions, like merge, subscribe, echo, etc. are available that can be executed on a given pair.

The utility can be freely downloaded from here.

The desired sync operations can also be scheduled via Windows’ task scheduler. Simply look in the SyncToy help to find out.

Continue Reading

WARNING: mysqlcheck has found corrupt tables

If you receive this e-mail from your system, issuing the following command would fix the corrupted tables:

mysqlcheck --user=[username] --password=[pwd] --repair -A

Continue Reading

Use fail2ban to stop brute-force attacks

apt-get install fail2ban
That’s all it takes to install this handy utility. It will monitor different services (ssh, postfix, courier, etc.) for repeated failed login attempts and will block the attacker for a given duration of time. All the settings can be found in /etc/fail2ban/jail.conf.
After you have updated the settings file, use:
/etc/init.d/fail2ban restart
to reload the new settings.

I was having brute-force dictionary attacks on pop3 port, fail2ban blocked the attacker within 1 minute. Thanks to the developers.

Continue Reading

Some Useful MySQL Commands

  • mysql -uusername -ppassword
    gets you into MySQL shell
  • show databases;
    shows all the databases;
  • create database databasename;
    creates a new database
  • grant all privileges on databasename.* to 'user'@'localhost' identified by 'password';
    creates user with password with all privileges on given database
  • use databasename;
    selects a database for further actions
  • show tables;
    displays the tables in the selected database
  • drop database databasename;
    deletes all tables in databasename and deletes the database.
  • select * from mysql.user;
    lists all the mysql users
  • drop user xxxx@localhost;
    deletes the xxxx user from the localhost
  • mysqldump --all-databases -p | bzip2 -c > databasebackup.sql.bz2
    dumps all mysql data in the compressed databasebackup.sql.bz2 file.
  • mysqldump -uroot -p databasename | bzip2 -c > databasename.sql.bz2
    dumps databasename database in the compressed databasename.sql.bz2 file.
Continue Reading