Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, August 13, 2012

RPM querry packages and there build arch

Most of the time rpm shows is the package name - version, but strips the build arch, ie. i386 or x86_64. Hence what we see are 2 similar package names and we wondering what is going on :)


$ rpm -qf /usr/bin/lsb_release
redhat-lsb-4.0-2.1.4.el5
redhat-lsb-4.0-2.1.4.el5

here is a way to see the arch use '--qf "%{n}-%{v}-%{r}-%{arch}\n"'


$ rpm -qf /usr/bin/lsb_release --qf "%{n}-%{v}-%{r}-%{arch}\n"
redhat-lsb-4.0-2.1.4.el5-x86_64
redhat-lsb-4.0-2.1.4.el5-i386






Tuesday, July 12, 2011

converting to world date/timezones on linux, with the humble date

Playing with dates in linux, our humble date is well equipped.

  • Want the IST date, in case your host is a PDT/UTC one.
#TZ="Asia/Calcutta" date
  • Want a specific date (older)
# TZ="Asia/Calcutta" date -d "2011-07-10 19:58 PDT"
Mon Jul 11 08:28:00 IST 2011
  • Other way
# TZ="America/Los_Angeles" date -d "2011-07-10 7:58 IST"
Sat Jul 9 19:28:00 PDT 2011
  • If you need to find all the valid country specific timezone constants :
# ls -l /usr/share/zoneinfo/{continent}/{city}

  • Here is something cool you can do at your bash prompt:
PS1="[\$(TZ=\"Asia/Calcutta\" date +%D-%k:%M:%S) IST, \$(TZ=\"America/Los_Angeles\" date +%D-%k:%M:%S) PDT]"
PS1="$PS1\[\e[36m\]\u\[\e[0m\]"
PS1="$PS1@"

Shows me this
[07/12/11-17:32:24 IST, 07/12/11- 5:02:24 PDT]myname@myhost]$

Monday, February 28, 2011

lsof is magical

Here is a link, which is kind of primer for lsof, since it has examples.

Here are some examples I have come across which are interesting and cool.

kill -9 `lsof -t -c sshd +f -- /dev/md2`
I want to kill all process which connects to my sshd, and are accessing raid /dev/md2. ensures no one is connected via ssh and is using the drive. I can then safely shut down sshd.


lsof -t -c java -a -u -a +f -- /dev/md2
this is a combination of
-c command
-a and
-u userid
-a and (another and)
+f file accessing raid disk.


lsof +f -- /var/log
everything accessing

you send a HUP to all process accessing /var/log, generally daemons accessing logs
kill -HUP `lsof +f -- /var/log`


lsof -i| grep LISTEN
all that your host is listening (-i is for tcp connections)

who is connected on port 6014
lsof -i:6014

lsof -i:22 -a -u
all those connected to port 22 and having remember if you do not specify -a, it becomes an or and that would mean any thing accessed by

# lsof -i:22 -a -u *uid* | wc -l
14

# lsof -i:22 -u *uid* | wc -l
1228

remeber -t is for terse, it understands, that you only are interested in the process id.

# lsof -t -i:22 -u *uid* | wc -l
100

even thoud *uid* user was accessing tons of files etc. he is running 100 process which are the handles to all those activity.

enjoy!




Thursday, February 17, 2011

Collection of links collected on monitoring/investigating memory on linux boxes

http://ktown.kde.org/~seli/memory/analysis.html
http://www.berthels.co.uk/exmap/doc.html
http://valgrind.org/docs/manual/QuickStart.html
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html



http://stackoverflow.com/about
http://blekko.com/

VIM issues with powerline

What to do if you get this annoying issue - vi requirements.txt ...