{"id":796,"date":"2020-01-29T06:25:44","date_gmt":"2020-01-29T06:25:44","guid":{"rendered":"http:\/\/www.liutianfeng.com\/?p=796"},"modified":"2020-01-29T06:25:44","modified_gmt":"2020-01-29T06:25:44","slug":"linux%e7%94%a8%e6%88%b7%e5%af%86%e7%a0%81%e8%bf%87%e6%9c%9f%e5%bb%b6%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/www.liutianfeng.com\/?p=796","title":{"rendered":"Linux\u7528\u6237\u5bc6\u7801\u8fc7\u671f\u5ef6\u671f"},"content":{"rendered":"<p>Linux\u7528\u6237\u9ed8\u8ba4\u7684\u7528\u6237\u6709\u6548\u671f\u662f\u6c38\u4e45\u6709\u6548\u3002\u5982\u679c\u505a\u8fc7\u4e86\u5b89\u5168\u52a0\u56fa\uff0c\u7528\u6237\u7684\u6709\u6548\u671f\u901a\u5e38\u4f1a\u8bbe\u7f6e\u4e00\u4e2a\u56fa\u5b9a\u7684\u6570\u503c\uff0c\u6bd4\u598290\u5929\u3002<\/p>\n<p>\u6709\u6548\u671f\u662f\u4e3a\u4e86\u8ba9\u7528\u6237\u5b9a\u671f\u4fee\u6539\u5bc6\u7801\uff0c\u589e\u52a0\u5b89\u5168\u6027\u3002\u5982\u679c\u4e0d\u8003\u8651\u5b89\u5168\u6027\u7684\u95ee\u9898\uff0c\u5728\u5bc6\u7801\u5373\u5c06\u5230\u671f\u7684\u65f6\u5019\uff0c\u5c06\u5bc6\u7801\u6709\u6548\u671f\u76f4\u63a5\u5ef6\u957f\u4e0b\u4e00\u4e2a90\u5929\u7684\u8bdd\uff0c\u5c31\u9700\u8981\u7528\u4e00\u4e9b\u64cd\u4f5c\u6765\u8fdb\u884c\u3002<\/p>\n<h4>1. vim\u76f4\u63a5\u4fee\u6539<\/h4>\n<p>\u8bb0\u5f55\u5bc6\u7801\u6709\u6548\u671f\u7684\u6587\u4ef6\u662f\/etc\/shadow\uff0c\u8fd9\u4e2a\u662froot\u6743\u9650\u624d\u80fd\u8fdb\u884c\u4fee\u6539\u7684\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u6bcf\u4e00\u6bb5\u7684\u542b\u4e49\uff0c\u8bf7\u8f6c\u5230\uff1a<a href=\"https:\/\/www.liutianfeng.com\/?p=283\">CentOS\u4e2d\/etc\/shadow\u8be6\u89e3<\/a><\/p>\n<p>\u5176\u4e2d\uff0c\u5192\u53f7\u5206\u5272\u7684\u7b2c\u4e09\u6bb5\uff0c\u5c31\u662f\u6700\u540e\u4e00\u6b21\u4fee\u6539\u7684\u65e5\u671f\uff0c\u8ddd\u79bb1970\u5e741\u67081\u65e5\u7684\u5929\u6570\uff0c\u6211\u4eec\u628a\u8fd9\u4e2a\u6570\u503c\u4fee\u6539\u4e3a+90\u7684\u6570\u5b57\uff0c\u5373\u53ef\u5ef6\u957f\u6709\u6548\u671f90\u5929\u3002<\/p>\n<h4>2. chage\u547d\u4ee4\u4fee\u6539<\/h4>\n<p>\u5e2e\u52a9\u4fe1\u606f\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; chage --help \r\nUsage: chage [options] LOGIN\r\n\r\nOptions:\r\n  -d, --lastday LAST_DAY        set date of last password change to LAST_DAY\r\n  -E, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE\r\n  -h, --help                    display this help message and exit\r\n  -I, --inactive INACTIVE       set password inactive after expiration\r\n                                to INACTIVE\r\n  -l, --list                    show account aging information\r\n  -m, --mindays MIN_DAYS        set minimum number of days before password\r\n                                change to MIN_DAYS\r\n  -M, --maxdays MAX_DAYS        set maximim number of days before password\r\n                                change to MAX_DAYS\r\n  -R, --root CHROOT_DIR         directory to chroot into\r\n  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS<\/code><\/pre>\n<p><strong>\u91cd\u8981\u9009\u9879\uff1a<\/strong><\/p>\n<p>-d\uff1a\u4fee\u6539\u6700\u540e\u4e00\u6b21\u4fee\u6539\u5bc6\u7801\u7684\u65f6\u95f4<\/p>\n<p>\u5148\u67e5\u770b\/etc\/shadow\u6587\u4ef6\u4e2d\uff0c\u76f8\u5173\u7528\u6237\u6700\u540e\u4e00\u6b21\u4fee\u6539\u65e5\u671f\u8ddd\u79bb1970\u5e741\u67081\u65e5\u7684\u5929\u6570<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; sudo grep ^lius \/etc\/shadow |awk -F: '{print $3}'\r\n18208<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\uff08\u6bd4\u598218208\uff0c+90=18298\uff09\uff0c\u7136\u540e\u7528chage\u547d\u4ee4\u4fee\u6539\u8fd9\u4e2a\u65e5\u671f\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">chage -d 18291 lius<\/code><\/pre>\n<p>-l\uff1a\u67e5\u770b\u7528\u6237\u8d26\u53f7\u7684\u5404\u79cd\u65f6\u95f4\u4fe1\u606f<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; sudo chage -l lius\r\nLast password change\t\t\t\t\t: Feb 06, 2020\r\n<span style=\"color: #ff6600;\">Password expires<\/span>\t\t\t\t\t: May 06, 2020\r\nPassword inactive\t\t\t\t\t: never\r\n<span style=\"color: #ff6600;\">Account expires<\/span>\t\t\t\t\t\t: never\r\nMinimum number of days between password change\t\t: 6\r\nMaximum number of days between password change\t\t: 90\r\nNumber of days of warning before password expires\t: 30\t\t\t\t\t\t: never\r\nMinimum number of days between password change\t\t: 0\r\nMaximum number of days between password change\t\t: 99999\r\nNumber of days of warning before password expires\t: 7<\/code><\/pre>\n<p>\u8fd9\u6837\uff0cPassword expires\u7684\u65e5\u671f\u5411\u540e\u5ef6\u671f\u4e8690\u5929\u3002<\/p>\n<p>-E\uff1a\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684-E\u662f\u8d26\u53f7\u8fc7\u671f\u7684\u65f6\u95f4\uff0c\u4e0d\u662f\u5bc6\u7801\u8fc7\u671f\u7684\u65f6\u95f4\uff0c\u4fee\u6539\u7684\u662fAccount expires\u8fd9\u4e2a\u9009\u9879\uff0c\u548c\u6211\u4eec\u7684\u9884\u671f\u4e0d\u7b26\uff08\u770b\u4e0a\u9762\u6807\u7ea2\u7684\u7b2c\u4e8c\u4e2a\uff09\u3002<\/p>\n<h4>3. usermod\u547d\u4ee4<\/h4>\n<p>\u5e2e\u52a9\u4fe1\u606f\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; sudo usermod --help\r\nUsage: usermod [options] LOGIN\r\n\r\nOptions:\r\n  -c, --comment COMMENT         new value of the GECOS field\r\n  -d, --home HOME_DIR           new home directory for the user account\r\n  <span style=\"color: #ff6600;\">-e, --expiredate EXPIRE_DATE<\/span>  set account expiration date to EXPIRE_DATE\r\n  -f, --inactive INACTIVE       set password inactive after expiration\r\n                                to INACTIVE\r\n  -g, --gid GROUP               force use GROUP as new primary group\r\n  -G, --groups GROUPS           new list of supplementary GROUPS\r\n  -a, --append                  append the user to the supplemental GROUPS\r\n                                mentioned by the -G option without removing\r\n                                him\/her from other groups\r\n  -h, --help                    display this help message and exit\r\n  -l, --login NEW_LOGIN         new value of the login name\r\n  -L, --lock                    lock the user account\r\n  -m, --move-home               move contents of the home directory to the\r\n                                new location (use only with -d)\r\n  -o, --non-unique              allow using duplicate (non-unique) UID\r\n  -p, --password PASSWORD       use encrypted password for the new password\r\n  -R, --root CHROOT_DIR         directory to chroot into\r\n  -s, --shell SHELL             new login shell for the user account\r\n  -u, --uid UID                 new UID for the user account\r\n  -U, --unlock                  unlock the user account\r\n  -v, --add-subuids FIRST-LAST  add range of subordinate uids\r\n  -V, --del-subuids FIRST-LAST  remove range of subordinate uids\r\n  -w, --add-subgids FIRST-LAST  add range of subordinate gids\r\n  -W, --del-subgids FIRST-LAST  remove range of subordinate gids\r\n  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account<\/code><\/pre>\n<p><strong>\u76f8\u5173\u9009\u9879\uff1a<\/strong><\/p>\n<p>-e\uff1a\u8fd9\u4e2a-e\u548cchage\u4e2d\u7684-E\u7684\u529f\u80fd\u76f8\u540c\uff0c\u6539\u53d8\u7684\u662f\u8d26\u53f7\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u548c\u9700\u6c42\u4e0d\u7b26\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.liutianfeng.com\">liutianfeng.com<\/a> &raquo; <a href=\"https:\/\/www.liutianfeng.com\/?p=796\">Linux\u7528\u6237\u5bc6\u7801\u8fc7\u671f\u5ef6\u671f<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Linux\u7528\u6237\u9ed8\u8ba4\u7684\u7528\u6237\u6709\u6548\u671f\u662f\u6c38\u4e45\u6709\u6548\u3002\u5982\u679c\u505a\u8fc7\u4e86\u5b89\u5168\u52a0\u56fa\uff0c\u7528\u6237\u7684\u6709\u6548\u671f\u901a\u5e38\u4f1a\u8bbe\u7f6e\u4e00\u4e2a\u56fa\u5b9a\u7684\u6570\u503c\uff0c\u6bd4\u598290\u5929 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/796"}],"collection":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=796"}],"version-history":[{"count":1,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/796\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/796\/revisions\/797"}],"wp:attachment":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}