Thursday, August 20, 2009

Linux Commands & Related

How to find the command that started a process......

It's easy stuff (again). This was the first thing i tried in the morning - I got up, logged in to my comp, started putty and tried quite a few options to figure out how to do it -- googled it out too --

Example : lets say if i ran a command like "service testservice start" in linux and it started a java process. If i do a ps -ef in the command line it gives me all the java processes running in the system. Now given the pids of these processes is there a way for me to figure out what was which of the pids correspond to "service testservice start" --

well, i tried the following first :

ps -ww -fp
ps -o "%u : %U : %p : %a"
cat /proc/pid/cmdline
ps -aux

but none of them provided the actual solution -- looks like pargs in solaris gives the command directly - but how does it happen in linux ? I got this solution from a friend.

run ps -ef command - it gives the process id and also gives the parent id of the process - now run a "ps ppid" where ppid corresponds to the parent pid - that gives the solution to the problem.

This was to figure out a command that was starting a tomcat process - there are quite a few eurekas about tomcat itself .. will consolidate and put them up, hopefully :)
How to know who all are connected to linux machine and what they are doing :

Is there a way to find out who all are logged into the machine and what they are doing ?? If you are working on a machine that is shared by multiple people and want to know who all are using right now and what they are doing - is there a way ?

w command in linux provides the information. ( http://linux.about.com/library/cmd/blcmdl1_w.htm) Also wall command can be used to send a broadcast message.

List of installed rpm's :a couple of days back i was trying to find the command that provides the list of rpm's installed on a linux box - if you have yum repository in the machine, then the way to do it is : yum list installed would do the job for you.

rpm -qa provides all the information about the rpm's but does not provide the versioning information explicitly - i was looking for version information explicitly - with some help figured out that this is the way it works :

rpm -qa --queryformat "%-30{NAME} %10{DISTRIBUTION} %10{VERSION}\n"

Using netcat and tar for network file transfer

some easy file transfer

http://www.screenage.de/blog/2007/12/30/using-netcat-and-tar-for-network-file-transfer/


No comments:

Post a Comment