Check that the console accepts input
Enter cl_hud_color without an argument. If the console prints its current value, it accepts input. Then enter the failing command on its own and read the response.
If you see Unknown command
Check the spelling and the game version in the guide you used. A CS:GO Legacy command may be absent from CS2. If it works when entered directly but fails from a file, check the CFG extension and run exec with the file name manually.
If the server blocks the command
Try it in a local practice session. Variables marked cheat require the relevant server permissions. If the value changes but resets after restarting, check whether a config sets it again.