setlogin 1 user commands nosh
setlogin set session login name then chain
`setlogin` account next-prog

## Description

`setlogin` is a chain-loading utility that (on the BSDs) sets the current session's login name to account, or (on Linux) sets the current process's login UID to the value for account in the system account database, and then chain loads to next-prog with the execvp 3 function.

next-prog may contain its own command line options, which `setlogin` will ignore.

This name is what is reported by the the logname 1 command. On the BSDs, the name is session-wide, so setting it in one process will affect all processes in the same session. On Linux, the login UID is inherited by child processes and is not session-wide. For consistent cross-platforms results, therefore, invoke `setlogin` in the session leader process of a new session before it creates further processes in the session.

The command may fail if the process is not running under the aegis of the superuser, or if the login name/UID is already set. Non-superusers are simply not permitted to set a BSD session-wide login name. Linux rules vary according to kernel build options. Non-superusers (and sometimes also superusers) are not permitted to set a Linux per-process login UID if it has already been set to something other than -1. Even superusers that are permitted to set a Linux per-process login UID may be barred from changing it to anything other than back to -1 if it is already set to something other than -1.

If it cannot find an account named account in the database, or fails setting the name or ID, it does not chain and exits with status code 111.

## Author

Jonathan de Boyne Pollard