linux 基础知识 之基础系统管理2

  1. 压缩、解压缩

[root@node6 ~]# cp -r /etc/security/ /tmp

[root@node6 ~]# cd /tmp/

[root@node6 tmp]# tar caf security.tar.gz security

[root@node6 tmp]# tar caf security.tar.bz2 security

[root@node6 tmp]# tar caf security.tar.xz security

[root@node6 tmp]# file security.tar.* # 判断文件的类型

[root@node6 tmp]# rm -rf security

[root@node6 tmp]# tar xaf security.tar.bz2

  1. NTP:网络时间协议,UDP123端口

  2. 计划任务:

30 * * * * command 每个小时的30分时执行

30 20 * * * command 每天2030执行

30 20 10 * * command 每月102030执行

30 20 10 3 * command 每年3102030执行

30 20 * * 3 command 每周三20:30执行

*/5 8-20 * * 1,3,5 command 周一三五从8点到到20点每隔5分钟

  1. 权限

[root@node6 ~]# ll anaconda-ks.cfg

-rw-------. root root anaconda-ks.cfg

第一个字符表示文件类型,-是文件,d是目录,l是软链接,b是块设备,c是字符设备。

接下来的9个字符,每三个字符分一组,分别表示属主u、属组g和其他人o的权限。这三个字符分别是读r4,写w2和执行x1


程序、命令总是以某个用户的身份去运行。默认情况下,哪个用户执行命令,命令就会以哪个用户的身份去运行。

  1. suid:程序、命令以属主的身份运行

[root@node6 ~]# ls /root/ 成功

[user1@node6 ~]$ ls /root/ 失败

[root@node6 ~]# chmod u+s /bin/ls

[root@node6 ~]# ll /bin/ls

[user1@node6 ~]$ ls /root/ 成功

------------------------------------------------------

[user1@node6 ~]$ touch user1

[root@node6 ~]# chmod u+s /bin/touch

[user1@node6 ~]$ touch user2

[user1@node6 ~]$ ll 两个文件属主不一样


  1. sgid: 新建的文件继承所在目录的属组

[root@node6 ~]# mkdir /tmp/demo

[root@node6 ~]# chgrp user1 /tmp/demo

[root@node6 ~]# ll -d /tmp/demo

drwxr-xr-x. 2 root user1 6 36 19:26 /tmp/demo

[root@node6 ~]# cp /etc/hosts /tmp/demo/

[root@node6 ~]# ll /tmp/demo/

-rw-r--r--. 1 root root 158 36 19:26 hosts

[root@node6 ~]# chmod g+s /tmp/demo/

[root@node6 ~]# cp /etc/passwd /tmp/demo/

[root@node6 ~]# ll /tmp/demo/

-rw-r--r--. 1 root root 158 36 19:26 hosts

-rw-r--r--. 1 root user1 2696 36 19:27 passwd

  1. sticky bit粘滞位:用户只能删除自己的文件

[root@node6 ~]# ll -d /tmp/ /var/tmp/


  1. NFS:网络文件系统,用于在linux系统间共享。端口号2049,基于RPC服务。NFS只提供了共享功能,没有实现底层数据传输,底层功能交给了RPC

  2. SAMBA:用于在linuxwindows系统间共享。


  1. LVM

逻辑卷管理。它是一种动态管理存储空间的方法。首先,将磁盘或分区转换成物理卷PV,然后将1到多个PV组合成卷组VG,再从VG上划分逻辑卷LVLV就可以像普通分区一样,进行格式化、挂载了。如果LV的空间不足了,可以在线进行扩容。


  1. 管道:前一个命令的输出作为后一命令的输入

[root@node6 ~]# echo '/etc/hosts' > /tmp/files

[root@node6 ~]# cat /tmp/files | ls -l 输出的是当前目录下所有文件的详细信息,而不是/etc/hosts的。 原因是ls不需要也不接受输入。

ls需要的是参数,所以使用管道时,需要把前一命令的输出转换成参数

[root@node6 ~]# cat /tmp/files | xargs ls -l

[root@node6 ~]# cat /tmp/files | chmod 640 报错

[root@node6 ~]# cat /tmp/files | xargs chmod 640


  1. 重定向

  1. 标准输入,文件描述符是0,默认是键盘

  2. 标准输出,文件描述符是1,默认是屏幕终端

  3. 标准错误,文件描述符是2,默认是屏幕终端

[root@node6 ~]# ll /etc/hosts 1> /tmp/list.out

[root@node6 ~]# ll /etc/hosts > /tmp/list.out 创建或覆盖

[root@node6 ~]# ls abc 2> /tmp/list.err

[root@node6 ~]# ls abc 2>> /tmp/list.err

[root@node6 ~]# tr 'a-z' 'A-Z' 将小写转大写,按ctrl+d结束输入

[root@node6 ~]# tr 'a-z' 'A-Z' 0< .bashrc

[root@node6 ~]# tr 'a-z' 'A-Z' < .bashrc

[root@node6 ~]# tr 'a-z' 'A-Z' < .bashrc > /tmp/bashrc

[root@node6 ~]# tr 'a-z' 'A-Z' <<EOF 输入EOF结束


  1. SELINUX

  1. 运行模式:Disabled / Permissive / Enforcing

  2. 修改: /etc/selinux/config => SELINUX=disabled


  1. team:链路聚合。将两块网卡绑定出一个逻辑网卡(team0),在team0上配置IP地址。一般底层的两块网卡采用主备的方式工作。teamRHEL7新增加的功能。如果是以前版本操作系统,配置的是BOND

https://my.oschina.net/jastme/blog/491095 bond配置












原文地址:https://www.cnblogs.com/fanever/p/10710647.html