Hello, I’m trying to understand why I don’t have full permission by using echo and cat.
I have here a some version of command where only version 3 works, can someone explain to me why the other don’t work?
I’m in the wheel group and I add my self to the sudoers file…
Version 1
if [[ -f /etc/fail2ban/jail.local ]]; then
sudo cat >/etc/fail2ban/jail.local <<<"
[DEFAULT]
bantime = 1d
[sshd]
enabled = true"
fi
Version 2
if [[ ! -f /etc/fail2ban/jail.local ]]; then
sudo echo -e "\n[DEFAULT]\nbantime = 1d\n[sshd]\nenabled = true\n" >/etc/fail2ban/jail.local
fi
Version 3
if [[ ! -f /etc/fail2ban/jail.local ]]; then
print '\n[DEFAULT]\nbantime = 1d\n[sshd]\nenabled = true' | sudo tee /etc/fail2ban/jail.local
fi
Version 4 / 5
sudo cat <<<'EOF' >>/etc/fail2ban/jail.local
test
EOF
sudo cat >/etc/fail2ban/jail.local <<<'
test2
'