Minecraft wiki entry for Permission_level, associated text: A command block or a minecart with command block has permission level of 2.
The console of a server has permission level of 4.
A function has permission level of 2 (but it can be changed in server.properties).
For a player:
If the player is an op in dedicated server, their permission level is specified in ops file, and its default value is specified in server.properties.
If the player is in a singleplayer world or is the owner of a LAN world, and cheats are enabled, permission level is 4.
If the player is in a cheat-allowed LAN world, permission level is 4.
Otherwise, permission level is 0.[needs testing]