随笔分类 - linux
ubuntu
摘要:crontab -e 创建定时任务 0 2 * * * 表示每天的晚上两点 crontab -l 查看定时任务
阅读全文
摘要:1.系统函数 1. basename [string/filepath] [suffix] 其实就是分割函数 suffix是指定的后缀 2. dirname 的到前面的部分 3. pwd 获取当前绝对路径 $(函数名) 2. 自定义函数 [ function ] funname [()] { Act
阅读全文
摘要:read (选项) (参数) 选项: -p : 指定读取时的提示符 -t : 指定读取时等待的时间(秒) 如果-t不加表示一直等待 参数 变量: 指定读取值的变量名
阅读全文
摘要:1. if 判断 单分支 if [ condition ] ;then 程序 ;fi (if 后面有空格,;后面也有) 在文件中 if [ conditio ] 为了避免出错 if [ "$1"x = "zhang"x ] then 防止对其不传递参数时报错 程序 fi codition 可以这样
阅读全文
摘要:1. 基本语法 test condition [ condition ] (前后都有空格) test $a = hello ( = 左右要有空格, 真的话$?为0 否则为1) 2. 比较运算符 整数 -eq 等于 equal -lt 小于 less than -gt 大于 greater than
阅读全文
摘要:1.expr expr 1 + 1 expr 5 \* 2 2. $ $((运算符)) $[运算符] 3. a=$[6 + 4] 空格 a=$(expr 5 \* 2) 空格 a=`expr 5 \* 2` \*前后有空格
阅读全文
摘要:1. 系统预定义变量 1. 子shell中的变量,父shell中是不可见的 (使用bash, 进入子shell) 2. 常用系统变量: 全局: $HOME , $PWD, $SHELL, $USER $PATH 局部: 3. 查看系统变量 echo $my_var set (查看所有变量局部全局)
阅读全文
摘要:1. bash/sh 相对路径、绝对路径 2. 直接执行: 先加上权限: chmod +x scripts/hello.sh 之后直接执行。 scripts/hello.sh(有别的写法) //使用频率高 用source或者(. )命令 : scoure(. ) hello.sh (source和.
阅读全文
摘要:1. sudo su { sudo (super do) su (switch user 转换用户) //没啥用。。 sudo su 长久提权 激活root : sudo passwd root 切换到root: su root 重新锁定root: sudo passwd -l root init
阅读全文