LPI

Dit zijn aantekeningen bij mijn studie voor Linux Professional Institute certificaten. Normaal gebruik ik de uitstekende tutorials van IBM (van Ian Shields) maar voor enkele onderwerpen zijn de tutorials nog niet klaar.

111 Administrative tasks

111.1 Users & groups

/etc/shadow

  1. login name
  2. encrypted password
  3. days since Jan 1, 1970 that password was last changed
  4. days before password may be changed
  5. days after which password must be changed
  6. days before password is to expire that user is warned
  7. days after password expires that account is disabled
  8. days since Jan 1, 1970 that account is disabled
  9. a reserved field

Password veld:

  • ! of *: deze gebruiker kan niet inloggen.
  • Begint met $1$ = Versleuteld met MD5.

/etc/passwd

  1. login name
  2. optional encrypted password (indien x, passwd staat in shadow)
  3. numerical user ID
  4. numerical group ID
  5. user name or comment field
  6. user home directory
  7. optional user command interpreter

/etc/group

  1. group_name: the name of the group.
  2. password: the (encrypted) group password. If this field is empty, no password is needed.
  3. GID: the numerical group ID.
  4. user_list: all the group member’s user names, separated by commas.

/etc/gshadow

  1. group name
  2. encrypted password
  3. comma-separated list of group administrators
  4. comma-separated list of group members

This information supersedes any password present in /etc/group.

chage

Password timeouts instellen.

gpasswd

gpasswd group
gpasswd -a user group
gpasswd -d user group
gpasswd -R group
gpasswd -r group
gpasswd [-A user,...] [-M user,...] group

Group administrator can add and delete users using -a and -d options respectively. Administrators can use -r option to remove group password. When no password is set only group members can use newgrp to join the group. Option -R disables access via a password to the group through newgrp command (however members will still be able to switch to this group).

groupadd

Maakt nieuwe groep aan.

  groupadd [-g GID [-o]] [-f] [-K KEY=VALUE] group

-f = exit met status succes als de groep al bestaat. -g GID = group ID instellen. -K KEY=VALUE = Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple -K options can be specified. Example: -K GID_MIN=100 -o = voeg groep toe met bestaand GID.

groupdel

  groupdel <group>

Je moet zelf controleren welke files er zijn met de groep.

groupmod

-n name = nieuwe naam -g GID = nieuw group ID -o = override niet-uniek GID

passwd

-aS = status voor alle gebruikers. -d = password leegmaken. -e = expire: gebruiker moet zijn password wijzigen. -i days = account wordt inactief na zoveel dagen passwd niet gewijzigd. -l = lock account. -u = unlock account. -m days = minimum aantal dagen waarna gebruiker passwd mag veranderen. -x days = max dagen dat wachtwoord geldig is. -w days = aantal dagen waarschuwing voordat passwd gewijzigd moet worden.

useradd

Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the new user account
                                home directory
  -c, --comment COMMENT         set the GECOS field for the new user account
  -d, --home-dir HOME_DIR       home directory for the new user account
  -D, --defaults                print or save modified default useradd
                                configuration
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP for the new user account
  -G, --groups GROUPS           list of supplementary groups for the new
                                user account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           specify an alternative skel directory
  -K, --key KEY=VALUE           overrides /etc/login.defs defaults
  -m, --create-home             create home directory for the new user
                                account
  -o, --non-unique              allow create user with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new user
                                account
  -r, --system                  create a system account
  -s, --shell SHELL             the login shell for the new user account
  -u, --uid UID                 force use the UID for the new user account

userdel

-f = ook als gebruiker is ingelogd -r = verwijder home-dir van gebruiker

usermod

-aG groep1,groep2 = gebruiker toevoegen aan groepen. -e yyyy-mm-dd = vervaldatum. -dm dir = nieuwe home dir (oude wordt verplaatst). -l newlogin = inlognaam wordt gewijzigd.

111.2 Tune user environment & sys env variables

/etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
        . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

umask 022

env

Commando’s uitvoeren in een gewijzigde environment.

env -i /bin/bash -c set

export

Maak variabelen beschikbaar aan volgende commando’s/programma’s.

-p = toon lijst gexporteerde variabelen.

set

       set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
              Without  options,  the name and value of each shell variable are
              displayed in a format that can be reused as input for setting or
              resetting the currently-set variables.  Read-only variables canâ
              not be reset.  In posix mode, only shell variables  are  listed.
              The  output  is  sorted  according  to the current locale.  When
              options are specified, they set or unset shell attributes.   Any
              arguments  remaining after the options are processed are treated
              as values for the positional parameters  and  are  assigned,  in
              order, to $1, $2, ...  $n.  Options, if specified, have the folâ
              lowing meanings:
              -a      Automatically mark variables  and  functions  which  are
                      modified  or  created  for  export to the environment of
                      subsequent commands.
              -b      Report the status of terminated background jobs  immediâ
                      ately, rather than before the next primary prompt.  This
                      is effective only when job control is enabled.
              -e      Exit immediately if a simple command (see SHELL  GRAMMAR
                      above) exits with a non-zero status.  The shell does not
                      exit if the command that fails is part  of  the  command
                      list  immediately  following  a  while or until keyword,
                      part of the test in an if statement, part of a && or  ââ
                      list, or if the commandâs return value is being inverted
                      via !.  A trap on ERR, if set, is  executed  before  the
                      shell exits.
              -f      Disable pathname expansion.
              -h      Remember  the location of commands as they are looked up
                      for execution.  This is enabled by default.
              -k      All arguments in the form of assignment  statements  are
                      placed  in the environment for a command, not just those
                      that precede the command name.
              -m      Monitor mode.  Job control is enabled.  This  option  is
                      on  by  default  for  interactive shells on systems that
                      support it (see JOB  CONTROL  above).   Background  proâ
                      cesses  run  in a separate process group and a line conâ
                      taining their exit status is printed upon their  compleâ
                      tion.
              -n      Read commands but do not execute them.  This may be used
                      to check a shell script  for  syntax  errors.   This  is
                      ignored by interactive shells.
              -o option-name
                      The option-name can be one of the following:
                      allexport
                              Same as -a.
                      braceexpand
                              Same as -B.
                      emacs   Use  an  emacs-style command line editing interâ
                              face.  This is enabled by default when the shell
                              is interactive, unless the shell is started with
                              the --noediting option.
                      errtrace
                              Same as -E.
                      functrace
                              Same as -T.
                      errexit Same as -e.
                      hashall Same as -h.
                      histexpand
                              Same as -H.
                      history Enable command history, as described above under
                              HISTORY.  This option is on by default in interâ
                              active shells.
                      ignoreeof
                              The  effect  is  as   if   the   shell   command
                              ââIGNOREEOF=10ââ  had  been  executed (see Shell
                              Variables above).
                      keyword Same as -k.
                      monitor Same as -m.
                      noclobber
                              Same as -C.
                      noexec  Same as -n.
                      noglob  Same as -f.  nolog Currently ignored.
                      notify  Same as -b.
                      nounset Same as -u.
                      onecmd  Same as -t.
                      physical
                              Same as -P.
                      pipefail
                              If set, the return value of a  pipeline  is  the
                              value  of  the  last (rightmost) command to exit
                              with a non-zero status, or zero if all  commands
                              in  the pipeline exit successfully.  This option
                              is disabled by default.
                      posix   Change the behavior of bash  where  the  default
                              operation differs from the POSIX 1003.2 standard
                              to match the standard (posix mode).
                      privileged
                              Same as -p.
                      verbose Same as -v.
                      vi      Use a vi-style command line editing interface.
                      xtrace  Same as -x.
                      If -o is supplied with no option-name, the values of the
                      current  options are printed.  If +o is supplied with no
                      option-name, a series of set commands  to  recreate  the
                      current  option  settings  is  displayed on the standard
                      output.
              -p      Turn on privileged mode.  In this  mode,  the  $ENV  and
                      $BASH_ENV  files  are not processed, shell functions are
                      not inherited from the environment,  and  the  SHELLOPTS
                      variable,  if it appears in the environment, is ignored.
                      If the shell is started with the effective user  (group)
                      id  not  equal  to  the real user (group) id, and the -p
                      option is not supplied, these actions are taken and  the
                      effective user id is set to the real user id.  If the -p
                      option is supplied at startup, the effective user id  is
                      not reset.  Turning this option off causes the effective
                      user and group ids to be set to the real user and  group
                      ids.
              -t      Exit after reading and executing one command.
              -u      Treat unset variables as an error when performing paramâ
                      eter expansion.  If expansion is attempted on  an  unset
                      variable, the shell prints an error message, and, if not
                      interactive, exits with a non-zero status.
              -v      Print shell input lines as they are read.
              -x      After expanding each simple command, for  command,  case
                      command, select command, or arithmetic for command, disâ
                      play the expanded value of PS4, followed by the  command
                      and its expanded arguments or associated word list.
              -B      The  shell performs brace expansion (see Brace Expansion
                      above).  This is on by default.
              -C      If set, bash does not overwrite an  existing  file  with
                      the  >,  >&,  and <> redirection operators.  This may be
                      overridden when creating output files by using the rediâ
                      rection operator >| instead of >.
              -E      If set, any trap on ERR is inherited by shell functions,
                      command substitutions, and commands executed in  a  subâ
                      shell  environment.  The ERR trap is normally not inherâ
                      ited in such cases.
              -H      Enable !  style history substitution.  This option is on
                      by default when the shell is interactive.
              -P      If  set,  the  shell does not follow symbolic links when
                      executing commands such as cd that  change  the  current
                      working  directory.   It  uses  the  physical  directory
                      structure instead.  By default, bash follows the logical
                      chain  of  directories  when  performing  commands which
                      change the current directory.
              -T      If set, any traps on DEBUG and RETURN are  inherited  by
                      shell  functions,  command  substitutions,  and commands
                      executed in  a  subshell  environment.   The  DEBUG  and
                      RETURN traps are normally not inherited in such cases.
              --      If  no arguments follow this option, then the positional
                      parameters are unset.  Otherwise, the positional parameâ
                      ters  are  set  to  the args, even if some of them begin
                      with a -.
              -       Signal the end of options, cause all remaining  args  to
                      be assigned to the positional parameters.  The -x and -v
                      options are turned off.  If there are no args, the posiâ
                      tional parameters remain unchanged.

              The  options are off by default unless otherwise noted.  Using +
              rather than - causes  these  options  to  be  turned  off.   The
              options  can  also be specified as arguments to an invocation of
              the shell.  The current set of options may be found in $-.   The
              return status is always true unless an invalid option is encounâ
              tered.

unset

 
lpi.txt · Laatst gewijzigd: 2007/06/07 12:49 door onno
 
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Copyright © Onno Zweers