File transfer between linux and windows, user configuration files and password configuration files, user group management, user management

1. File transfer between Linux and Windows

At work, we will encounter the need to upload a file on the pc to Linux, or download a file on Linux to the pc. Later, we will learn samba and ftp services. We have not built samba and ftp yet. You can use a tool, lrzsz , to use this tool, first install it on the server side

[root@test-01 ~]# yum install -y lrzsz

*It should be noted that this tool can only be used on Xshell and secureCRT, PuTTy cannot use this tool

  • After installation, use the rz command directly, and a dialog box will pop up, in which you can select the file on the PC side. After selecting, the file will be uploaded to Linux, and the file will be uploaded to the current directory.
  • If you want to download a file to windows, you can run sz_ filename_ and a dialog box will appear, to download the file to that directory of windows. very simple and very practical

2. User Profiles and Password Profiles

User profile /etc/passwd

[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 This is the content of the configuration file, take out the last line to analyze, each line is divided into 6: divided into seven segments, each segment represents with their own content.

  • lichao=username
  • x=password (the user's password was once put in this place, but later because of security reasons, the password is not put here, but there is still a place in this place, which has no practical significance).
  • The next two sets of numbers, the previous number represents the uid, the user id. The latter number represents the gid, the group id.
  • The paragraph after the number is the user's comment information, which has no practical effect. Most of them are empty. The user root is root.
  • The sixth segment is the user's home directory
  • The seventh paragraph is the user's shell, the common one is /bin/bash, which is a user who can log in, and /sbin/nologin is a user who cannot log in, even if a password is set for this user, it cannot log in

Password configuration file /etc/shadow

[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::: This is the user's password configuration file. Like the user configuration file, when viewed in the system, one line corresponds to one user, and each line is divided into 9 segments by:

  • The first paragraph also indicates the username
  • The second segment is the password, which is encrypted, and the encryption process is irreversible, that is, a string is generated by encrypting a plaintext password, but it cannot be decrypted into a plaintext password through the string. Use this line to analyze, the second paragraph two! Indicates no password, if yes! Followed by a bunch of strings, indicating that the user's password is locked and cannot log in normally as follows:
[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:::

As for what each paragraph of each line of this configuration file means, you can use man shadow to view it

 每个字段的含义是:

       ·   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

3. User group management and user management

User group management

User groups also have a configuration file, /etc/group

[root@test-01 ~]# tail -n3 /etc/group
lc2:x:1001:
lichao:x:1002:
slocate:x:21:

The meaning of each row with table is similar to passwd, the first group name, the second group password, and the third gid, we can specify the gid for the group, or specify the gid when creating the group, the following is created When specifying the gid, and then changing the command used by the gid:

[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:

The command to delete a group is groupdel in the format groupdel groupname

[root@test-01 ~]# groupdel 111
[root@test-01 ~]# !tail
tail -n3 /etc/group
lc2:x:1001:
lichao:x:1002:
slocate:x:21:

If there are users in this group, you must first delete the user to delete the group, otherwise it cannot be deleted.

User Management

The command to create a user is useradd, the format is useradd -u uid -g gid/group name user name -d home directory. When creating a user, you can specify uid, gid and home directory for the user. If not specified, the uid will be created than the system. The number of the largest uid number + 1, you can specify a group when creating a user, if you do not specify a group, a group with the same name as the user name will be created

[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:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324476893&siteId=291194637