LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2012, 12:53 AM   #1
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Rep: Reputation: Disabled
working between 2-shells


i have opened a file using vi in 1st shell ,
now i want to kill it , using my another shell ..... How can i kill it .
 
Old 08-19-2012, 01:17 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Code:
wim@aa0:/boot/grub$ ps -ef |grep vi
wim       2030  2016  0 07:20 pts/1    00:00:00 vi hallo.txt
wim       2032  1849  0 07:20 pts/0    00:00:00 grep vi
wim@aa0:/boot/grub$
will give you the pid of the vi process in the first numeric column; next use kill to kill it
 
Old 08-19-2012, 01:25 AM   #3
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Jessie
Posts: 592

Rep: Reputation: 119Reputation: 119
Do you mean shell or VT (virtual terminal)?

In any case, if you're logged in as the same user in the second VT, kill vi running in the first VT with:
Code:
kill $(pgrep vi)    # or,
pkill vi
Hope it helps.
 
Old 08-19-2012, 02:03 AM   #4
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
see i have 2-accounts ! daa & daa_1

now i have created a file f_1 and use vi to view it , with the help of daa's command prompt , so vi process is un run state !

now i want to kill this process using daa_1's command prompt . how can i do this !
 
Old 08-19-2012, 02:15 AM   #5
es0teric
Member
 
Registered: Apr 2007
Distribution: Ubuntu
Posts: 105

Rep: Reputation: 19
You can kill any process by doing 'ps ax' to find the ID number of the process you want to kill. Once you know that number, just do 'kill #' (where # = PID). If the process doesn't wanna die, do "kill -9 #"
 
Old 08-19-2012, 02:24 AM   #6
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
in my first_account

Code:
daa@daa-Aspire-5740:~/only_for_unix$ vi f_1 &
[4] 5778
in my second_account
Code:
daa_1@daa-Aspire-5740: kill -9 5778 
output is :: operation not permitted
 
Old 08-19-2012, 09:08 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
From account daa_1 issue 'sudo -u daa kill -9 5778'. If that doesn't work then you need to configure Sudo to allow it, but more importantly please don't consider 'kill -9' as the convenient, default way to exit applications as it may leave temporary files when an editor is in edit mode or may deny an application to close its file descriptors properly.
 
Old 08-19-2012, 09:14 AM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Of course you can't do it as another user; that would be a nice mess if anybody in a multi user system can kill the processes of other users. Totally defeats the security model.

The only user that can do this is root, so you need to be root (seeing that you're using ubuntu, sudo will do the trick).

In your case, as you know daa's password
Code:
daa_1@daa-Aspire-5740: su - daa
You will be prompted for daa's password after which you can kill daa's processes.
 
1 members found this post helpful.
Old 08-19-2012, 09:35 AM   #9
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
sorry , for wrong post !

Last edited by tushar_pandey; 08-19-2012 at 09:46 AM.
 
Old 08-19-2012, 11:53 AM   #10
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Nothing to be sorry about. You (and others) can learn from your question and the replies.

If it's solved, please mark it as such using the thread tools above the first post.
 
Old 08-19-2012, 11:57 AM   #11
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
but i find , something from your post
Code:
that would be a nice mess if anybody in a multi user system can kill the processes of other users. Totally defeats the security model.
after it , i changed the mode of my file
Code:
chmod 777 file_name

vi file_name &
after it , i open my second account ! than
Code:
sudo kill -9 file_name
after it , i can delete the file easily !
 
Old 08-19-2012, 12:06 PM   #12
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
In that case you (as daa) give explicit permission to other users (e.g. daa1) to do anything with the file.

Also be aware that by using sudo, you basically elevate your privileges to those of a root user.

I've never never used kill to delete a file; will one day test it.

Last edited by Wim Sturkenboom; 08-19-2012 at 12:08 PM.
 
1 members found this post helpful.
Old 08-19-2012, 12:56 PM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by Wim Sturkenboom View Post
Also be aware that by using sudo, you basically elevate your privileges to those of a root user.
...unless you explicitly "-u" another user.
 
Old 08-19-2012, 02:48 PM   #14
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
That's not the way it was used by OP and that's what I was referring to.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can all shells read all environmental variables set by other shells? carlodelmundo Linux - Newbie 2 07-23-2010 03:03 PM
shells? sycamorex Linux - Software 3 11-14-2008 02:15 AM
help on the different shells... JoannesX Programming 2 02-06-2005 12:07 PM
do I need all the shells? helpme0904 Fedora 6 10-01-2004 03:03 PM
Shells andrewtc Linux - Newbie 3 05-01-2003 04:52 PM


All times are GMT -5. The time now is 01:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration