Bo's Oracle Station

查看: 2248|回复: 0

课程第6次

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2019-4-17 20:18:48 | 显示全部楼层 |阅读模式
2019-04-17星期三
在man page里进行一个单词的查找(查找N这个“词“):
  1. ASCII(7)                   Linux Programmer's Manual                  ASCII(7)

  2. NAME
  3.        ascii - ASCII character set encoded in octal, decimal, and hexadecimal

  4. DESCRIPTION
  5.        ASCII is the American Standard Code for Information Interchange.  It is
  6.        a 7-bit code.  Many 8-bit codes (such as ISO 8859-1, the Linux  default
  7.        character  set)  contain  ASCII as their lower half.  The international
  8.        counterpart of ASCII is known as ISO 646.

  9.        The following table contains the 128 ASCII characters.

  10.        C program '\X' escapes are noted.

  11.        Oct   Dec   Hex   Char                        Oct   Dec   Hex   Char
  12.        ────────────────────────────────────────────────────────────────────────
  13.        000   0     00    NUL '\0'                    100   64    40    @
  14.        001   1     01    SOH (start of heading)      101   65    41    A
  15.        002   2     02    STX (start of text)         102   66    42    B
  16.        003   3     03    ETX (end of text)           103   67    43    C
  17.        004   4     04    EOT (end of transmission)   104   68    44    D
  18.        005   5     05    ENQ (enquiry)               105   69    45    E
  19.        006   6     06    ACK (acknowledge)           106   70    46    F
  20.        007   7     07    BEL '\a' (bell)             107   71    47    G
  21.        010   8     08    BS  '\b' (backspace)        110   72    48    H
  22.        011   9     09    HT  '\t' (horizontal tab)   111   73    49    I
  23.        012   10    0A    LF  '\n' (new line)         112   74    4A    J
  24.        013   11    0B    VT  '\v' (vertical tab)     113   75    4B    K
  25.        014   12    0C    FF  '\f' (form feed)        114   76    4C    L
  26.        015   13    0D    CR  '\r' (carriage ret)     115   77    4D    M
  27.        016   14    0E    SO  (shift out)             116   78    4E    N
  28.        017   15    0F    SI  (shift in)              117   79    4F    O
  29.        020   16    10    DLE (data link escape)      120   80    50    P
  30.        021   17    11    DC1 (device control 1)      121   81    51    Q
  31.        022   18    12    DC2 (device control 2)      122   82    52    R
  32.        023   19    13    DC3 (device control 3)      123   83    53    S
  33.        024   20    14    DC4 (device control 4)      124   84    54    T
  34.        025   21    15    NAK (negative ack.)         125   85    55    U
  35.        026   22    16    SYN (synchronous idle)      126   86    56    V
  36.        027   23    17    ETB (end of trans. blk)     127   87    57    W
  37.        030   24    18    CAN (cancel)                130   88    58    X
  38.        031   25    19    EM  (end of medium)         131   89    59    Y
  39.        032   26    1A    SUB (substitute)            132   90    5A    Z
  40.        033   27    1B    ESC (escape)                133   91    5B    [
  41.        034   28    1C    FS  (file separator)        134   92    5C    \  '\\'
  42.        035   29    1D    GS  (group separator)       135   93    5D    ]
  43.        036   30    1E    RS  (record separator)      136   94    5E    ^
  44. /\<N\>
复制代码
man -k 是非常有用的:
  1. [root@station60 ~]# man -k boot
  2. binfmt.d (5)         - Configure additional binary formats for executables at boot
  3. bootchart.conf (5)   - Boot performance analysis graphing tool configuration files
  4. bootchart.conf.d (5) - Boot performance analysis graphing tool configuration files
  5. bootctl (1)          - Control the firmware and boot manager settings
  6. bootparam (7)        - introduction to boot time parameters of the Linux kernel
