LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   working between 2-shells (https://www.linuxquestions.org/questions/linux-newbie-8/working-between-2-shells-4175422844/)

tushar_pandey 08-18-2012 11:53 PM

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 .

Wim Sturkenboom 08-19-2012 12:17 AM

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

towheedm 08-19-2012 12:25 AM

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.

tushar_pandey 08-19-2012 01:03 AM

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 !

es0teric 08-19-2012 01:15 AM

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 #"

tushar_pandey 08-19-2012 01:24 AM

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


unSpawn 08-19-2012 08:08 AM

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.

Wim Sturkenboom 08-19-2012 08:14 AM

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.

tushar_pandey 08-19-2012 08:35 AM

sorry , for wrong post !

Wim Sturkenboom 08-19-2012 10:53 AM

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.

tushar_pandey 08-19-2012 10:57 AM

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 !

Wim Sturkenboom 08-19-2012 11:06 AM

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.

unSpawn 08-19-2012 11:56 AM

Quote:

Originally Posted by Wim Sturkenboom (Post 4758339)
Also be aware that by using sudo, you basically elevate your privileges to those of a root user.

...unless you explicitly "-u" another user.

Wim Sturkenboom 08-19-2012 01:48 PM

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 10:34 PM.