Author Archive

May 17th, 2011 No comments

Cisco change ssh default port

How to change cisco default port :

g1r5_router(config)#ip ssh port 2000 rotary 1
g1r5_router(config)#line  vty 0 4 
g1r5_router(config-line)#rotary 1
g1r5_router#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...

Now lets try it:

[13:16]vhristev@g1r5:~$uname -a
Darwin g1r5 10.2.0 Darwin Kernel Version 10.2.0: Tue Nov  3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386 i386
[13:16]vhristev@g1r5:~$ssh -p 2000 
vhristev@'s password: 
g1r5_router#sh ver 
Cisco IOS Software, 1841 Software (C1841-ADVIPSERVICESK9-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)
Categories: Всичко друго Tags:

Cisco lab

April 7th, 2011 2 comments

This is one of my labs when I deal with networking.

Categories: Всичко друго Tags:

To be or not to be.

March 29th, 2011 No comments

Categories: Всичко друго Tags:

Gentoo software RAID

March 29th, 2011 No comments

Gentoo Software RAID

Software RAID massives

You can check your RAID/LVM support with this command

cat /boot/config-`uname -r` | egrep 'RAID|LVM'

Kernel Config

 Device Drivers
 Multi-device support (RAID and LVM)
 Multiple devices driver support (RAID and LVM) (MD [=y])
 RAID support (BLK_DEV_MD [=y])

Load modules:

modprobe raid0
modprobe raid1
modprobe raid10

Partitions with “cfdisk”

cfdisk (util-linux-ng
Disk Drive: /dev/sda
Size: 80025280000 bytes, 80.0 GB
Heads: 255   Sectors per Track: 63   Cylinders: 9729
Name               Flags             Part Type        FS Type                   [Label]                Size (MB)
sda1               Boot               Primary         Linux raid autodetect                               115.16
sda2                                  Primary         Linux swap / Solaris                               4087.97
sda3                                  Primary         Linux raid autodetect                             75820.64

Put partiton table from /dev/sda to /dev/sdb /dev/sdc1 /dev/sdd1 (:

sfdisk -d /dev/sda | sfdisk /dev/sdb | sfdisk /dev/sdc | sfdisk /dev/sdd

Create MD devices

cd /dev

!!! Linux can’t boot from software RAID 10 we make new BOOT partition with RAID1

# Create Boot partition
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

#Create Root partition

mdadm --create --verbose /dev/md1 --level=10 --raid-devices=4 /dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3

Watch our RAID creation

watch cat /proc/mdstat
watch -n1 'cat /proc/mdstat'

Update the mdadm config file.

mdadm --detail --scan >> /etc/mdadm.conf


grub> find /boot/grub/stage1

#Install to drive 1

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)

#Install to drive 2

grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)

#Install to drive 3

grub> device (hd0) /dev/sdc
grub> root (hd0,0)
grub> setup (hd0)

#Install to drive 4

grub> device (hd0) /dev/sdd
grub> root (hd0,0)
grub> setup (hd0)

Set grub menu.list

!!!!! change real_root=/dev/md???? whith your RAID ROOT configuration !!!!!!!!

echo -e "default 0\ntimeout 3\n\ntitle=Gentoo Linux (2.6.29-gentoo-r1-VHristev)\nroot (hd0,0)" > /boot/grub/grub.conf
echo "kernel `ls /boot/kernel*` root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/md1 udev" >> /boot/grub/grub.conf
echo "initrd `ls /boot/initramfs*`" >> /boot/grub/grub.conf
grep --invert-match rootfs /proc/mounts > /etc/mtab
Categories: Всичко друго Tags:

Mac OS X create ISO from DVD/CD

March 29th, 2011 No comments

You have DVD with software and you want to install with Parallels/VMware Fusion/Virtual Box but … you don’t want to use your old scribbled disk and we need to convert it to .iso.


[18:31]vhristev@coco-12:~$drutil status
Vendor   Product           Rev
Type: DVD-ROM              Name: /dev/disk1
Sessions: 1                  Tracks: 1
Overwritable:   00:00:00         blocks:        0 /   0.00MB /   0.00MiB
Space Free:   00:00:00         blocks:        0 /   0.00MB /   0.00MiB
Space Used:  348:05:15         blocks:  1566390 /   3.21GB /   2.99GiB
Book Type: DVD-ROM (v1)
[18:31]vhristev@coco-12:~$diskutil umountDisk /dev/disk1
Unmount of all volumes on disk1 was successful
[18:31]vhristev@coco-12:~$dd if=/dev/disk1 of=Solaris_10.iso bs=2048



