Featured Post

read more

A new beginning.

So we are almost starting a new year together. Couple days ago I moved back to Colorado to attend college. I will be starting January 20th. My flight from Amsterdam to the United States didn’t start very good. Before I even left Amsterdam I had already a 4 hour delay. Then finally when we got to Chicago I figured out that my flight was canceled to Colorado Springs. So I had to stay the night in Chicago. United Airlines gave me a hotel room though, in the Hilton Hotel. So that was nice. They also gave me a dinner voucher. So I could eat where ever I wanted to and spend 15 dollars.

So I left my luggage out there with the lady, and she said that it would get on the first flight the next morning. Which I were supposed to be on too. After I slept for a couple hours in the hotel, I went back to the lady’s desk and asked if my luggage was still good.. She checked and everything was alright, it was scheduled for the same flight I was on. I felt pretty good about it. So I got on the airplane. Oh did I mention I got a First Class seat? That was kind of nice. So after about 2,5 hours or so I finally arrived in Colorado Springs.. And guess what.. No luggage. So I had to claim it, I had to fill out some paper work and wait for Tim and Zach to pick me up. It was a long day. But I can’t really complain I guess, cause then later I heard there was happened some crazy stuff in other airplains like you can read HERE. I could have been on that one.. You never know.

But I’m here, and safe. So thats good. Now I pretty much have some time to get back on my feet. I have been looking for furniture for about 5 days now. It’s harder then I thought. Also I really need a laptop, because now I’m using Tim’s computer all the time.. thats not really a problem though. But it’s easier for myself to have a laptop again. So I can install my email client and all that.

Yesterday I went to visit my old host family, it was nice to see them again. We had fun. And I brought some presents. So everybody happy. haha.

So this is all what’s on my mind right now, when I have some new stuff I’ll post it! Thanks for reading!

Convert .flv to .wmv using bash.

Package needed: ffmpeg

root@server:$ yum install ffmpeg

Using the command shown underneath you can convert the movie extension .flv to .wmv real easily.

user@server:$ ffmpeg -i movie.flv -vcodec wmv1 -acodec adpcm_ima_wav movie.wmv

How to get yum package update notifications via e-mail?

This will work for: Red Hat / CentOS / Fedora
For Debian / Ubuntu: Please visit this website.

My server sends me a notifications for everything what happens on the server through e-mail, the only thing I had to check manually every time were the updates / upgrades for my Linux system. I figured there should be a way to get yum-update send notifications with available upgrades. So what we are going to do now is force yum to send an email when a update or upgrade is available.

First thing we need to do is open the yum config file.

root@server:$ nano /etc/yum/yum-updatesd.conf
[main]
# how often to check for new updates (in seconds)
run_interval = 3600
# how often to allow checking on request (in seconds)
updaterefresh = 600

# how to send notifications (valid: dbus, email, syslog)
emit_via = dbus
# should we listen via dbus to give out update information/check for
# new updates
dbus_listener = yes

# automatically install updates
do_update = no
# automatically download updates
do_download = no
# automatically download deps of updates
do_download_deps = no

Add these variables, and change “email_to” to your e-mail address:

emit_via = email
# who to send the email to:
email_to = email@example.com
# who send the notifications
email_from = yum-update@yourserver.com

Here is my working config file. You can also just copy and use this one and change the e-mail addresses.

[main]
# how often to check for new updates (in seconds)
run_interval = 3600
# how often to allow checking on request (in seconds)
updaterefresh = 600

# how to send notifications (valid: dbus, email, syslog)
emit_via = email
# who to send the email to:
email_to = email@example.com
# who send the notifications
email_from = yum-update@yourserver.com

# should we listen via dbus to give out update information/check for
# new updates
dbus_listener = yes

# automatically install updates
do_update = no
# automatically download updates
do_download = no
# automatically download deps of updates
do_download_deps = no

After saving the file. Restart notification yum-updatesd service.

root@server:$ /etc/init.d/yum-updatesd restart

E-mail notification sample sent by yum notification.

Five ways to backup your Linux Computer or Server using bash.

Using “DD”

Make a backup of a local hard disk on remote host via ssh.

user@server:$ dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz'

Backup content of the hard drive to a file.

user@server:$ dd if=/dev/sda of=/tmp/file1

Make a copy of MBR (Master Boot Record) to floppy.

user@server:$ dd if=/dev/hda of=/dev/fd0 bs=512 count=1

Restore MBR from backup copy saved to floppy.

user@server:$ dd if=/dev/fd0 of=/dev/hda bs=512 count=1

Using “Dump”

Make a full backup of directory ‘/home’.

