Linux ps aux port

How to Use the ps aux Command in Linux?

Linux distributions are mostly managed by using the different command utilities. Likewise, we can manage the running processes on the Linux computer by running the ps command in the terminal. This tutorial is about the usage of the ps command with its aux options in Linux and also provides some knowledge of the below-mentioned:

  • What is the ps Command Utility in Linux?
  • How to Use the ps aux Command Utility in Linux?
  • How to Use the ps Command Utility With the ‘a’ Option?
  • How to Use the ps Command Utility With the ‘u’ Option?
  • How to Use the ps Command Utility With the ‘x’ Option?
  • What is the Usage of the ps Command Utility With the aux Options in Linux?
  • Conclusion

Let’s start with the tutorial!

What is the ps Command Utility in Linux?

The ps command displays the information on the active processes in Linux. This command is useful when you want to manage any process, and prior information to that process is required.

The syntax of the command is provided below:

The functionality of the “ps” command mainly relies on the number of options supported by it. These options are described below:

UNIX Options These are the grouped options and start with the dash (-), for example, (-v).
BSD Options These are not the grouped options and also do not start with any characters, for example, help.
GNU Options These options always start with the double dash (–), for example, the –version.

There are different options that can be displayed by using the command:

The above-mentioned command will display the manual of the ps command.

How to Use the ps aux Command Utility in Linux?

First, we will learn the usage of the ps command in Linux we know that the ps command displays the active processes in Linux and can be executed with the command:

In the output above, we can see a few things whose details are mentioned below:

PID This display the process id of the running processes
TTY This option will displays the terminal screen to which the running process is associated
TIME This displays the time which the process has consumed of CPU in its execution
CMD The full command by which the process has been spawned

The options mentioned above are displayed about the running process when a simple ps command is executed. There are different options that can be used with the ps command, as can be explored following the manual or the link of the ps command article.

Читайте также:  Add end line linux

In this tutorial, we are focused on the usage of three options with the ps command, which are tabulated below:

a This option is used to display the users who are running the processes.
u This option displays some additional useful information about the processes.
x This option displays the processes not associated with any running terminal screen.

We will understand all the options mentioned above one by one.

How to Use the ps Command Utility With the ‘a’ Option?

We will run the ps command with its “a” opinion and observe the output:

In the above output, the additional thing is the “STAT” column which is used to display the state codes of running processes. For example, in the above output, “S” represents the sleep processes, and the “R” is used for the running process.

How to Use the ps Command Utility With the ‘u’ Option?

The next option needed to explain is the “u” option with the ps command. If this option is run with the ps command, then the output will be:

In the output above, the details of the columns are shown below:

USER It displayed the user who is running the proccess.
%CPU It displays the percentage of the CPU which is used by the process.
%MEM It displays the percentage of the RAM which is used by the process.
VSZ It displays the size of the virtual memory occupied by the process.
RSS It displays the size of the physical memory used by the process.
START It displays the size when the process is being initiated.
COMMAND Refers to the command which started the process.

How to Use the ps Command Utility With the ‘x’ Option?

The last option, which will be explained in this tutorial, is the x option with the ps command, and the output by running the ps command with the x is described below:

It can be noted that the output of the ps command with the u option is similar to the option. The difference between both the options is that option a shows the details of the running processes whereas the option x displays the processes which are running but are not associated with any terminal screen.

What is the Usage of the ps Command With the aux Options in Linux?

When the ps command is executed with the aux option, it will display all the information of the processes discussed above. For example, we will run the command:

It has displayed all the useful information of the process which are running on the computer.

Note: The description of all the components of the output is described earlier in a table.

This is all about this tutorial!

Conclusion

To use the ps aux command in Linux, run the “ps” command with “aux” options which are used to display the information of all running processes. This post has provided a brief explanation of the “pas aux” command, and for a better understanding, we have presented the usage of “ps” with all these options separately.

Источник

How to find out which Port number a process is using

I want to be able to find out which port number a process is and filtering the results using a keyword. For example, I may want to quickly find out which port numbers are being used by «node» js apps. This did not work:

netstat tulnap | grep "node" 

By the way, i notice that on osx the command doesnt have a hyphen. Here are the results i got, not useful: Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr

Читайте также:  Connect function in linux

3 Answers 3

This is how I found a solution:

 » lsof -i -P | grep node node 14489 me 12u IPv4 0x. 0t0 TCP *:4000 (LISTEN) 