Categories: Всичко друго Tags:

Reinstalling the host management agents and HA agents on ESXi

March 28th, 2011 No comments

1. Right-click on the ESXi host and click Disconnect. This disconnects the ESXi host from the VirtualCenter Inventory.

2. Log in to ESXi Troubleshooting Mode. For more information, see Tech Support Mode for Emergency Support (1003677).

3. Uninstall the vpxa and aam components from the VMware ESXi host using the following commands:



4. Right-click on the ESXi host and click Connect. This initiates a re-install of the vpxa agent.

5. Add the host to the appropriate cluster. This initiates a re-install of the aam agent.

If the agent fails to automatically install when connecting the ESX host in the vCenter Server:

1. Verify that /tmp/vmware-root exists on the ESX host. vCenter stages the vpxa RPM in this folder. To add this directory, execute:

 mkdir -p /tmp/vmware-root

Categories: ESX, ESX 4.x, VMware, Всичко друго Tags:

Console torrent client (rtorrent)

March 23rd, 2011 1 comment

I really like my rtorrent it is really easy to use it.

Install rtorrent on Mac os x (you need installed ports to use this feature)

[21:05]vhristev@g1r5:~$port search rtorrent
rtorrent @0.8.4 (net)
    console-based BitTorrent client
rtorrent-devel @0.8.5 (net)
    console-based BitTorrent client (development version)
Found 2 ports.
[21:05]vhristev@g1r5:~$sudo port install rtorrent
--->  Computing dependencies for rtorrent
--->  Cleaning rtorrent

How to start downloading torrent file.

