update scripts

This commit is contained in:
Zhang Peng 2019-10-10 14:16:45 +08:00
parent 0c58f678fe
commit 0aafd7e706
6 changed files with 37 additions and 11 deletions

View File

@ -1,3 +0,0 @@
# Shell 脚本实战
> 本目录的代码是本人在学习、开发中总结的一些面向实战的 Shell 代码。

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
current_dir=$(cd `dirname $0`;
pwd)
echo "当前目录是:${current_dir}"
parent_dir=$(dirname $(pwd))
echo "父目录是:${parent_dir}"

View File

@ -0,0 +1,3 @@
# Shell 脚本实战
> 本目录的代码是本人在学习、开发中收集、总结的一些面向实战的 Shell 脚本代码。

View File

@ -1,5 +1,10 @@
#!/usr/bin/env bash
###################################################################################
# Linux 系统用户管理
# @author: Zhang Peng
###################################################################################
# 创建用户组
groupadd elk
# 创建新用户,-g elk 设置其用户组为 elk-p elk 设置其密码为 elk

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
###################################################################################
# 目录操作示例
# @author: Zhang Peng
###################################################################################
# 创建目录(整个文件路径中的目录如果不存在,都会一一创建,如果目录已存在,则什么也不做)
mkdir -p /home/linux-tutorial/temp
# 进入目录
cd /home/linux-tutorial/temp
# 查看目录路径
current_dir=$(pwd)
echo "当前目录是:${current_dir}"
# 查看目录上一级路径
parent_dir=$(dirname $(pwd))
echo "父目录是:${parent_dir}"
# 复制目录(复制 temp 目录所有内容,并命名新文件夹叫 temp2
cp -rf /home/linux-tutorial/temp /home/linux-tutorial/temp2
# 移动目录(将 temp2 移到 temp 目录下)
mv /home/linux-tutorial/temp2 /home/linux-tutorial/temp/temp2
# 删除目录
rm -rf /home/linux-tutorial