shell经典脚本或命令行

查看文件或目录大小

~$du -h file_path 	//查看某个文件大小,并显示易读的单位
~$du -ah			//查看当前目录下及其子目录下所有文件的大小

生成自签名证书

create-ca.sh

#!/bin/sh

openssl genrsa -out ca.key 2048 && \
printf "\\n\\n\\n\\n\\n\\n\\n" | \
openssl req -config tmp.cnf -x509 -new -nodes -key ca.key -sha256 -days 1024 -out ca.pem

create-client-cert.sh

#!/bin/sh

if [ -z "$1" ] ; then
	echo "Usage $0 "
	exit 1
fi

openssl genrsa -out $1.key 4096 && \
printf "\\n\\n\\n\\n\\nlocalhost\\n\\n1234\\n\\n" | \
 openssl req -config tmp.cnf -new -key $1.key -out $1.csr && \
openssl ca -config tmp.cnf \
 	-keyfile ca.key \
	-cert ca.pem \
	-extensions usr_cert \
	-days 375 \
	-notext \
	-md sha256 \
       	-in $1.csr \
	-out $1.pem && \
openssl pkcs12 -export -in $1.pem -inkey $1.key -out $1.p12

create-server.sh

#!/bin/sh

if [ -z "$1" ] ; then
	echo "Usage $0 "
	exit 1
fi

openssl genrsa -out $1.key 4096 && \
printf "\\n\\n\\n\\n\\nlocalhost\\n\\n1234\\n\\n" | \
 openssl req -config tmp.cnf -new -key $1.key -out $1.csr && \
openssl ca -config tmp.cnf \
 	-keyfile ca.key \
	-cert ca.pem \
	-extensions server_cert \
	-days 375 \
	-notext \
	-md sha256 \
       	-in $1.csr \
	-out $1.pem

启动docker容器

echo "12345" | sudo -S docker start [id] && sudo docker exec-it [id] /bin/bash

你可能感兴趣的:(shell经典脚本或命令行)