LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-18-2012, 11:53 PM   #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, 12:17 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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, 12:25 AM   #3
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
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, 01: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, 01: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, 01: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, 08:08 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
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, 08:14 AM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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, 08: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 08:46 AM.
 
Old 08-19-2012, 10:53 AM   #10
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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, 10: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, 11:06 AM   #12
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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 11:08 AM.
 
1 members found this post helpful.
Old 08-19-2012, 11:56 AM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
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, 01:48 PM   #14
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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 02:03 PM
shells? sycamorex Linux - Software 3 11-14-2008 01:15 AM
help on the different shells... JoannesX Programming 2 02-06-2005 11:07 AM
do I need all the shells? helpme0904 Fedora 6 10-01-2004 02:03 PM
Shells andrewtc Linux - Newbie 3 05-01-2003 03:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:36 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
Open Source Consulting | Domain Registration