Using bash to define with ip6tables the rules

Ubuntu Support Template

Ubuntu Version:
Example:24.04.4 LTS

Desktop Environment (if applicable):
Example: server only VM Hyper-V

Problem Description:
When using the line commands as sudo and type ip6tables -F, then all went fine
when using a bash script and set define $ip6tables -F or $ip6tables --flush, I get command not found
This behavior is the same for many other lines similar as -Z --zero, -A --append

Example:
Create a bash shell file
insert some ip6table rules like:

Flush all tables.

$ip6tables -F

Zero out all counters.

$ip6tables -Z

Relevant System Information:
standard installation

Screenshots or Error Messages:
If applicable, paste error messages or screenshots.
We prefer copy-pasted text and screenshots instead of photos of screens.

What I’ve Tried:
use terminal command to test the ip6commands according to the manual

How to solve this issue?

Please check your details…

Either you’re a time traveller, or that isn’t what you’re using, so please check and correct.

Please also remove the details in the template that don’t belong in your question (the template is there to help you know what to put, examples should be removed where they don’t apply)… Are you using Ubuntu?