复制代码
bootparam:
  1. BOOTPARAM(7)                                                    Linux Programmer's Manual                                                    BOOTPARAM(7)

  2. NAME
  3.        bootparam - introduction to boot time parameters of the Linux kernel

  4. DESCRIPTION
  5.        The  Linux kernel accepts certain 'command-line options' or 'boot time parameters' at the moment it is started.  In general this is used to supply
  6.        the kernel with information about hardware parameters that the kernel would not be able to determine on its own, or to avoid/override  the  values
  7.        that the kernel would otherwise detect.

  8.        When  the  kernel is booted directly by the BIOS (say from a floppy to which you copied a kernel using 'cp zImage /dev/fd0'), you have no opportu‐
  9.        nity to specify any parameters.  So, in order to take advantage of this possibility you have to use a boot loader that is able to pass parameters,
  10.        such as GRUB.

  11.    The argument list
  12.        The kernel command line is parsed into a list of strings (boot arguments) separated by spaces.  Most of the boot arguments take have the form:

  13.            name[=value_1][,value_2]...[,value_10]

  14.        where  'name'  is  a  unique keyword that is used to identify what part of the kernel the associated values (if any) are to be given to.  Note the
  15.        limit of 10 is real, as the present code handles only 10 comma separated parameters per keyword.  (However, you can reuse the same keyword with up
  16.        to an additional 10 parameters in unusually complicated situations, assuming the setup function supports it.)

  17.        Most  of  the sorting is coded in the kernel source file init/main.c.  First, the kernel checks to see if the argument is any of the special argu‐
  18.        ments 'root=', 'nfsroot=', 'nfsaddrs=', 'ro', 'rw', 'debug' or 'init'.  The meaning of these special arguments is described below.

  19.        Then it walks a list of setup functions (contained in the bootsetups array) to see if the specified argument string (such as 'foo') has been asso‐
  20.        ciated  with  a  setup function ('foo_setup()') for a particular device or part of the kernel.  If you passed the kernel the line foo=3,4,5,6 then
  21.        the kernel would search the bootsetups array to see if 'foo' was registered.  If it was, then it would call the  setup  function  associated  with
  22.        'foo' (foo_setup()) and hand it the arguments 3, 4, 5 and 6 as given on the kernel command line.

  23.        Anything  of  the  form 'foo=bar' that is not accepted as a setup function as described above is then interpreted as an environment variable to be
  24.        set.  A (useless?) example would be to use 'TERM=vt100' as a boot argument.

  25.        Any remaining arguments that were not picked up by the kernel and were not interpreted as environment variables are then passed onto process  one,
  26.        which is usually the init(1) program.  The most common argument that is passed to the init process is the word 'single' which instructs it to boot
  27.        the computer in single user mode, and not launch all the usual daemons.  Check the manual page for the version of init(1) installed on your system
  28.        to see what arguments it accepts.

  29.    General non-device specific boot arguments
  30.        'init=...'
复制代码
打印man page:
  1. [root@station60 Examples]# man -t  5  passwd > /root/labs/passwd.ps
  2. [root@station60 Examples]# cd /root/labs/
  3. [root@station60 labs]# ls
  4. !  1  1.sh  2  2.sh  3  4  4.sh  5  5.sh  a  [abcd]  b  c  d  list.txt  passwd.ps
  5. [root@station60 labs]# ps2
  6. ps2ascii  ps2epsi   ps2pdf    ps2pdf12  ps2pdf13  ps2pdf14  ps2pdfwr  ps2ps     ps2ps2
  7. [root@station60 labs]# ps2pdf  passwd.ps
  8. [root@station60 labs]# ls
  9. !  1  1.sh  2  2.sh  3  4  4.sh  5  5.sh  a  [abcd]  b  c  d  list.txt  passwd.pdf  passwd.ps
  10. [root@station60 labs]#
复制代码
把标准出错合并到标准输出:
  1. [root@station60 labs]# ls xxxx >  6.txt 2>&1
  2. [root@station60 labs]# cat 6.txt
  3. ls: cannot access xxxx: No such file or directory
  4. [root@station60 labs]#
复制代码
注意以下的8.txt是误操作:
  1. [root@station60 labs]# ls xxxx  &> 7.txt
  2. [root@station60 labs]# cat 7.txt
  3. ls: cannot access xxxx: No such file or directory
  4. [root@station60 labs]# ls xxxx  & > 8.txt
  5. [1] 20111
  6. [root@station60 labs]# ls: cannot access xxxx: No such file or directory

  7. [1]+  Exit 2                  ls --color=auto xxxx
