实用 Shell 脚本示例:备份、服务器配置与用户管理
在系统管理和运维工作中,Shell 脚本是提高效率、自动化任务的强大工具。本文将介绍几个实用的 Shell 脚本示例,涵盖备份、Web 服务器配置、用户管理等方面。
1. 基于用户输入创建当前备份
我们可以创建一个交互式脚本,根据用户输入的备份源和目标来创建当前备份。以下是具体脚本:
#!/bin/bash
# V1.0 / Jasmin Redzepagic / 01/11/2021 Initial script version
# Distribution allowed under GNU Licence V2.0
# This script does a custom backup, based on our arguments
# We need to give it a couple of arguments @start:
# - backup file name
# - list of directories (or a single directory) that we
# want to backup
# We also added a bit of code to skip standard error
echo -e "Type in the backup file name, use something like file-date.tar.gz:"
read filename
echo -e "Type in the list or a single directory that you want to backup:"
read di
超级会员免费看
订阅专栏 解锁全文
902

被折叠的 条评论
为什么被折叠?



