Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
faq:nix [2018/02/13 12:37] – Added some information on binding to ports below 1024 as non-root on Linux, since that question seems to come up from time to time nightfox | faq:nix [2018/02/13 12:41] – [Ports Below 1024 Without Root On Linux] Add reference to Linux non-root page deuce |
---|
| |
===== Ports Below 1024 Without Root On Linux ===== | ===== Ports Below 1024 Without Root On Linux ===== |
| **Question:**\\ |
| How can I bind to network ports below 1024 as a non-root user on Linux? |
| |
| **Answer:**\\ |
By default, Linux does not allow non-root processes to bind to ports below 1024. This was done as a security measure, although some argue that the reasons for this are obsolete. It is often a bad practice to run processes as root unless it's really necessary to do so, and perhaps even more so with an Internet-accessible server. Thus, it is often desirable to run servers on standard ports (below 1024) as a non-root user. You can do so with the setcap command. For example:\\ | By default, Linux does not allow non-root processes to bind to ports below 1024. This was done as a security measure, although some argue that the reasons for this are obsolete. It is often a bad practice to run processes as root unless it's really necessary to do so, and perhaps even more so with an Internet-accessible server. Thus, it is often desirable to run servers on standard ports (below 1024) as a non-root user. You can do so with the setcap command. For example:\\ |
setcap cap_net_bind_service=+ep /sbbs/exec/sbbs | setcap cap_net_bind_service=+ep /sbbs/exec/sbbs |
| |
For more information, see the following:\\ | For more information, see the following:\\ |
| [[howto:linux_non-root]]\\ |
[[https://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-on-linux|StackOverflow: Is there a way for non-root processes to bind to “privileged” ports on Linux?]]\\ | [[https://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-on-linux|StackOverflow: Is there a way for non-root processes to bind to “privileged” ports on Linux?]]\\ |
[[https://www.jumpingbean.co.za/blogs/mark/run-application-port-below-1024-linux|How to bind to ports below 1024 without being root on Linux?]]\\ | [[https://www.jumpingbean.co.za/blogs/mark/run-application-port-below-1024-linux|How to bind to ports below 1024 without being root on Linux?]]\\ |