在工做当中咱们会遇到须要把pc上的一个文件上传到Linux上,或者须要把Linux上的某一个文件下载到pc上,后期咱们会学到samba和ftp服务,目前没有搭建samba和ftp咱们能够使用一个工具,lrzsz,要使用这个工具,首先在服务器端安装一下shell
[root@test-01 ~]# yum install -y lrzsz
*须要注明一点,这个工具只能在Xshell和secureCRT上使用,PuTTy 不能使用这个工具windows
[root@test-01 ~]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin lc1:x:1000:1000::/home/lc1:/bin/bash lc2:x:1001:1001::/home/lc2:/bin/bash lichao:x:1002:1002::/home/lichao:/bin/bash
lichao:x:1002:1002::/home/lichao:/bin/bash 这是配置文件里面的内容,拿出最后一行来分析,每一行都是被6个:分割成七段,每一段分别表明着各自的内容。安全
[root@test-01 ~]# cat /etc/shadow root:$6$L.93uoKv$HS4BaUfhO4cnEdHjAw56JAhUbmuz4Q9c3.tAjPvXiUFksYDy9lVYXxMsuV6WKipulJbM69PaEszcVhMILDXnv1:17516:0:99999:7::: bin:*:16231:0:99999:7::: daemon:*:16231:0:99999:7::: adm:*:16231:0:99999:7::: lp:*:16231:0:99999:7::: sync:*:16231:0:99999:7::: shutdown:*:16231:0:99999:7::: halt:*:16231:0:99999:7::: mail:*:16231:0:99999:7::: operator:*:16231:0:99999:7::: games:*:16231:0:99999:7::: ftp:*:16231:0:99999:7::: nobody:*:16231:0:99999:7::: dbus:!!:17512:::::: polkitd:!!:17512:::::: avahi:!!:17512:::::: avahi-autoipd:!!:17512:::::: postfix:!!:17512:::::: sshd:!!:17512:::::: lc1:!!:17521:0:99999:7::: lc2:!!:17521:0:99999:7::: lichao:$6$scJg7AnT$iJx/pPM2mLK8sWq0NDRX5Dur9wWLEKWwL8Zb5iYG6Y5ioV.WZtFbTeGaDGb4EVxrEXIsFuq3QKZrPyVrNzZLF0:17522:0:99999:7:::
lc2:!!:17521:0:99999:7::: 这是用户的密码配置文件,跟用户配置文件同样,当在系统中查看时,是一行对应一个用户,每一行被:分红了9段bash
[root@test-01 ~]# usermod -L lichao [root@test-01 ~]# tail -n2 /etc/shadow lc2:!!:17521:0:99999:7::: lichao:!$6$scJg7AnT$iJx/pPM2mLK8sWq0NDRX5Dur9wWLEKWwL8Zb5iYG6Y5ioV.WZtFbTeGaDGb4EVxrEXIsFuq3QKZrPyVrNzZLF0:17522:0:99999:7:::
至于这个配置文件每行的每一段表示什么意思,能够使用man shadow查看服务器
每一个字段的含义是: · sp_namp - 指向以 null 结束的用户名的指针 · sp_pwdp - 指向 null 结束的密码的指针 · sp_lstchg - 最近更改密码的日期(日期计算方法是从1970年1月1日开始的天数) · sp_min - days before which password may not be changed · sp_max - days after which password must be changed · sp_warn - days before password is to expire that user is warned of pending password expiration · sp_inact - days after password expires that account is considered inactive and disabled · sp_expire - days since Jan 1, 1970 when account will be disabled · sp_flag - reserved for future use
用户组也有一个配置文件,/etc/groupssh
[root@test-01 ~]# tail -n3 /etc/group lc2:x:1001: lichao:x:1002: slocate:x:21:
每一行带表的含义跟passwd相似,第一段组名,第二段组密码,第三段gid, 咱们能够给组指定gid,也能够在建立组的时候就指定gid,下面就是在建立的时候指定gid,而后再更改gid所使用的命令:ide
[root@test-01 ~]# groupadd -g 1111 111 [root@test-01 ~]# !tail tail -n3 /etc/group lichao:x:1002: slocate:x:21: 111:x:1111: [root@test-01 ~]# groupmod -g 2222 111 [root@test-01 ~]# !tail tail -n3 /etc/group lichao:x:1002: slocate:x:21: 111:x:2222:
删除组的命令是groupdel 格式为groupdel groupname工具
[root@test-01 ~]# groupdel 111 [root@test-01 ~]# !tail tail -n3 /etc/group lc2:x:1001: lichao:x:1002: slocate:x:21:
若是这个组里有用户,首先要删掉用户才能删掉组,不然不能删除。post
建立用户的命令是useradd,格式是useradd -u uid -g gid/组名用户名 -d 家目录 在建立用户时能够给用户指定uid和gid和家目录 ,若是不指定就会建立出uid比系统中最大的uid号+1的号,建立用户时能够指定组,不指定组就会建立一个和用户名同名的组ui
[root@test-01 ~]# useradd -u 2222 -g 2222 li1 [root@test-01 ~]# tail -n3 /etc/group lichao:x:1002: slocate:x:21: 22:x:2222: [root@test-01 ~]# tail -n3 /etc/passwd lc2:x:1001:1001::/home/lc2:/bin/bash lichao:x:1002:1002::/home/lichao:/bin/bash li1:x:2222:2222::/home/li1:/bin/bash [root@test-01 ~]# useradd li3 [root@test-01 ~]# tail -n3 /etc/passwd lichao:x:1002:1002::/home/lichao:/bin/bash li1:x:2222:2222::/home/li1:/bin/bash li3:x:2223:2223::/home/li3:/bin/bash [root@test-01 ~]# tail -n3 /etc/group slocate:x:21: 22:x:2222: li3:x:2223: