Monday, June 21, 2010

Customize Linux Bash Envirenment

Configure .bashrc to customize user’s bash environment.
.bashrc file is locate in the user’s home directory. It contain lots of configurable items which can customize how the bash looks like and how user interactive with bash.
  • Aliases could be configured under ‘#User specific aliases and functions’ in the .bashrc file. After add aliases item in the .bashrc file, user need log-off and log-in the system or restart bash by execute ‘bash’ command in the terminal to active the newly added aliases.
    Aliases example: alias cls=’clear’
  • Bash Prompt could be configured under ‘# Source global definitions’ in the .bashrc file. Environment variable $PS1 which could be change by PS1=’optionsPlusAnything’ is represent the bash prompt. The available options are as following
    • \a an ASCII bell character (07)
    • \d the date in “Weekday Month Date” format
    • (e.g., “Tue May 26”)
    • \e an ASCII escape character (033)
    • \h the hostname up to the first `.’
    • \H the hostname
    • \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
    • \u the username of the current user
    • \v the version of bash (e.g., 2.00)
    • \V the release of bash, version + patchlevel
    • (e.g., 2.00.0)
    • \w the current working directory
    • \W the basename of the current working direc-
    • tory
    • \! 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 con-
    • trol sequence into the prompt
    • \] end a sequence of non-printing characters
  • Configure bash shell options with set/shopt
    set -o check the current bash shell option setting
    set -o bashOption to enable the bashOption
    set +o bashOptioon to disable the bashOption

F-port Anti Virus for Linux

  • Download F-port for Linux workstation from http://www.f-prot.com/products/home_use/linux/ 
  • Extract the downloaded file to the user’s home folder use tar -xvf filename 
  • Enter the extracted folder execute ./install-f-prot.pl then type yes if system ask ln -fs /home/username/f-port/fpscan /usr/sbin/fpscan 
  • Preform a scan by execute fpscan /filepath/to/scan

Monday, June 07, 2010

Restore Ubuntu gnome panel

In the terminal execute following command to restore gnome panel to default setting.
$ gconftool-2 --shutdown
$ rm -rf .gconf/apps/panel
$ pkill gnome-panel

Friday, June 04, 2010

Linux Permission and Owernship

File Permission
chmod permissionNumber fileName
Owner Group Other Users
ExecuteWriteRead ExecuteWriteRead ExecuteWriteRead
124124124


File Ownership
chown userName fileName
chown userName.groupName fileName

Monday, May 24, 2010

Uninstall VMWare Player3.0 on Fedora 12

[root@MyPC resources]# vmware-uninstall
You have gotten this message because you are either downgrading VMware
Workstation, Player, or VIX, or because you attempted to run either
vmware-uninstall or vmware-uninstall-vix.

If you are downgrading, please uninstall all newer versions first, then
install again.

The vmware-uninstall* scripts have been deprecated. Instead, please use
the vmware-installer.

Long form:
vmware-installer --uninstall-product PRODUCT
Short form:
vmware-installer -u PRODUCT

Where PRODUCT is one of vmware-workstation, vmware-player, or vmware-vix.

For a list of which products are installed, you may run:
vmware-installer --list-products
or:
vmware-installer -l


[root@MyPC resources]# vmware-installer -l
Product Name Product Version
====================== ====================
vmware-player 3.0.1.227600
[root@MyPC resources]# vmware-installer --uninstall-product vmware-player

Wednesday, May 19, 2010

Linux LVM Snapshot

LVM Snapshot use smaller logic volume to represent the whole data on the large logic volume and only save the data writing to the original LV when the snapshot LV is mounted. The snapshot LV will be automatically unmount when it is full. Thus the size of the snapshot LV must be larger than the possible data may changed during the time of the snapshot LV mount on the system.It is usfull when execute some script on the live system. For exmple back a database drive when the database still running.

To create a snapshot LV use following command:
# lvcreate -L10G -s -n snapshotName /dev/volgroupName/LVname

To mount a snapshot LV use following command:
# mkdir /mnt/locationName/snapshotLVName
# mount /dev/volgroupName/snapshotLVName /mnt/locationName/snapshotLVName
To backup a LV
tar -pczf /backups/root.tar.gz /mnt/locationName/snapshotLVName


To remove a snapshot LV use following command:

# umount
/mnt/locationName/LVName
# lvremove /dev/ops/dbbackup

Monday, May 10, 2010

Install Mac4Lin on Ubuntu 10.1

  • Download Mac4Lin from http://sourceforge.net/projects/mac4lin/
  • unzip it to a temp folder
  • Make sure you have ~/.themes and ~/.icons if you not install Mac4Lin on Ubuntu 10.1
  • Install Emerald Theme Manager
  • Install Tracker
  • execute Mac4Lin_Install_v1.0.sh
  • Type 'y' and enter when system popup "Do you want to enable Metacity Compositor?"
  • Type 'y' and enter when system popup "The following componenets require root access. You can opt out of installing them as they can be manually installed as well. Would you like to install these components?"
  • Install Avant Window Navigator

Wednesday, January 27, 2010

Fix Kmplayer "class not registered" problem

I have successfully installed kmplayer on Windows 7 Ultimate, however it will pop up an error message "class not registered" After check window troubleshooting message, found the problem was that I have downloaded and installed Adobe flash player from firefox not IE. That case the adobe flash player not active the activeX.

Uninstall Adobe flash player and reinstall it from IE problem fixed.

Friday, January 08, 2010

ISCSI Enterprise Target on RHEL

NAME

/etc/ietd.conf - configuration for iSCSI Enterprise Target Daemon

SYNOPSIS

/etc/ietd.conf

DESCRIPTION

/etc/ietd.conf contains configuration information for the ietd (8) command. This is the place, where you configure your iSCSI targets and daemon defaults. Only lines starting with ‘#’ are ignored. Putting ’#’ in the middle of a line is disallowed. A line may be extended across multiple lines by making the last character a backslash. The "Yes" and "No" for parameter values are case sensitive. The parameter names are case insensitive. The file consists of a global part and zero or more "Target" stanzas. Everything until the first target definition belongs to the global configuration. Here is an example: IncomingUser joe secret OutgoingUser jack secret2 Target iqn.2001-04.com.example:storage.disk2.sys1.xyz IncomingUser jim othersecret OutgoingUser james yetanothersecret Lun 0 Path=/dev/sdc,Type=fileio Lun 1 Sectors=10000,Type=nullio Alias Test HeaderDigest None DataDigest None MaxConnections 1 InitialR2T Yes ImmediateData No MaxRecvDataSegmentLength 8192 MaxXmitDataSegmentLength 8192 MaxBurstLength 262144 FirstBurstLength 65536 DefaultTime2Wait 2 DefaultTime2Retain 20 MaxOutstandingR2T 8 DataPDUInOrder Yes DataSequenceInOrder Yes ErrorRecoveryLevel 0 Stanzas start with the word "Target" and the target name. This name must be a globally unique name, as defined by the iSCSI standard : the "iSCSI Qualified Name". The daemon brings the targets up in the order listed.

GLOBAL OPTIONS

Global Options are case sensitive. [IncomingUser ] The and used during discovery sessions to authenticate iSCSI initiators. Several of those can be specified for discovery. If no IncomingUser is specified, any initiator is allowed to open a discovery session. HINT: RFC 3720 requires to be 12 characters long. This is enforced e.g. by MS Initiator. [OutgoingUser ] The and used during discovery sessions to authenticate the target to initiators. Only one outgoing / combination may be specified. HINT: RFC 3720 requires to be 12 characters long. This is enforced e.g. by MS Initiator. Target iqn..[:] A target definition and the target name. The targets name (the iSCSI Qualified Name ) must be a globally unique name (as defined by the iSCSI standard) and has to start with iqn followed by a single dot. The EUI-64 form is not supported. is the date (year and month) at which the domain is valid. This has to be followed by a single dot and the reversed domain name. The optional - which is freely selectable - has to be separated by a single colon. For further details please check the iSCSI spec. Here is an example: Target iqn.2004-07.com.example.host:storage.disk2.sys1.xyz

TARGET OPTIONS

Target options are also case sensitive. [IncomingUser ] The and used to authenticate the iSCSI initiators to this target. It may be different from the username and password in section GLOBAL OPTIONS, which is used for discovery. If you omit the IncomingUser Option, connections are allowed without authentication. A has to be provided, if there is a given. Specifying several different IncomingUser accounts is supported. [OutgoingUser ] The and used to authenticate this iSCSI target to initiators. Only one OutgoingUser per target is supported. It may be different from the username and password in section GLOBAL OPTIONS, which is used for discovery. A has to be provided, if there is a given. Lun Path=,Type=(fileio|blockio)[,ScsiId=][,ScsiSN=][,IOMode=(wb|ro)] | Sectors=,Type=nullio Parameters after should not contain any blank space character except the first blank space after is needed. This line must occur at least once. The value of can be between 0 and 2^14-1. In fileio mode (default), it defines a mapping between a "Logical Unit Number" and a given device , which can be any block device (including regular block devices like hdX and sdX and virtual block devices like LVM and Software RAID devices) or regular files. In blockio mode, it defines a mapping between a "Logical Unit Number" and a given block device . This mode will perform direct block i/o with the device, bypassing page-cache for all operations. This allows for efficient handling of non- aligned sector transfers (virtualized environments) and large block transfers (media servers). This mode works ideally with high-end storage HBAs and for applications that either do not need caching between application and disk or need the large block throughput. Optionally a can be specified to assign a unique ID to the iSCSI volume. This is useful e.g. in conjunction with a multipath-aware initiator host accessing the same through several targets. The must not exceed 16 characters and controls the content of VPD 0x83. The must not exceed 16 characters and controls the content VPD 0x80. By default, LUNs are writable, employing write-through caching. By setting IOMode to "ro" a LUN can only be accessed read only. Setting IOMode to "wb" will enable write-back caching. Please note that this could lead to data loss e.g. in case of power outages, so it is strongly recommended to use an UPS when enabling write-back caching. NOTE: IOMode "wb" is ignored when employing blockio. In nullio mode, it defines a mapping between a "Logical Unit Number" and an unnamed virtual device with sectors. This is ONLY useful for performance measurement purposes. All writes to this virtual device will be discarded and reads will return random data. [Alias ] This assigns an optional to the target. [HeaderDigest ] Optional. If set to "CRC32C" and the initiator is configured accordingly, the integrity of an iSCSI PDU’s header segments will be protected by a CRC32C checksum. The default is "None". Note that header digests are not supported during discovery sessions. [DataDigest ] Optional. If set to "CRC32C" and the initiator is configured accordingly, the integrity of an iSCSI PDU’s data segment will be protected by a CRC32C checksum. The default is "None". Note that data digests are not supported during discovery sessions. [MaxConnections ] Optional. Has to be set to "1" (in words: one), which is also the default. [InitialR2T ] Optional. If set to "Yes" (default), the initiator has to wait for the target to solicit SCSI data before sending it. Setting it to "No" allows the initiator to send a burst of FirstBurstLength bytes unsolicited right after and/or (depending on the setting of ImmediateData ) together with the command. Thus setting it to "No" may improve performance. [ImmediateData ] Optional. This allows the initiator to append unsolicited data to a command. To achieve better performance, this should be set to "Yes". The default is "No". [MaxRecvDataSegmentLength ] Optional. Sets the maximum data segment length that can be received. The should be set to multiples of PAGE_SIZE. Currently the maximum supported value is 64 * PAGE_SIZE, e.g. 262144 if PAGE_SIZE is 4kB. Configuring too large values may lead to problems allocating sufficient memory, which in turn may lead to SCSI commands timing out at the initiator host. The default value is 8192. [MaxXmitDataSegmentLength ] Optional. Sets the maximum data segment length that can be sent. The actually used is the minimum of MaxXmitDataSegmentLength and the MaxRecvDataSegmentLength announced by the initiator. The should be set to multiples of PAGE_SIZE. Currently the maximum supported value is 64 * PAGE_SIZE, e.g. 262144 if PAGE_SIZE is 4kB. Configuring too large values may lead to problems allocating sufficient memory, which in turn may lead to SCSI commands timing out at the initiator host. The default value is 8192. [MaxBurstLength ] Optional. Sets the maximum amount of either unsolicited or solicited data the initiator may send in a single burst. Any amount of data exceeding this value must be explicitly solicited by the target. The should be set to multiples of PAGE_SIZE. Configuring too large values may lead to problems allocating sufficient memory, which in turn may lead to SCSI commands timing out at the initiator host. The default value is 262144. [FirstBurstLength ] Optional. Sets the amount of unsolicited data the initiator may transmit in the first burst of a transfer either with and/or right after the command, depending on the settings of InitialR2T and ImmediateData should be set to multiples of PAGE_SIZE. Configuring too large values may lead to problems allocating sufficient memory, which in turn may lead to SCSI commands timing out at the initiator host. The default value is 65536. [DefaultTime2Wait ] Currently not supported. [DefaultTime2Retain ] Currently not supported. [MaxOutstandingR2T ] Optional. Controls the maximum number of data transfers the target may request at once, each of up to MaxBurstLength bytes. The default is 1. [DataPDUInOrder ] Optional. Has to be set to "Yes" - which is also the default. [DataSequenceInOrder ] Optional. Has to be set to "Yes" - which is also the default. [ErrorRecoveryLevel ] Optional. Has to be set to "0" (in words: zero), which is also the default. [Wthreads ] Optional. The iSCSI target employs several threads to perform the actual block I/O to the device. Depending on your hardware and your (expected) workload, the number of these threads may be carefully adjusted. The default value of 8 should be sufficient for most purposes. [QueuedCommands ] Optional. This parameter defines a window of commands an initiator may send and that will be buffered by the target. Depending on your hardware and your (expected) workload, the value may be carefully adjusted. The default value of 32 should be sufficient for most purposes.



Show IET ISCSI target information
# cat /proc/net/iet/volume

Show IET ISCSI connected session information
# cat /proc/net/iet/session

Thursday, January 07, 2010

mount ntfs partition in RHEL 5.4

New version RHEL is not officially support NTFS partition. The third party plug in ntfs-3g is needed for mounting NTFS partition in the RHEL. There are a detailed instruction on CentOS wiki http://wiki.centos.org/TipsAndTricks/NTFS?highlight=(ntfs)
Add rpmforge to repository

yum install fuse fuse-ntfs-3g

Sunday, December 27, 2009

Add Windows XP to the GRUB menu

  1. Back up GRUB configuration file.
    cp /boot/grub/menu.lst /root/backup/menu.lst.grub.bak
    cp /boot/grub/menu.lst /boot/grub/menu.lst.bak
  2. Add Windows XP boot up option in the GRUB menu.
    Vi /boot/grub/menu.lst
    add following lines in the menu.lst:
    title Windows XP
    map (hd0) (hd1)
    map (hd1) (hd0)
    root (hd1,0)
    chainloader +1




    Note:
    map (hd0) (hd1)
    map (hd1) (hd0)
    This two lines are called "virtual swap" which can solve windows installed on second harddisk.
    root (hd1,0) (hd1,0)means on second harddisk's first partition.


Saturday, December 26, 2009

Enable Dlink DWA-110 USB Wireless Adapter on CentOs 5.4

Plug in the USB wireless adapter

Check the chipset of the USB wireless adapter by using following command.

[root@localhost sbin]# lsusb
Bus 005 Device 001: ID 0000:0000
Bus 001 Device 004: ID 07d1:3c07 D-Link System Wireless G DWA-110 Adapter

[root@localhost sbin]# lsmod | grep rt
rt73usb 60481 0
crc_itu_t 35265 1 rt73usb
rt2x00usb 47041 1 rt73usb
rt2x00lib 56641 2 rt73usb,rt2x00usb
mac80211 182985 2 rt2x00usb,rt2x00lib
cfg80211 63825 2 rt2x00lib,mac80211

Enable ELRepo
repository

To install ELRepo for RHEL5, CentOS-5 or SL5:

Import the public key:

Install firmware for Dlink DWA-110 wireless adapter:
yum --enablerepo=elrepo install rt73usb-firmware

Open NetworkManager serveice at the system start up:
chkconfig NetworkManager on

service NetworkManager start

Turn off network and wpa_supplicant services at boot time as NetworkManager will in charge the network connections.
chkconfig network off
chkconfig wpa_supplicant off


Reference:

Making Wireless work on your laptop(or desktop) http://wiki.centos.org/HowTos/Laptops/Wireless#head-a7388039af96da5400e599133447452d2ca61fb5


Sunday, November 29, 2009

Linux Running level

There 7 running level in Linux system:
  • rc0.d - System Halted
  • rc1.d - Single User Mode
  • rc2.d - Single User Mode with Networking
  • rc3.d - Multi-User Mode - boot up in text mode
  • rc4.d - Not yet Defined
  • rc5.d - Multi-User Mode - boot up in X Windows
  • rc6.d - Shutdown & Reboot
To check which program are running at which level use command chkconfig --list.

Sunday, November 15, 2009

Usefull word in IT tech doc

A

adjacent: [ә'dʒeisәnt]adj. 毗连的, 邻近的, 连接的 be adjacent to...
anomaly: [ә'nɒmәli] n, anomalous thing; irregularity
anomalous: [ә'nɒmәlәs] adj. different from what is normal; irregular

E

erratic: *[i'rætik] adj, irregular or uneven in movement,quality or behaviors; unreliable

Thursday, October 29, 2009

Let non-root user can reboot linux box

There are one command called sudo could allow normal linux user execute root command. The configuration file or sudo command is /etc/sudoers and the configuration file should only be modified by using visudo command. For example we creat a group called shutdown. Following line will allow all shutdown group user can use sudo shutdown the linux box.

%shutdown ALL=(root) NOPASSWD: /sbin/reboot
%shutdown ALL=(root) NOPASSWD: /sbin/halt
%shutdown ALL=(root) NOPASSWD: /sbin/shutdown

usermod command can add user to other group.

Options:

* -d home directory
* -s starting program (shell)
* -p password
* -g (primary group assigned to the users)
* -G (Other groups the user belongs to)

Example: To add the group 'others' to the user roger

usermod -Gothers roger

chgrp, chown command can change the group. chgrp can be used by normal user

*

chgrp group target1

* chown [-R] newowner filenames


Example:Give permissions as owner to user test.
chown test files.log

Clean up SQL database use command line tools

There are some SQL server command line tools are installed in C:\Program Files\Microsoft SQL Server\80\Tools\Binn folder. OSQL.exe can connect to the database and execute SQL query on it.

The usage of OSQL.exe is
OSQL /u username
system will pop up for password, after authentication. we can type in SQL query and execute them on the server.
for example

To release unused database space:
DBCC SHRINKDATABASE (local, 80 TRUNCATEONLY)
GO

To find a database name:
select db_name(0) [0 is the database index number]
Go

Sunday, October 11, 2009

Juniper Router Interface Naming:


Juniper router interface naming based on model:

  • “media type-FPC number/PIC number/port number” It commonly knows as MM-F/P/T model for M series router.

  • “media type-PIM slot number/virtual PIM number/port number, It commonly knows as MM-F/P/T for J series router. Fixed interface use PIM slot number 0.



FPC - Flexible PIC Concentrator which contain several PIC slots (on M series)

PIC – Physical Interface Card

PIM – Physical Interface Module (on J series) Each PIM contains a network processor that handles some of the packet processing functions.



  • at: ADSL interface;

  • dsc: Virtual interface that discards packets;

  • fxp0: This is an Out of Band (OOB) management Ethernet interface. It is connected to the router's Routing Engine (RE) and can be used for Out of Band management access to the router. It can also be used to send management messages such as syslog or Simple Network Management Protocol (SNMP) traps. This interface is a nontransit interface, which means that traffic cannot enter this interface and exit via a LAN/WAN interface, nor can it enter a LAN/WAN interface and exit through the management interface.

  • fxp1: This is an internal Fast Ethernet or Gigabit Ethernet (depending on the model of router) interface between the RE and the Packet Forwarding Engine (PFE). This interface is never configured but can be helpful when troubleshooting router issues. It is only in application-specific integrated circuit (ASIC) platforms (M/T-series) and not in the virtualized PFE J-series platforms.

  • e1: E1 WAN interface;

  • fe: Fast Ethernet(10/100) LAN interface;

  • ge: Gigabit Ethernet (10/100/1000) LAN interface;

  • gr,gre: Generic touting encapsulation (GRE) interface for tunnel services-this interface is internally generated and not configurable;

  • ip, ipip: IP-over-IP interface-this interface is internally generated and not configurable;

  • ls, lsi: link services interface- this interface is internally generated and not configurable;

  • mt, mtun: Muticast GRE interface-this interface is internally generated and not configurable;

  • pd, pimd: Protocol Independent Multicast(PIM) de-encapsulator interface-this interface is internally generated and not configurable;

  • pe, pime: PIM encapsulator interface-this interface is internally generated and not configurable;

  • pp: Point-to-point Protocol(PPP) interface-used for PPP over Ethernet (PPPoE);

  • se: Serial interface(include EIA230, RS232, RS449, V.35 and X.21 interfaces);

  • sp: Services interface;

  • tap: The tap interface is internally generated and not configurable;

  • t1: T1 (also called DS1) WAN interface;

  • t3: T3 (also called DS3) WAN interface;


Thursday, August 13, 2009

Windows Remote Desktop Firewall Setting

open port 3389 for TCP+UDP connection.

Wednesday, August 12, 2009

Display CPU info in Linux

cat /proc/cpuinfo
cat /proc/meminfo
dmesg
lspci

Sunday, August 02, 2009

Known Attack

zero-day (or zero-hour) attack or threat is a computer threat that tries to exploit computer application vulnerabilities that are unknown to others, undisclosed to the software vendor, or for which no security fix is available. Zero-day exploits (actual code that can use a security hole to carry out an attack) are used or shared by attackers before the software vendor knows about the vulnerability.