Hacking with the “groups” GNU command

20.4 `groups': Print group names a user is in
=============================================

`groups' prints the names of the primary and any supplementary groups
for each given USERNAME, or the current process if no names are given.
If more than one name is given, the name of each user is printed before
the list of that user's groups and the user name is separated from the
group list by a colon.  Synopsis:

     groups [USERNAME]...

   The group lists are equivalent to the output of the command `id -Gn'.

   The only options are `--help' and `--version'.  *Note Common
options::.

   Primary and supplementary groups for a process are normally inherited
from its parent and are usually unchanged since login.  This means that
if you change the group database after logging in, `groups' will not
reflect your changes within your existing login session.  Running
`groups' with a list of users causes the user and group database to be
consulted afresh, and so will give a different result.

   An exit status of zero indicates success, and a nonzero value
indicates failure.

source: http://www.gnu.org/software/coreutils/manual/coreutils.txt
$groups 
jeffrin cdrom floppy audio dip video plugdev
$groups --help
Usage: groups [OPTION]... [USERNAME]...
Print group memberships for each USERNAME or, if no USERNAME is specified, for
the current process (which may differ if the groups database has changed).
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: 
Full documentation at: 
or available locally via: info '(coreutils) groups invocation'
$groups cdrom
groups: cdrom: no such user
$groups jeffrin
jeffrin : jeffrin cdrom floppy audio dip video plugdev
$groups root
root : root
$groups daemon
daemon : daemon
$groups nobody
nobody : nogroup
$groups messagebus
messagebus : messagebus
$groups colord
colord : colord
$groups hack
groups: hack: no such user
$groups mail
mail : mail
$groups man
man : man
$

true – do nothing, successfully. false – do nothing, unsuccessfully

GNU command

$true
$echo $?
0
$false
$echo $?
1
$
Explanation

true - do nothing, successfully
exit with a status code indicating success.
false - do nothing, unsuccessfully
exit with a status code indicating failure.
Related Source Code Exposition

int
main (int argc, char **argv)
{

  if (argc == 2)
    {
      initialize_main (&argc, &argv);
      set_program_name (argv[0]);
      setlocale (LC_ALL, "");
      bindtextdomain (PACKAGE, LOCALEDIR);
      textdomain (PACKAGE);

      atexit (close_stdout);

      if (STREQ (argv[1], "--help"))
        usage (EXIT_STATUS);

      if (STREQ (argv[1], "--version"))
        version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
                     (char *) NULL);
    }

  exit (EXIT_STATUS);
}

Source Code Highlight
Recognize --help or --version only if it's the only
command-line argument.
Featured Image
FIXME
Related Knowledge

`true' does  nothing except return  an exit status  of 0,
meaning "success".  It  can be used as a  place holder in
shell  scripts  where  a  successful command  is  needed,
although the  shell built-in  command `:' (colon)  may do
the same thing faster.   In most modern shells, `true' is
a built-in command,  so when you use `true'  in a script,
you're probably  using the built-in command,  not the one
documented here.

Note,  however, that it  is possible  to cause  `true' to
exit   with  nonzero   status:  with   the   `--help'  or
`--version'  option,  and  with standard  output  already
closed or redirected to a  file that evokes an I/O error.
For example, using a Bourne-compatible shell:

 $ ./true --version >&-
     ./true: write error: Bad file number
     $ ./true --version > /dev/full
     ./true: write error: No space left on device

This version of `true' is implemented as a C program, and
is  thus  more secure  and  faster  than  a shell  script
implementation, and  may safely be used as  a dummy shell
for the purpose of disabling accounts.
source : info coreutils 'true invocation'

true and false

A UNIX Command

$true
$echo $?
0
$false
$echo $?
1
$

UNIX Explanation

true - do nothing, successfully
exit with a status code indicating success.
false - do nothing, unsuccessfully
exit with a status code indicating failure.

Related Source Code Exposition


int
main (int argc, char **argv)
{

if (argc == 2)
{
initialize_main (&argc, &argv);
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);

atexit (close_stdout);

if (STREQ (argv[1], "--help"))
usage (EXIT_STATUS);

if (STREQ (argv[1], "--version"))
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
(char *) NULL);
}

exit (EXIT_STATUS);
}

Source Code Highlight

Recognize –help or –version only if it’s the only
command-line argument.

Featured Image

Related Knowledge

`true' does  nothing except return  an exit status  of 0,
meaning "success".  It  can be used as a  place holder in
shell  scripts  where  a  successful command  is  needed,
although the  shell built-in  command `:' (colon)  may do
the same thing faster.   In most modern shells, `true' is
a built-in command,  so when you use `true'  in a script,
you're probably  using the built-in command,  not the one
documented here.

Note,  however, that it  is possible  to cause  `true' to
exit   with  nonzero   status:  with   the   `--help'  or
`--version'  option,  and  with standard  output  already
closed or redirected to a  file that evokes an I/O error.
For example, using a Bourne-compatible shell:

 $ ./true --version >&-
     ./true: write error: Bad file number
     $ ./true --version > /dev/full
     ./true: write error: No space left on device

This version of `true' is implemented as a C program, and
is  thus  more secure  and  faster  than  a shell  script
implementation, and  may safely be used as  a dummy shell
for the purpose of disabling accounts.

source : info coreutils ‘true invocation’

setterm – set terminal attributes

GNU Command
$setterm 
setterm: Argument error.

Usage:
 setterm [options]

Options:
 -term 
 -reset
 -initialize
 -cursor 
 -repeat 
 -appcursorkeys 
 -linewrap 
 -default
 -foreground 
 -background 
 -ulcolor 
 -ulcolor 
 -hbcolor 
 -hbcolor 
 -inversescreen 
 -bold 
 -half-bright 
 -blink 
 -reverse 
 -underline 
 -store >
 -clear 
 -tabs       (tabn = 1-160)
 -clrtabs    (tabn = 1-160)
 -regtabs 
 -blank 
 -dump   
 -append 
 -file dumpfilename
 -msg 
 -msglevel 
 -powersave 
 -powerdown 
 -blength 
 -bfreq freqnumber
 -version
 -help

For more information see lsblk(1).
$

setterm sets terminal attributes.

Explanation

-cursor [on|off]
Turns the terminal's cursor on or off.

Related Source Code Exposition

        if (opt_cursor) {
                if (opt_cu_on)
                        putp(ti_entry("cnorm"));
                else
                        putp(ti_entry("civis"));
        }

Source Code Highlight
 -cursor [on|off].

Featured Image
FIXME

General Knowledge

A  terminal consists of  a screen  and keyboard  that one
uses  to  communicate   remotely  with  a  computer  (the
host). One uses it almost like it was a personal computer
but the terminal is remote from its host computer that it
communicates with (on the other  side of the room or even
on the other side of  the world). Programs execute on the
host  computer but  the results  display on  the terminal
screen.  Originally  terminals  were stand-alone  devices
with  no computational  ability and  thus they  were once
much cheaper in cost than computers. They had no pictures
or  audio, but  could  only display  text  and were  thus
called "text terminals". Today,  the cost of PC computers
is so low  that one may use a PC like  a text terminal by
running a software program to  make it behave like an old
text terminal. You formerly  found real text terminals at
libraries and schools.