How to enable a system-wide function for users including sudo?

后端 未结 2 2021
独厮守ぢ
独厮守ぢ 2021-01-22 10:12

I want to make a global alias for killprocessatport so I put at the end in /etc/bash.bashrc

fuserfunction() {
    fuser -KILL -k -n tcp         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 10:45

    You can't use an alias or a function in this case. Create an executable script in a location that's on your PATH (as configured by sudo, if your /etc/suoders modifies root's PATH).

    #!/bin/sh
    exec fuser -KILL -k -n tcp "$@"
    

    Save the script, then set its permissions with chmod +x.

提交回复
热议问题