find . -name '*.log' | xargs grep some_function
find . -iname '*something*'
grep -r 内容 *
yum install psmisc -y
pstree -p
history | awk '{CMD[$2]++;count++;}END{for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t |sort -nr |nl|head -n10
python -m http.server 7777
python -m SimpleHTTPServer 8080
mvn -Dparallel=all -DperCoreThreadCount=false -DthreadCount=8 -DskipTests -Dskip.npm -Pfast clean install
cat ~/.ssh/id_rsa.pub | ssh root@host "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"find /opt/unb/cmc/ -mtime +15 -name "*.*" -exec rm -f {} \;
/opt/unb/cmc/ : 准备要进行清理的任意目录 -mtime - 标准语句写法 +10 - 查找15天前的文件,这里用数字代表天数,+30表示查找30天前的文件 "." - 希望查找的数据类型,".jpg"表示查找扩展名为jpg的所有文件,""表示查找所有文件 -exec - 固定写法 rm -rf - 强制删除文件,包括目录 {} ; - 固定写法,一对大括号 + 空格 + \ + ;
du -ah --max-depth=1 /opt/unb
df -h
history | tail -fn 50
关闭
set +o history
执行命令
开启
set -o history
直接清空
history -c
只针对一条
pwd;history -d $(history 1)
grep -r PROMPT_COMMAND /etc/bash* /etc/profile* /etc/profile.d目录下保存着zzz_euleros_history.sh脚本文件,每次操作系统启动后, 会自动执行zzz_euleros_history.sh脚本记录执行记录到/var/log/messages文件中 所以任何命令执行都会被记录ip
EulerOS_history ()
{
typeset result=$?;
typeset result_str="";
if [ ${result} -eq 0 ]; then
result_str="return code=[0], execute success";
else
result_str="return code=[${result}], execute failed";
fi;
history -a;
typeset user=$(whoami);
typeset user_id=$(id -ur $user);
typeset login=$(who -m | awk '{print $2" "$NF}');
typeset msg=$(history 1 | { read x y; echo "$y"; });
typeset num=$(history 1 | { read x y; echo "$x"; });
if [ "${num}" != "${LastComandNum_for_history}" ] && [ "${LastComandNum_for_history}" != "" -o "${num}" == "1" ]; then
logger -t "[${SHELL}]" "[${msg}]" "${result_str}" "by [${user}(uid=$user_id)] from [$login]";
fi;
LastComandNum_for_history=${num}
}
EulerOS_variable_readonly ()
{
typeset var="$1";
typeset val="$2";
typeset ret=$(readonly -p | grep -w "${var}" | awk -F "${var}=" '{print $NF}');
if [ "${ret}" = "\"${val}\"" ]; then
return;
else
export "${var}"="${val}";
readonly "${var}";
fi
}if [ "${num}" != "${LastComandNum_for_history}" ]这里可以使用history -d $(history 1)
来打破,使其计数相等不再记录进日志,达到隐秘执行的目的
history -c;history -d $(history 1)
echo "" > /var/log/messages;history -d $(history 1)
less /var/log/messages;history -d $(history 1)
HISTSIZE的神奇效果,以上的历史命令删除只对当前session有效,如果下次再打开一个session
对话框还是会有日志被记录,起决定性作用的是/etc/profile文件里HISTSIZE的设置,可以先修改
为0,然后source /etc/profile生效,然后再改回来再次执行source /etc/profile,
再关闭重新打开session,发现没有历史命令了,然后再清除下echo "" > /var/log/messages;history -d $(history 1)
自定义变量是用户在当前 Shell 里面自己定义的变量,仅在当前 Shell 可用。一旦退出当前 Shell,该变量就不存在了。
set命令可以显示所有变量(包括环境变量和自定义变量),以及所有的 Bash 函数。
set
:5,204376d
telnet 127.0.0.1 19090
GET /play/appUser
tcpdump -i any -nn port 19090 -A