how to kill all processed from "lsof -i" [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How do I kill all processes returned from the following?
lsof -i
I have tried the following to no avail:
lsof -i | awk '{print $2}' | kill

kill takes PID's as its arguments whereas when you pipe it, it goes to the stdin of kill.
Pass them as arguments:
kill $(lsof -i | awk '{print $2}')

Related

How to get from a file exactly what I want in Linux? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
How to get from a file exactly what I want in Linux?
I have: 123456789012,refid2141,test1,test2,test3 and I want this: 123456789012 or 123456789012 test3.
$ echo "123456789012,refid2141,test1,test2,test3" | awk -F "," '{print $1}'
123456789012
$ echo "123456789012,refid2141,test1,test2,test3" | awk -F "," '{printf("%s, %s", $1,$5)}'
123456789012, test3
foo.csv:
123456789012,refid2141,test1,test2,test3
import csv
with open("foo.csv", "rt") as fd:
data = list(csv.reader(fd))
print(data[0][0])
For a bash solution:
cat foo.csv | cut -d',' -f1

Highest CPU utilisation process in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I want find highest cpu utilisation process.I am using
ps -aux|awk -F " " '{print $2" ,"$3}'|sort -r | head -5
Please help me if this is right or wrong command.I am getting 'Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ'
ps aux --sort %cpu | tail -n 1
user 5627 7.6 16.0 1928396 1331680 ? Sl Mar12 120:58 /opt/firefox/firefox
-n 1 gives the highest, adjust number to give highest x processes. Tail because default (+) for --sort is lowest to highest.
To get just the top cpu itself though that's not particularly useful:
ps aux --sort %cpu | tail -n 1 |awk '{print $3}'
7.6
To get it with the headers use highest to lowest (-) sort:
ps aux --sort -%cpu | head -n 2
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
user 5627 7.6 16.0 1928396 1331680 ? Sl Mar12 120:58 /opt/firefox/firefox

What do the fields in ls -ali output mean [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
The ls -ali shell command shows the following output:
933442 -rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe
What are all the fields in the preceding display?
+--------------+------------------+-----------------+-------+-------+------+-------+-----+-------+-----------+
| index number | file permissions | number of links | owner | group | size | month | day | time | filename |
+--------------+------------------+-----------------+-------+-------+------+-------+-----+-------+-----------+
| 933442 | -rwxrw-r-- | 10 | root | root | 2048 | Jan | 13 | 07:11 | afile.exe |
+--------------+------------------+-----------------+-------+-------+------+-------+-----+-------+-----------+
Note: month, day and time is the date of last modification.

Command for finding process using too much CPU [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What command can I use to find a process that's using a lot of CPU? Can I do this without installing something new?
Or using a few other utils you could do:
ps aux | sort -rk 3,3 | head -n 5
Change the value of head to get the number of processes you want to see.
Try doing this :
top -b -n1 -c
And if you want the process that takes the most %CPU times :
top -b -n1 -c | awk '/PID *USER/{print;getline;print}'
or
top -b -n1 -c | grep -A 2 '^$'

Linux command df extract "name" and "available space" [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How can extract only "name" and "available space" from df linux command.
You can use...
df | tail -n +2 | awk '{ print $1, $4 }'
...assuming you don't want the headers too. If you do, remove the tail.
We are piping df's output into tail, where we cut the first line off (the headers), and then pipe that into awk, using it to print the first and fourth columns.
Assuming name and available space are 1st and 4th columns:
df | awk '{print $1, $4}'
the traditional approach would be
df | awk '{printf "%-15s%-8s\n",$1,$5}'

Resources