How to enable cheat in my own minecraft sever?

When i create my minecraft sever to play with friends
I wasn't be able to use op commands like gamemode;tp and stuff.
I try to put my name in the "ops" file but it just doesn't save it for me
can any body help me

If its Lan then when you start the game click enable cheats, if its a server then just op yourself by doing /op (name) (Through the command prompt or minecraft server client)