determine pid from ps -ef | grep something


 
Thread Tools Search this Thread
# 8  
Code:
ps -ef | grep "/var/lib/dpkg/lock" | awk '{print $1}'

will give the PID.

Do a
Code:
ps -ef

and verify that that is the process you wanted to kill before killing it.


cheers,
Devaraj Takhellambam
# 9  
Data

Hello,

the result of your help command line returned "ubuntu" ???

is that a process name ?

if so,

is it possible to kill ubuntu ?
lol
when you kill a process, is it possible to kill it by its name or
how to know the pid of a process when you have the name of it ?

Last edited by DukeNuke2; 05-03-2009 at 02:13 PM..
# 10  
Quote:
Originally Posted by harlock59
if so,

is it possible to kill ubuntu ?
lol
when you kill a process, is it possible to kill it by its name or
how to know the pid of a process when you have the name of it ?
That is not the prcess name but the UID or the user name

yu should get the PID with this

Code:
ps -ef | grep "/var/lib/dpkg/lock" | awk '{print $2}'

cheers,
Devaraj Takhellambam
# 11  
Hammer & Screwdriver

Re-Hello,

if i'm not too stupid, i understood that being logged as ubuntu on the live cd,

the /var/dpkg/lock file was used by me with (linux user account name "ubuntu"). The $1 value is "ubuntu", the $2 should be the pid of the process that is using it, is it right ?
# 12  
You are correct, $1 is the user. If you logged in as ubuntu, then it is you.
$2 is the PID of your process that is using the file /var/dpkg/lock

If things are not clear, do man ps

cheers,
Devaraj Takhellambam
# 13  
the reason why my user account is ubuntu is because i boot on live cd of ubuntu (of course)
unless i make my own ubuntu live cd (which i don't even know anything at it)
every time you use a live cd of it, your default user account will be stated as ubuntu

it is stunning the number of processes that i get using ps -e or -ef on mac os x compared to the number with ubuntu live. but it 's understandable because i used the last version 9 of ubuntu and you can't be as at ease on a live than on a desktop hdd boot installed system.

Last edited by DukeNuke2; 05-03-2009 at 02:13 PM..
# 14  
at
Code:
ps -ef | grep "/var/lib/dpkg/lock" | awk '{print $2}'

i got result: 3058, then i killed
Code:
kill 3058

then i got error:
Code:
bash: kill: (3058) - Aucun processus de ce type
(no such process)

???
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #64
Difficulty: Easy
HTTP uses UDP as the core transport protocol on the Internet.
True or False?

10 More Discussions You Might Find Interesting

1. AIX

How to grep PID and program name from netstat in AIX?

Hi All, I am using netstat on AIX to grep info on all open connections. However, unlike on Linux(Centos), I do not get the PID and program name using netstat on AIX. I need this info to be clubbed along with the information retrieved using netstat version of AIX. Is there a way this can be... (1 Reply)
Discussion started by: Vipin Batra
1 Replies

2. UNIX for Dummies Questions & Answers

Determine uniqueness of pid to name output files

Hi, We've a process on AIX UNIX server which is executed by multiple uses during a day. I wish to create a log file for every time the process is executed. I wish to know how unique are PID(s) on AIX UNIX servers if I were to name the log files with <date> and <PID>? E.g. If I create my... (1 Reply)
Discussion started by: vkumbhakarna
1 Replies

3. Shell Programming and Scripting

Error in finding the PID by grep and assigning to a variable

Hello All, I am facing difficulty in getting the PID value & then assigning it to a variable, kindly help me in resolving the issue. Thanks a lot in advance. The custom utility used inside the Test2.sh will process the file in a batch of 10 lines at once and for efficient memory management,... (3 Replies)
Discussion started by: duddukuri
3 Replies

4. Shell Programming and Scripting

grep PID and collect data ?

I have a file current.csv file 2011/05/06 11:12:20 | 16:guest pid=014782 opened Boards 0, 1, 2, 3 2011/05/06 12:23:13 | 16:guest pid=014782 closed 2011/05/06 12:26:05 | 17:guest pid=022383 opened Boards 0, 1, 2, 3 2011/05/06 20:09:04 | 17:guest pid=022383 closed 2011/05/06... (5 Replies)
Discussion started by: sabercats
5 Replies

5. Shell Programming and Scripting

Using grep to extract PID

Hi unix experts! I need help to solve the following problem: I'm getting the prstat info: stats=`prstat 0 1` #dont worry about how many processes are running I'm aware that no all processes will be listed without the -n (specify number) then I'm doing the following to extract the... (2 Replies)
Discussion started by: sanjaybhatt6
2 Replies

6. Shell Programming and Scripting

how to grep parent process PID in shell scripting

hi all, for an example: $ ps -ef | grep apache | awk '{ print $2, $3 }' 24073 11784 28021 1 28022 1 28038 1 28041 28040 28045 28041 28047 28041 28040 1 28049 28041 28051 28041 28053 28041 28030 1 28054 28041 28055 28041 28056 28041 28057 28041 (5 Replies)
Discussion started by: raghur77
5 Replies

7. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

8. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

9. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

10. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

Featured Tech Videos