shell-0. Brief introduction

Source: Internet
Author: User

Shell-0. Introduction
1. Use shell scripts in those environments
• Application environment: Several complex parameters are required to execute certain commands
Requires multiple commands for State view and maintenance management of the system
Regular backup of the database
Monitor system critical processes and logs based on specific conditions
Weekly inspection of Major systems
Analyze the configuration file of important network equipment and give the corresponding analysis report.
Probe the equipment in the network, collect the related assets information, and enter the asset information table.

For example:
• By command: Carefully check the syntax and parameters every time
Write detailed system maintenance documentation, lists the commands to be maintained, and the administrator will follow the system maintenance documentation.
Daily 6 o'clock in the afternoon, perform a backup of the database
Monitor, command, or view the system screen every 10 or 15 minutes
Heavy workload, poor data collation

2. What is a shell
Shell----Kernel----hardware
Please view
http://yuanji6699.blog.51cto.com/11568362/1771930

Elements of a 3.Shell script
• Notes
• System Commands
• Text Processing tool (Sort,grep,sed,awk ... )
• variables
• Conditional judgment
• Cycle structure
• function

4. View system support for those shells
debian:/myshell# Cat/etc/shells
#/etc/shells:valid Login Shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/bash
/bin/rbash
So much, it's basically bash.

5. View the type of sh used by the current user
debian:/myshell# echo $SHELL "Note this may not be correct"
/bin/bash

should use "be sure to check before use, the individual system version is not bash by default】
Ls-alh/bin/sh

[Email protected]:/home/log# ls-lah/bin/sh
lrwxrwxrwx 1 root root 4 Nov 15:15/bin/sh, dash [actually using dash]
[Email protected]:/home/log# Echo $SHELL
/bin/bash

Workaround:
-----------
So how do you change sh to point to bash?
The most violent approach, of course, is to change/bin/sh's soft links directly into bash,
such as: Ln-s/bin/bash/bin/sh

To check again, Ls/bin/sh-al found that the soft link points to/bin/bash.
-------------

6. First script (international practice, Hello World)
debian:/# Vim first.sh
#!/bin/sh
echo "Hello World"

debian:/# SH first.sh
Hello World

debian:/# chmod +x first.sh
debian:/#./first.sh
Hello World

After
debian:/myshell# echo $? (This section is described in detail later)
0
If it's 0, it means normal.


The above individuals a little summary and understanding, level is not high, the level of writing is very bad, please greatly forgive me.
Can exchange learning together.

My qq:610851588.
Can join my build group (now very few people, hope slowly more up)
Linux Clusters: 183932302
Python, Shell AC Group: 469094734

This article from the "Go to the Origin dimension" blog, reproduced please contact the author!

shell-0. Brief introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.