C:\Users\ambars>tasklist /m /fi "modules eq msvcrt.dll"
Image Name PID Modules
========================= ======== ============================================
csrss.exe 748 ntdll.dll, CSRSRV.dll, basesrv.DLL,
USP10.dll, msvcrt.dll, sxssrv.DLL, sxs.dll,
RPCRT4.dll, CRYPTBASE.dll
wininit.exe 800 ntdll.dll, kernel32.dll, KERNELBASE.dll,
USER32.dll, GDI32.dll, LPK.dll, USP10.dll,
msvcrt.dll, RPCRT4.dll, sechost.dll,
csrss.exe 808 ntdll.dll, CSRSRV.dll, basesrv.DLL,
USP10.dll, msvcrt.dll, sxssrv.DLL, sxs.dll,
RPCRT4.dll, CRYPTBASE.dll
[SNIP/]
petrichor (/'pe - tri - kor'/) is the familiar scent of rain on dry earth
this tech blog is the wafting fragrance of my geeky outpourings, one post at a time
Saturday, October 16, 2010
windows: which processes have loaded xyz.dll?
Thursday, October 14, 2010
vim: how to record and replay macros
- Start recording: press ‘q’
- Choose a macro register: press ‘a’ to select ‘a’ as a location to save the macro to. You will see “recording” at the bottom left of the vim window.
- Perform editing actions: for example, suppose you want to delete any line containing the string, “Stage:” You can do this by pressing:
Esc /Stage: dd
- Stop recording: press ‘q’
- Choose a macro register: In our case, we want the macro we just saved to register ‘a’.
- Repeat the saved macro: by pressing “@[register_name]” which in our case is:
@a
- Multiple-repeat: press “[count]@[register_name]”, for example:
8@a
linux: which process is listening on port X?
Discovered a new tool, ss, to view "socket statistics. From the man page:
Name
ss - another utility to investigate sockets
Synopsis
ss [options] [ FILTER ]
Description
ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP information than state than other tools.
[root@g2aqa3br1.qai ~]# ss -t State Recv-Q Send-Q Local Address:Port Peer Address:Port ESTAB 0 0 127.0.0.1:56227 127.0.0.1:6802 ESTAB 0 0 127.0.0.1:56228 127.0.0.1:6802 ESTAB 0 0 172.29.8.131:38140 10.230.6.27:ldaps ESTAB 0 0 172.29.8.131:38142 10.230.6.27:ldaps
reference: http://linux.die.net/man/8/ss
[root@g2aqa3br1.qai ~]# netstat -plunt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 ::ffff:172.29.8.131:1098 :::* LISTEN 18572/java tcp 0 0 :::1099 :::* LISTEN 18572/java tcp 0 0 :::80 :::* LISTEN 26695/httpd tcp 0 0 :::22 :::* LISTEN 7327/sshd tcp 0 0 :::443 :::* LISTEN 26695/httpd udp 2616 0 0.0.0.0:514 0.0.0.0:* 6898/syslogd [root@g2aqa3br1.qai ~]# ps 26695 PID TTY STAT TIME COMMAND 26695 ? SNs 0:00 /opt/ec/apache2/bin/httpd -d /opt/ec/apache2 -f /opt/ec/broker/conf/httpd.conf -k start -DSSL
reference:
http://www.cyberciti.biz/faq/find-out-which-service-listening-specific-port
Wednesday, October 13, 2010
linux: my usual ~/.bashrc file
This is the typical ~/.bashrc file I use, especially on cygwin/mintty on Windows boxes. It's work-in-progress and keeps evolving.
Note the handy little shell function, tailHelpAlert, that was designed to run on cygwin, on the Windows box where HelpAlert is running. It determines which is the correct (i.e. most recent) HelpAlert log, and then tails it. You don't have to know which build of HelpAlert you're running, or which temp directory the logs are going to right now.
Another handy little utility is the diskhoggers alias which is a cute little bit of nixcraft (works only on RPM-based distros, of course) to determine which packages (i.e. RPMs) are hogging the most disk space. Very handy when you're critically short of HDD real estate and want to remove junk and clutter quickly.
# ################
# My Section:
# ################
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
export HISTSIZE=5000
export HISTFILESIZE=2000
export HISTLENGTH=50000
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoredups:ignorespace
# http://serverfault.com/questions/72456/stop-bash-tab-completion-from-thinking-i-want-to-cd-into-svn-directories
# Stop bash tab completion from thinking I want to cd into .svn directories
export FIGNORE=svn
alias ls='ls -hF --color=tty' # classify files in colour
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias ll='ls -l' # long list
alias la='ls -A' # all but . and ..
alias l='ls -CF' #
# shortcut to see which RPMs are taking the most disk space
alias diskhoggers='rpm -qa --qf "%10{SIZE}\t%{NAME}\n" | sort -n'
# shell prompt
export PS1="[\e[2;33m\u@mintty\e[m \e[0;33m\t\e[m \w] \$ "
#function to tail the correct HA logs automatically
function tailHelpAlert
{
# NOTE: correct the following logs path for your system:
g2aLogsDir=/cygdrive/c/Users/ambars/AppData/Local/Temp/CitrixLogs/GoToAssist/
#find out the correct build number
build_dir=`cd $g2aLogsDir; ls -1t | head -n 1`
cd $g2aLogsDir/$build_dir
targetdir=`ls -1t | head -n 1`
cd $targetdir
tail -f GoToAssist*
}
Friday, September 24, 2010
favorite shell prompt in BASH
Here’s my typical prompt in mintty/cygwin:
[ambars@mintty 11:54:28 ~] $
And here’s the code: simply append to ~/.bashrc:
export PS1="[\u@mintty \e[0;33m\t\e[m \w] \$ "
Source:
Bash Shell PS1: 10 Examples to Make Your Linux Prompt like Angelina Jolie
Thursday, September 23, 2010
windows: powertools that replace the plain old netstat command
- currports: powerful, easy-to-use and free! Can filter processes. A perfect replacement for port explorer.
- tcpview (sysinternals)
- procmon (sysinternals)
- port explorer (Trialware, old favorite. Development has long stopped since the parent company seems to be dead. Also redundant now, thanks to the above free options)
Sunday, September 5, 2010
network basics: how NAT works
In A Nutshell : Example
- A host at private IP address 192.168.0.2 on the private network may ask for a connection to a remote host on the public network.
- The initial packet has the address 192.168.0.2:15345.
- The PAT device (which we assume has a public IP of 1.2.3.4) may arbitrarily translate this source address:port pair to 1.2.3.4:16529, making an entry in its internal table that port 16529 being used for a connection by 192.168.0.2 on the private network, with port 15345.
- When a packet is received from the public network by the PAT device for address 1.2.3.4:16529 the packet is forwarded to 192.168.0.2:15345.
Port Address Translation (PAT)
Port Address Translation (PAT) is a feature of a network device that translates TCP or UDP communications made between hosts on a private network and hosts on a public network. It allows a single public IP address to be used by many hosts on a private network, which is usually a Local Area Network or LAN.A PAT device transparently modifies IP packets as they pass through it. The modifications make all the packets which it sends to the public network from the multiple hosts on the private network appear to originate from a single host, (the PAT device) on the public network.
Translation of the Endpoint
With PAT, all communication sent to external hosts actually contain the external IP address and port information of the PAT device instead of internal host IPs or port numbers.- When a computer on the private (internal) network sends a packet to the external network, the PAT device replaces the internal IP address in the source field of the packet header (sender's address) with the external IP address of the PAT device. It then assigns the connection a port number from a pool of available ports, inserting this port number in the source port field (much like the post office box number), and forwards the packet to the external network. The PAT device then makes an entry in a translation table containing the internal IP address, original source port, and the translated source port. Subsequent packets from the same connection are translated to the same port number.
- The computer receiving a packet that has undergone PAT establishes a connection to the port and IP address specified in the altered packet, oblivious to the fact that the supplied address is being translated (analogous to using a post office box number).
- A packet coming from the external network is mapped to a corresponding internal IP address and port number from the translation table, replacing the external IP address and port number in the incoming packet header (similar to the translation from post office box number to street address). The packet is then forwarded over the inside network. Otherwise, if the destination port number of the incoming packet is not found in the translation table, the packet is dropped or rejected because the PAT device doesn't know where to send it.