您的位置:首页 > 运维架构 > Linux

0722linux基础内容小记

2016-07-22 21:35 453 查看
执行原始命令,而非别名,三种方式,例如:
’ls'
\ls
/usr/bin/ls


yum install bash-completioncp /usr/share/bash-completion/bash_completion /etc vim /etc/bashrc 添加
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
source /etc/bashrc 实现命令补全功能,例如
[root@centos7 ~]# ls --h
--help                --hide-control-chars
--hide=               --human-readable


date:系统时间 clock:硬件时间
hwclock命令:
-s, --hctosys 将系统时间改为硬件时间,即校正系统时间
-w, --systohc 将硬件时间改为系统时间,即校正硬件时间

screen -S user1 创建一个名为user1的会话
另一个终端登录到该机器上,screen -ls 看到有哪些会话
[root@centos7 tmp]# screen -ls
There is a screen on:
4830.user1      (Attached)
screen -x user1 -x加入会话,共享桌面就连接上了,两边操作都是同步

其中一方ctrl+a+d 剥离会话,若要重新连接,则screen -x ID|SESSION_NAME
[root@centos7 ~]# screen -x 4830|user1
结束该共享会话则使用exit

对于需要持续运行的进程,避免因终端断开而进程结束,
先输入screen,再执行任务如mysqldump -uUSER -pPASSWORD > /bakdir/format.sql
ctrl+a+d暂时离开该会话,过一会screen -r恢复原来的会话
[root@centos7 testdir]# screen  -r


shell脚本中echo显示内容带颜色显示,echo显示带颜色,需要使用参数-e
格式如下:echo -e "\033[字背景颜色;文字颜色m字符串\033[0m"
字颜色:30-37
30m 黑色字

31m 红色字
32m 绿色字
33m 黄色字
34m 蓝色字
35m 紫色字
36m 天蓝字
37m 白色字
[root@centos7 testdir]# echo -e "\033[35m 玫瑰 \033[0m"
玫瑰

字背景颜色:40-47

40; 绿底
41; 绿底
42; 绿底
43; 黄底
44; 蓝底
45; 紫底
46; 天蓝
47; 白底

echo -e "\033[43;31m hello \033[0m"
hello

控制选项说明:
  \33[0m 关闭所有属性
  \33[1m 设置高亮度
  \33[4m 下划线
  \33[5m 闪烁
  \33[7m 反显
  \33[8m 消隐
  \33[30m — \33[37m 设置前景色
  \33[40m — \33[47m 设置背景色
  \33[nA 光标上移n行
  \33[nB 光标下移n行
  \33[nC 光标右移n行
  \33[nD 光标左移n行
  \33[y;xH设置光标位置
  \33[2J 清屏
  \33[K 清除从光标到行尾的内容
  \33[s 保存光标位置
  \33[u 恢复光标位置
  \33[?25l 隐藏光标
  \33[?25h 显示光标
echo -e "\033[43;32;5m ME\033[0m"
ME 闪烁
echo -e "\033[32;4m ME\033[0m"
ME 有下划线
[root@centos7 testdir]# echo -e "\033[32;5m***倒***\033[0m \n \033[32;5m**金**\033[0m \n \033[32;5m *字*\033[0m \n \033[32;5m  塔\033[0m"
显示闪烁的倒金字塔




cat /etc/DIR_COLORS 颜色设置

whatis生成数据库:
centos6上 makewhatis(等价于man -f) centos7上 mandb
cd /usr/share/man/ 帮助手册路径

date +%F 显示 2016-07-22
date -d yesterday 显示昨天日期

date -d "10 day ago" +%F   //显示10天前的日期
date -d "+20 day" +%F       //
+%W 一年的第几星期
+%a 星期几
+%j 一年的第多少天
+%D 年/月/日
+%T 时/分/秒
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux基础