Thursday, September 16, 2010

802.1x

Configuration:

dot1x max-req: The dot1x max-req interface configuration command sets the maximum number of times that the device sends an Extensible Authentication Protocol (EAP) - request frame (assuming that no response is received) to the client before restarting the authentication process.
Other definition:
Sets the number of times that the switch retransmits an EAP-Request frame of a type other than EAP-Request/Identity to the client before restarting the authentication process.


dot1x max-reauth-req: The number of times that the switch restarts the authentication process before the port changes to an unauthorized state.
Other definition: The number of times that the switch sends an EAP-request/identity frame (assuming no response is received) to the client before restarting the authentication process.


The number of EAP-Request/Identity retransmissions is controlled by the dot1x max-reauth-req command; the number of retransmissions for other EAP-Request frames is controlled by the dot1x max-req command.

Timers:
dot1x timeout re-authperiod: The dot1x timeout re-authperiod interface configuration command sets the number of seconds between re-authentication attempts. To return to the default setting, use the no form of this command.

dot1x timeout quiet-period:
The dot1x timeout quiet-period interface configuration command sets the number of seconds that the device remains in the quiet state following a failed authentication exchange (for example, the client provided an invalid password). To return to the default setting, use the no form of this command.

dot1x timeout tx-period: The dot1x timeout tx-period interface configuration command sets the number of seconds that the device waits for a response to an Extensible Authentication Protocol (EAP) - request/identity frame from the client before resending the request. To return to the default setting, use the no form of this command.

dot1x timeout supp-timeout: The dot1x timeout supp-timeout interface configuration command sets the time that the device waits for a response before retransmitting an Extensible Authentication Protocol (EAP)-request frame to the client. To return to the default setting, use the no form of this command.

dot1x timeout server-timeout: The dot1x timeout server-timeout interface configuration mode command sets the time that the device waits for a response from the authentication server before retransmitting packets. To return to the default setting, use the no form of this command.

Authorization Features:
Critical Vlan: is Assigning a VLAN , when AAA server is not reachable.
                      authentication event server dead action authorize vlan vlan-id
Guest Vlan: is Assigning a VLAN, when the client doesn't have the ability to get authenticated.
                      authentication event no-response action authorize vlan vlan-id
Auth fail(Restricted) Vlan: Assigning a VLAN, when the client has ability to get authenticated but authentication fails like users with wrong credentials. auth-fail vlan won't work in multi-auth mode(Just think about having two devices on that port, one being able to authenticate and another showing up that fails and pulling the complete port into the auth-fail VLAN: that's probably not what your customer wants)
                      authentication event fail action authorize vlan vlan-id  [OR]
                      dot1x auth-fail vlan vlan-id


Commands:
aaa authentication dot1x default group radius none 
   -- Uses no authentication. The client is automatically authenticated by the switch without using the information supplied by the client.


Dynamic VLAN Assignment with RADIUS Server:
Radius attributes needs to be passed:
tunnel-type=VLAN
tunnel-medium-type=ALL_802
tunnel-private-group-id="Vlanname" or "uservlanid"

For rsim:
attribute 64 numeric 13
attribute 65 numeric 6
attribute 81 string "nms"

Configuratoin needed on switch:
1. aaa authorization network default group radius
2. "vlanname" or "vlanid" that is sent from radius server need to configured on the switch.


References:
ACS 5.2 configuration:
http://www.cisco.com/en/US/products/ps10315/products_configuration_example09186a0080bc8129.shtml
ACS4.x configuration:
http://www.cisco.com/en/US/tech/tk722/tk809/technologies_configuration_example09186a008076317c.shtml

References:
http://docs.us.dell.com/support/edocs/network/pc6024/en/cli/html/802.htm#1054577
http://www.cisco.com/en/US/docs/switches/lan/catalyst4500/12.1/19ew/configuration/guide/dot1x.html

Monday, June 21, 2010

why do we safely remove hardware

When you plug in a USB drive, you give your PC free reign to write and read data from it; some of which is cached.

Caching occurs by not writing information immediately to the USB device, and instead keeping it in your PC's memory (RAM). If you were to yank the USB drive out of your PC before this infromation is written, or while its being written, you'll end up with a corrupted file.

However, Windows automatically disables caching on USB devices, unless you specifically say that you want it enabled. For the most part you don't have to click the 'Safely Remove Hardware' button, if you aren't writting or reading anything from the device.

Its there simply as an extra level of security preventing you from destroying your own files.

Doing so causes the files to close "gracefully", preserving data, pointers and file size indicators. When writing to disk the computer doesn't always "flush" a buffer and only part of the data may have been written. Using the proper procedure will assure that the data and pointers are in good shape.

References:
http://wiki.answers.com/Q/Why_click_safely_remove_hardware_icon_on_USB_flash_drive

Sunday, June 20, 2010

Keyboad shortcuts

Ctrl-H: show hidden files
Ctrl-N: new window
Ctrl-Shift-N: create new folder
Alt-Home : jump to home folder
Alt-Enter : file / folder properties
Alt-F1 : launch application menu
Alt-F2 : launch "run application" dialogue
Ctrl-Alt - Right/Left arrow : move to the next virtual desktop
Ctrl-Alt-Shift - Right/Left arrow : take current window to the next virtual desktop
Ctrl-Alt-D: minimize all windows, and gives focus to the Desktop
Alt-Tab: switch between windows. When you use these shortcut keys, a list of windows that you can select is displayed. Release the keys to select a window.
Ctrl-Alt-Tab: switch the focus between the panels and the desktop. When you use these shortcut keys, a list of items that you can select is displayed. Release the keys to select an item.
CTRL + ALT + Enter: for toggling Full screen mode in rdesktop
ALT+ENTER: Show file properties without right-clicking the mouse



2.How to create a custom hotkey to launch whatever application you want in GNOME:
As an example, we will set a lock-screen shortcut.
Open "gconf-editor" as the user as you're logged in in GNOME (typing gconf-editor in the terminal or "Run Application").
Go to apps > metacity > keybinding_commands
Here we have a list of twelve slots for commands. Double click on e.g. "run_command_1"
In Key Value Type in the name of the application or command you want to launch (e.g. gnome-screensaver-command --lock).
Go to apps > metacity > global_keybindings
Double click on e.g. "run_command_1"
Change the key value to whatever key combination you like (e.g. L).Press "Ok".


3.How to create/change GNOME shortcuts:

Click on System > Preferences > Keyboard Shortcuts
Click the action in the list and press Enter.
Press the new key or key combination you want to assign to the action. (To clear a shortcut, press the Backspace key)

References:
http://www.linuxquestions.org/questions/linux-newbie-8/most-used-shortcuts-in-gnome-and-nautilus-640504/

Saturday, June 12, 2010

Linux installation methods

Adobe Reader 9 for Unix (Linux/Solaris-x86) can be installed using various different methods, depending on the distribution of the OS you are running.

There are 5 installer formats for Adobe Reader available via yum/apt-get OR via FTP from Adobe’s FTP server:
  1. BIN installer
  2. RPM installer
  3. DEB installer
  4. TARball installer
  5. PKG installer
Installation using yum and apt-get/aptitude is convenient and updates happen automagically so we recommend doing that. We’ve previously described how to install using yum and using apt-get.

Installer formats explained

Here’s a brief description and the merits/demerits of each installer format, to help you choose the format that best suits your needs/constraints:
  1. BIN installer: The BIN installer can be used to install Adobe Reader on any location that is writable by the current user.
    The advantages of using this installer are:
    • Smallest size. This installer has the smallest size amongst all installers for Adobe Reader on Unix platforms. (It is approximately 29% smaller than the second smallest installer.)
    • Install anywhere. This installer can be used to install Adobe Reader on any location that is writable by the user performing the installation.
    The BIN installers are available for both Linux and Solaris-x86 platforms.
  2. RPM installer: The RPM installer may be used to install Adobe Reader on RPM-based Linux distributions such as RedHat, Fedora, CentOS etc.
    The advantages of using this installer are:
    • Native installation. The package can be managed using RPM manager, which provides a one-stop place for managing all RPM-based packages.
    • Managing updates. RPM allows fully-automated, in-place upgrades of the package.
    • Package querying and verification.
    However, unlike the BIN installer, the RPM installer can only be installed by a privileged user. Once installed, it can used by any user on the system. The RPM installer can be used only on RPM-based Linux distributions.
  3. DEB installer: The DEB installer may be used to install Adobe Reader in Debian-based distributions such as Debian, Ubuntu, Linspire, KNOPPIX etc.
    It has exactly the same advantages and limitations as RPM installer. The DEB installer can only be used on Debian-based Linux distributions.
  4. TARball installer: The TARball installer is provided for legacy reasons.
    It has the following advantage:
    • Install anywhere. Just like the BIN installer, the TARball installer can be used to install Adobe Reader on any location that is writable by the user performing the installation.
    The TARball installer is available for both Linux and Solaris-x86 platforms.
  5. PKG installer: The PKG installer is native installer for Solaris and uses the ‘pkg’ installation mechanism, which is similar to RPM/DEB on Linux.
    It shares its advantages and shortcomings with the RPM and DEB installers. The PKG installer can be used only on Solaris-x86 platform.
Installation methods

Once you’ve chosen the installer format that suits your needs best, here’s how you can install Adobe Reader using it:
  1. Download the latest installer (9.1.1, at the time of writing this post) from here and save it to you HOME directory.
  2. Now, open a terminal (gnome-terminal / xterm / konsole /… ) and go to your home directory (which is where you downloaded the installer in step 1.)
BIN installer:
  • Now, mark the installer file as executable for the current user, that’s you:
    • On Linux:
    • On Solaris-x86:
  • Launch the installer:
    • On Linux:
    • On Solaris-x86:
  • Now follow the steps and answer the questions asked to complete the installation.
