How to delete ufw rule by number without prompt

105 Views Asked by At
root@mail:~# ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
...
        
[16] 22                         ALLOW IN    82.133.xx.yy              
[17] 25                         ALLOW IN    Anywhere                  
[18] 443                        ALLOW IN    Anywhere                  
[19] 993                        ALLOW IN    Anywhere                  
[20] 587                        ALLOW IN    Anywhere                  
[21] 22/tcp                     ALLOW IN    82.133.xx.zz             
[22] 25 (v6)                    ALLOW IN    Anywhere (v6)             
[23] 443 (v6)                   ALLOW IN    Anywhere (v6)             
[24] 993 (v6)                   ALLOW IN    Anywhere (v6)             
[25] 587 (v6)                   ALLOW IN    Anywhere (v6) 
# root@mail:~# ufw delete 16
Deleting:
 allow from 80.133.xx.yy to any port 22
Proceed with operation (y|n)? 

How can I suppress being prompted, especially when executing the command in a shell script?

1

There are 1 best solutions below

0
Krischu On

I found a solution :

ufw delete 16 <<EOF
y
EOF