复制代码
输出和出错同时重定向:
  1. [student@station60 ~]$ find /etc/ -name passwd > 1.txt 2>2.txt
  2. [student@station60 ~]$ cat 1.txt
  3. /etc/pam.d/passwd
  4. /etc/passwd
  5. [student@station60 ~]$ cat 2.txt
  6. find: ‘/etc/pki/CA/private’: Permission denied
  7. find: ‘/etc/pki/rsyslog’: Permission denied
  8. find: ‘/etc/grub.d’: Permission denied
  9. find: ‘/etc/selinux/targeted/active’: Permission denied
  10. find: ‘/etc/selinux/final’: Permission denied
  11. find: ‘/etc/dhcp’: Permission denied
  12. find: ‘/etc/lvm/archive’: Permission denied
  13. find: ‘/etc/lvm/backup’: Permission denied
  14. find: ‘/etc/lvm/cache’: Permission denied
  15. find: ‘/etc/polkit-1/rules.d’: Permission denied
  16. find: ‘/etc/polkit-1/localauthority’: Permission denied
  17. find: ‘/etc/sudoers.d’: Permission denied
  18. find: ‘/etc/vmware-tools/GuestProxyData/trusted’: Permission denied
  19. find: ‘/etc/audisp’: Permission denied
  20. find: ‘/etc/audit’: Permission denied
  21. find: ‘/etc/ipsec.d’: Permission denied
  22. find: ‘/etc/libvirt’: Permission denied
  23. find: ‘/etc/cups/ssl’: Permission denied
  24. find: ‘/etc/firewalld’: Permission denied
  25. [student@station60 ~]$

复制代码
UPG规则和非UPG方式建用户的区别:
  1. [root@station60 labs]# cat /etc/passwd
  2. root:x:0:0:root:/root:/bin/bash
  3. bin:x:1:1:bin:/bin:/sbin/nologin
  4. daemon:x:2:2:daemon:/sbin:/sbin/nologin
  5. adm:x:3:4:adm:/var/adm:/sbin/nologin
  6. lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
  7. sync:x:5:0:sync:/sbin:/bin/sync
  8. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  9. halt:x:7:0:halt:/sbin:/sbin/halt
  10. mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
  11. operator:x:11:0:operator:/root:/sbin/nologin
  12. games:x:12:100:games:/usr/games:/sbin/nologin
  13. ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
  14. nobody:x:99:99:Nobody:/:/sbin/nologin
  15. systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
  16. dbus:x:81:81:System message bus:/:/sbin/nologin
  17. polkitd:x:999:998:User for polkitd:/:/sbin/nologin
  18. libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
  19. colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin
  20. rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
  21. saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
  22. abrt:x:173:173::/etc/abrt:/sbin/nologin
  23. rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
  24. pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
  25. chrony:x:995:990::/var/lib/chrony:/sbin/nologin
  26. radvd:x:75:75:radvd user:/:/sbin/nologin
  27. rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
  28. nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
  29. unbound:x:994:989:Unbound DNS resolver:/etc/unbound:/sbin/nologin
  30. gluster:x:993:988:GlusterFS daemons:/run/gluster:/sbin/nologin
  31. qemu:x:107:107:qemu user:/:/sbin/nologin
  32. tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
  33. usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
  34. geoclue:x:992:986:User for geoclue:/var/lib/geoclue:/sbin/nologin
  35. setroubleshoot:x:991:985::/var/lib/setroubleshoot:/sbin/nologin
  36. saned:x:990:984:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
  37. gdm:x:42:42::/var/lib/gdm:/sbin/nologin
  38. gnome-initial-setup:x:989:983::/run/gnome-initial-setup/:/sbin/nologin
  39. sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
  40. avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
  41. postfix:x:89:89::/var/spool/postfix:/sbin/nologin
  42. ntp:x:38:38::/etc/ntp:/sbin/nologin
  43. tcpdump:x:72:72::/:/sbin/nologin
  44. student:x:1000:1000:student:/home/student:/bin/bash
  45. [root@station60 labs]# id student
  46. uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
  47. [root@station60 labs]# gro
  48. groff      grops      grotty     groupadd   groupdel   groupmems  groupmod   groups     growisofs
  49. [root@station60 labs]# group
  50. groupadd   groupdel   groupmems  groupmod   groups
  51. [root@station60 labs]# groups student
  52. student : student wheel
  53. [root@station60 labs]# su - student
  54. Last login: Wed Apr 17 09:05:47 EDT 2019 on pts/0
  55. [student@station60 ~]$ umask
  56. 0002
  57. [student@station60 ~]$ touch student1.txt
  58. [student@station60 ~]$ ls -l
  59. total 8
  60. -rw-rw-r--. 1 student student  30 Apr 17 09:06 1.txt
  61. -rw-rw-r--. 1 student student 929 Apr 17 09:06 2.txt
  62. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Desktop
  63. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Documents
  64. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Downloads
  65. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Music
  66. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Pictures
  67. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Public
  68. -rw-rw-r--. 1 student student   0 Apr 17 09:38 student1.txt
  69. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Templates
  70. drwxr-xr-x. 2 student student   6 Apr  4 16:45 Videos
  71. [student@station60 ~]$ exit
  72. logout
  73. [root@station60 labs]# groupadd oinstall
  74. [root@station60 labs]# group oinstall
  75. bash: group: command not found...
  76. [root@station60 labs]# groups oinstall
  77. groups: oinstall: no such user
  78. [root@station60 labs]# groups  student
  79. student : student wheel
  80. [root@station60 labs]# id student
  81. uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
  82. [root@station60 labs]# useradd oracle -g oinstall -G student
  83. [root@station60 labs]# groups oinstall
复制代码

不同用户进程访问文件系统案例(顺带研究目录这种特殊文件):
  1. [root@station60 labs]# id oracle
  2. uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1000(student)
  3. [root@station60 labs]# su - oracle
  4. [oracle@station60 ~]$ umask
  5. 0022
  6. [oracle@station60 ~]$ touch oracle.txt
  7. [oracle@station60 ~]$ ls
  8. oracle.txt
  9. [oracle@station60 ~]$ ls -l
  10. total 0
  11. -rw-r--r--. 1 oracle oinstall 0 Apr 17 09:42 oracle.txt
  12. [oracle@station60 ~]$ ls -l
  13. total 0
  14. -rw-r--r--. 1 oracle oinstall 0 Apr 17 09:42 oracle.txt
  15. [oracle@station60 ~]$ vim oracle.txt
  16. [oracle@station60 ~]$ cd /home/student/
  17. -bash: cd: /home/student/: Permission denied
  18. [oracle@station60 ~]$ ls -ld /home/student/
  19. drwx------. 15 student student 4096 Apr 17 09:38 /home/student/
  20. [oracle@station60 ~]$ exit
  21. logout
  22. [root@station60 labs]# su - studednt
  23. su: user studednt does not exist
  24. [root@station60 labs]# su - student
  25. Last login: Wed Apr 17 09:37:46 EDT 2019 on pts/0
  26. [student@station60 ~]$ ls -ld
  27. drwx------. 15 student student 4096 Apr 17 09:38 .
  28. [student@station60 ~]$ chmod g=rx ./
  29. [student@station60 ~]$ ls -ld
  30. drwxr-x---. 15 student student 4096 Apr 17 09:38 .
  31. [student@station60 ~]$ exit
  32. logout
  33. [root@station60 labs]# su - oracle
  34. Last login: Wed Apr 17 09:42:13 EDT 2019 on pts/0
  35. [oracle@station60 ~]$ cd /home/student/
  36. [oracle@station60 student]$
复制代码
对以上操作的解释:oracle这个用户之所以能够进入student的家目录是因为:1. oracle属于副组student
2.
  1. [oracle@station60 student]$ ls -ld .
  2. drwxr-x---. 15 student student 4096 Apr 17 09:38 .
复制代码

