Friday, August 24, 2012

Customizing terminal theme with bashish

Feel bored with your dry looking, non intuitive PS1 terminal? Try bashish. It really rocks up to you feel wants to cry.

 
I just used the tarball from here, as the link for *.deb is dead. Just initialize "bashish" the moment you finished installed it into your system.

To use the various theming, run bashish list and bashish <your theme of choice>. Cool ha?


Friday, August 17, 2012

Installing Linux on Mac Mini

I finally decided to install Linux on Mac Mini 2009. It runs Intel Core 2 Duo and has around 1GB RAM + 100GB+ HDD storage. Yes, not a decent specs. I also planning to upgrade the RAM but since it's using DDR3 which is quite rare to find it in Lowyat, I decided to stay with the specs.

1) Since Mac is advanced enough and not relying to normal BIOS, we have to do some workaround with its EFI. What we need to do is by using rEFIt. You can use the command line installation or install by using Mac's DMG file.


2) First of all, we need to repartition the hard disk. Use bootcamp (Application->Utilities->Bootcamp). Like in my case I need to use DiskUtility as well to segregate the partition. If you plan to use GParted, you need to insert your installation CD first then reboot, after that go to your live CD session and use GParted to repartition your Mac HDD

3) Then install. For my Mac Mini, it was painfully slow. But with some patience(actually.. a lot!) I managed to install Linux Mint Maya on my Mac Mini. However, unlike Ubuntu 12.04 LTS, it does not come with Wireless Driver (I guess, propietary). Hence we need to use Ethernet cable to install it or in my case I use my phone through USB tethering. You will also noticed during the installation you need to create at least 2 partitions. One small partition, 1MB for grub installation. Another one is for your root.. and you may create your swap partition as well. In my case I created:

  • partition for Grub/BIOS
  • / (root) partition
  • /home (in case I want to change to other distro.. I can just wipe my / partition and retain this
  • swap

4) The rest is pretty straightforward.


Intel Core 2 Duo is equivalent to 64 bit architecture. If nothing was wrong you could see two processors append in /proc/cpuinfo 


You can also mount you Mac partition from your Linux. Mac is using HFS+ filesystem. If you want to automount, just edit your /etc/fstab. In the filesystem type use "hfsplus" for the filesystem option.

 


Thursday, August 9, 2012

Editing boot up service in Linux Mint

Last time when I had the "Redhat" time, I comfortably use chkconfig to edit which service to boot up at which init level.

Now that I left my old job, I don't really much bother which service starts during the boot up and what not.

In Linux Mint, you ca n use "sysv-rc-conf" to accomplish this:

Check in your repo:

$ apt-cache search sysv-rc-conf
sysv-rc-conf - SysV init runlevel configuration tool for the terminal

It's there, then install

sudo apt-get install sysv-rc-conf

Fire up the tool, 

sudo sysv-rc-conf

You will get this display:


You can toggle which service that you want to boot up in which level. As simple as that.


Have fun! Tested on Linux Maya 13 based on Ubuntu 12.04



Monday, August 6, 2012

Fetch md5sum

I dealt with a lot of Windows malware sample for my PhD work, hence I need a simple way to copy these files. Here goes

for i in `ls|grep -e "^[0-9a-f]\{32\}"`; do cp $i ~/Desktop/testbed/ -vi;done

This will basically fetch all filenames which has 32 characters (md5sum, which consist numbers and small letters a through f)

Saturday, July 21, 2012

Changing Storage Label on Linux

On Windows, you can simply right click on a device and rename it. On Linux in the other hands, you can use the following method:

During formatting, use let say if you want FAT as the filesystem:


Let say the device is located in /dev/sdc and I want it to be named as "najmi-archsight". Issue this command:

sudo mkfs.vfat  -I /dev/sdc -n "najmi-archsight"

While let say in the other hand, you already got a data inside and want to change the label, use dosfslabel:

1- If the device is mounted, unmount it first
2- Issue this command:

Let say here I want to rename the device to "najmi-csm". The device is firstly mounted at /media/B807-ED09.

najmi@vostro:~$ df -kh
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        47G   42G  3.1G  94% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           752M  1.4M  750M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G   88K  1.9G   1% /run/shm
/dev/sda6       173G  164G   12K 100% /home
/dev/sdb        2.0G  4.0K  2.0G   1% /media/najmi-archs
/dev/sdc        3.8G  2.5M  3.8G   1% /media/B807-ED09
 

Unmount first:
najmi@vostro:~$ sudo umount /media/B807-ED09/
 

Label it:
najmi@vostro:~$ sudo dosfslabel /dev/sdc "najmi-csm"
 

Check and plug back/mount the drive:
najmi@vostro:~$ df -kh
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        47G   42G  3.1G  94% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           752M  1.4M  750M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G   88K  1.9G   1% /run/shm
/dev/sda6       173G  164G  4.0K 100% /home
/dev/sdb        2.0G  4.0K  2.0G   1% /media/najmi-archs
/dev/sdc        3.8G  2.5M  3.8G   1% /media/najmi-csm

As you can see, device /media/B807-ED09 was changed to /media/najmi-csm

Wednesday, July 18, 2012

Regular expression in bash "for" loop for file exclusion

najmi@aku-PC ~/cuba
$ touch ayam.txt ayam.csv ayam.egg

najmi@aku-PC ~/cuba
$  for i in a*[!.csv,.txt];do echo $i;done
ayam.egg


Here we use the popular ! mark to exclude the file extension within the brackets. Got the solution after few trials.

Friday, July 13, 2012

Using regexp in Linux commands

What if you have several files with same name but different extension and you want to choose only few files and leave the rests?

See the example here:

Create several files:
najmi@vostro:~/test$ touch aku.png aku.jpg aku.txt

Check:
najmi@vostro:~/test$ ls
aku.jpg  aku.png  aku.txt

New directory to separate the files
najmi@vostro:~/test$ mkdir newdir


Use {} braces to include only the specific extensions that you want to handle:
najmi@vostro:~/test$ mv aku.{jpg,txt} newdir/ -v
`aku.jpg' -> `newdir/aku.jpg'
`aku.txt' -> `newdir/aku.txt'


Check current directory
najmi@vostro:~/test$ ls
aku.png  newdir

Selected files already affected(moved)
najmi@vostro:~/test$ ls newdir/
aku.jpg  aku.txt