Posts

Showing posts with the label linux

Building packages in Linux from source

Always remember that when you build packages in Linux, always do consider these packages as its requirement by the compiler to build the package from source. git-core  build-essential libboost-dev  libboost-program-options-dev libboost-thread-dev  libboost-filesystem-dev scons gcc-c++ glibc-devel

tcpdump - just for my notes

Well, I just want to put this to my blog for my own sake. tcpdump -nq -s 0 -A -vvv -i eth0 port 80 Thanks to tcpdump.

LVM: How to remove a volume using pvremove

First, I encountered this error "Can't pvremove physical volume "/dev/sdc1" of volume group "nova-volumes" without -ff" (I'm actually using OpenStack but it's another story). So to remove this, do first, ~# pvscan   PV /dev/sdb1   VG nova-volumes    lvm2 [1.82 TiB / 1.82 TiB free]   PV /dev/sda5   VG cloudmaster     lvm2 [297.85 GiB / 12.00 MiB free]   PV /dev/sdc1                      lvm2 [1.82 TiB]   Total: 3 [3.93 TiB] / in use: 2 [2.11 TiB] / in no VG: 1 [1.82 TiB] Then, when I do, ~# pvremove /dev/sdc1  Can't pvremove physical volume "/dev/sdc1" of volume group "nova-volumes" without -ff So I need to, ~# vgreduce nova-volumes /dev/sdc1   Removed "/dev/sdc1" from volume group "nova-volumes" Then do `pvscan` again, ~# pvscan   PV /dev/sdb1   VG nova-volumes    lvm2 [1.82 TiB / 1.82 TiB free]   PV /dev/sda5   VG clou...

Resizing Disk Images in Linux

To resize the disk image in Linux, do # sudo fsck.ext4 -f DISK_IMAGE_FILE # sudo resize2fs DISK_IMAGE_FILE This is very helpful specially if you are having an instance in the cloud and wanted to resize an image.

Mounting an EBS in Eucalyptus

First, do # fdisk -l to list the device available. You can identify what's the current device the Eucalyptus have avail for the current block storage given. Now, to mount this, do # mkfs.ext4 /dev/sda where my current filing system is ext4 and the availed virtual device is /dev/sda. Then afterwards, you can do # mount -t ext4 /dev/sda /path/to/mounted/directory Hope this helps.

Delete a file with a leading "dash" or (-) in Linux

To delete a file with a leading dash, for example, # ls -al total 36195068 drwxr-xr-x  3 toor toor        4096 2011-06-15 16:46 . drwxrwxrwx 12 toor toor        4096 2011-06-21 14:11 .. -rw-r--r--  1 toor toor        6887 2011-06-10 13:01 -C do # unlink -- -C Hope this helps

IP Masquerading - To share internet connection within a private network

So I have this setup, SERVER1 - This connects to the LAN/Internet connection SERVER2 and SERVER3 is connected to SERVER1, where SERVER1 is acting their gateway. So SERVER1 is using CLASS A IP Address, using 10.0.2.45 while SERVER2 and SERVER3 is using CLASS C, having SERVER2 as 192.168.10.2 and SERVER3 as 192.168.10.3 and SERVER1 as their gateway using 192.168.10.1 IP. Server3 has 2 interfaces, one connects to the LAN and one connects to the private network of SERVER2 and SERVER3. So to achieve SERVER2 and SERVER3 must have internet connection, first in SERVER1, login as root and then check if the ip forwarding is enabled by, $> cat /proc/sys/net/ipv4/ip_forward if the result is 1, leave it behind, else, $> echo "1" > /proc/sys/net/ipv4/ip_forward then, do $> iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE I'm not going to explain fully what does the command do, you can check this by doing "man iptables". So the "...

Issue Single Command To Kill a Process In Linux/Unix system

I am so tired of issuing back and forth this 'ps axu' command thing. I was debugging stuff in JBoss and I do always 'ps axu|grep jboss' then I took the process id and kill it by: kill -9 processid Then I just tried killing two process id at a time like for example: kill -9 processid1 processid2 and that will actually kill two process id, however, that's still tedious but it does help in some way. So I figure it out that I can use awk tool for this and get the column where the processid would be printed. So I found out a way with just one command to kill a process either in Linux/Unix system. I did this in my Mac OS X Snow Leopard. kill -9 $(ps -e|grep jboss|awk '{ print $1 }') // works in Snow Leopard or kill -9 $(ps -re|grep sl1 | awk -F ':' '{ print $3}'| awk '{print $1}') // Works in Mac OS X 10.8 Snow Lion or kill -9 $(ps axu|grep jboss|awk '{ print $2 }') // Linux   the '$1' there is the ...