RPM installer:
  • Start the installation using the RPM installer (remember this would need to be done as root):
  • Alternatively, you can open the Desktop folder in nautilus installer and double-click the AdbeRdr9.1.1-1_i486linux_enu.rpm file to automatically start the installation. This method also requires you to be a privileged (or root) user.
DEB installer:
  • Start the installation using the DEB installer (remember this would need to be done as root):
  • Alternatively, you can open the Desktop folder in nautilus and double-click the AdbeRdr9.1.1-1_i386linux_enu.deb file to automatically start the installation. This method also requires you to be a privileged (or root) user.
TARball installer:
  • Extract the contents of the compressed tarball:
    • On Linux:
    • On Solaris-x86:
  • Launch the installation script:
  • Now follow the steps and answer the questions asked to complete the installation.
PKG installer:
  • Extract the contents of the compressed PKG installer:
We hope this will act as a definitive guide to install Adobe Reader using the various installer formats offered. In case you run into any issues related to Adobe Reader for Unix, please let us know at our forum.

References:
http://blogs.adobe.com/acroread/2009/05/installer_formats_for_adobe_re.html

Thursday, May 27, 2010

password recovery

Add following code in “/etc/inittab” file to secure it from change in single user mode:
# password protect single user mode
su:S:wait:/sbin/sulogin

References:
http://thedaneshproject.com/posts/password-protect-single-user-mode/

Tuesday, May 11, 2010

Memory Management

In Memory management, virtual memory is highly used concept.
Generally Virtual memory is per process but not for whole system. Pagetables, Translation lookaside buffers etc are swapped when a context switching of process happens.

In Linux:
Approximately the first two megabytes of physical memory are reserved
– For the PC architecture and for OS text and data, the rest is available for paging
• The logical address space of a process is divided into two parts
– 0x00000000 to PAGE_OFFSET-1 can be addressed in either
user or kernel mode
– PAGE_OFFSET to 0xffffffff can be addressed only in
kernel mode
– PAGE_OFFSET is usually 0xc00000000

Friday, April 23, 2010

File system

File System

Developer

Directory Contents

File Allocation

Third Extended Filesystem(EXT3)

Stephen tweedie

Hashed B-tree

Bitmap(Free space), Table(meta data)

New Technology File System(NTFS)

Microsoft

B+ tree

Bitmap

File Allocation Table(FAT)

Microsoft

Table

Linkedlist

Thursday, April 22, 2010

Questions

How does SVI(switch virtual interface) works?
How does default-gateway works??

Thursday, April 15, 2010

VIM



VIM 
 
:set -- To see current configuration of VIM
How to recover from swap:
1 Open the swap file .file.swp in vim
2 :recover will recover your file 

wrap:
set wrap -- to wrap lines to fit into window

Set highlight search color
set hlsearch
hi Search ctermbg=LightYellow
hi Search ctermfg=Red

Registry:
Registers in Vim let you run actions or commands on text stored within them. To access a register, you type "a before a command, where a is the name of a register. If you want to copy the current line into register k, you can type
"kyy
Or you can append to a register by using a capital letter
"Kyy
You can then move through the document and paste it elsewhere using
"kp
To paste from system clipboard on Linux
"+p
To paste from system clipboard on Windows (or from "mouse highlight" clipboard on Linux)
"*p
To access all currently defined registers type
:reg

Changing Color scheme
colorscheme default/morning/evening etc..

show scripts running under vim:
scriptnames

Block commenting:
1. Move to the first column in the first line you want to comment-out.
2. Press Ctrl-V to start block-mode selection.
3. Move down to select the first column of a block of lines.
4. Press I and then the desired comment starter (i.e. // or #)
5. Press ESC and the insertion will be applied to the whole block.
To uncomment with this techniques follow the directions but instead of I use x to delete the first char.

VIM diff:
To get the diff between current open file file1 and another file file2:
:vert diffsplit file2
To get the diff between two files files1 and file2:
:tabe file1
:vert diffsplit file2
To traverse between the diffs:
[c :Jump backward to the previous start of a change
]c: Jump forward to the previous start of a change

 vimdiff /path/to/file scp://remotehost//path/to/file

[[     --   Jump to funtion start.
[{    --   Jump to block start.
%    --   Jump to matching parenthesis.
=%  --  Indent code between parenthesis. 
*      --  Search the word under the cursor.

Multiple searches at same time:
/ \|

Multiple search & replace at same time:
:%s/aaa/bbb/e | %s/111/222/e

To white spaces(by default endof line is shown with '$' and tab as ^I):
:set list
:set list! --- no form of above command

Ex editor commands:
:e#     --  opens last opened files.
:ls       --  List the list opened files through vim.
:e#n   --  Will re-open the  nth opened file, listed in ":ls" command.

:b#     --  opens last opened opened file("Ctrl-6" does the same).
:bn      --  Will re-open the  nth opened file, listed in ":ls" command.
:b[TAB] -- Will list the buffers.
:b [any partof file name][TAB] -- auto completes the complete file name in the buffer.

Basic configuration of .vimrc
set nocompatible
set bs=2
set shiftwidth //No of spaces to be used for each step of (auto)indent.

Search ∧ Replace:
:%s/abc.*//gc -- remove trailing abc including abc from a line
:%s/abc\zs.*//gc -- remove trailing abc excluding abc
:%s/.*\ze\abc//gc -- remove leading abc excluding abc 
%s/.*abc/abc/ -- remove leading abc excluding abc
:%s/.\{-}abc/abc -- remove leading abc excluding abc fist occurrence
%s/.*\ze\<undefined\>//g  --- remove leading abc excluding undefined.
 
%s/<[^>]*>//gc  -- replace angular bracket contents to different string
g!/<pattern>/d -- delete lines which doesn't match pattern
 
:put =range(1,100)  -- set number on each line


%s/\s\+$//  -- remove  all spaces and tabs at the end of the line

 :.,$s/pattern1/pattern2/gc  -- to find and replace from the current location to end of the file.
:1,.s/pattern1/pattern2/gc -- to find and replace from start of the file to current location.

Add a word at particular coloumn at all lines of the file
 
set ve=all
Go to the column number
Ctrl-v
select number of rows we need to copy.
press r
type the character
escape
Done :-) 

-----------------------------
word completion: 
ctrl-x ctrl-n -- Word completion – forward
CTRL-x CTRL-p -- Word completion – backward

 
Ctrl+x Ctrl+l -- line completion
 
Ctrl+x Ctrl+f -- file completion
  
set dictionary+=/usr/share/dict/words  -- dictionary words

Ctrl+x Ctrl+k -- dictionary word completion
 
 

set nocompatible: This option stops vim from behaving in a strongly vi-compatible way. It should be at the start of any vimrc 
file as it can affect lots of other options which you may want to override.
*****************************************
Syntax highlighting not working in vim:
Just check your vim runtimepath settings by giving following command:
:set rtp
Check whether your runtimepath path info has the same vim version location 
as your vim version if not change the path location to your vim version.
For example:
if the ":set rtp" is 
set runtimepath=~/.vim,/usr/share/vim/vim63/macros/vimfiles,/usr/share/vim/vim63,/usr/share/vim/vim63/macros/vimfiles/after,~/.vim/plugin
but your vim version is vim7.0 then change the runtimepath to following:
set runtimepath=~/.vim,/usr/share/vim/vim70/macros/vimfiles,/usr/share/vim/vim70,/usr/share/vim/vim70/macros/vimfiles/after,~/.vim/plugin
*****************************************
TO grep in VIM:

in ex editor

: grep -rin "label" *
This will give the results in buffer. If you type "ENTER" there, you will be taken to first item in the search list.
To traverse through the all the items of the search. type ":cscope" on ex editor which will open the buffer.
You can use the arrow keys to traverse the buffer & to the item press "ENTER".
Other option to move between the search items is use ":cn" and ":cp"

To get Help from VIM, try
:h

To traverse between the tags use "ctrl-t" and "ctrl-]"

Ctrl-[ can be used as alias to ESC key to enter command mode
:set wildmode=longest,list -- This will find the longest match with the first 'wildchar', then list all matching files with the next.
:set ai -- To set auto indentation.
:history -- to see the history of commands in ex-mode
:history / -- to get search history of vim.
q: -- in the normal mode to open history of commands window. You can search/edit here using regular vim commands. You start in Normal mode. Press 'Enter' to execute a command.
:u -- undo changes.
Ctrl -R -- redo changes.
ga -- show ascii value of character under cursor in decimal, hex, and octal.

Follow the follow commands to indent total file: gg=G
gg -- to go to the top of file
= -- To fix the indentation
G -- Perform the operation till the end of the file.

Ctrl-w c -- Make buffer hidden and close window.
Ctrl-w q -- Quit editing and close window
Ctrl-w o -- Make current window only one on the screen.
Ctrl-w s -- Splits the window Horizontally.
Ctrl-w v -- Splits the window Vertically.
Ctrl-w w -- To navigate between the windows.
Ctrl-w ] -- Split window and jump to tag under cursor
Ctrl-w n -- Create new empty window
Ctrl-w r -- Rotate windows downwards.
Ctrl-w R -- Rotate windows upwards.
CTRL-W x -- Exchange current window with next one
Ctrl-w = -- Make all windows equal height
CTRL-W - -- Decrease current window height
CTRL-W + -- Increase current window height
CTRL-W _ -- Set current window height (default: very high)


 :h quickfix -- Command help for Vim's special mode to speedup the edit-compile-edit cycle. :h csqf -- Help commands for Vim's cscopequickfix commands
VIM on windows:

Saving font & color setting on gvim -
First, specify your font by going to Edit > Select Font (btw, I'm on a Windows machine, so maybe the linux menus are different).

Second, after you've selected your font, enter the command :mkvimrc!. This will write your font choice (and key mappings, etc) to your _vimrc file. This will NOT save your color settings if you're using a theme, however. To tell gVIM to use a color theme at startup, go to the next step.

Third, to specify your color theme, enter the command :e _vimrc. This will open your VIM settings file for editing. Scroll to the bottom of the file and add the line "colors blue". You can specify whatever color theme you want in place of "blue", provided you use the name of the theme itself. No file references are necessary. And it's case-insensitive too, so you could enter "colors Elflord" or "colors elflord" and be fine either way. Just make sure you write the file to disk before you quit gVIM.

Windows GVIM:
.vimrc equivalent file can be found at: Edit > Startup Settings
:vimgrep -- equivalent grep command used
:cs -- to list the grep'd results 
Config:
colorscheme koehler
set wildmode=longest,list

References:
http://www.scribd.com/doc/33619079/VIM-%E2%80%93-VI-Improved
http://www.fprintf.net/vimCheatSheet.html
http://www.linuxquestions.org/questions/programming-9/how-to-save-gvim-settings-307945/
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know 
http://www.lilax.net/textfiles/2001-06-09/vim_multifile.html 
http://www.kevinberridge.com/2008/10/vim-file-editing.html 
http://www.openlogic.com/wazi/bid/188018/Vim-Undo-Tips-and-Trickshttp://www.openlogic.com/wazi/bid/188018/Vim-Undo-Tips-and-Tricks
http://vimdoc.sourceforge.net/htmldoc/cmdline.html#history 
http://vim.wikia.com/wiki/VimTip1572 --- highlight
http://stackoverflow.com/questions/6225291/vim-delete-all-text-in-line-before-after-highlighted-search-pattern 
https://stackoverflow.com/questions/1497958/how-do-i-use-vim-registers?rq=1
https://stackoverflow.com/questions/7103173/vim-how-to-change-the-highlight-color-for-search-hits-and-quickfix-selection

Tuesday, April 6, 2010

cygwin

Backspace problem with vim in cygwin:
a) Make sure you are in nocompatible mode, ":set nocp"
b) Check your 'backspace' setting. ":set bs=2" should allow you to
backspace normally in insert mode.




References:
http://comments.gmane.org/gmane.editors.vim/33436

Thursday, March 25, 2010

Firefox

Firefox shortcuts:

Back one Page: "Backspace"
Go Down One Screen : "PageDown" or "Spacebar"
Go Up One Screen: "PageUp" or "Shift+Spacebar"

References:
http://www.7is7.com/software/firefox/shortcuts.html

Monday, March 22, 2010

Pine

Pico Editor

Pico, short for Pine Composer, started life as the built-in editor for the Pine email program. Lots of people use Pico as a text editor because they also use the friendly Pine program for email.

PINE

By default, Pine automatically checks for new mail every 2.5 minutes. (You can change this time interval with the mail-check-interval option in the SETUP CONFIGURATION screen.) Some system administrators may have globally modified this interval.

When viewing the FOLDER INDEX, you can force Pine to check for new mail by pressing ^L, or if on the last item in the Index, by pressing "N". The eXpunge command will also force a new-mail check. If you would like to have some visual indication of when Pine is checking for new mail, set the enable-mail-check-cue feature and watch for an asterisk to flash in the upper-left-hand corner of the screen. (Two asterisks mean that Pine is check-pointing --saving state changes in-- your INBOX.)

jump to start of line : ctrl-a

jump to end of line : ctrl-e

page-down : ctrl-v

page-up : ctrl-y

jump to bottom : ctrl-w ctrl-v

jump to top : ctrl-w ctrl-y

set mark (for copy) : ctrl-^

cut line (or marked text) : ctrl-k

paste : ctrl-u

delete : ctrl-d

backspace : Backspace

delete : backspace (yup, you read that right, depends on your terminal settings)

wrap text : ctrl-j

search : ctrl-w

replace : (NOTE pico needs to be started with -b for this to work) ctrl-w ctrl-r

spell-check : ctrl-t (note that pico needs to be started with -s ispell for this to work), I add this line to my .profile: alias pico='pico -s ispell' so that this can be done automatically.

get cursor position - ctrl-c

insert an external file : ctrl-r

exit (will prompt to save) : ctrl-x

sort threads : $ h

delete/mark as read all messages : ; then a then a then *


General config in .pinerc:

user-domain=domain.com
default-fcc="{email.domain.com/user=username}Sent Items"
postponed-folder={email.domain.com/user=username}Drafts
rsh-open-timeout=0
inbox-path={email.domain.com/user=username}INBOX
smtp-server=outbound.domain.com


References:

http://www.blogger.com/post-create.g?blogID=5997165761357298829

http://www.washington.edu/pine/


Friday, March 19, 2010

GNU Screen

 Screenrc

caption always
#caption string "%{kw}%-w%{wr}%n %t%{-}%+w"
caption string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "

Ctrl-a : -- will take you to the GNU SCREEN command mode(vim kind of ex mode)

Ctrl-a :altscreen on/off -- To clear/not screen up on exiting from vim/less/man
Ctrl-a :number -- To renumber current terminal with newer one, incase a terminal exist with new number,
                  it   will take the current terminal number.
Ctrl-a :A -- To rename the current window
Ctrl-a :hardcopy -h [filename] -- copy entire contents of scrollback buffer
Ctrl-a :H       Begins/ends logging of the current window to the file "screenlog.n".
Ctrl-a :log [on|off] -- Begins/ends logging of the current window to the file "screenlog.n".
Ctrl-a :logfile filename -- Setting filename for logging.
Ctrl-a :logfile flush [secs] --  is used to set delay between each write to the logfile, by default it’s 10 seconds.

Configuring the Scrollback Buffer

By default, the scrollback buffer only keeps the last 100 lines of text, which is not enough for my typical interaction with Screen. I’ve found a setting of 5000 lines to be more than adequate for my usage. The number of scrollback lines can be configured in your $HOME/.screenrc file, by adding the following line:
defscrollback 5000
This sets the scrollback to 5000 lines.
You can also override this default value when starting screen using the -h [num] option, where num is the number of scrollback lines.
Finally, if you want to change the number of lines of scrollback for a single window, using the “scrollback” command. Hit C-a (Ctrl-A) : to go to the Screen command line and type scrollback num, where num is the number of scrollback lines.
In screen search to turn off case:
C-a :ignorecase off/on
Problem: GNU got struck because of mistakenly pressed "ctrl-s"
Solution: Ctrl+s “tells the system not to send any more data to the screen until a ctrl-q is pressed”. so pressing ctrl-q will solve the problem here :-)
References:
https://bbs.archlinux.org/viewtopic.php?id=55618
https://wiki.archlinux.org/index.php/GNU_Screen
http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/
http://www.gnu.org/software/screen/manual/screen.html
http://aperiodic.net/screen/commands:start 
http://superuser.com/questions/137714/using-screen-commands-like-less-and-man-dont-clear-the-screen-afterwards/137751#137751 
http://serverfault.com/questions/244294/gnu-screen-how-to-re-order-windows-change-the-scroll-shortcut-and-modify-th 
https://github.com/saltycrane/homedir/blob/master/etc/.screenrc

Thursday, March 18, 2010

Finding serial number of PC

On windows:
1. On your Windows PC, activate WMIC (Windows Management Instrumentation Command-line). Open the "Start" menu and choose the "Run" option. In the dialogue box that is opened, type "wmic." If this is the first time you have used WMIC, Windows will install it automatically.
2.Type the serial number request into WMIC. When installed, WMIC will display a command prompt, into which various commands can be typed into. The command to retrieve your PC's serial number is "bios get serialnumber."





Reference:
http://www.ehow.com/how_5794011_serial-number-pc-windows.html

Monday, March 15, 2010

Proxy Server

A proxy server, also known as a "proxy" or "application level gateway", is a computer that sits between a client and a server to intercept requests. There are several uses of a proxy server, but the most common is to speed network traffic by caching pages or files that are requested often. By doing so, the proxy server can deliver the request quickly, only polling the server when required. In this way, a proxy server not only speeds up network traffic, but also relieves server load. Major Internet hubs and Internet Service Providers (ISPs) employ dozens of proxy servers.

With proxy server an enterprise can ensure security, administrative control, and caching service.

A proxy server is associated with or part of a gateway server that separates the enterprise network from the outside network and a firewall server that protects the enterprise network from outside intrusion.

Some proxy servers are a group of applications or servers that block common Internet services. For example, an HTTP proxy intercepts web access, and an SMTP proxy intercepts email.

Note: Do not confuse a proxy server with a NAT (Network Address Translation) device. A proxy server connects to, responds to, and receives traffic from the Internet, acting on behalf of the client computer, while a NAT device transparently changes the origination address of traffic coming through it before passing it to the Internet.

For those who understand the OSI (Open System Interconnection) model of networking, the technical difference between a proxy and a NAT is that the proxy server works on the transport layer (layer 4) or higher of the OSI model, whereas a NAT works on the network layer (layer 3).



References:
http://www.wisegeek.com/what-is-a-proxy-server.htm
http://whatis.techtarget.com/definition/0,,sid9_gci212840,00.html
http://kb.iu.edu/data/ahoo.html

Thursday, March 11, 2010

expect

Expect keywords:
spawn
send
expect
interact
$expect_out(0,string)
$expect_out(buffer)
set timeout
expect eof


EXPECT EXAMLES: 
1. Pattern matching 
#!/usr/bin/expect
set timeout 15
expect "hi"  { send "You said hi\n" } \
     "hello"  { send "Hello to you\n" } \
     "bye"    { send "Goodbye\n" } \
     timeout  { send "I’m fed up\nbye\n" }


2. Expect script to connect to ssh server iteratively:
#!/usr/bin/expect -f
set timeout 3600
set iter 50
for {set i 1} {$i <= $iter} {incr i} {
        puts "SSh Iteration : $i \n"
        spawn ssh admin@192.168.1.4
        expect "Password:"
        send "mail4567\n"
        close $spawn_id
        after 900
}
 

3. Expect example
$ cat test.sh
#!/bin/sh
echo "Whats your name"
read name
echo "Hello $name"Here is expect script "test.exp" to automate the above script#!/usr/bin/expect -f

spawn ./test.sh

expect "Whats your name"
send "RAJA\r"
interact$ expect test.exp
spawn ./test.sh
Whats your name
RAJA
Hello RAJA

4. attaching to gdb server
#!/usr/bin/expect                                                              
spawn telnet 10.64.70.21                                                      
expect "$ " {send "gdbserver :1234 --attach \$(pgrep wncd)\n"}                 
interact


5. Attaching to gdb client:
#!/usr/bin/expect                                                              
spawn /auto/binos-tools/bin/mcp_gdb  -r $env(PWD) -p $env(PWD)/linkfarm/x86_64_cge7/usr/binos/bin/wncd
expect "\(gdb\) " {send "target remote 10.64.70.21:1234\n"}                   
interact  







References:

http://www.tcl.tk/man/expect5.31/expect.1.htmlhttp://www.tcl.tk/man/expect5.31/expect.1.html
http://unstableme.blogspot.com/search/label/Expect

http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html
http://www.thegeekstuff.com/2010/10/expect-examples/http://www.thegeekstuff.com/2010/10/expect-examples/

Monday, March 8, 2010

Port forwarding

There are a couple of concepts you need to know before you can understand port forwarding. I'm going to make a couple broad statements that are almost always true. For simplicity lets assume they are true for now.

1.) Every device on the internet has at least one ip address. The IP address is a number that is used to identify a device. For more information on ip addresses refer to our What is an IP Address page.

2.) Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an ip address to a port on an ip address. For more information on ports refer to our What is a Port page.

3.) A port can only be used by one program at a time.

Now that we've got those general concepts out of the way let's talk about NAT. NAT is an acronym for Network Address Translation. NAT takes one ip address and basically breaks it into many ip addresses.

[img]http://www.portforward.com/help/BasicNetwork.jpg[\img]

Here the external ip address is broken into two internal ip addresses. The first ip address "IP Address1" is the gateway. While "IP Address2" is the ip address of the first computer. Take note that the router has two ip addresses. It has the external ip address, and an internal ip address which acts as the gateway for every computer on the network.

[img]http://www.portforward.com/help/NetworkVisibility.jpg[\img]

Excuse my rough drawing. Computers on the internal network can only "see" internal ip addresses. So computers on the internal network can not send data directly to a computer outside of the network. When a computer on the network wants to send data to a computer outside of the network, it sends the data to the gateway. Remember the gateway is the internal ip address of the router. The router then takes this data and sends it out to the computer on the internet. The router sends the data out of the external ip address. The same thing is true of computers on the internet. A computer outside of the network can not "see" a computer inside of the network. They can only "see" and send data to the external ip address of the router. The router must then decide what to do with this data. Lucky for us NAT takes care of most of the work for us. There are some programs that NAT was not designed to work with, those are the programs we need to set up port forwarding for. Okay take a deep breath! We are on to port forwarding.

Now that you understand the general concepts of a network, explaining port forwarding is easy. When a computer on the internet sends data to the external ip address of the router, the router needs to know what to do with the data. Port Forwarding simply tells the router which computer on the local area network to send the data to. When you have port forwarding rules set up, your router takes the data off of the external ip address:port number and sends that data to an internal ip address:port number. Port Forwarding rules are created per port. So a rule set up for port 53 will only work for port 53.

A port can only be used by one program at a time! Think of how this rule interacts with NAT. Well you've only got one external ip address on your router. When computer 1 is using port 500, it is using port 500 on it's internal ip address. If you have set up a port forwarding rule for computer 1 and port 500, the external ip address's port 500 is also in use. This means that you can only use port 500 on one computer on the network at a time. Using port 500 on two computers at the same time would violate the one program rule, and your data would get messed up. Most routers require you to specify an internal ip address to forward ports to, just for this reason. Some do not, so be aware of this. Port Forwarding rules will only work for one computer at a time!

Reference:
http://portforward.com/help/portforwarding.htm

Friday, February 26, 2010

Firefox

To change the firefox, start from - about:config

How to make firefox ask me to choose whether to open or save links
tools>options>applications ; Find the program that you want changed. Change action to "Always Ask"

Monday, February 8, 2010

Switching & Routing

