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

linux常见知识点总结

2016-03-28 21:54 465 查看
常见知识点总结
1.date -s 日期设置
[root@localhost ppp]# date -s 2015-7-5
2015年 07月 05日 星期日 00:00:00 CST
2.date -d 时间的设置
[root@localhost ppp]# date -d 3:45:45
2015年 07月 05日 星期日 03:45:45 CST
3.hwclcok -s 硬件时钟同步系统时钟

[root@localhost ppp]# date
2015年 07月 05日 星期日 00:03:28 CST
[root@localhost ppp]# hwclock -s
[root@localhost ppp]# date
2016年 03月 28日 星期一 03:07:49 CST
4.hwclock - w 系统时钟同步硬件时钟

[root@localhost ppp]# hwclock -w
[root@localhost ppp]# date
2015年 04月 05日 星期日 00:00:24 CST
5.bash中的引用:
'':强引用
"":弱引用
``:命令引用
6.通配符练习

(1) 显示/etc目录下,以非字母开头,后面跟了一个字母及其它任意长度任意字符的文件或目录;
[root@localhost /]# ls -d /etc/ [^[:alpha:]][a-z]*
ls: 无法访问[^[:alpha:]][a-z]*: 没有那个文件或目录
/etc/
(2)复制/etc目录下,所有以n开头,以非数字结尾的文件或目录至/tmp/etc目录下;
[root@localhost /]# mkdir /tmp/etc
[root@localhost /]# cp -r /etc/n*[^0-9] /tmp/etc
[root@localhost /]# ls -ld /tmp/etc
drwxr-xr-x. 3 root root 4096 4月 5 00:54 /tmp/etc
(3)显示/usr/share/man目录下,所有以man开头,后跟一个数字结尾的文件或目录
[root@localhost etc]# ls -ld /usr/share/man/man[0-9]
drwxr-xr-x. 2 root root 69632 3月 28 2016 /usr/share/man/man1
drwxr-xr-x. 2 root root 20480 3月 28 2016 /usr/share/man/man2
drwxr-xr-x. 2 root root 495616 3月 28 2016 /usr/share/man/man3
drwxr-xr-x. 2 root root 4096 3月 28 2016 /usr/share/man/man4
drwxr-xr-x. 2 root root 20480 3月 28 2016 /usr/share/man/man5
drwxr-xr-x. 2 root root 4096 3月 28 2016 /usr/share/man/man6
drwxr-xr-x. 2 root root 12288 3月 28 2016 /usr/share/man/man7
drwxr-xr-x. 2 root root 36864 3月 28 2016 /usr/share/man/man8
drwxr-xr-x. 2 root root 4096 9月 23 2011 /usr/share/man/man9
(4)复制/etc目录下,所有以p,m,r开头的,且以.conf结尾的文件或目录至/tmp/conf.d目录下;
[root@localhost etc]# mkdir /tmp/conf.d
[root@localhost etc]# cp -r /etc/[pmr]*.conf /tmp/conf.d
[root@localhost etc]# ls -ld /tmp/conf.d
drwxr-xr-x. 2 root root 4096 4月 5 01:02 /tmp/conf.d
7.程序的数据流有三个:
输入数据流: <--,标准输入(stdin),键盘; stdin=0
输出数据流:-->,标准输出(stdout), 显示器; stdin=1
错误数据流:-->,错误输出(stderr),显示器; stdin=2
8.输出重定向知识点:

COMMAND > /PATH/TO/SOMEFILE

覆盖重定向:覆盖目标文件中的原有内容;
例如:touch liwenming
cat /etc/fstab > liwenming
COMMAND >> /PATH/TO/SOMEFILE
追加重定向:追加新产生的内容至目标文件尾部;
cat /etc/fstab >> liwenming
9.管道知识点总结练习:
(1)把/etc/passwd文件最后三行信息中所有小写字符改为大写后输出;

[root@localhost /]# tail -n 3 /etc/passwd | tr "a-z" "A-Z"
SSHD:X:74:74:PRIVILEGE-SEPARATED SSH:/VAR/EMPTY/SSHD:/SBIN/NOLOGIN
TCPDUMP:X:72:72::/:/SBIN/NOLOGIN
LWM:X:500:500:LWM:/HOME/LWM:/BIN/BASH
(2)取出/etc/fstab的第6行;

[root@localhost /]# head /etc/fstab | tail -1
NI HOA MA
(3)取出/etc目录下所有以p开头的文件或目录,只显示前5个;

[root@localhost /]# ls -d /etc/p* | head -n 5
/etc/pam.d
/etc/pango
/etc/passwd
/etc/passwd-
/etc/pbm2ppa.conf
(4)tee命令,指的是双向输出,输出屏幕然后保存到文件中一份。
[root@localhost /]# echo lilili | tee li
lilili
(5)为用户提供默认配置的配置文件
/etc/login.defs, /etc/default/useradd
(6)把用户添加到组中,把用户移除组中
[root@localhost /]# useradd ming
[root@localhost /]# gpasswd -a ming li
Adding user ming to group li
[root@localhost /]# gpasswd -d ming li
Removing user ming from group li
(7)创建用户gentoo,UID为5000,基于组为gentoo,附加组为distro和peguin;

root@localhost /]# gpasswd -a gentoo distor
gpasswd: group 'distor' does not exist in /etc/group
[root@localhost /]# gpasswd -a gentoo peguin
Adding user gentoo to group peguin
[root@localhost /]# gpasswd -a gentoo distor
gpasswd: group 'distor' does not exist in /etc/group
[root@localhost /]# gpasswd -a gentoo distro
Adding user gentoo to group distro
[root@localhost /]#

(8)创建用户fedora,基于注释信息为"Fedora Core",默认shell为/bin/tcsh
useradd -s /bin/tcsh fedora -c "Fedora Core"
查看结果 cat /etc/passwd
[root@localhost etc]#useradd gentoo

[root@localhost etc]# useradd -g gentoo -G distro peguin
[root@localhost etc]# cat /etc/group
distro:x:1006:gentoo,peguin
(9)逻辑运算知识点总结

逻辑运算:
运算数:true, false
COMMAND:
0: TRUE
1-255: FALSE

与:

true && true = true
true && false = false
第一个操作数为true,其结果将取决于第二个操作数;
false && true = false
false && false = false
第一个操作数为False,其结果至此可断定,为false;

或:
true || true = true
true || false = true
第一个操作数为true,其结果至此可断定,为true;
false || true = true
false || false = false
第一个操作数为false,其结果将取决于第二个操作数;

非:
! true = false
! false = true
(10)特殊变量:
$0:脚本文件路径本身;
$#;脚本参数的个数;
$*:所有参数
$@:所有参数
(10)
内核编译过程:
步骤:
~]# tar xf linux-3.10.67.tar.xz -C /usr/src 将其内核源码压缩包进行解压,然后指明解压到的目录。
~]# cd /usr/src 然后进入这个目录
~]# ln -s linux-3.10.67 linux 将其解压的文件做一个链接,链接到linux
~]# cd linux 进入linux目录
~]# make menuconfig 进行配置内核选项
~]# make [-j #] 编译内核,可使用-j指定编译线程数量,例如:make -j 4
~]# make modules_install 安装内核模块
~]# make install 进行内核的安装

本文出自 “李文明的博客” 博客,请务必保留此出处http://liwenming18.blog.51cto.com/11068518/1757722
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: