Complex example Using the saved uid to get back to root later: setresuid( getuid(), getuid(), 0 ); /* become user, with saved uid */ /* do something as user */ system("/some/program"); fd = open("/some/file", O_CREAT | O_TRUNC | O_EXCL, 0666); setresuid( 0, 0, 0 ); /* get back our full root privs */ /* do something as root */ system("/usr/bin/id"); This method is prone to mistakes when you try to manipulate id's back and forth frequently. (And using system is a big big no-no.)