drwxr-x---. 15 student student 4096 Apr 17 09:38 .
主组信息在/etc/passwd,副组信息在/etc/group:
  1. [root@station60 labs]# cat /etc/passwd
  2. root:x:0:0:root:/root:/bin/bash
  3. bin:x:1:1:bin:/bin:/sbin/nologin
  4. daemon:x:2:2:daemon:/sbin:/sbin/nologin
  5. adm:x:3:4:adm:/var/adm:/sbin/nologin
  6. lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
  7. sync:x:5:0:sync:/sbin:/bin/sync
  8. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  9. halt:x:7:0:halt:/sbin:/sbin/halt
  10. mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
  11. operator:x:11:0:operator:/root:/sbin/nologin
  12. games:x:12:100:games:/usr/games:/sbin/nologin
  13. ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
  14. nobody:x:99:99:Nobody:/:/sbin/nologin
  15. systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
  16. dbus:x:81:81:System message bus:/:/sbin/nologin
  17. polkitd:x:999:998:User for polkitd:/:/sbin/nologin
  18. libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
  19. colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin
  20. rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
  21. saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
  22. abrt:x:173:173::/etc/abrt:/sbin/nologin
  23. rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
  24. pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
  25. chrony:x:995:990::/var/lib/chrony:/sbin/nologin
  26. radvd:x:75:75:radvd user:/:/sbin/nologin
  27. rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
  28. nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
  29. unbound:x:994:989:Unbound DNS resolver:/etc/unbound:/sbin/nologin
  30. gluster:x:993:988:GlusterFS daemons:/run/gluster:/sbin/nologin
  31. qemu:x:107:107:qemu user:/:/sbin/nologin
  32. tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
  33. usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
  34. geoclue:x:992:986:User for geoclue:/var/lib/geoclue:/sbin/nologin
  35. setroubleshoot:x:991:985::/var/lib/setroubleshoot:/sbin/nologin
  36. saned:x:990:984:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
  37. gdm:x:42:42::/var/lib/gdm:/sbin/nologin
  38. gnome-initial-setup:x:989:983::/run/gnome-initial-setup/:/sbin/nologin
  39. sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
  40. avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
  41. postfix:x:89:89::/var/spool/postfix:/sbin/nologin
  42. ntp:x:38:38::/etc/ntp:/sbin/nologin
  43. tcpdump:x:72:72::/:/sbin/nologin
  44. student:x:1000:1000:student:/home/student:/bin/bash
  45. oracle:x:1001:1001::/home/oracle:/bin/bash
  46. [root@station60 labs]# cat /etc/group
  47. group   group-
  48. [root@station60 labs]# cat /etc/group
  49. root:x:0:
  50. bin:x:1:
  51. daemon:x:2:
  52. sys:x:3:
  53. adm:x:4:
  54. tty:x:5:
  55. disk:x:6:
  56. lp:x:7:
  57. mem:x:8:
  58. kmem:x:9:
  59. wheel:x:10:student
  60. cdrom:x:11:
  61. mail:x:12:postfix
  62. man:x:15:
  63. dialout:x:18:
  64. floppy:x:19:
  65. games:x:20:
  66. tape:x:33:
  67. video:x:39:
  68. ftp:x:50:
  69. lock:x:54:
  70. audio:x:63:
  71. nobody:x:99:
  72. users:x:100:
  73. utmp:x:22:
  74. utempter:x:35:
  75. input:x:999:
  76. systemd-journal:x:190:
  77. systemd-network:x:192:
  78. dbus:x:81:
  79. polkitd:x:998:
  80. printadmin:x:997:
  81. libstoragemgmt:x:996:
  82. colord:x:995:
  83. rpc:x:32:
  84. dip:x:40:
  85. cgred:x:994:
  86. ssh_keys:x:993:
  87. saslauth:x:76:
  88. abrt:x:173:
  89. rtkit:x:172:
  90. pulse-access:x:992:
  91. pulse-rt:x:991:
  92. pulse:x:171:
  93. chrony:x:990:
  94. radvd:x:75:
  95. rpcuser:x:29:
  96. nfsnobody:x:65534:
  97. unbound:x:989:
  98. gluster:x:988:
  99. kvm:x:36:qemu
  100. qemu:x:107:
  101. tss:x:59:
  102. libvirt:x:987:
  103. usbmuxd:x:113:
  104. geoclue:x:986:
  105. setroubleshoot:x:985:
  106. saned:x:984:
  107. gdm:x:42:
  108. gnome-initial-setup:x:983:
  109. sshd:x:74:
  110. slocate:x:21:
  111. avahi:x:70:
  112. postdrop:x:90:
  113. postfix:x:89:
  114. ntp:x:38:
  115. tcpdump:x:72:
  116. stapusr:x:156:
  117. stapsys:x:157:
  118. stapdev:x:158:
  119. student:x:1000:oracle
  120. oinstall:x:1001:
  121. [root@station60 labs]#
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-12-5 03:04 , Processed in 0.032802 second(s), 24 queries .

快速回复 返回顶部 返回列表