How to kill comand in terminal in linux/ubuntu

388 views Asked by At

less

Hi my homework is to " end operation of less browsers" using fuser, so i assume i need to close terminal running less comand using kill. I wrote in terminal sudo fuser -v -k -i . and i have some list. How using that i can kill less comand whcih is in the image below?

2

There are 2 answers

0
Anton Krug On

Not going to get you a full answer as this is homework.

Could you use fuser in a similar way that ps? There are often smarter ways doing these, but noticed often this grep/cut approach works in many places. For example when I want to see processes of specific name I grep the output by the string 'less'

ps -fax | grep less

Then pipe it to cut (or awk) to get a specific field (the process number)

https://man7.org/linux/man-pages/man1/cut.1.html

And then wrap it in the backticks to be fed into the kill command. Example to find java process and kill it:

kill `ps aux | grep 'java' | head -1 | cut -d " " -f 2`

or

ps aux | grep 'java' | head -1 | cut -d " " -f 2 | xargs kill

Can you use similar ideas to your problem?

0
Matthew On

Ok so after trying all of your answers i didn't have idea what was wrong but i asked my teacher about it. The exercise was so badly explained that i explained here very bad too. All i had to do was to write fuser -k plikczwarty.txt. I am very sorry for your wasted time.