{"id":6303,"date":"2022-01-12T09:01:03","date_gmt":"2022-01-12T01:01:03","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?page_id=6303"},"modified":"2025-12-04T14:35:42","modified_gmt":"2025-12-04T06:35:42","slug":"ubuntu","status":"publish","type":"page","link":"https:\/\/blog.ywdevops.cn\/index.php\/ubuntu\/","title":{"rendered":"Ubuntu\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>ufw status                                #\u67e5\u770b\u9632\u706b\u5899\u72b6\u6001\uff0cinactive\u8868\u793a\u672a\u5f00\u542f\uff0cactive\u8868\u793a\u5f00\u542f\nufw enable                                #\u5f00\u542f\u9632\u706b\u5899\nufw disable                               #\u5173\u95ed\u9632\u706b\u5899\nufw allow 22\/tcp                          #\u9632\u706b\u5899\u5f00\u542ftcp 22\u7aef\u53e3\uff0c\u914d\u7f6e\u6587\u4ef6\u5728\/etc\/ufw\u4e2d,user6.rules\u8868\u793aipv6\nufw allow 53\/udp                          #\u9632\u706b\u5899\u5f00\u542fudp 53\u7aef\u53e3\nufw delete allow 3306\/tcp                 #\u5220\u96643306\u7aef\u53e3\ndpkg -l                                   #\u663e\u793a\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u7684deb\u5305\ndpkg -l |grep ssh                         #\u67e5\u770b\u662f\u5426\u5b89\u88c5\u4e86ssh\u670d\u52a1\uff0c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5\ndpkg -i package.deb                       #\u5b89\u88c5\/\u66f4\u65b0\u4e00\u4e2adeb\u5305\ndpkg -r package.deb                       #\u4ece\u7cfb\u7edf\u4e2d\u5220\u9664\u4e00\u4e2adeb\u5305\ndpkg -s package.deb                       #\u83b7\u53d6deb\u5305\u7684\u4fe1\u606f\ndpkg -S \/bin\/ping                         #\u786e\u5b9a\u6240\u7ed9\u7684\u6587\u4ef6\u7531\u54ea\u4e2adeb\u5305\u63d0\u4f9b\napt-get -y install openssh-server         #\u5b89\u88c5ssh\u670d\u52a1\napt-cdrom install package_name            #\u4ece\u5149\u76d8\u5b89\u88c5\/\u66f4\u65b0\u4e00\u4e2adeb\u5305\napt-get update -y                         #\u5347\u7ea7\u8f6f\u4ef6\u5305\napt-get upgrade                           #\u5347\u7ea7\u6240\u6709\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\napt-get remove package_name               #\u5220\u9664\u4e00\u4e2adeb\u5305\napt-get check                             #\u786e\u8ba4\u4f9d\u8d56\u7684\u8f6f\u4ef6\u4ed3\u5e93\u6b63\u786e\napt-get clean                             #\u4ece\u4e0b\u8f7d\u7684\u8f6f\u4ef6\u5305\u4e2d\u6e05\u7406\u7f13\u5b58\nsystemctl start nginx                     #\u5f00\u542f\u670d\u52a1\nsystemctl stop nginx                      #\u505c\u6b62\u670d\u52a1\nsystemctl restart nginx                   #\u91cd\u542f\u670d\u52a1\nsystemctl reload nginx                    #\u91cd\u8f7d\u914d\u7f6e\nsystemctl status nginx                    #\u67e5\u770b\u72b6\u6001\nsystemctl is-enabled  nginx               #\u67e5\u770b\u662f\u5426\u914d\u7f6e\u4e3a\u81ea\u542f\u52a8\nsystemctl enable nginx                    #\u5f00\u542f\u81ea\u542f\u52a8\nsystemctl disable nginx                   #\u5173\u95ed\u81ea\u542f\u52a8\nsystemctl mask nginx                      #\u7981\u7528\uff0c\u95f4\u63a5\u542f\u52a8\u4e5f\u4e0d\u53ef\u4ee5\nsystemctl unmask nginx                    #\u53d6\u6d88\u7981\u7528\nsystemctl set-default multi-user.target   #\u5173\u95ed\u56fe\u5f62\u754c\u9762\uff0c\u91cd\u542f\u751f\u6548\nsystemctl set-default graphical.target    #\u5f00\u542f\u7528\u6237\u56fe\u5f62\u754c\u9762\uff0c\u91cd\u542f\u751f\u6548\napt-cache madison kubelet | grep \"1.20.8\" #\u641c\u7d22\u8f6f\u4ef6\u7684\u6307\u5b9a\u7248\u672c\napt-cache madison \u8f6f\u4ef6\u540d                  #\u641c\u7d22\u8f6f\u4ef6\nuseradd -r -m -s \/bin\/bash \u7528\u6237\u540d         #\u6dfb\u52a0\u65b0\u7528\u6237\nifconfig ens33 down &amp;&amp; ifconfig ens33 up  #\u505c\u6b62\u5e76\u542f\u52a8\u7f51\u5361\napt remove git                            #\u5378\u8f7dgit\u5305\napt purge package_name                    #\u5378\u8f7d\u5305\uff0c\u540c\u65f6\u5220\u9664\u914d\u7f6e\u6587\u4ef6\ndpkg --get-selections                     #\u67e5\u770b\u5b89\u88c5\u4e86\u54ea\u4e9b\u5305\ndpkg --purge package_name                 #\u5220\u9664\u8f6f\u4ef6\u5305\u7684\u914d\u7f6e\u6587\u4ef6\napt install tzdata                        #\u5305\u542b\u4e16\u754c\u5404\u5730\u65f6\u533a\u7684\u8f6f\u4ef6\u5305\napt-cache madison nginx                   #\u67e5\u770b\u6e90\u91cc\u7684\u8f6f\u4ef6\u7248\u672c\napt-get install -y --download-only -o dir::cache::archives=\/tmp\/linshi nginx #\u5c06\u6e90\u91cc\u7684nginx\u8f6f\u4ef6\u4e0b\u8f7d\u5230\u672c\u5730\/tmp\/linshi\u8def\u5f84,\u8def\u5f84\u9700\u8981\u63d0\u524d\u521b\u5efa\napt-mark hold nginx                       #\u9501\u5b9a\u7248\u672c\uff0c\u9501\u5b9a\u540e\u53ef\u4ee5\u9632\u6b62\u81ea\u52a8\u66f4\u65b0\napt-mark unhold nginx                     #\u89e3\u9501\nsystemctl stop unattended-upgrades        #\u5173\u95ed\u81ea\u52a8\u66f4\u65b0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u5982\u679c\u901a\u8fc7docker\u6765\u8fd0\u884cubuntu 22.04\uff0c\u90a3\u4e48docker Engine\u7248\u672c\u81f3\u5c11\u9700\u898120.10.10\u4ee5\u4e0a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4fee\u6539\u65f6\u533a\u4e3a24\u5c0f\u65f6\u5236\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timedatectl set-timezone Asia\/Shanghai   #\u8bbe\u7f6e\u65f6\u533a\u4e3a\u4e0a\u6d77\nLC_TIME=en_DK.UTF-8                      #\u6dfb\u52a0\u5230\/etc\/default\/locale\u4e2d \nupdate-locale                            #\u914d\u7f6e\u751f\u6548\uff0c\u6267\u884c\u540e\u91cd\u65b0\u767b\u5f55\u7ec8\u7aef\u5373\u53ef\n\n\u5907\u6ce8\uff1a\u5982\u679c\u6267\u884cupdate-locale\u62a5\u9519update-locale: Error: invalid locale settings:  LC_TIME=en_DK.UTF-8\uff0c\u53ef\u80fd\u662flocale\u4e0d\u53ef\u7528\uff0c\u53ef\u6309\u5982\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a\nlocale -a           #\u5982\u679cen_DK.utf8 \u6216 en_DK.UTF-8 \u4e0d\u5728\u5217\u8868\u4e2d\uff0c\u8bf4\u660e\u8be5 locale \u672a\u751f\u6210\nvim \/etc\/locale.gen #\u627e\u5230en_DK.UTF-8\uff0c\u53d6\u6d88\u6ce8\u91ca\nlocale-gen          #\u751f\u6210locale\uff0c\u7136\u540e\u518d\u6309\u7167\u4e0a\u9762\u4fee\u6539\u4e3a24\u5c0f\u65f6\u5236\u5373\u53ef<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u4fee\u6539ubuntu\u666e\u901a\u7528\u6237\u7684\u7ec8\u7aefshell\u4e3a\/bin\/bash<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ubuntu\u65b0\u5efa\u7528\u6237\u540e\uff0c\u5982\u679c\u4f7f\u7528\u7684\u662f\/bin\/sh\u7ec8\u7aefshell\uff0c\u90a3\u4e48\u662f\u65e0\u6cd5\u4f7f\u7528tab\u952e\uff0c\u6b64\u65f6\u9700\u8981\u914d\u7f6e\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>usermod --shell \/bin\/bash username    #\u4fee\u6539\u7528\u6237username\u7684shell\u7c7b\u578b\u4e3a\/bin\/bash\ngrep username \/etc\/passwd             #\u67e5\u8be2shell\n#\u4e5f\u53ef\u4ee5\u5728\u521b\u5efa\u7528\u6237\u7684\u65f6\u5019\u6307\u5b9ashell,\u5982\uff1auseradd -m -s \/bin\/bash username,-s\u8868\u793a\u6307\u5b9ashell<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\uff1aubuntu\u6216\u8005\u884d\u751f\u7248\uff0c\u6bd4\u5982linux mint\u4e5f\u53ef\u4ee5\u4f7f\u7528\u622a\u56fe\u5de5\u5177Snipaste<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001ubuntu\u666e\u901a\u7528\u6237\u6dfb\u52a0\u4e86visudo\u6743\u9650\u540e\uff0c\u6267\u884csudo su -\u8fd8\u662f\u63d0\u793a\u8f93\u5165\u5bc6\u7801<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u529e\u6cd5\uff0c\u5c06\u914d\u7f6e\u7684\u7528\u6237\u653e\u5728\/etc\/sudoers\u4e2d<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">%sudo<\/mark><\/strong>\u7ec4\u7684\u4e0b\u65b9\u5373\u53ef<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001ubuntu\u684c\u9762\u7248\u5b89\u88c5\u540e\uff0c\u53ef\u4ee5\u5b89\u88c5latte-dock\u6765\u6574\u7406\u684c\u9762\u90e8\u4ef6\uff0c\u914d\u7f6e\u540e\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"348\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/03\/wechat_2025-03-06_144840_583.png\" alt=\"\" class=\"wp-image-17951\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/03\/wechat_2025-03-06_144840_583.png 652w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/03\/wechat_2025-03-06_144840_583-300x160.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2025\/03\/wechat_2025-03-06_144840_583-600x320.png 600w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u610f\uff1a\u5982\u679c\u901a\u8fc7docker\u6765\u8fd0\u884cubuntu 22.04\uff0c\u90a3\u4e48docker Engine\u7248\u672c\u81f3\u5c11\u9700\u898120.10 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6303","page","type-page","status-publish","hentry"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/pages\/6303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=6303"}],"version-history":[{"count":38,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/pages\/6303\/revisions"}],"predecessor-version":[{"id":19221,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/pages\/6303\/revisions\/19221"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=6303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}