Difference b/w Switching & Routing.
In short, If packet forwarding is dependent on mac then your doing switching and if it IP then your doing routing.

Difference between L3 switch and a Router.
Router does forwarding through S/W algoritms whereas L3 does through inbuilt ASICs.
In latest trend, any forwarding done in h/w is named as a switch :-).

L2 switch is a bridge which forward the packets based on MAC address.

Switch is faster than a router because forwarding is built in h/w.

bridges can’t block a broadcast (where a data packet is sent to all nodes on a network). Broadcasts can consume a great deal of bandwidth. Routers are able to block broadcasts, so they provide security and assist in bandwidth control.

Switching:
Ethernet is fundamentally what we call a shared technology.And that is, all users of a given LAN segment are fighting for the same amount of bandwidth.

A by-product that we have in any Ethernet network is something called collisions. And this is a result of the fundamental characteristic of how any Ethernet network works.Basically, what happens in an Ethernet network is that many stations are sharing the same segment. So what can happen is any one of these stations can transmit at any given time.And if 2 or more stations try to transmit at the same time, it's going to result in what we call a collision.

It's also important to understand fundamentally how transmissions can occur in the network. There's basically three different ways that we can communicate in the network.
1. Unicast
2. Broadcast
3. Multicast

in shared bandwidth, Broadcasts Consume Bandwidth & Processor Performance.







