I know that a root user can read a file even if the access permissions are all set to 0 but i don't understand about the write and execute permissions in specific. Can a superuser write and execute a file having permissions as
It can write the same as it can read. Being root trumps these. But with execution it's a different story. If a file is not marked as executable, then it's not considered executable. However, once it's marked executable, it doesn't have to be readable for root to be executed (if it is a script). Unlike it is with the regular users.
The superuser (or equivalent) can write to the file unless it is the program image of a currently executing process. (It could have been executed and its permissions then set to 000 whilst the process is executing.) This is taking it as a given that the filesystem is read-write mounted, and that you have taken no action with security policies and other mechanisms to restrict the normal behaviour of the superuser, of course.
The superuser (or equivalent) cannot execute the file, as 000 does not grant any execute permission to anyone, a required precondition for the superuser (or equivalent) to have execute access.
- "File Access Permissions". Base Specifications. Issue 7. 2018. The Open Group.