My first advice is USE “screen” like me .I am in the office and want to start downloading something.
1.I run screen then i run my rtorrent and voala perfect console torrent client and i don’t have to worry about my connection between office and home (:
2. rtorrent TORRENT_FILE


Im lazy and download this pictures from internet (:


Basic keyboard shortcuts:

    ^q — closes rTorrent, done twice makes the program shutdown.
    Up, down arrows — highlight the downloads.
    Left arrow — returns to the previous screen.
    Right arrow — goes to the next screen.
    a|s|d — increase global upload speed about 1|5|50 KB/s
    A|S|D — increase global download speed about 1|5|50 KB/s
    z|x|c — decrease global upload speed about 1|5|50 KB/s
    Z|X|C — decrease global download speed about 1|5|50 KB/s
    ^S — starts download
    ^D — pauses and resumes the active download
    +|- — changes the download priority of selected torrent.
    Backspace — adds the specified .torrent. After pressing this button write full path or URL of .torrent file. You can use Tab and other tricks from bash.
Categories: Всичко друго Tags:

Sysadmin’s Unixersal Translator

March 16th, 2011 No comments

One day I need to check something on AIX and I didn’t know the right command and this was the site who save my ass.
Here you can find differences in many OS (LInux,HP-UX,Mac OS X,AIX,IRIX,Solaris …etc )

OS differences

Categories: Всичко друго Tags:

VIM rc

March 11th, 2011 No comments

This is my VIM rc which I tune a little bit to have a better look

[17:45]vhristev@g1r5:~/Desktop$cat ~/.vimrc
iab _NAME Valentin Hristev
iab _URL
iab _DATE =strftime("%A, %B %e %Y %I:%M:%S %p %Z")
" Configuration file for vim
set modelines=1         " CVE-2007-2438
set nu
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible        " Use Vim defaults instead of 100% vi compatibility
set backspace=2         " more powerful backspacing
"Vhristev tuning"
set history=5000 "Keep my history in order"
set ruler " I want to see my cursor position"
set title
filetype plugin on
set title
set nowrap
set ignorecase
set smartcase
"set wildmenu"
set clipboard+=nonnamed
set mouse=a
set noerrorbells
set hidden
set wildmenu
set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,
set wildmode=list:longest " turn on wild mode huge list
syntax on
"set cursorcolumn"
set cursorline
set incsearch
set hlsearch
set magic
syn on
set laststatus=2
set lazyredraw
set linespace=0
set list
set report=0
set showcmd
set showmatch
set backspace=indent,eol,start
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

You can find very useful information here –> VIMrc

Categories: Всичко друго Tags:

Tune your bash > .bash_profile | .bashrc | ./etc/profile

March 11th, 2011 No comments

This is very useful things in my Linux = .bashrc and my Mac = .bash_profile

Linux = .bashrc | /etc/profile

I just found this useful link with .bashrc examples bashrc examples
Here is full list for timestamps TIMESTAMPS

Here is my HISTORY section in .bashrc

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize


export PATH
HISTSIZE=100000        # history size use big motherfucker size
HISTFILESIZE=1000      # file log size
HISTCONTROL=erasedups # dont dublucate 
HISTCONTROL=ignorespace #ignorepsaces
DATA=`date`                   # variable for `date`
HISTFILE=~/.bash_history.$DATA  # histfile will look .bash_histori + command `date`

Here is something very useful for me and i put it in my .bashrc
1. random pass generator
2. simple console calculator
3. colours
4. easy access servers with alias

genpasswd() {
        local l=$1
        [ "$l" == "" ] && l=20 
        tr -dc A-Za-z0-9-!@%^*_ < /dev/urandom | head -c ${l} | xargs
function calc () {
        { echo "$*" | bc -l; }
alias ls='ls --color'
# i want my grep to color my search word and exclude my grep command
alias grep='grep -v grep | grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

Lets see it in action :

[14:21]vhristev@hristev:~$ genpasswd
[14:21]vhristev@hristev:~$ calc 54-4
[14:21]vhristev@hristev:~$ ps aux | grep nginx
root      1920  0.0  0.2  27772  1084 ?        Ss   Mar10   0:00 nginx: master process /usr/sbin/nginx
www-data  1921  0.0  0.4  28700  2416 ?        S    Mar10   0:01 nginx: worker process
www-data  1922  0.0  0.4  28536  2280 ?        S    Mar10   0:01 nginx: worker process
www-data  1925  0.0  0.4  28536  2244 ?        S    Mar10   0:02 nginx: worker process
www-data  1926  0.0  0.4  28536  2252 ?        S    Mar10   0:02 nginx: worker process

Why I need put colors in my prompt ?
– We are humans and make mistakes.I remember one day how I execute command on different server and … in fact it was not so big deal but if it was ???
– If you have 1-2 machines its not so useful but if you have 10 or more you may want to put some RED or YELLOW color in your prompt to identify your important servers.

\A – the current time in 24-hour HH:MM format
33[00;31m – RED
33[01;32m – Yellow

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[33[00;31m\]\u@\[33[01;32m\]\h\[33[00m\]:\[33[01;34m\]\w\[33[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[33[0;35m\]\[33[01;33m\][\A]\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

And voalaaa… you get the prettiest bash prompt :
You can see another idea for customize your PS1 prompt

I want to access my servers very easy without typing every time USER/HOSTNAME/PORT in this case i use aliases
syntax= “alias NAME_OF_COMMAND=’real command’
example= alias homepc=’ssh -l root -p 3333′

Now when i put this in my ~/.bashrc and update it (source ~/.bashrc) when i type “homepc” command “ssh -l root -p 3333” will be executed
In action:

Bash special characters codes

    * \a : an ASCII bell character (07)
    * \d : the date in "Weekday Month Date" format (e.g., "Tue May 26")
    * \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
    * \e : an ASCII escape character (033)
    * \h : the hostname up to the first '.'
    * \H : the hostname
    * \j : the number of jobs currently managed by the shell
    * \l : the basename of the shell’s terminal device name
    * \n : newline
    * \r : carriage return
    * \s : the name of the shell, the basename of $0 (the portion following the final slash)
    * \t : the current time in 24-hour HH:MM:SS format
    * \T : the current time in 12-hour HH:MM:SS format
    * \@ : the current time in 12-hour am/pm format
    * \A : the current time in 24-hour HH:MM format
    * \u : the username of the current user
    * \v : the version of bash (e.g., 2.00)
    * \V : the release of bash, version + patch level (e.g., 2.00.0)
    * \w : the current working directory, with $HOME abbreviated with a tilde
    * \W : the basename of the current working directory, with $HOME abbreviated with a tilde
    * \! : the history number of this command
    * \# : the command number of this command
    * \$ : if the effective UID is 0, a #, otherwise a $
    * \nnn : the character corresponding to the octal number nnn
    * \\ : a backslash
    * \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
    * \] : end a sequence of non-printing characters

Here is my MacBook .bash_profile some good function ps and grep some process example = psgrep apache will ps aux | grep apache .

Categories: bash Tags: