Linux Sysadmin

From Colettapedia
(Redirected from Unix Network Administration)
Jump to navigation Jump to search

What distro am I working with?

  • /etc/os-release - present on any system that uses systemd
  • lsb_release -a - Linux Standard Base (LSB) utility, not present in minimal images
  • /etc/*release
  • cat /etc/issue
  • hostnamectl

What Shell am I running in right now?

  • echo $0

Commands

  • The Complete Guide to “useradd” Command in Linux – 15 Practical Examples
  • chfn = change full name
  • chsh = change default shell
  • passwd <username> = change a user's password
  • crypt
  • groupadd -g 56 svn
    • Add a group called "svn" to the list of groups and give it a unique numerical value group ID number of 56.
    • The -g looks unnecessary, just let the system assign an id number
  • groupdel
  • groupmod
  • login.defs
  • newusers
  • userdel
    • -r = remove user's home directory
  • useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false -u 56 svn
    • -c "SVN Owner" = comment, usually user's name
    • -d, --home /home/svn = specifies the value of new user's login dir, will be created if doesn't exist
    • -m, --create-home = The user’s home directory will be created if it does not exist. The files contained in SKEL_DIR will be copied to the home directory if the -k option is used, otherwise the files contained in /etc/skel will be used instead.
    • -M = DO NOT create home dir
    • -g svn = The group name or number of the user’s initial login group. The group name must exist. A group number must refer to an already existing group.
    • -G group1,group2,group3 - multiple groups separated by comma, no whitespace
    • -s --shell SHELL The name of the user’s login shell. The default is to leave this field blank, which causes the system to select the default login shell.
      • specifying -s /bin/false prevents you from logging in as them via su or ssh
    • -u = unique numerical value of the user ID
  • passwd
  • groups
  • usermod usermod [options] LOGIN
    • may have to log out and log back in to see changes, could also look at /etc/groups
    • -G newgroup,wheel
    • usermod -G svntest -a svn
    • -a, --append =Add the user to the supplemental group(s). Use only with -G option.
    • -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
      • A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via -a option, which appends user to the current supplementary group list.
  • visudo - edit the sudoers file - might have to uncomment a line that includes the group "wheel" as an admin group

supplementary

  • vipw = locks the file and brings it up for editing in your favourite editor (as found in the VISUAL or EDITOR environment variables).

Files

  • /etc/passwd = User account information.
  • /etc/shadow = Secure user account information.
  • /etc/group = Group account information.
  • /etc/gshadow = Secure group account information.
  • /etc/default/useradd = Default values for account creation.
  • /etc/skel/ = Directory containing default files.
  • /etc/login.defs = Shadow password suite configuration.
  • /etc/profile = default login script