Pages

Monday, July 11, 2011

Rsync on different port rather than 22

One day, I need to rsync between two Linux servers. And i have to know that only port 80 is opened between those. So use the following command so that rsync can use port 80 rather than 22.
#rsync -e "ssh -p 80" -avp /tmp root@remotehost:/tmp
Hope that somebody find this post useful.
Published with Blogger-droid v1.7.2

Wednesday, July 6, 2011

Sysloging To Remote Log Server on RHEL/CentOS

Purpose - Logging to remote log server instead of keeping log on locally for security reason.
In our case, we will send logs messages to a server with IP Address ( 192.168.1.2 )
How To
#vi /etc/syslog.conf
find the following line
*.info;mail.none;authpriv.none;cron.none                           /var/log/messages

change it to
*.info;mail.none;authpriv.none;cron.none                           @192.168.1.2

and restart the syslog server
#service syslog restart

May your logs be safe in peace! :D

Saturday, June 4, 2011

Default Folder Path For Screenshots On Mac OSX

Here shows how to change default file type of screenshots to JPG on Mac OSX. Another trick is how to change the default folder path that the captured screenshots are saved. Screenshots are saved on Desktop by default. I want to change it to "/Users/netlynker/Pictures/Screenshots". I type the following command in Terminal.

$defaults write com.apple.screencapture location /Users/netlynker/Pictures/Screenshots

I need to log out and log in again to make it affected immediately.
Now your screenshots will be saved in your preferred location in future.

Bash Command History with Time Stamps

Nomally, 'history' command will only show you the following output.
==================================  
   56  sudo find / -mtime 1
   57  sudo vi /etc/hosts
   58  ls
   59  shell
   60  ls
   61  ifconig
   62  ifconfig
   63  ls
   64  ls
   65  exit
   66  exit
   67  exit
   68  history
   Unix:~ netlynker$ 
==================================   
As you see, it doesn't show when these commands were executed. As an administrator, you need to know WHEN WHO did WHAT.  
To enable Time of execution in 'history' for existing users, we need to define the time format of 'history' in ".bash_profile" of each user.

#echo "export HISTTIMEFORMAT='%F %T '" >> ~/.bash_profile"

To enable it for new user account for future, we need to did the same thing to "/etc/profile"

#echo "export HISTTIMEFORMAT='%F %T '" >> /etc/profile"

Now when you run 'history' command this time, the output will be like the following:
==================================   
   69  2011-06-05 12:42:21 history 
   70  2011-06-05 12:48:21 cd /dev/
   71  2011-06-05 12:48:22 ls
   72  2011-06-05 12:48:29 ls -al tty*
   73  2011-06-05 12:48:36 cd /etc
   74  2011-06-05 12:48:38 ls hosts
   75  2011-06-05 12:48:41 ls -al hosts
   76  2011-06-05 12:48:48 visudo 
   77  2011-06-05 12:48:52 sudo visudo
   78  2011-06-05 12:49:06 vi /etc/hosts
   79  2011-06-05 12:49:13 ping 10.0.0.8
   80  2011-06-05 12:50:13 scp root@10.0.0.12:~/checkinstall* ~/Downloads/
   81  2011-06-05 12:50:27 history 
   Unix:~ netlynker$ 
==================================   
Cool! right?


Sunday, May 15, 2011

Changing Captured Screenshot's Defult File Type In Snow Leopard

Every now and then, I need to capture screenshot on my computer to create how-to documents for my users. I notice that Mac OS X captures the screenshot into PNG format by default. I prefer JPG to PNG because of the smaller file size. Here is how to change default file type of screenshots in Mac Snow Leopard. 

$defaults write com.apple.screencapture type jpg

Then, U need to restart the UIServer.
$killall SystemUIServer

Now take some screenshots by shortcut (Command+Shift+3) and U will find captured jpeg files on Desktop.

Saturday, April 9, 2011

Changing Time Zone On RHEL by One Command

I was told to change Time Zone on RHEL servers. According to them, I need to run "system-config-time" , choose the correct time zone and press ENTER on OK. Sound simple? Right? The problem is that I need to do the same thing on 20+ Servers. I am the laziest guy in the world. So I try a solution called "one liner". Here is the command that I run on all servers.

#ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime

Now time zone is changed to Asia/Singapore. Isn't it cool?
Be Lazy!

To know IBM Serial Number and Dell Service Tag from Linux CLI

On one of my chaotic days, I was told to note down Serial Number on 50+ IBM servers.I was very lazy to go down and see the serial number. When I used my brain instead of my legs, "dmidecode" came cross over my mind.
Yes! I can get the serial number by running the following commands
#dmidecode -s system-serial-number
or
#dmidecode -t system

Finally, I can shake my legs and drink coffee while running scripts on all servers... :D
"Be Lazy In Outstanding Ways!"

Creating Ext2 and Ext3 partitions on Windows OS

Objective
To create Ext3 Partations with Windows OS
Solution
Natively we can't create Ext2/3 partations on Windows OS. Although we can use a Linux Live CD to do this, we need to do some extra processes like downloading Linux LiveCD, booting your computer into that Live CD and so on.
Now I found a software called Minitool Partition Wizard Home Edition. The following video shows how to create Ext3 Partation for D2SD Hack on Android Phones.

I hope it helps somebody.

Wednesday, January 19, 2011

SPANNING TREE POEM

I came across the following poem in a networking book. I don't know whether it is serious or not.But I found it quite informative. :D
*********************
I think that I shall never see
A graph more lovely than a tree.
A tree whose crucial property
Is loop-free connectivity.
A tree which must be sure to span.
So packets can reach every LAN.
First the Root must be selected
By ID it is elected.
Least cost paths from Root are traced
In the tree these paths are placed.
A mesh is made by folks like me
Then bridges find a spanning tree.
*********************