Also if i knew the port and I was looking for the process name I would:

 » lsof -i :4000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 14489 me 12u IPv4 0x. 0t0 TCP *:terabase (LISTEN) 

Active Internet connections (w/o servers)

Active Internet connections (only servers)

What you’re doing may also never work since GREP is never guaranteed to deliver either no, one, or more than 1 results.

But, in context of your specific case, any process IS actually unique, and has a unique number. So, you must do your search first to find a process number.

Doing a simple grep will still give you either none, one, or more than one process number. But you’ll need to find an additional filter, so that you end up with 1 process number.

If you have 1 process number, you can check port(s) being used by that process.

What makes you think «node» is reported in PS ? It may also not be.

Источник

How to Find Out all the Open Ports in Linux?

How To Find Out All The Open Ports In Linux

In this tutorial, we will learn how to find out all the open ports in Linux.

There are different commands to know which ports are opened such as nmap, netstat, and lsof. But do we know what ports are? Some people might think that it is the gateway to enter the system. There are a lot of myth concepts regarding port numbers. Let’s discuss this in detail.

What is Port number?

There are many services running in the system such as httpd, Hadoop service and so on. How will the network client identify the particular service from the bundle of services running on the system? Whenever we start the web server, instead of creating unique names for each service, a port number is assigned where the service listens for packets. Let’s look at some common ports.

  • Port number of HTTP: 80
  • Port number of SMTP: 25
  • Port number of FTP: 21
  • Port number of DNS: 53

The user can use his own personal port also. The port is internally stored in 2 bytes i.e. 2^16 = 65536. The range of the port number is from 0 to 65535. This is divided into different categories:

  • 0 – 1023: The ports in this range are called well-known ports or system ports.
  • 1024 –49151: The ports in this range are called registered ports or user ports.
  • 49152-65535: The ports in this range are called the Dynamic ports and Private ports.

I hope the concept is clear. Let’s understand how to find out list of the open ports in Linux.

List all the services and their ports

If you want to know the list of all the services with their ports, it can be done using cat command. The file named services in /etc/ directory consists of the name and ports of all the services. It will also display the protocols related to the service. Let’s have a look at command below:

Читайте также:  Linux завершение работы консоль

Services 1

You can see that it has displayed the list of services with their port and protocols.

Find out all the open ports in Linux using netstat command

Earlier, we described how to list all the services. If the user wants to know the find out all the open ports in Linux, we can use the netstat command. It will list all the network connections in the system. Apart from this, it also prints the routing tables, interfaces statistics, and multicast memberships.

For more detail information, check the Linux Official Documentation.

The user will use -lntu option with the netstat command where,

  • -l: It will print only listening sockets
  • -n: It will display the port number
  • -t: It enables the listing of TCP ports.
  • -u: It enables the listing of UDP ports.

Let’s have a look at the command below:

Netstat 1

Display the running ports using ss command

Earlier we used netstat command to display the running ports. Here, we are using the ss command to do so. You might be thinking that what is the difference between both of them.

The ss command is the substitute of the netstat command. Although it is similar to the netstat command, it displays more information. It is used to track TCP connections and sockets. The ss is included in the iproute2 package while netstat uses /proc/net/tcp to gather the information about the system network.

Let’s have a look at the following command:

Ss

The significance of -lntu is described above in the netstat command.

Find out all the open ports in Linux using lsof command

Earlier, we discussed how to list the ports using netstat command and ss command. Both were used to display the running services. Here, we will discuss about lsof command. The LSOF stands for List open files. This command is used to list all the open files and processes in the system. It is used in Unix-Linux operating system.

Let’s have a look at the command below:

sudo lsof -i -P -n | grep LISTEN

Lsof

The options associated with this command are:

  • -i: It will list all the running process of specific ports
  • -P: It will convert the port numbers to port names for network files.
  • -n: It will convert the network names to hostnames for network files.

Grep command is used to search for the particular word. As here it will print the ports which are in LISTEN state.

Find out all the open ports using the ps Command

Earlier, we used lsof command to print the ports. Here we will discuss the ps command. The ps command is used to display the information related to the running process in the system. Here, we will use ps -aux command which will print all those processes that are owned by the user. Remember, using “ps aux” will print the warning.

Let’s have a look at the following command:

Ps Command

Conclusion

We have discussed how to find out all the open ports in Linux using ps, netstat, lsof and ss command. Since most of the commands have usage apart from what’s described here, go ahead use the man pages by using the man command in Linux. We hope the concept is cleared. If you face any issues, do let us know in the comments.

Источник

Оцените статью
Adblock
detector