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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-18-2012, 11:53 PM
|
#1
|
Member
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105
Rep: 
|
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 .
|
|
|
08-19-2012, 12:17 AM
|
#2
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
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
|
|
|
08-19-2012, 12:25 AM
|
#3
|
Member
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612
Rep: 
|
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.
|
|
|
08-19-2012, 01:03 AM
|
#4
|
Member
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105
Original Poster
Rep: 
|
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 !
|
|
|
08-19-2012, 01:15 AM
|
#5
|
Member
Registered: Apr 2007
Distribution: Ubuntu
Posts: 105
Rep:
|
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 #"
|
|
|
08-19-2012, 01:24 AM
|
#6
|
Member
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105
Original Poster
Rep: 
|
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
|
|
|
08-19-2012, 08:08 AM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,417
|
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.
|
|
|
08-19-2012, 08:14 AM
|
#8
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
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.
|
08-19-2012, 08:35 AM
|
#9
|
Member
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105
Original Poster
Rep: 
|
sorry , for wrong post !
Last edited by tushar_pandey; 08-19-2012 at 08:46 AM.
|
|
|
08-19-2012, 10:53 AM
|
#10
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
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.
|
|
|
08-19-2012, 10:57 AM
|
#11
|
Member
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105
Original Poster
Rep: 
|
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 !
|
|
|
08-19-2012, 11:06 AM
|
#12
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
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.
|
08-19-2012, 11:56 AM
|
#13
|
Moderator
Registered: May 2001
Posts: 29,417
|
Quote:
Originally Posted by Wim Sturkenboom
Also be aware that by using sudo, you basically elevate your privileges to those of a root user.
|
...unless you explicitly "-u" another user.
|
|
|
08-19-2012, 01:48 PM
|
#14
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
That's not the way it was used by OP and that's what I was referring to.
|
|
|
All times are GMT -5. The time now is 06:33 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|