Postfix + Cyrus IMAP Relay access denied (state 14)

Solving this problem was freaking easy. I just did add the user, must have the proper domain name link to your IMAP, like us, I have toytoy.is-a-geek.org. So what I did, I just add first the user's e-mail address like for example: echo "mypassword" | /usr/sbin/saslpasswd2 -p -u toytoy.homeunix.org toytoy@toytoy.homeunix.org  Since I have the script to create an IMAP account for Cyrus, I just run /path/to/imapcreate.pl -u cyrus -m "toytoy@toytoy.is-a-geek.org" -p cyruspassword -s localhost then cd to the assigned virtual_alias file, if your postfix configuration doesn't modify or customized the default config, so execute (mostly /etc/postfix/virtual_alias) cd /etc/postfix/virtual_alias echo "toytoy@toytoy.is-a-geek.org toytoy@toytoy.is-a-geek.org" >> virtual_alias which postmap virtual_alias Then try sending e-mails, you can check the spool at /var/spool/imap/domain/t/toytoy. is-a-geek .org/t/user/toytoy/2. where " 2. " is t...

My guide on how did I able to use autoconf

In my experience, it seems that autoconf  needs Makefile.am and configure.ac. How did I do it, I run autoreconf -i -v -f Makefile.am then I did run automake to create Makefile.in then afterwards, I was able to run ./configure successfully.

Some CentOS/RHEL/Fedora rpm repositories for yum that would be helpful

I got the repository from remi for my CentOS. By issuing the following commands: su - cd /etc/yum.repos.d wget http://rpms.famillecollet.com/remi-enterprise.repo  For webtatic, rpm –import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo  where I got my latest versions of PHP. For EPEL and remi, wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm Some warned to discourage using the RPMForge because of some conflict with the repository under EPEL. EPEL is known for the repository project for Fedora. For RPMForge, rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm This repos might help you fixing problems on looking for available repository packages.   This repositories are well applied for RHEL ...

Awk and Bash: Print Linux/Unix User Accounts

There are ways how to do this: awk -F':' '{ print $1 "\t"  $3 }' /etc/passwd That would  print the username and the UID. You can also add the sort command at the end like awk -F':' '{ print $1 "\t"  $3 }' /etc/passwd | sort and this will sort alphabetically. To add filter in the result, you can awk -F':' '$1 == "hachiko" { print $1 "\t"  $3 }' /etc/passwd | sort where hachiko is a username you wanted to print with its UID. Hope this helps!

Installing wpa_supplicant in Slackware

Ever since I'm connecting to my wireless router WRT54GL from LinkSys, I never thought of WPA and the wpa_supplicant for my Slackware Linux box. I do connect through WEP security mode for my encryption algorithm. I know it's just a basic authorization for my wireless, instead with wpa_supplicant for WPA, until I found out that my neighbors are abusing my connection, and don't want my stuffs to be exposed. It was funny actually when my neighbors approach me and ask me if I'm the owner of that connection that they able to detect, and say, "hey, don't put any password on that". Really, it sounds daring and hilarious but rude. I do connect from my Slackware Linux via shell using the commands: $> ifconfig wlan0 up $> iwlist wlan0 scan $> iwconfig wlan0 essid "myssid" key "8EEDEEFE41" $> dhcpcd wlan0 The first command will take my wireless LAN card to be up, which actually down during start up. Somewhat like, disable and enabl...

Linux Using xargs to Copy All Files in Directory or Subdirectory

To copy all the files, for example, mp3 files in a directory/subdirectory to another directory in Linux, you can use the xargs command and the find but by using "sed" tool to also filter the quotes of file names. The command is pretty simple which is write down below. $> find . -name "*.mp3" | sed -r "s/'/\\\\\'/g" | xargs -t -I '{}' cp '{}' /media/disk/Music/ What it does, is that, it will find any files that ends with *.mp3 file extension from the current directory the command is being executed, and sed will will apply a regular expression to filter the quotes and replace it with "\'" (a slash and a single quote). After this, xargs command will catch the lines outputed by the find command but filtered with sed and executes a cp command and directs it to /media directory. find options: -name = specifies the name to find sed options: -r = will do an extended regular expression xargs options: -t = print the command l...