'Any way to force ufw to show the status both verbose and numbered?
I can get a non verbose ufw output with numbers (convenient to edit / delete rules based on their number):
pi@raspberrypi:~ $ sudo ufw status numbered verbose
Status: active
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 22/tcp (v6) ALLOW IN Anywhere (v6)
but I cannot get a verbose (to also display the defaults) output numbered:
pi@raspberrypi:~ $ sudo ufw status verbose numbered
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)
Any idea how to get the ufw verbose output, with numbers on the rules (so that I can edit / delete them etc, while being aware of the defaults at the same time?)?
Solution 1:[1]
afaik there is no built-in way to display both. But you can just pipe your verbose output to awk to get both, like:
me:~$ sudo ufw status verbose | awk '{if ($1 !~ /^[0-9]+/) {print $0} else {print (i++)+1 "\t" $0} }'
Result:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
1 80,443/tcp (Nginx Full) ALLOW IN Anywhere
2 ****/tcp ALLOW IN Anywhere
3 80,443/tcp (Nginx Full (v6)) ALLOW IN Anywhere (v6)
4 ****/tcp (v6) ALLOW IN Anywhere (v6)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user3192295 |