A
A
Alexander Nazarov2017-09-06 19:23:54
C++ / C#
Alexander Nazarov, 2017-09-06 19:23:54

How to use grep to display all the ports that are used by programs running as a specific user?

How to use grep to display all the ports that are used by programs running as a specific user?
Command: netstat -natpdisplays all ports in use, and how to use grep to compose a command so that only the user's ports can be displayed.
For example! The user "Vasya" launched two programs using ports 443 and 80, and the user "Petya" launched a program that uses ports 22 and 21. How to grep the terminal to see the ports used by the program running on behalf of "Petya".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
goldolov_na, 2019-05-18
@goldolov_na

int i;
        int tk;
        string c;
        private void Button1_Click(object sender, EventArgs e)
        {
            i = 300;
            c ="5:00";
            
            label1.Text = c;
            timer1.Interval = 1000;
            timer1.Enabled = true;
            timer1.Start();
        }

        private void Timer1_Tick(object sender, EventArgs e)
        {
            
            tk = --i;
            TimeSpan span = TimeSpan.FromMinutes(tk);
            string label = span.ToString(@"hh\:mm");
            label1.Text = label.ToString();
            if (i < 0)
                timer1.Stop();
        }

A
Andrey Zubkov, 2017-09-06
@wergio

lsof -i | grep Vasya

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question