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

Saturday, June 30, 2012

Ripping Video CD (VCD)

I have a VCD which I bought years back in a year which I didn't remember. Since I want let my family watch in on TV which can be connected via USB hard disk, I want to have the copy in AVI format. So I need to rip it first.

1- Rip using K3b. If you have 2CDs, you need to create two separate folder
2- Rename the file in 2nd CD to follow the sequence of first CD.

For example; 1st CD might produce bla1.mpg, bla2.mpg. 2nd CD will have bla1.mpg also. Rename it to bla3.mpg

3- Using cat command combine them all;

cat bla1.mpg bla2.mpg bla3.mpg > all.mpg

4- Use ffmpeg to convert the combined file to AVI format

ffmpeg -i all.mpg -qscale 2 mymovie.avi


Hope it works.
 

Wednesday, June 27, 2012

VMware kernel patch for Linux Mint 13 Maya

Hi,

I tried several times running VMware player on my Mint machine to no success. Luckily a Mint user blogged it out here . I mirrored her VMware player patch so that it will have several copies here

Successfully running on my machine now. Sweet!

Tuesday, June 19, 2012

Monday, June 11, 2012

ifstat - showing real time network

Ever use ifconfig to configure or check your IP address. There is also "ifstat", the purpose is to show simple stats, and in real time the usage of your network bandwidth.

najmi@vostro:~$ ifstat -tib wlan0
  Time          wlan0      
HH:MM:SS   Kbps in  Kbps out
00:23:36     64.79     57.53
00:23:37     43.89     54.96
00:23:38     56.76     54.02
00:23:39     25.62     16.33
^C





Use CTRL+C to terminate.. as other console based tool.
Switch to -b flag to get the reading in KB or kbps


najmi@vostro:~$ ifstat -ti wlan0
  Time          wlan0      
HH:MM:SS   KB/s in  KB/s out
00:23:47      4.97      5.12
00:23:48      3.00      2.61
00:23:49      4.83      4.70
00:23:50      3.85      4.26

If this not satisfy you, check my tutorial on ntop.