user@server:$ dump -0aj -f /tmp/home0.bak /home

Make a incremental backup of directory ‘/home’

user@server:$ dump -1aj -f /tmp/home0.bak /home

Restoring a backup interactively.

user@server:$ restore -if /tmp/home0.bak

Using “Rsync”

Synchronization between directories.

user@server:$ rsync -rogpav --delete /home /tmp

Rsync via SSH tunnel.

user@server:$ rsync -rogpav -e ssh --delete /home ip_address:/tmp

Synchronize a local directory with a remote directory via ssh and compression.

user@server:$ rsync -az -e ssh --delete ip_addr:/home/public /home/local

Synchronize a remote directory with a local directory via ssh and compression.

user@server:$ rsync -az -e ssh --delete /home/local ip_addr:/home/public

Using “tar”

Make a incremental backup of directory ‘/home/user’

user@server:$ tar -Puf backup.tar /home/user

For more or better ways to backup your system using tar look here.

Using “SSH”

Copy content of a directory on remote directory via ssh.

user@server:$ ( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p'

Copy a local directory on remote directory via ssh.

user@server:$ ( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p'

Local copy preserving permits and links from a directory to another.

user@server:$ tar cf - . | (cd /tmp/backup ; tar xf - )

Eight interesting Linux/Unix commands.

This command shows you information about who is logged in.

user@server:$ w

This gathers information about a domain name.

user@server:$ dig domain.com

Query DNS servers for information about domain names

user@server:$ nslookup domain.com

Ancient command to find out more information about DNS

user@server:$ whois domain.com

Find the disk usage of a file or a directory.
(-sh = better readable | -ch = the same but larger output)

user@server:$ du *
user@server:$ du -sh *
user@server:$ du -ch *

Disk freespace, pretty much self explaining but I use it with the -h switch to convert the bytes to megabytes or gigabytes

user@server:$ df
user@server:$ df -h

Find information about users.

user@server:$ finger username

Show who is logged on, and print: time of last system boot, dead processes, system login processes, active processes spawned by init, current runlevel, last system clock change.

user@server:$ who -a

How to add overlay .png image to video as logo using bash?

Using this command you can create/convert a video with your own chosen logo. Have fun.

user@server:$ ffmpeg -i movie.mpg -vhook '/usr/lib/vhook/watermark.so -f overlay.png -m 1 -t 222222' -an mm.flv

How to update your twitter status in linux using bash?

Updating your twitter status using the bash SHell in Linux is easier then you may think, you can update your status using “curl“, curl is a tool to transfer data from or to a server. All you have to do is execute this command showed underneath. This will transfer the status data to the twitter site using the Twitter API.

user@server:$ curl -u user:pass -d status=”Tweeting from the shell” http://twitter.com/statuses/update.xml

But of course, you don’t want to be typing all that every time you want to update your twitter status. So I found this website which has a executable twitter bash script.

user@server:$ curl --basic --user "user:password" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json"

Replace the user and password with your twitter user id and password. Now save the text to a file called ‘twitter‘ and give the file execute permission. Put this file in any folder in your path. If you want to use this script everywhere on the server make sure it’s located in /usr/local/bin or ~/bin. If you are a user on the server, you may just create the file in your ~/user folder.

Now, how to use the script?

If you have created the twitter file in /usr/local/bin or ~/bin you may use this command anywhere you are in the server.

user@server:$ twitter Testing and using Twitter CLI.

For best results, enclose the message within quotes. This will prevent problems when using wild card characters like ‘?’

user@server:$ twitter "Testing and using Twitter CLI."

And if have created the twitter file in your ~/user directory, make sure you are in the same folder as the file and then you may use this command.

user@server:$ ./twitter "Testing and using Twitter CLI."

Not working?

Did you make sure the file has executable rights?

user@server:$ chmod +x twitter

How to unrar multiple .rar files using bash?

You might need the package: unrar

You can check your server using the following command if you have already installed it or not.

user@server:$ rpm -q unrar

If nothing shows up, install the package unrar. If you are using a Linux OS which uses yum update you can use the following command to install it.

user@server:$ yum install unrar

If that does not work for you, you can simply install it manually using the next commands.

user@server:$ wget http://www.rarlab.com/rar/unrar-3.7.7-centos.gz
gzip -d unrar-3.7.7-centos.gz
chmod +x unrar-3.7.7-centos
cp unrar-3.7.7-centos /usr/bin/unrar # Need to do this as admin

When that is all done, we can start using unrar. If you want to unrar multiple .rar files at once, you may use this command.

user@server:$ find -type f -name '*.rar' -exec unrar x {} \;