Section 3 - Basic tools for the administrator

Diarmuid O'Briain, diarmuid@obriain.com
06-04-2014, version 2.0

Last updated: 11-05-2014 00:55


<< Back HOME Next >>
  1. Graphics tools and command line
  2. Standards
  3. System documentation
  4. Shell scripting
  5. Shells
  6. System variables
  7. Programming scripts in Bash
  8. Package management tools
  9. Generic administration tools

1. Graphics tools and command line

GNU/Linux distributions include command line, text and graphics tools to allow for task administration. The following must be taken into account with regard to graphical tools:

2. Standards

2.1. Filesystem Hierchachy Standard (FHS)

The FHS describes the main file system tree structure used in UNIX style operating systems.

2.2. Linux standard base (LSB)

LSB is a joint project by several Linux distributions to develop and promote a set of open standards that will increase compatibility among Linux distributions and enable software applications to run on any compliant system even in binary form. In addition, the LSB will help coordinate efforts to recruit software vendors to port and write products for Linux Operating Systems.

LSB defines that all complians systems must support Redhat Package Manager (RPM) to allow for interoperability of packages. Debian provides alien to transform non .deb packages to .deb format.

  $ alien --to-deb /path/to/file.rpm
  

For more information The Linux Foundation LSB website

3. System documentation

Linux provides a number of information resources to system administrators:

3.1. man

Standard UNIX interface to the on-line reference manuals.

  $ man useradd
  
  USERADD(8)                System Management Commands                USERADD(8)
  
  NAME
         useradd - create a new user or update default new user information
  

3.2. info

Similar to man, offers access to information documents.

  $ info useradd
  
  File: *manpages*,  Node: useradd,  Up: (dir)
  
  USERADD(8)                System Management Commands                USERADD(8)
  
  NAME
         useradd - create a new user or update default new user information
  

3.3. Applications documentation

Application documentation can be found at:

4. Shell scripting

Program that serves as an interface between the user and the GNU/Linux system's kernel. The diagram shows either a local terminal or a remote connection (typically using Secure Shell (SSH)). When the shell is opened or the ssh connection arrives, the initialisation process (init) calls a Get TTY (getty) to respond. The getty processes configured by entries in /etc/inittab creates a pseudoterminal session and a Login: prompt is presented so the user can login. Locally getty's can be accessed by pressing <CTRL><ALT><F#>, where <F#> is one of the <F1>-<F6> keys (<F7> is typically the X-Server.

The getty processes is configured in /etc/inittab.

4.1. Interactive shells

After logging in, the shell becomes responsible for validating the user and starting to run the required processes, in a number of phases:

Normally, command lines will be ways of running the system's commands, interactive shell commands, starting up applications or shell scripts.

Shell scripts are text files that contain command sequences of the system, plus a series of internal commands of the interactive shell, plus the necessary control structures for processing the program flow.

The system can run script files directly under the name given to the file. To run them, we invoke the shell together with the file name or we give the shell script execution permissions.

To some extent, we can see shell script as the code of an interpreted language that is executed on the corresponding interactive shell. For the administrator, shell scripts are very important, basically for two reasons:

  1. The system's configuration and most of the services are provided through tools in the form of shell scripts.
  2. The main way of automating administration processes is creating shell scripts.

4.2. Special filehandles

All the programs that are invoked by a shell possess three predefined files, specified by the corresponding file handles. By default, these files are:

This tells us that any program run from the shell by default will have the input associated to the terminal's keyboard, the output associated to the screen, and that it will also send errors to the screen.

Also, the shells provide:

5. Shells

6. System variables

Shell scripts and batch files use environment variables to communicate data and preferences to child processes. They can also be used to store temporary values for reference later in a shell script. The shell has some default variables set, these can be found by using the command env.

  $ env
  
  XDG_VTNR=8
  SSH_AGENT_PID=1988
  XDG_SESSION_ID=c1
  GPG_AGENT_INFO=/run/user/1000/keyring-2eG2Ra/gpg:0:1
  TERM=xterm
  SHELL=/bin/bash
  VTE_VERSION=3406
  XDG_SESSION_COOKIE=84273682289cb92af8f07c1052ab3664-1396653002.106639-2767098
  CLUTTER_DISABLE_XINPUT=1
  WINDOWID=52428808
  GNOME_KEYRING_CONTROL=/run/user/1000/keyring-2eG2Ra
  USER=dobriain
  ~~~ ~~~ ~~~ ~~~
  MDMSESSION=default
  TEXTDOMAIN=im-config
  WINDOWPATH=8
  XDG_RUNTIME_DIR=/run/user/1000
  DISPLAY=:0
  MDM_LANG=en_IE.UTF-8
  XDG_CURRENT_DESKTOP=GNOME
  TEXTDOMAINDIR=/usr/share/locale/
  COLORTERM=gnome-terminal
  XAUTHORITY=/home/dobriain/.Xauthority
  _=/usr/bin/env
  OLDPWD=/usr/share
  
  $
  

7. Programming scripts in Bash

Here is an example script to demonstrats some of the script structures.

  $ vi MyBASH-Script
  
  #!/bin/bash                           # She-Bang line, defines the shell to use
  
  echo "My first bash script"           # echo to standard out (stdout)
  clear                                 # Clear stdout
                                        # Declare variables
  my_variable="My first variable"
  my_num1=3
  my_num2=4
  my_array=( G N U L i n u x )
  
                                        # Main script section
  echo; echo "$my_variable"; echo
  ans=`expr $my_num2 - $my_num1`        # Calculate sum and assign answer to variable 'ans'
  echo $ans; echo                       # echo answer to screen
  
                                        # IF/ELSE Conditional
   
  if [ -f /var/log/syslog ]; then               
  	echo "The syslog file exists."; echo 
  else                                          
  	echo "The syslog file does NOT exist."; echo 
  fi
  
                                        # CASE Conditional
  case $ans in 
     1) echo "1 must have been the answer of the earlier sum.";echo;; 
     2) echo "2 must have been the answer of the earlier sum.";echo;; 
     *) echo "Don't know the result of the earlier sum.";echo;; 
  esac
  
                                        # LOOP
  for i in ${my_array[@]}; do
     echo "$i";
  done
  
  :wq!
  

To run the script from the shell, make it executable and then run. Review the script and check if the given output is what you expect.

  $ chmod +x MyBASH-Script
  $ ./MyBASH-Script
  
  My first variable
  
  1
  
  The syslog file exists.
  
  1 must have been the answer of the earlier sum.
  
  $
  

8. Package management tools

To install a package the shell will:

8.1. TGZ package

Oldest system of package, combination of Tape ARchive (tar) and GNUzip.

Installing a .tgz package generally follows these steps:

8.2. Fedora / Redhat

8.2.1. Redhat Package Manager (rpm)

RPM is a package manager for installation of Redhat packages. Use rpm to install packages downloaded directly, those not found via the repositories only. If packages can be found in repositories it is better to use yum.

These packages will be named by convention as:

package-version-rev.rpm

where

$ rpm -ql package-version-rev.rpm # List of the files it contains

$ rpm -qi package-version-rev.rpm # Package description

$ rpm -qR package-version-rev.rpm # Package prior requirements, libraries or software

$ rpm -i package-version-rev.rpm # Install the package

$ rpm -U package # Update the package

$ rpm -V package # Verify the package

$ rpm -e package # Delete/erase the package

8.2.2. Yellow dog Update (yum)

yum is a higher level package manager that was developed by Duke University to improve the installation of RPMs. Yum searches numerous repositories for packages and their dependencies so they may be installed together in an effort to alleviate dependency issues.

$ yum search package # Searches for package in repositories defined in /etc/yum.repos.d

$ yum install package # Downloads package plus any dependent packages and installs them

$ yum update package # Update package

$ yum update # Update the entire system of packages

8.3. Debian / Ubuntu

8.3.1. Debian Package Manager (deb)

dpkg is a package manager for installation of debian (.deb) packages. Use dpkg to install packages downloaded directly, those not found via the repositories only. If packages can be found in repositories it is better to use apt.

These packages will be named by convention as:

package-version-rev.deb

where

$ dpkg -l # List all installed packages

$ dpkg -p package-version-rev.deb # Package description

$ dpkg -i package-version-rev.deb # Install the package

$ dpkg -i package # Update the package

$ dpkg -r package # Delete/remove the package

8.3.2. Advanced Package Tool (apt)

apt is a higher level package manager that resolves problems of dependencies and retrieves the requested packages, works with dpkg to handle the actual installation and removal of packages.

$ apt-cache search package # Searches for package in repositories defined in /etc/apt/sources.list

$ apt-cache depends package # Check a package dependencies

$ apt-get install package # Downloads package plus any dependent packages and installs them

$ apt-get update package # Update package

$ apt-get update # Update the entire system of packages

$ apt-get remove package # Remove the entire system of packages

8.3.2.1. Aptitude

Aptitude is an Ncurses based FrontEnd to Apt.

$ aptitude

9. Generic administration tools

9.1. Linuxconf

Generic administration tool that groups together different aspects in a kind of text menu interface, which in the latest versions evolved to web support; it can be used with practically any GNU/Linux distribution and supports various details inherent to each one (unfortunately, it has not been updated for a while).

Linuxconf project website

9.2. Webmin

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely..

Example: Edit user quotas screen

webmin project website

9.3. ISPconfig

Hosting Control Panel Software.

ISPConfig - Hosting Control Panel Software

Example: ISPconfig topbar

ISPconfig project website

9.4. Desktop Control Panels

Desktop environments like Gnome and KDE include Control Panels which allow for the management of the graphical desktop as well as the parameters of some system devices.

Example: Linux Mint Cinnamon system settings panel

9.5. Other tools


<< Back HOME Next >>