References:
http://www.e-tutes.com/index.html
http://www.e-tutes.com/lesson8/networking_fundamentals_lesson8_1.htm
http://www.tcpipguide.com/

Sunday, February 7, 2010

Linux

You know how telnet works in linux..

In general xinetd will be listening for general daemons like ssh & telnet. When telnet request comes, xinetd handovers the control to telnetd and it inturn starts login which

xinetd--->telnetd--->login--->shell
xinetd--->sshd--->shell

PAM: Pluggable Authentication Modules
PAM is a library.
Through the PAM we can customize our the authentication methods.
For example: telnet spawns login. login will be having dependency on libpam.so. libpam.so reads the configuration file where we can define our customized authentication method(as a library) or we can use default linux authentication method.

similar to login for telnet, sshd will be having dependency on libpam.so.

To know the installed packages in linux:
Fedora:
#yum list installed 
#rpm -qa
Ubuntun:
#dpkg --get-selections

Linux repositories are at:
#ls /etc/yum.repos.d/*  OR
#cat /etc/yum.conf

Installing firefox in fedora:
http://www.if-not-true-then-false.com/2011/install-firefox-5-on-fedora/ 

To add new search plugin to firefox:
cp cisco.xml /usr/lib64/firefox/searchplugins/




Difference between zombie & orphan process

Tuesday, January 19, 2010

Memory Layout of a C Program

high     --------------
        |               |
        | Arguments and |
        |  environment  |
        |   variables   |
        |               |
        |---------------|
        |     Stack     |<--|--
        |(grow downward)|   |
        |               |   |User
        |               |   |Stack
        |               |   |Frame
        |               |   |
        | (grow upward) |   |( Mind the Gap )
        |      Heap     |<--|--
        |---------------|
        |      BSS      |<-- uninitialized static data(block started by symbol
|||| | | long sum[1000];
|| | |
        |---------------|
        |      Data     |<-- initilized static data(int   maxcount = 99)
        |---------------|
        |      Code     |<-- text segment machine instructions     low  
Stack : where automatic variables are stored, along with information that is
saved each time a function is called. Each time a function is called, the
address of where to return to and certain information about the caller's
environment, such as some of the machine registers, are saved on the stack. The
newly called function then allocates room on the stack for its automatic and
temporary variables. This is how recursive functions in C can work. Each time a
recursive function calls itself, a new stack frame is used, so one set of
variables doesn't interfere with the variables from another instance of the
function.
Text Segment: The text segment contains the actual code to be executed. It's
usually sharable, so multiple instances of a program can share the text segment
to lower memory requirements. This segment is usually marked read-only so a
program can't modify its own instructions.
Initialized Data Segment: This segment contains global variables which are
initialized by the programmer.
Uninitialized Data Segment: Also named "bss" (block started by symbol) which
was an operator used by an old assembler. This segment contains uninitialized
global variables. All variables in this segment are initialized to 0 or NULL
pointers before the program begins to execute.
The stack: The stack is a collection of stack frames which will be described in
the next section. When a new frame needs to be added (as a result of a newly
called function), the stack grows downward.
Every time a function is called, an area of memory is set aside, called a stack frame,
for the new function call. This area of memory holds some crucial information, like:
1. Storage space for all the automatic variables for the newly called function.
2. The line number of the calling function to return to when the called function
returns.
3. The arguments, or parameters, of the called function.
The heap: Most dynamic memory, whether requested via C's malloc() and friends
or C++'s new is doled out to the program from the heap. The C library also gets
dynamic memory for its own personal workspace from the heap as well. As more
memory is requested "on the fly", the heap grows upward.

Constants are stored in text segment since they are non-writeable. However u can make them to writeable by moving them to data segment. gcc provides this functionality
gcc -fwritable-strings sample.c // this will keep constants in data segment

References:
http://discussknowhow.blogspot.com/2008/08/memory-layout-of-c-program-stack-wise.html