18 Jul, 2008  |  Posted by Danesh  |  in HowTo, Linux

Here’s an easy way to get the pid of a running process.

Running the “pidof” command will return the pid(s) for a running program. See sample below,

danny@pandora:~> pidof syslog-ng
2043
danny@pandora:~> pidof acpid
2045
danny@pandora:~> pidof /usr/bin/firefox
14408
danny@pandora:~> pidof /usr/bin/compiz
27164
danny@pandora:~> pidof /bin/bash
27011 17339 16792 16477 15151 14403

Simple right!?

19 Jun, 2008  |  Posted by Danesh  |  in HowTo, Linux

Here’s a quick way to reload your bachrc file without having to invoke a new shell.

[root@bambee]# source ~/.bashrc

or

[root@bambee]# . ~/.bashrc

18 Mar, 2008  |  Posted by Danesh  |  in HowTo, Linux, hacks

Recently I wrote about implementing session timeouts on Linux. For admin’s who know what they are doing(most times) this can sometimes be an annoying experience.

There’s a simple noop script over at bashcurescancer to help work around session timeouts. This will work for ssh and also the default virtual consoles.

 

 

Watch noop in action.

[youtube]http://www.youtube.com/watch?v=BeBvp5gEyGU[/youtube]

Source: BashCuresCancer

21 Aug, 2007  |  Posted by Danesh  |  in Linux

My Firefox freezes up when I have too many flash videos loading at the same time. Wrote a simple script to restart Firefox every time this happens.

#!/bin/bash
#simple script to kill and restart firefox
#20th August 2007
#Writen by Danesh aka Danny
#http://thedaneshproject.com
#
#look for the firefox PID
PID=`ps -ef | grep firefox-bin | grep -v grep | awk ‘{print $2}’`
#locate firefox executable
FIRE=`which firefox`
#kill firefox
CMD=�kill -9 $PID�
`$CMD`
#pause for 2 seconds
`sleep 2`
#start firefox
CMD=�$FIRE�
`$CMD &`
#End of script

I will be adding more functionality to the script in the future. Once sure feature will be the ability to choose either to kill all running instances or just kill a specific instance.