BASH shell en: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
=Using shell scripting to automate Linux maintenance tasks=
=Using shell scripting to automate Linux maintenance tasks=
 
==Author==
Translated from Estonian by Steven Rugam
==Short introduction==
==Short introduction==
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.
Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work.

Revision as of 10:56, 4 May 2017

Using shell scripting to automate Linux maintenance tasks

Author

Translated from Estonian by Steven Rugam

Short introduction

Bash (Bourne-again shell) is a well-known shell. Bash scripts are used to simplify and automate system work. When talking about bash in few words, then the structure of the language and possible usages are being checked. At length, however, focus lies on the certain administrating assignments which are solved with bash scripting language.

Purpose

Providing skills for the bash scripting language to simplify and to improve efficiency towards our daily work.

Prerequisites/Assumptions

History with GNU/Linux operation system and acquired skills, which are being tested by automated self-test.

To test prerequisites, you should pass

SELF TEST FILE

Target group

Support engineers and system administrators.

Educational materials for learning BASH shell

Bash for the beginners

Additional learning materials

https://bash.cyberciti.biz/guide/Main_Page

Topics

  • Bash in general
    • What is bash and shell
    • Bash script writing
    • Executing bash scripts
  • Bash configuration files
    • .bash_profile: .bash_login ja .profile
    • .bashrc
    • .bash_logout
    • /etc/profile, /etc/profile.d/
    • Bash command history in .bash_history
  • Bash Syntax
    • Commenting
    • Symbols with special meaning(metacharacters, escaping characters, wildcards)
    • Difference between quotation marks and single quotation mark
    • Parameters
    • Catching user input and interactive scripts
    • Exit codes
    • Multiple commands on the same row
    • Piping
    • If sentences (if-else, case)
    • Cycles (for, while, until, select)
    • Control of strings (larger than, larger/smaller than or equal, smaller than)
    • File descriptors (stdin, stdout, stderr)
    • File existance scripts
    • Functions
    • Arithmetic operations, rounding
    • Regular expressions
    • Usage of arrays
  • Basics of bash
    • Utilities and their usage (echo, cat, cut, wc, sed, awk, mv, cp, mkdir, ls, file, head, uniq, tail, etc.)
    • Processes and executing them (ps, pstree, top, &)
    • Detecting shell script mistakes and fixing them

Example exercises

  • Calculation exercises
  • String manipulations
  • Exercises with files
  • Writing scripts, which show system configurations (logged in users, OS version, RAM info, Partitions etc)
  • Stopping processes and restarting processes
  • Adding new domains to DNS servers from the shell
  • Converting file lowercase characters to uppercase characters

Links

http://gnome-look.org/content/show.php/Ultimate+Bashrc+File?content=129746 hacking .bashrc