{"id":104,"date":"2025-12-20T00:20:04","date_gmt":"2025-12-20T00:20:04","guid":{"rendered":"https:\/\/blogs.giamkichsan.com\/?p=104"},"modified":"2025-12-21T04:06:17","modified_gmt":"2025-12-21T04:06:17","slug":"mot-so-cau-lenh-trong-ubuntu","status":"publish","type":"post","link":"https:\/\/blogs.giamkichsan.com\/index.php\/2025\/12\/20\/mot-so-cau-lenh-trong-ubuntu\/","title":{"rendered":"M\u1ed9t s\u1ed1 c\u00e2u l\u1ec7nh trong Ubuntu"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">1. Thay \u0111\u1ed5i m\u1eadt kh\u1ea9u<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo passwd ten_user<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">2. T\u1ea1o user m\u1edbi<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo adduser ten_user<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Xo\u00e1 user (n\u1ebfu c\u1ea7n)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo deluser ten_user<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Xo\u00e1 lu\u00f4n home:<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo deluser --remove-home ten_user<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\ud83d\udd10 C\u1ea5u h\u00ecnh b\u1ea3o m\u1eadt SSH (khuy\u1ebfn ngh\u1ecb)<\/h5>\n\n\n\n<p>Ch\u1ec9 cho ph\u00e9p user c\u1ee5 th\u1ec3 SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p>Th\u00eam:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AllowUsers devuser admin<\/code><\/pre>\n\n\n\n<p>Restart:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart ssh<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">3. C\u1ea5p quy\u1ec1n sudo<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo usermod -aG sudo ten_user \/\/to\u00e0n quy\u1ec1n qu\u1ea3n tr\u1ecb<\/code><\/pre>\n\n\n\n<p>Ki\u1ec3m tra: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>groups ten_user\n\n\/\/N\u1ebfu c\u00f3 <span style=\"background-color: initial; font-family: inherit; font-size: inherit; color: initial;\">sudo<\/span> \u2192 OK \u2705<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">4. T\u1eaft \u0111\u0103ng nh\u1eadp root qua SSH(\u0110\u1ed1i v\u1edbi CONTABO &#8211; KH\u00d4NG N\u00caN D\u00d9NG)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p>S\u1eeda \/ ki\u1ec3m tra:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PermitRootLogin no<\/code><\/pre>\n\n\n\n<p>Restart SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart ssh<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">5\ufe0f\u20e3 Ph\u00e2n quy\u1ec1n th\u01b0 m\u1ee5c \/ file<\/h5>\n\n\n\n<h3 class=\"wp-block-heading\">G\u00e1n quy\u1ec1n s\u1edf h\u1eefu:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R ten_user:ten_user &#91;\/duong\/dan]<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Ph\u00e2n quy\u1ec1n \u0111\u1ecdc\/ghi\/ch\u1ea1y:<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod 755 &#91;\/duong\/dan]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">1\ufe0f\u20e3 D\u00f9ng <code>scp<\/code> (secure copy)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">C\u00fa ph\u00e1p chung:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp \/path\/to\/local\/file username@server_ip:\/path\/to\/remote\/directory\/\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">V\u00ed d\u1ee5:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>File tr\u00ean client: <code>\/home\/user\/test.txt<\/code><\/li>\n\n\n\n<li>Server: <code>vmi2928652<\/code> (IP 109.199.101.177)<\/li>\n\n\n\n<li>User tr\u00ean server: <code>root<\/code><\/li>\n\n\n\n<li>Copy v\u00e0o <code>\/root\/<\/code> tr\u00ean server<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>scp \/home\/user\/test.txt root@109.199.101.177:\/root\/\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sau \u0111\u00f3 nh\u1eadp <strong>m\u1eadt kh\u1ea9u root<\/strong> l\u00e0 file s\u1ebd \u0111\u01b0\u1ee3c copy.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2\ufe0f\u20e3 Copy c\u1ea3 th\u01b0 m\u1ee5c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -r \/home\/user\/myfolder root@109.199.101.177:\/root\/\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-r<\/code> = recursive, copy to\u00e0n b\u1ed9 folder<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3\ufe0f\u20e3 D\u00f9ng <code>rsync<\/code> (n\u1ebfu mu\u1ed1n copy nhi\u1ec1u file v\u00e0 \u0111\u1ed3ng b\u1ed9)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>rsync -avz \/home\/user\/myfolder\/ root@109.199.101.177:\/root\/myfolder\/\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-a<\/code> : archive (gi\u1eef quy\u1ec1n, timestamp)<\/li>\n\n\n\n<li><code>-v<\/code> : verbose<\/li>\n\n\n\n<li><code>-z<\/code> : n\u00e9n khi g\u1eedi<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4\ufe0f\u20e3 L\u01b0u \u00fd<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Client ph\u1ea3i c\u00f3 quy\u1ec1n truy c\u1eadp SSH v\u00e0o server.<\/li>\n\n\n\n<li>N\u1ebfu server d\u00f9ng port SSH kh\u00e1c 22, th\u00eam <code>-P port_number<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -P 2222 file.txt root@109.199.101.177:\/root\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>1. Thay \u0111\u1ed5i m\u1eadt kh\u1ea9u 2. T\u1ea1o user m\u1edbi Xo\u00e1 user (n\u1ebfu c\u1ea7n) Xo\u00e1 lu\u00f4n home: \ud83d\udd10 C\u1ea5u h\u00ecnh b\u1ea3o m\u1eadt SSH (khuy\u1ebfn ngh\u1ecb) Ch\u1ec9 <a class=\"mh-excerpt-more\" href=\"https:\/\/blogs.giamkichsan.com\/index.php\/2025\/12\/20\/mot-so-cau-lenh-trong-ubuntu\/\" title=\"M\u1ed9t s\u1ed1 c\u00e2u l\u1ec7nh trong Ubuntu\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-ubuntu-he-dieu-hanh"],"_links":{"self":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":6,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions\/170"}],"wp:attachment":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}