{"id":87181,"date":"2025-05-24T20:25:58","date_gmt":"2025-05-24T13:25:58","guid":{"rendered":"https:\/\/itviec1.uptech.vn\/?p=87181"},"modified":"2025-05-24T20:25:58","modified_gmt":"2025-05-24T13:25:58","slug":"cau-hoi-phong-van-bash-shell","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/","title":{"rendered":"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#Tong_quan_ve_Bash_shell\" >T\u1ed5ng quan v\u1ec1 Bash shell<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#Cau_hoi_phong_van_Bash_Shell_co_ban\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell c\u01a1 b\u1ea3n<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#Cau_hoi_phong_van_Bash_Shell_nang_cao\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell n\u00e2ng cao<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>Bash Shell l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd v\u00e0 kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean ho\u1eb7c qu\u1ea3n tr\u1ecb vi\u00ean h\u1ec7 th\u1ed1ng n\u00e0o l\u00e0m vi\u1ec7c v\u1edbi Linux. Khi tham gia ph\u1ecfng v\u1ea5n, nh\u1eefng c\u00e2u h\u1ecfi v\u1ec1 Bash Shell c\u00f3 th\u1ec3 xu\u1ea5t hi\u1ec7n \u1edf nhi\u1ec1u c\u1ea5p \u0111\u1ed9 kh\u00e1c nhau, t\u1eeb nh\u1eefng c\u00e2u h\u1ecfi c\u01a1 b\u1ea3n v\u1ec1 c\u00fa ph\u00e1p \u0111\u1ebfn c\u00e1c c\u00e2u h\u1ecfi ph\u1ee9c t\u1ea1p v\u1ec1 scripting, t\u1ef1 \u0111\u1ed9ng h\u00f3a h\u1ec7 th\u1ed1ng \u0111\u1ebfn \u1ee9ng d\u1ee5ng th\u1ef1c ti\u1ec5n.\u00a0<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n v\u1ec1:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Nh\u1eefng v\u1ecb tr\u00ed th\u01b0\u1eddng y\u00eau c\u1ea7u k\u1ef9 n\u0103ng v\u1ec1 Bash shell<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Nh\u1eefng c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n c\u01a1 b\u1ea3n v\u1ec1 Bash shell<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Nh\u1eefng c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n v\u1ec1 Bash shell cho ng\u01b0\u1eddi c\u00f3 kinh nghi\u1ec7m<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tong_quan_ve_Bash_shell\"><\/span><b>T\u1ed5ng quan v\u1ec1 Bash shell<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Bash shell l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn trong c\u00e1c h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux v\u00e0 Unix-like. N\u00f3 kh\u00f4ng ch\u1ec9 l\u00e0 m\u1ed9t m\u00f4i tr\u01b0\u1eddng d\u00f2ng l\u1ec7nh \u0111\u1ec3 ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 t\u01b0\u01a1ng t\u00e1c tr\u1ef1c ti\u1ebfp v\u1edbi h\u1ec7 th\u1ed1ng, m\u00e0 c\u00f2n l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh \u0111\u1ec3 vi\u1ebft c\u00e1c script t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00f4ng vi\u1ec7c, x\u1eed l\u00fd t\u1ec7p, qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng v\u00e0 r\u1ea5t nhi\u1ec1u t\u00e1c v\u1ee5 kh\u00e1c. Trong m\u00f4i tr\u01b0\u1eddng ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m v\u00e0 qu\u1ea3n tr\u1ecb h\u1ec7 th\u1ed1ng, Bash l\u00e0 c\u00f4ng c\u1ee5 kh\u00f4ng th\u1ec3 thi\u1ebfu cho nh\u1eefng ai mu\u1ed1n t\u0103ng hi\u1ec7u qu\u1ea3 l\u00e0m vi\u1ec7c.<\/span><\/p>\n<h3><b>Nh\u00e0 tuy\u1ec3n d\u1ee5ng \u0111\u00e1nh gi\u00e1 \u0111i\u1ec1u g\u00ec khi ph\u1ecfng v\u1ea5n v\u1ec1 Bash shell?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Khi tuy\u1ec3n d\u1ee5ng cho c\u00e1c v\u1ecb tr\u00ed li\u00ean quan \u0111\u1ebfn h\u1ec7 th\u1ed1ng ho\u1eb7c ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, nh\u00e0 tuy\u1ec3n d\u1ee5ng th\u01b0\u1eddng t\u1eadp trung v\u00e0o ki\u1ebfn th\u1ee9c v\u00e0 k\u1ef9 n\u0103ng s\u1eed d\u1ee5ng Bash shell, bao g\u1ed3m c\u1ea3 m\u1ee9c c\u01a1 b\u1ea3n v\u00e0 n\u00e2ng cao. Nh\u1eefng y\u1ebfu t\u1ed1 th\u01b0\u1eddng \u0111\u01b0\u1ee3c \u0111\u00e1nh gi\u00e1 bao g\u1ed3m:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hi\u1ec3u bi\u1ebft v\u1ec1 c\u00e1c l\u1ec7nh v\u00e0 c\u1ea5u tr\u00fac l\u1ec7nh trong Bash.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">K\u1ef9 n\u0103ng vi\u1ebft Bash script \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a t\u00e1c v\u1ee5 v\u00e0 x\u1eed l\u00fd t\u1ec7p.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ki\u1ebfn th\u1ee9c v\u1ec1 c\u00e1c l\u1ec7nh nh\u01b0 <\/span><span style=\"font-weight: 400;\">grep<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">find<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">chmod<\/span><span style=\"font-weight: 400;\"> v\u00e0 c\u00e1c c\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh kh\u00e1c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Kh\u1ea3 n\u0103ng l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c c\u00e2u l\u1ec7nh \u0111i\u1ec1u ki\u1ec7n (if, case), v\u00f2ng l\u1eb7p (for, while) v\u00e0 c\u00e1ch x\u1eed l\u00fd l\u1ed7i trong Bash.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">K\u1ef9 n\u0103ng qu\u1ea3n l\u00fd v\u00e0 c\u1ea5u h\u00ecnh m\u00f4i tr\u01b0\u1eddng shell qua c\u00e1c file nh\u01b0 <\/span><span style=\"font-weight: 400;\">.bashrc<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">.bash_profile<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">K\u1ef9 n\u0103ng t\u1ef1 \u0111\u1ed9ng h\u00f3a v\u00e0 t\u1ea1o cron jobs.<\/span><\/li>\n<\/ul>\n<h3><b>Nh\u1eefng v\u1ecb tr\u00ed n\u00e0o th\u01b0\u1eddng g\u1eb7p c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Bash shell l\u00e0 k\u1ef9 n\u0103ng quan tr\u1ecdng trong nhi\u1ec1u v\u1ecb tr\u00ed k\u1ef9 thu\u1eadt, \u0111\u1eb7c bi\u1ec7t khi l\u00e0m vi\u1ec7c v\u1edbi h\u1ec7 th\u1ed1ng Unix\/Linux. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 vai tr\u00f2 ph\u1ed5 bi\u1ebfn m\u00e0 c\u00e2u h\u1ecfi v\u1ec1 Bash th\u01b0\u1eddng xu\u1ea5t hi\u1ec7n:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>System Administrator (Qu\u1ea3n tr\u1ecb h\u1ec7 th\u1ed1ng)<\/b><span style=\"font-weight: 400;\">: \u0110\u00e2y l\u00e0 v\u1ecb tr\u00ed th\u01b0\u1eddng xuy\u00ean s\u1eed d\u1ee5ng Bash \u0111\u1ec3 qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng, vi\u1ebft c\u00e1c script t\u1ef1 \u0111\u1ed9ng h\u00f3a, th\u1ef1c hi\u1ec7n sao l\u01b0u v\u00e0 gi\u00e1m s\u00e1t h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>DevOps Engineer<\/b><span style=\"font-weight: 400;\">: V\u1edbi m\u00f4i tr\u01b0\u1eddng DevOps, vi\u1ec7c t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c quy tr\u00ecnh, tri\u1ec3n khai ph\u1ea7n m\u1ec1m v\u00e0 qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng qua Bash script \u0111\u00f3ng vai tr\u00f2 quan tr\u1ecdng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Linux Engineer<\/b><span style=\"font-weight: 400;\">: V\u1ecb tr\u00ed n\u00e0y y\u00eau c\u1ea7u \u1ee9ng vi\u00ean ph\u1ea3i th\u00e0nh th\u1ea1o c\u00e1c l\u1ec7nh v\u00e0 script Bash \u0111\u1ec3 qu\u1ea3n l\u00fd v\u00e0 v\u1eadn h\u00e0nh c\u00e1c h\u1ec7 th\u1ed1ng Linux.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Software Developer<\/b><span style=\"font-weight: 400;\">: Trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, Bash shell c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 ki\u1ec3m tra, t\u1ef1 \u0111\u1ed9ng h\u00f3a v\u00e0 ph\u00e1t tri\u1ec3n c\u00e1c c\u00f4ng c\u1ee5 h\u1ed7 tr\u1ee3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Security Engineer<\/b><span style=\"font-weight: 400;\">: Ki\u1ebfn th\u1ee9c v\u1ec1 Bash gi\u00fap c\u00e1c chuy\u00ean gia b\u1ea3o m\u1eadt t\u1ef1 \u0111\u1ed9ng h\u00f3a ki\u1ec3m tra b\u1ea3o m\u1eadt, th\u1ef1c thi c\u00e1c l\u1ec7nh an to\u00e0n v\u00e0 gi\u00e1m s\u00e1t h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Cloud Engineer:<\/b><span style=\"font-weight: 400;\"> V\u1ecb tr\u00ed n\u00e0y th\u01b0\u1eddng y\u00eau c\u1ea7u ki\u1ebfn th\u1ee9c v\u1ec1 Bash \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a vi\u1ec7c tri\u1ec3n khai v\u00e0 qu\u1ea3n l\u00fd t\u00e0i nguy\u00ean tr\u00ean c\u00e1c n\u1ec1n t\u1ea3ng \u0111\u00e1m m\u00e2y.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Site Reliability Engineer (SRE):<\/b><span style=\"font-weight: 400;\"> T\u01b0\u01a1ng t\u1ef1 nh\u01b0 DevOps Engineer, c\u00e1c SRE c\u1ea7n s\u1eed d\u1ee5ng Bash \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a quy tr\u00ecnh v\u00e0 \u0111\u1ea3m b\u1ea3o \u0111\u1ed9 tin c\u1eady c\u1ee7a h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Data Engineer:<\/b><span style=\"font-weight: 400;\"> S\u1eed d\u1ee5ng Bash \u0111\u1ec3 x\u1eed l\u00fd d\u1eef li\u1ec7u, t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c pipeline ETL v\u00e0 qu\u1ea3n l\u00fd lu\u1ed3ng d\u1eef li\u1ec7u.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Bash_Shell_co_ban\"><\/span><b>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell c\u01a1 b\u1ea3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>Gi\u1ea3i th\u00edch shell v\u00e0 shell script l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Shell l\u00e0 m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh m\u00e1y t\u00ednh \u0111\u00f3ng vai tr\u00f2 l\u00e0 giao di\u1ec7n gi\u1eefa ng\u01b0\u1eddi d\u00f9ng v\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh, cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng t\u01b0\u01a1ng t\u00e1c v\u1edbi h\u1ec7 th\u1ed1ng qua c\u00e1c l\u1ec7nh. S\u1edf d\u0129 c\u00f3 t\u00ean &#8220;shell&#8221; (v\u1ecf) v\u00ec n\u00f3 nh\u01b0 l\u00e0 l\u1edbp v\u1ecf bao quanh h\u1ec7 \u0111i\u1ec1u h\u00e0nh, cung c\u1ea5p giao di\u1ec7n \u0111\u1ec3 ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 \u0111\u01b0a ra y\u00eau c\u1ea7u v\u00e0 nh\u1eadn k\u1ebft qu\u1ea3 t\u1eeb h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00f2n shell script l\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c l\u1ec7nh shell \u0111\u01b0\u1ee3c l\u01b0u trong m\u1ed9t t\u1ec7p v\u0103n b\u1ea3n (th\u01b0\u1eddng c\u00f3 \u0111u\u00f4i <\/span><span style=\"font-weight: 400;\">.sh<\/span><span style=\"font-weight: 400;\">). Nh\u1eefng script n\u00e0y cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5, gi\u00fap gi\u1ea3m thi\u1ec3u c\u00f4ng vi\u1ec7c l\u1eb7p l\u1ea1i. V\u00ed d\u1ee5, ch\u00fang ta c\u00f3 th\u1ec3 vi\u1ebft m\u1ed9t shell script \u0111\u1ec3 sao l\u01b0u h\u1ec7 th\u1ed1ng, c\u1eadp nh\u1eadt ph\u1ea7n m\u1ec1m ho\u1eb7c ki\u1ec3m tra t\u00ecnh tr\u1ea1ng c\u1ee7a c\u00e1c d\u1ecbch v\u1ee5 h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/shell-script-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>Shell script l\u00e0 g\u00ec: T\u1eeb A-Z v\u1ec1 c\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh cho l\u1eadp tr\u00ecnh vi\u00ean<\/strong><\/a><\/em><\/p><\/blockquote>\n<h3><b>Shell \u0111\u1ea3m nhi\u1ec7m nh\u1eefng ch\u1ee9c n\u0103ng g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Shell l\u00e0 c\u1ea7u n\u1ed1i gi\u1eefa ng\u01b0\u1eddi d\u00f9ng v\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh, \u0111\u1ea3m nhi\u1ec7m 3 ch\u1ee9c n\u0103ng ch\u00ednh:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Nh\u1eadn l\u1ec7nh t\u1eeb ng\u01b0\u1eddi d\u00f9ng<\/b><span style=\"font-weight: 400;\">: Ng\u01b0\u1eddi d\u00f9ng nh\u1eadp l\u1ec7nh v\u00e0o shell th\u00f4ng qua d\u00f2ng l\u1ec7nh (CLI &#8211; Command Line Interface).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Chuy\u1ec3n c\u00e1c l\u1ec7nh \u0111\u00f3 th\u00e0nh m\u00e3 l\u1ec7nh h\u1ec7 th\u1ed1ng<\/b><span style=\"font-weight: 400;\">: Sau khi nh\u1eadn l\u1ec7nh, shell s\u1ebd truy\u1ec1n l\u1ec7nh \u0111\u00f3 \u0111\u1ebfn kernel (h\u1ea1t nh\u00e2n c\u1ee7a h\u1ec7 \u0111i\u1ec1u h\u00e0nh) \u0111\u1ec3 th\u1ef1c thi.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3<\/b><span style=\"font-weight: 400;\">: Sau khi th\u1ef1c thi, shell s\u1ebd hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 t\u1eeb h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 khi nh\u1eadp l\u1ec7nh <\/span><span style=\"font-weight: 400;\">ls<\/span><span style=\"font-weight: 400;\"> v\u00e0o terminal (shell) \u0111\u1ec3 li\u1ec7t k\u00ea c\u00e1c t\u1ec7p trong th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i, shell s\u1ebd chuy\u1ec3n l\u1ec7nh n\u00e0y th\u00e0nh m\u1ed9t y\u00eau c\u1ea7u m\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh c\u00f3 th\u1ec3 hi\u1ec3u v\u00e0 tr\u1ea3 v\u1ec1 danh s\u00e1ch c\u00e1c t\u1ec7p trong th\u01b0 m\u1ee5c.<\/span><\/p>\n<h3><b>C\u00e1c t\u00ednh n\u0103ng c\u1ee7a Shell g\u1ed3m nh\u1eefng g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ec7nh c\u01a1 b\u1ea3n<\/b><span style=\"font-weight: 400;\">: Shell cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng nh\u1eadp c\u00e1c l\u1ec7nh c\u01a1 b\u1ea3n nh\u01b0 <\/span><span style=\"font-weight: 400;\">ls<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">cd<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">pwd<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">cp<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">mv<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">rm<\/span><span style=\"font-weight: 400;\">, \u0111\u1ec3 qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ef1 \u0111\u1ed9ng h\u00f3a<\/b><span style=\"font-weight: 400;\">: T\u1ea1o c\u00e1c shell script \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c c\u00f4ng vi\u1ec7c nh\u01b0 sao l\u01b0u d\u1eef li\u1ec7u, ki\u1ec3m tra t\u00ecnh tr\u1ea1ng h\u1ec7 th\u1ed1ng, ho\u1eb7c c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Qu\u1ea3n l\u00fd t\u1ec7p tin<\/b><span style=\"font-weight: 400;\">: Shell gi\u00fap t\u1ea1o, di chuy\u1ec3n, sao ch\u00e9p v\u00e0 x\u00f3a t\u1ec7p tin, th\u01b0 m\u1ee5c m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>\u0110i\u1ec1u ki\u1ec7n v\u00e0 v\u00f2ng l\u1eb7p<\/b><span style=\"font-weight: 400;\">: Shell h\u1ed7 tr\u1ee3 c\u00e1c c\u00e2u l\u1ec7nh \u0111i\u1ec1u ki\u1ec7n (<\/span><span style=\"font-weight: 400;\">if-else<\/span><span style=\"font-weight: 400;\">) v\u00e0 v\u00f2ng l\u1eb7p (<\/span><span style=\"font-weight: 400;\">for<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">while<\/span><span style=\"font-weight: 400;\">) \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 ph\u1ee9c t\u1ea1p.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Qu\u1ea3n l\u00fd quy\u1ec1n truy c\u1eadp<\/b><span style=\"font-weight: 400;\">: Shell c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh nh\u01b0 <\/span><span style=\"font-weight: 400;\">chmod<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">chown<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">chgrp<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 thay \u0111\u1ed5i quy\u1ec1n truy c\u1eadp v\u00e0 s\u1edf h\u1eefu t\u1ec7p.<\/span><\/li>\n<\/ul>\n<h3><b>Ph\u00e2n bi\u1ec7t c\u00e1c lo\u1ea1i shell ph\u1ed5 bi\u1ebfn<\/b><\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Lo\u1ea1i Shell<\/b><\/td>\n<td><b>C\u00fa ph\u00e1p<\/b><\/td>\n<td><b>\u01afu \u0111i\u1ec3m<\/b><\/td>\n<td><b>Nh\u01b0\u1ee3c \u0111i\u1ec3m<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Bash (Bourne Again Shell)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p d\u1ec5 hi\u1ec3u, h\u1ed7 tr\u1ee3 t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh, l\u1ecbch s\u1eed l\u1ec7nh, v\u00e0 nhi\u1ec1u t\u00ednh n\u0103ng m\u1edf r\u1ed9ng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; T\u01b0\u01a1ng th\u00edch cao v\u1edbi c\u00e1c l\u1ec7nh c\u1ee7a Bourne Shell.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; T\u00ednh linh ho\u1ea1t cao, c\u00f3 th\u1ec3 x\u1eed l\u00fd c\u00e1c t\u00e1c v\u1ee5 \u0111\u01a1n gi\u1ea3n v\u00e0 ph\u1ee9c t\u1ea1p.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; T\u00edch h\u1ee3p v\u1edbi nhi\u1ec1u c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd nh\u01b0 <\/span><span style=\"font-weight: 400;\">grep<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\">.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; C\u1ea5u h\u00ecnh ph\u1ee9c t\u1ea1p h\u01a1n so v\u1edbi m\u1ed9t s\u1ed1 shell kh\u00e1c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; C\u00f3 th\u1ec3 kh\u00f4ng t\u1ed1i \u01b0u cho c\u00e1c t\u00e1c v\u1ee5 r\u1ea5t ph\u1ee9c t\u1ea1p.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Csh (C Shell)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p gi\u1ed1ng C, d\u00f9ng l\u1ec7nh nh\u01b0 trong ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh C<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; C\u00fa ph\u00e1p th\u00e2n thi\u1ec7n v\u1edbi l\u1eadp tr\u00ecnh vi\u00ean C.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; H\u1ed7 tr\u1ee3 l\u1ecbch s\u1eed l\u1ec7nh v\u00e0 c\u00e1c t\u00ednh n\u0103ng \u0111i\u1ec1u khi\u1ec3n c\u00f4ng vi\u1ec7c.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; \u00cdt ph\u1ed5 bi\u1ebfn v\u00e0 c\u00f3 \u00edt t\u00ednh n\u0103ng t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh l\u1ec7nh.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; T\u00edch h\u1ee3p h\u1ea1n ch\u1ebf v\u1edbi c\u00e1c c\u00f4ng c\u1ee5 Unix.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ksh (Korn Shell)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">K\u1ebft h\u1ee3p c\u00e1c t\u00ednh n\u0103ng c\u1ee7a Bourne Shell v\u00e0 C Shell, v\u1edbi c\u00e1c c\u1ea3i ti\u1ebfn m\u1ea1nh m\u1ebd<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; H\u1ed7 tr\u1ee3 c\u00e1c m\u1ea3ng, chu\u1ed7i, v\u00e0 c\u00e1c thao t\u00e1c ph\u1ee9c t\u1ea1p.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; T\u00ednh hi\u1ec7u qu\u1ea3 cao, th\u00edch h\u1ee3p cho c\u00e1c t\u00e1c v\u1ee5 t\u1ef1 \u0111\u1ed9ng h\u00f3a l\u1edbn.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; C\u1ea5u h\u00ecnh kh\u00f3 h\u01a1n, \u00edt h\u1ed7 tr\u1ee3 c\u1ed9ng \u0111\u1ed3ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; \u00cdt s\u1eed d\u1ee5ng trong c\u00e1c m\u00f4i tr\u01b0\u1eddng kh\u00f4ng ph\u1ea3i doanh nghi\u1ec7p.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Zsh (Z Shell)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">T\u00ednh n\u0103ng t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh, s\u1eeda l\u1ed7i ch\u00ednh t\u1ea3, t\u00f9y ch\u1ec9nh cao<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; T\u00ednh linh ho\u1ea1t v\u00e0 d\u1ec5 d\u00e0ng t\u00f9y ch\u1ec9nh v\u1edbi plugin v\u00e0 ch\u1ee7 \u0111\u1ec1.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; H\u1ed7 tr\u1ee3 r\u1ea5t m\u1ea1nh m\u1ebd cho vi\u1ec7c ho\u00e0n th\u00e0nh l\u1ec7nh v\u00e0 x\u1eed l\u00fd c\u00fa ph\u00e1p.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; C\u00f3 th\u1ec3 m\u1ea5t th\u1eddi gian l\u00e0m quen v\u1edbi c\u00e1c t\u00ednh n\u0103ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Kh\u00f4ng t\u01b0\u01a1ng th\u00edch ho\u00e0n h\u1ea3o v\u1edbi c\u00e1c script c\u1ee7a Bash.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Fish (Friendly Interactive Shell)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng d\u1ec5 s\u1eed d\u1ee5ng, c\u00fa ph\u00e1p r\u00f5 r\u00e0ng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; D\u1ec5 s\u1eed d\u1ee5ng, th\u00e2n thi\u1ec7n v\u1edbi ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; T\u00ednh n\u0103ng t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh l\u1ec7nh m\u1ea1nh m\u1ebd v\u00e0 hi\u1ec3n th\u1ecb c\u00fa ph\u00e1p m\u00e0u s\u1eafc.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">&#8211; Kh\u00f4ng t\u01b0\u01a1ng th\u00edch ho\u00e0n h\u1ea3o v\u1edbi c\u00e1c script c\u1ee7a Bash.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; \u00cdt ph\u1ed5 bi\u1ebfn h\u01a1n so v\u1edbi Bash v\u00e0 Zsh.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>Bash script l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Bash script l\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c l\u1ec7nh Bash \u0111\u01b0\u1ee3c ghi l\u1ea1i trong m\u1ed9t file v\u0103n b\u1ea3n, gi\u00fap t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 ho\u1eb7c x\u1eed l\u00fd d\u1eef li\u1ec7u m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i nh\u1eadp l\u1ea1i l\u1ec7nh t\u1eebng b\u01b0\u1edbc. Nh\u1eefng script n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng, c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m, sao l\u01b0u d\u1eef li\u1ec7u ho\u1eb7c th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 b\u1ea3o tr\u00ec h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u1eb7c d\u00f9 ch\u00fang c\u00f3 th\u1ec3 \u0111\u01a1n gi\u1ea3n ho\u1eb7c ph\u1ee9c t\u1ea1p t\u00f9y thu\u1ed9c v\u00e0o m\u1ee5c \u0111\u00edch s\u1eed d\u1ee5ng, nh\u01b0ng \u0111i\u1ec1u quan tr\u1ecdng l\u00e0 bash script gi\u00fap ti\u1ebft ki\u1ec7m th\u1eddi gian v\u00e0 gi\u1ea3m thi\u1ec3u c\u00e1c l\u1ed7i c\u00f3 th\u1ec3 x\u1ea3y ra khi th\u1ef1c hi\u1ec7n th\u1ee7 c\u00f4ng.<\/span><\/p>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/bash-script-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>Bash script l\u00e0 g\u00ec? C\u00e1ch ch\u1ea1y Bash script hi\u1ec7u qu\u1ea3<\/strong><\/a><\/em><\/p><\/blockquote>\n<h3><b>C\u1ea5u tr\u00fac c\u1ee7a m\u1ed9t Bash Script g\u1ed3m nh\u1eefng th\u00e0nh ph\u1ea7n n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">M\u1ed9t Bash script \u0111\u01a1n gi\u1ea3n\u00a0 th\u01b0\u1eddng c\u00f3 \u0111u\u00f4i <\/span><span style=\"font-weight: 400;\">.sh<\/span><span style=\"font-weight: 400;\"> v\u00e0 b\u1eaft \u0111\u1ea7u v\u1edbi d\u00f2ng shebang <\/span><span style=\"font-weight: 400;\">#!\/bin\/bash<\/span><span style=\"font-weight: 400;\">, cho ph\u00e9p h\u1ec7 th\u1ed1ng bi\u1ebft r\u1eb1ng script n\u00e0y c\u1ea7n \u0111\u01b0\u1ee3c ch\u1ea1y b\u1eb1ng Bash shell. Sau \u0111\u00f3 l\u00e0 c\u00e1c l\u1ec7nh Bash m\u00e0 ch\u00fang ta mu\u1ed1n th\u1ef1c thi, bao g\u1ed3m l\u1ec7nh shell, c\u00e2u l\u1ec7nh \u0111i\u1ec1u ki\u1ec7n, v\u00f2ng l\u1eb7p, c\u0169ng nh\u01b0 c\u00e1c thao t\u00e1c v\u1edbi t\u1ec7p v\u00e0 th\u01b0 m\u1ee5c.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre>#!\/bin\/bash\r\n# This script prints \"Hello, World!\"\r\necho \"Hello, World<\/pre>\n<p><span style=\"font-weight: 400;\">Khi l\u01b0u script tr\u00ean v\u00e0o t\u1ec7p <\/span><span style=\"font-weight: 400;\">hello.sh<\/span><span style=\"font-weight: 400;\"> v\u00e0 c\u1ea5p quy\u1ec1n th\u1ef1c thi b\u1eb1ng l\u1ec7nh <\/span><span style=\"font-weight: 400;\">chmod +x hello.sh<\/span><span style=\"font-weight: 400;\">, ch\u00fang ta c\u00f3 th\u1ec3 ch\u1ea1y script n\u00e0y b\u1eb1ng c\u00e1ch g\u00f5 <\/span><span style=\"font-weight: 400;\">.\/hello.sh<\/span><span style=\"font-weight: 400;\">, v\u00e0 k\u1ebft qu\u1ea3 s\u1ebd l\u00e0:<\/span><\/p>\n<pre>Hello, World!<\/pre>\n<h3><b>Superblock c\u00f3 li\u00ean h\u1ec7 g\u00ec v\u1edbi Shell scripting l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong h\u1ec7 th\u1ed1ng file Unix\/Linux, Superblock l\u00e0 m\u1ed9t c\u1ea5u tr\u00fac d\u1eef li\u1ec7u l\u01b0u tr\u1eef th\u00f4ng tin quan tr\u1ecdng v\u1ec1 h\u1ec7 th\u1ed1ng file. N\u00f3 kh\u00f4ng ch\u1ee9a d\u1eef li\u1ec7u c\u1ee7a ch\u00ednh t\u1ec7p tin, m\u00e0 ch\u1ee9a c\u00e1c th\u00f4ng tin qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng file nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">K\u00edch th\u01b0\u1edbc h\u1ec7 th\u1ed1ng file (k\u00edch th\u01b0\u1edbc c\u1ee7a c\u00e1c block, nh\u00f3m block,\u2026)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1ed1 l\u01b0\u1ee3ng c\u00e1c block tr\u1ed1ng v\u00e0 \u0111\u00e3 s\u1eed d\u1ee5ng<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">V\u1ecb tr\u00ed c\u1ee7a c\u00e1c inode (bi\u1ec3u \u0111\u1ed3 th\u00f4ng tin v\u1ec1 c\u00e1c t\u1ec7p tin)<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Superblock l\u00e0 ph\u1ea7n th\u00f4ng tin quan tr\u1ecdng \u0111\u1ec3 h\u1ec7 th\u1ed1ng file c\u00f3 th\u1ec3 ho\u1ea1t \u0111\u1ed9ng \u0111\u00fang. M\u1ed7i khi truy c\u1eadp v\u00e0o h\u1ec7 th\u1ed1ng file, th\u00f4ng tin t\u1eeb Superblock s\u1ebd gi\u00fap \u0111i\u1ec1u h\u01b0\u1edbng v\u00e0 qu\u1ea3n l\u00fd vi\u1ec7c \u0111\u1ecdc v\u00e0 ghi d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u1eb7c d\u00f9 Superblock kh\u00f4ng ph\u1ea3i l\u00e0 m\u1ed9t ph\u1ea7n tr\u1ef1c ti\u1ebfp c\u1ee7a Shell scripting, nh\u01b0ng khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c h\u1ec7 th\u1ed1ng file ho\u1eb7c khi c\u1ea7n qu\u1ea3n l\u00fd v\u00e0 ki\u1ec3m tra dung l\u01b0\u1ee3ng \u0111\u0129a, s\u1ed1 l\u01b0\u1ee3ng block tr\u1ed1ng, hay c\u00e1c s\u1ef1 c\u1ed1 v\u1edbi h\u1ec7 th\u1ed1ng file, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng Shell scripting \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 li\u00ean quan \u0111\u1ebfn Superblock.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Khi th\u1ef1c hi\u1ec7n c\u00e1c l\u1ec7nh nh\u01b0 <\/span><span style=\"font-weight: 400;\">df<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">du<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 <\/span><span style=\"font-weight: 400;\">fsck<\/span><span style=\"font-weight: 400;\"> trong Linux, ta \u0111ang gi\u00e1n ti\u1ebfp l\u00e0m vi\u1ec7c v\u1edbi th\u00f4ng tin trong Superblock \u0111\u1ec3 ki\u1ec3m tra ho\u1eb7c s\u1eeda ch\u1eefa h\u1ec7 th\u1ed1ng file. V\u00ed d\u1ee5 \u0111\u1ec3 ki\u1ec3m tra th\u00f4ng tin h\u1ec7 th\u1ed1ng file v\u00e0 Superblock:<\/span><\/p>\n<pre>sudo fsck -N \/dev\/sda1<\/pre>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh tr\u00ean s\u1ebd kh\u00f4ng s\u1eeda ch\u1eefa g\u00ec m\u00e0 ch\u1ec9 hi\u1ec3n th\u1ecb c\u00e1c th\u00f4ng tin v\u1ec1 l\u1ed7i, bao g\u1ed3m nh\u1eefng th\u00f4ng tin li\u00ean quan \u0111\u1ebfn Superblock v\u00e0 c\u00e1c l\u1ed7i c\u1ee7a h\u1ec7 th\u1ed1ng file.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 ki\u1ec3m tra dung l\u01b0\u1ee3ng \u1ed5 \u0111\u0129a v\u00e0 th\u00f4ng tin v\u1ec1 Superblock:<\/span><\/p>\n<pre>df -h<\/pre>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh n\u00e0y s\u1ebd hi\u1ec3n th\u1ecb dung l\u01b0\u1ee3ng h\u1ec7 th\u1ed1ng file v\u00e0 th\u00f4ng tin s\u1eed d\u1ee5ng kh\u00f4ng gian \u0111\u0129a, nh\u01b0ng kh\u00f4ng hi\u1ec3n th\u1ecb chi ti\u1ebft v\u1ec1 Superblock c\u1ee7a t\u1eebng ph\u00e2n v\u00f9ng, gi\u00fap ng\u01b0\u1eddi d\u00f9ng bi\u1ebft \u0111\u01b0\u1ee3c c\u00f3 bao nhi\u00eau kh\u00f4ng gian tr\u1ed1ng v\u00e0 \u0111\u00e3 s\u1eed d\u1ee5ng.<\/span><\/p>\n<h3><b>B\u1ea1n hi\u1ec3u sao v\u1ec1 tham s\u1ed1 v\u1ecb tr\u00ed (positional parameters) trong Bash?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Bash, tham s\u1ed1 v\u1ecb tr\u00ed l\u00e0 c\u00e1c tham s\u1ed1 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 truy c\u1eadp c\u00e1c \u0111\u1ed1i s\u1ed1 (arguments) m\u00e0 ng\u01b0\u1eddi d\u00f9ng truy\u1ec1n v\u00e0o m\u1ed9t script ho\u1eb7c m\u1ed9t l\u1ec7nh. C\u00e1c tham s\u1ed1 n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c \u0111\u00e1nh s\u1ed1 t\u1eeb 1 \u0111\u1ebfn n v\u00e0 ch\u00fang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 nh\u1eadn gi\u00e1 tr\u1ecb t\u1eeb d\u00f2ng l\u1ec7nh m\u00e0 ng\u01b0\u1eddi d\u00f9ng nh\u1eadp khi ch\u1ea1y script.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Tham s\u1ed1 v\u1ecb tr\u00ed r\u1ea5t h\u1eefu \u00edch khi ng\u01b0\u1eddi d\u00f9ng mu\u1ed1n truy\u1ec1n c\u00e1c gi\u00e1 tr\u1ecb t\u1eeb d\u00f2ng l\u1ec7nh v\u00e0o script \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i s\u1eeda \u0111\u1ed5i code script m\u1ed7i l\u1ea7n. V\u00ed d\u1ee5, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng tham s\u1ed1 v\u1ecb tr\u00ed \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh t\u1ec7p c\u1ea7n x\u1eed l\u00fd, \u0111\u01b0\u1eddng d\u1eabn, t\u00ean ng\u01b0\u1eddi d\u00f9ng ho\u1eb7c c\u00e1c tham s\u1ed1 c\u1ea5u h\u00ecnh kh\u00e1c khi ch\u1ea1y script.<\/span><\/p>\n<h3><b>S\u1eed d\u1ee5ng tham s\u1ed1 v\u1ecb tr\u00ed nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Khi g\u1ecdi m\u1ed9t script t\u1eeb d\u00f2ng l\u1ec7nh, ch\u00fang ta c\u00f3 th\u1ec3 truy\u1ec1n c\u00e1c tham s\u1ed1 v\u00e0o script \u0111\u00f3. C\u00e1c tham s\u1ed1 n\u00e0y \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef d\u01b0\u1edbi d\u1ea1ng c\u00e1c bi\u1ebfn \u0111\u1eb7c bi\u1ec7t trong Bash, \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 tham s\u1ed1 v\u1ecb tr\u00ed. C\u00e1c tham s\u1ed1 n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c truy c\u1eadp v\u00e0 s\u1eed d\u1ee5ng trong script th\u00f4ng qua c\u00fa ph\u00e1p <\/span><span style=\"font-weight: 400;\">$1<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">$2<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">$3<\/span><span style=\"font-weight: 400;\">, \u2026 t\u01b0\u01a1ng \u1ee9ng v\u1edbi tham s\u1ed1 \u0111\u1ea7u ti\u00ean, th\u1ee9 hai, th\u1ee9 ba v\u00e0 c\u1ee9 ti\u1ebfp t\u1ee5c nh\u01b0 v\u1eady.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Gi\u1ea3 s\u1eed ta c\u00f3 m\u1ed9t script Bash t\u00ean l\u00e0 <\/span><span style=\"font-weight: 400;\">example.sh<\/span><span style=\"font-weight: 400;\"> v\u00e0 c\u1ea7n ch\u1ea1y script n\u00e0y v\u1edbi c\u00e1c tham s\u1ed1 sau:<\/span><\/p>\n<pre>.\/example.sh apple banana cherry<\/pre>\n<p><span style=\"font-weight: 400;\">Trong script <\/span><span style=\"font-weight: 400;\">example.sh<\/span><span style=\"font-weight: 400;\">, ta c\u00f3 th\u1ec3 truy c\u1eadp c\u00e1c tham s\u1ed1 v\u1ecb tr\u00ed nh\u01b0 sau:<\/span><\/p>\n<pre>#!\/bin\/bash\r\necho \"Tham s\u1ed1 \u0111\u1ea7u ti\u00ean: $1\"\r\necho \"Tham s\u1ed1 th\u1ee9 hai: $2\"\r\necho \"Tham s\u1ed1 th\u1ee9 ba: $3\"<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 khi ch\u1ea1y script tr\u00ean s\u1ebd l\u00e0:<\/span><\/p>\n<pre>Tham s\u1ed1 \u0111\u1ea7u ti\u00ean: apple\r\nTham s\u1ed1 th\u1ee9 hai: banana\r\nTham s\u1ed1 th\u1ee9 ba: cherr<\/pre>\n<h3><b>H\u00e3y k\u1ec3 t\u00ean c\u00e1c tham s\u1ed1 v\u1ecb tr\u00ed quan tr\u1ecdng<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$1<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">$2<\/span><span style=\"font-weight: 400;\">, &#8230;: Truy c\u1eadp c\u00e1c tham s\u1ed1 v\u1ecb tr\u00ed \u0111\u00e3 \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o. M\u1ed7i s\u1ed1 \u0111\u1ea1i di\u1ec7n cho m\u1ed9t tham s\u1ed1.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$#<\/span><span style=\"font-weight: 400;\">: S\u1ed1 l\u01b0\u1ee3ng tham s\u1ed1 \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o script.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$@<\/span><span style=\"font-weight: 400;\">: T\u1ea5t c\u1ea3 c\u00e1c tham s\u1ed1 \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o d\u01b0\u1edbi d\u1ea1ng m\u1ed9t danh s\u00e1ch. M\u1ed7i tham s\u1ed1 \u0111\u01b0\u1ee3c t\u00e1ch bi\u1ec7t b\u1eb1ng d\u1ea5u c\u00e1ch.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$*<\/span><span style=\"font-weight: 400;\">:: C\u0169ng gi\u1ed1ng nh\u01b0 <\/span><span style=\"font-weight: 400;\">$@<\/span><span style=\"font-weight: 400;\">, nh\u01b0ng m\u1ecdi tham s\u1ed1 \u0111\u01b0\u1ee3c g\u1ed9p l\u1ea1i th\u00e0nh m\u1ed9t chu\u1ed7i duy nh\u1ea5t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$0<\/span><span style=\"font-weight: 400;\">: T\u00ean c\u1ee7a script (ho\u1eb7c l\u1ec7nh) \u0111ang \u0111\u01b0\u1ee3c ch\u1ea1y.<\/span><\/li>\n<\/ul>\n<h3><strong>Ph\u00e2n bi\u1ec7t $@ v\u00e0 $*<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Bash, c\u1ea3 <\/span><span style=\"font-weight: 400;\">$@<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">$*<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho t\u1ea5t c\u1ea3 c\u00e1c tham s\u1ed1 v\u1ecb tr\u00ed (arguments) \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o script ho\u1eb7c l\u1ec7nh, nh\u01b0ng ch\u00fang c\u00f3 s\u1ef1 kh\u00e1c bi\u1ec7t nh\u1ecf trong c\u00e1ch ch\u00fang x\u1eed l\u00fd c\u00e1c tham s\u1ed1, \u0111\u1eb7c bi\u1ec7t l\u00e0 khi c\u00e1c tham s\u1ed1 ch\u1ee9a kho\u1ea3ng tr\u1eafng.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$@<\/span><span style=\"font-weight: 400;\">: M\u1ed7i tham s\u1ed1 \u0111\u01b0\u1ee3c xem l\u00e0 m\u1ed9t ph\u1ea7n t\u1eed ri\u00eang bi\u1ec7t v\u00e0 \u0111\u01b0\u1ee3c x\u1eed l\u00fd \u0111\u1ed9c l\u1eadp. N\u1ebfu c\u00f3 b\u1ea5t k\u1ef3 tham s\u1ed1 n\u00e0o c\u00f3 ch\u1ee9a kho\u1ea3ng tr\u1eafng (v\u00ed d\u1ee5 nh\u01b0 t\u00ean t\u1ec7p c\u00f3 kho\u1ea3ng tr\u1eafng), m\u1ed7i tham s\u1ed1 s\u1ebd \u0111\u01b0\u1ee3c gi\u1eef nguy\u00ean v\u00e0 kh\u00f4ng b\u1ecb n\u1ed1i v\u1edbi c\u00e1c tham s\u1ed1 kh\u00e1c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$*<\/span><span style=\"font-weight: 400;\">: T\u1ea5t c\u1ea3 c\u00e1c tham s\u1ed1 \u0111\u01b0\u1ee3c n\u1ed1i l\u1ea1i v\u1edbi nhau th\u00e0nh m\u1ed9t chu\u1ed7i duy nh\u1ea5t, t\u00e1ch bi\u1ec7t b\u1eb1ng d\u1ea5u c\u00e1ch. \u0110i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn v\u1ea5n \u0111\u1ec1 khi c\u00f3 tham s\u1ed1 ch\u1ee9a kho\u1ea3ng tr\u1eafng, v\u00ec n\u00f3 s\u1ebd coi t\u1ea5t c\u1ea3 c\u00e1c tham s\u1ed1 l\u00e0 m\u1ed9t chu\u1ed7i \u0111\u01a1n.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Gi\u1ea3 s\u1eed ta c\u00f3 m\u1ed9t script Bash \u0111\u01a1n gi\u1ea3n sau \u0111\u00e2y, v\u1edbi t\u00ean l\u00e0 <\/span><span style=\"font-weight: 400;\">example.sh<\/span><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>#!\/bin\/bash\r\necho \"Gi\u00e1 tr\u1ecb c\u1ee7a \\\"\\$@\\\" : $@\"\r\necho \"Gi\u00e1 tr\u1ecb c\u1ee7a \\\"\\$*\\\" : $*\"\r\n# In gi\u00e1 tr\u1ecb t\u1eebng tham s\u1ed1\r\nfor param in \"$@\"; do\r\n \u00a0\u00a0\u00a0echo \"Param (with \\$@): $param\"\r\ndone\r\n# In gi\u00e1 tr\u1ecb t\u1eebng tham s\u1ed1 v\u1edbi \\$*\r\nfor param in \"$*\"; do\r\n \u00a0\u00a0\u00a0echo \"Param (with \\$*): $param\"\r\ndo<\/pre>\n<p><span style=\"font-weight: 400;\">Sau \u0111\u00f3 ch\u1ea1y script n\u00e0y v\u1edbi c\u00e1c tham s\u1ed1 c\u00f3 ch\u1ee9a kho\u1ea3ng tr\u1eafng, v\u00ed d\u1ee5 nh\u01b0 sau:<\/span><\/p>\n<pre>.\/example.sh \"apple pie\" banana \"fruit salad\"<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 s\u1ebd l\u00e0:<\/span><\/p>\n<pre>Gi\u00e1 tr\u1ecb c\u1ee7a \"$@\" : apple pie banana fruit salad\r\nGi\u00e1 tr\u1ecb c\u1ee7a \"$*\" : apple pie banana fruit salad\r\nParam (with $@): apple pie\r\nParam (with $@): banana\r\nParam (with $@): fruit salad\r\nParam (with $*): apple pie banana fruit salad<\/pre>\n<h3><b>B\u1ea1n hi\u1ec3u m\u1ed9t ti\u1ebfn tr\u00ecnh tr\u00ean Linux l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux, m\u1ed9t ti\u1ebfn tr\u00ecnh (process) l\u00e0 m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh \u0111ang ch\u1ea1y. M\u1ed7i ti\u1ebfn tr\u00ecnh c\u00f3 m\u1ed9t v\u00f9ng nh\u1edb ri\u00eang bi\u1ec7t v\u00e0 m\u1ed9t kh\u00f4ng gian ri\u00eang \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5. Ti\u1ebfn tr\u00ecnh c\u00f3 th\u1ec3 l\u00e0 b\u1ea5t k\u1ef3 ch\u01b0\u01a1ng tr\u00ecnh n\u00e0o \u0111ang \u0111\u01b0\u1ee3c th\u1ef1c thi tr\u00ean h\u1ec7 th\u1ed1ng, v\u00ed d\u1ee5 nh\u01b0 tr\u00ecnh duy\u1ec7t web, \u1ee9ng d\u1ee5ng terminal, hay b\u1ea5t k\u1ef3 \u1ee9ng d\u1ee5ng n\u00e0o kh\u00e1c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u1ed7i ti\u1ebfn tr\u00ecnh tr\u00ean Linux \u0111\u01b0\u1ee3c qu\u1ea3n l\u00fd v\u00e0 theo d\u00f5i b\u1edfi h\u1ec7 \u0111i\u1ec1u h\u00e0nh th\u00f4ng qua c\u00e1c c\u01a1 ch\u1ebf nh\u01b0 ID ti\u1ebfn tr\u00ecnh (PID), b\u1ed9 \u0111\u1ebfm ti\u1ebfn tr\u00ecnh, c\u00e1c quy\u1ec1n truy c\u1eadp t\u00e0i nguy\u00ean v\u00e0 c\u00e1c tr\u1ea1ng th\u00e1i ti\u1ebfn tr\u00ecnh.<\/span><\/p>\n<h3><b>C\u00e1c th\u00e0nh ph\u1ea7n ch\u00ednh c\u1ee7a m\u1ed9t ti\u1ebfn tr\u00ecnh g\u1ed3m nh\u1eefng g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>PID (Process ID)<\/b><span style=\"font-weight: 400;\">: M\u1ed7i ti\u1ebfn tr\u00ecnh tr\u00ean Linux \u0111\u1ec1u c\u00f3 m\u1ed9t m\u00e3 s\u1ed1 duy nh\u1ea5t g\u1ecdi l\u00e0 PID, \u0111\u00e2y l\u00e0 c\u00e1ch \u0111\u1ec3 h\u1ec7 \u0111i\u1ec1u h\u00e0nh theo d\u00f5i v\u00e0 qu\u1ea3n l\u00fd ti\u1ebfn tr\u00ecnh \u0111\u00f3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>PPID (Parent Process ID)<\/b><span style=\"font-weight: 400;\">: \u0110\u00e2y l\u00e0 ID c\u1ee7a ti\u1ebfn tr\u00ecnh cha &#8211; th\u1ee9 kh\u1edfi t\u1ea1o n\u00ean ti\u1ebfn tr\u00ecnh con. M\u1ed7i ti\u1ebfn tr\u00ecnh (tr\u1eeb ti\u1ebfn tr\u00ecnh \u0111\u1ea7u ti\u00ean c\u1ee7a h\u1ec7 th\u1ed1ng, th\u01b0\u1eddng l\u00e0 PID 1 &#8211; <\/span><span style=\"font-weight: 400;\">init<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">systemd<\/span><span style=\"font-weight: 400;\">) \u0111\u1ec1u c\u00f3 m\u1ed9t ti\u1ebfn tr\u00ecnh cha. V\u00ed d\u1ee5 khi ch\u1ea1y m\u1ed9t script trong Bash, ti\u1ebfn tr\u00ecnh cha c\u00f3 th\u1ec3 l\u00e0 terminal ho\u1eb7c m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh kh\u1edfi t\u1ea1o script \u0111\u00f3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ti\u1ebfn tr\u00ecnh con v\u00e0 ti\u1ebfn tr\u00ecnh cha<\/b><span style=\"font-weight: 400;\">: Ti\u1ebfn tr\u00ecnh con l\u00e0 ti\u1ebfn tr\u00ecnh \u0111\u01b0\u1ee3c t\u1ea1o ra b\u1edfi m\u1ed9t ti\u1ebfn tr\u00ecnh kh\u00e1c (ti\u1ebfn tr\u00ecnh cha). M\u1ed9t ti\u1ebfn tr\u00ecnh c\u00f3 th\u1ec3 t\u1ea1o ra nhi\u1ec1u ti\u1ebfn tr\u00ecnh con, t\u1ea1o th\u00e0nh m\u1ed9t c\u1ea5u tr\u00fac c\u00e2y ti\u1ebfn tr\u00ecnh.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>State (Tr\u1ea1ng th\u00e1i c\u1ee7a ti\u1ebfn tr\u00ecnh)<\/b><span style=\"font-weight: 400;\">: M\u1ed9t ti\u1ebfn tr\u00ecnh c\u00f3 th\u1ec3 c\u00f3 nhi\u1ec1u tr\u1ea1ng th\u00e1i kh\u00e1c nhau, nh\u01b0:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Running: Ti\u1ebfn tr\u00ecnh \u0111ang th\u1ef1c thi.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Sleeping: Ti\u1ebfn tr\u00ecnh \u0111ang ch\u1edd m\u1ed9t s\u1ef1 ki\u1ec7n (v\u00ed d\u1ee5 nh\u01b0 ch\u1edd nh\u1eadp li\u1ec7u).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Zombie: Ti\u1ebfn tr\u00ecnh \u0111\u00e3 k\u1ebft th\u00fac nh\u01b0ng th\u00f4ng tin v\u1ec1 ti\u1ebfn tr\u00ecnh ch\u01b0a \u0111\u01b0\u1ee3c thu h\u1ed3i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Stopped: Ti\u1ebfn tr\u00ecnh \u0111\u00e3 b\u1ecb t\u1ea1m d\u1eebng (v\u00ed d\u1ee5 l\u1ec7nh <\/span><span style=\"font-weight: 400;\">kill<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00e0i nguy\u00ean ti\u1ebfn tr\u00ecnh<\/b><span style=\"font-weight: 400;\">: M\u1ed7i ti\u1ebfn tr\u00ecnh c\u00f3 quy\u1ec1n truy c\u1eadp v\u00e0o c\u00e1c t\u00e0i nguy\u00ean h\u1ec7 th\u1ed1ng nh\u01b0 CPU, b\u1ed9 nh\u1edb v\u00e0 c\u00e1c thi\u1ebft b\u1ecb nh\u1eadp\/xu\u1ea5t. B\u1ea1n c\u00f3 th\u1ec3 theo d\u00f5i c\u00e1c t\u00e0i nguy\u00ean m\u00e0 ti\u1ebfn tr\u00ecnh s\u1eed d\u1ee5ng th\u00f4ng qua c\u00e1c l\u1ec7nh Bash nh\u01b0 <\/span><span style=\"font-weight: 400;\">top<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">htop<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">ps<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<h3><b>H\u00e3y li\u1ec7t k\u00ea c\u00e1c l\u1ec7nh Bash d\u00f9ng \u0111\u1ec3 qu\u1ea3n l\u00fd ti\u1ebfn tr\u00ecnh<\/b><\/h3>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>L\u1ec7nh<\/strong> <\/span><span style=\"font-weight: 400;\">ps<\/span><span style=\"font-weight: 400;\"> (Process Status): l\u00e0 l\u1ec7nh li\u1ec7t k\u00ea c\u00e1c ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y. N\u1ebfu kh\u00f4ng c\u00f3 tham s\u1ed1, <\/span><span style=\"font-weight: 400;\">ps<\/span><span style=\"font-weight: 400;\"> ch\u1ec9 hi\u1ec3n th\u1ecb c\u00e1c ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y trong phi\u00ean l\u00e0m vi\u1ec7c hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>L\u1ec7nh<\/strong> <\/span><span style=\"font-weight: 400;\">top<\/span><span style=\"font-weight: 400;\">: cung c\u1ea5p th\u00f4ng tin theo th\u1eddi gian th\u1ef1c v\u1ec1 c\u00e1c ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y, bao g\u1ed3m CPU, b\u1ed9 nh\u1edb v\u00e0 c\u00e1c th\u00f4ng tin h\u1ec7 th\u1ed1ng kh\u00e1c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ec7nh <\/b><span style=\"font-weight: 400;\">htop<\/span><span style=\"font-weight: 400;\">: l\u00e0 m\u1ed9t phi\u00ean b\u1ea3n n\u00e2ng cao c\u1ee7a <\/span><span style=\"font-weight: 400;\">top<\/span><span style=\"font-weight: 400;\">, gi\u00fap b\u1ea1n qu\u1ea3n l\u00fd c\u00e1c ti\u1ebfn tr\u00ecnh d\u1ec5 d\u00e0ng h\u01a1n v\u1edbi giao di\u1ec7n \u0111\u1ed3 h\u1ecda. K\u1ebft qu\u1ea3 s\u1ebd hi\u1ec3n th\u1ecb d\u01b0\u1edbi d\u1ea1ng b\u1ea3ng v\u1edbi c\u00e1c ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y, cho ph\u00e9p cu\u1ed9n v\u00e0 t\u00ecm ki\u1ebfm d\u1ec5 d\u00e0ng h\u01a1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ec7nh <\/b><span style=\"font-weight: 400;\">pgrep<\/span><span style=\"font-weight: 400;\">: gi\u00fap b\u1ea1n t\u00ecm ki\u1ebfm c\u00e1c ti\u1ebfn tr\u00ecnh d\u1ef1a tr\u00ean t\u00ean ho\u1eb7c ID. V\u00ed d\u1ee5:\u00a0<\/span><\/li>\n<\/ol>\n<pre><span style=\"font-weight: 400;\">pgrep bash<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">=&gt; K\u1ebft qu\u1ea3 s\u1ebd tr\u1ea3 v\u1ec1 PID c\u1ee7a ti\u1ebfn tr\u00ecnh <\/span><span style=\"font-weight: 400;\">bash<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><b>M\u1ee5c \u0111\u00edch c\u1ee7a d\u00f2ng shebang l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Bash v\u00e0 nhi\u1ec1u shell kh\u00e1c tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Unix-like, d\u00f2ng shebang (hay c\u00f2n g\u1ecdi l\u00e0 &#8220;hashbang&#8221;) l\u00e0 d\u00f2ng \u0111\u1ea7u ti\u00ean c\u1ee7a m\u1ed9t script, c\u00f3 ch\u1ee9c n\u0103ng ch\u1ec9 \u0111\u1ecbnh ch\u01b0\u01a1ng tr\u00ecnh ho\u1eb7c tr\u00ecnh th\u00f4ng d\u1ecbch (interpreter) s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 th\u1ef1c thi script \u0111\u00f3. D\u00f2ng shebang gi\u00fap h\u1ec7 th\u1ed1ng hi\u1ec3u \u0111\u01b0\u1ee3c lo\u1ea1i script m\u00e0 n\u00f3 s\u1ebd x\u1eed l\u00fd v\u00e0 l\u00e0m c\u00e1ch n\u00e0o \u0111\u1ec3 th\u1ef1c thi n\u00f3 \u0111\u00fang c\u00e1ch.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u00f2ng shebang c\u00f3 c\u00fa ph\u00e1p c\u01a1 b\u1ea3n l\u00e0:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">#!\/path\/to\/interpreter<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">#<\/span><span style=\"font-weight: 400;\"> l\u00e0 d\u1ea5u hash (d\u1ea5u th\u0103ng).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">!<\/span><span style=\"font-weight: 400;\"> l\u00e0 d\u1ea5u bang (d\u1ea5u ch\u1ea5m than).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\/path\/to\/interpreter<\/span><span style=\"font-weight: 400;\"> l\u00e0 \u0111\u01b0\u1eddng d\u1eabn tuy\u1ec7t \u0111\u1ed1i \u0111\u1ebfn tr\u00ecnh th\u00f4ng d\u1ecbch m\u00e0 b\u1ea1n mu\u1ed1n s\u1eed d\u1ee5ng \u0111\u1ec3 th\u1ef1c thi script.<\/span><\/li>\n<\/ul>\n<h3><b>V\u00ec sao c\u1ea7n \u0111\u1ea3m b\u1ea3o \u0111\u01b0\u1eddng d\u1eabn ch\u00ednh x\u00e1c khi d\u00f9ng shebang?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">V\u00ec n<\/span><span style=\"font-weight: 400;\">\u1ebfu kh\u00f4ng d\u00f9ng \u0111\u01b0\u1eddng d\u1eabn ch\u00ednh x\u00e1c, ch\u00fang ta s\u1ebd g\u1eb7p ph\u1ea3i l\u1ed7i &#8220;<\/span><i><span style=\"font-weight: 400;\">command not found<\/span><\/i><span style=\"font-weight: 400;\">&#8221; ho\u1eb7c c\u00e1c l\u1ed7i li\u00ean quan \u0111\u1ebfn kh\u00f4ng t\u00ecm th\u1ea5y tr\u00ecnh th\u00f4ng d\u1ecbch.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, <\/span><span style=\"font-weight: 400;\">#!\/bin\/bash<\/span><span style=\"font-weight: 400;\"> th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong m\u00f4i tr\u01b0\u1eddng Linux, nh\u01b0ng tr\u00ean macOS ho\u1eb7c h\u1ec7 th\u1ed1ng kh\u00e1c, b\u1ea1n c\u00f3 th\u1ec3 c\u1ea7n d\u00f9ng <\/span><span style=\"font-weight: 400;\">\/usr\/bin\/bash<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><b>Ngo\u00e0i Bash, shebang c\u00f3 th\u1ec3 d\u00f9ng v\u1edbi nh\u1eefng tr\u00ecnh th\u00f4ng d\u1ecbch n\u00e0o kh\u00e1c?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Ch\u00fang ta<\/span> <span style=\"font-weight: 400;\">c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng d\u00f2ng shebang v\u1edbi nhi\u1ec1u lo\u1ea1i tr\u00ecnh th\u00f4ng d\u1ecbch kh\u00e1c nhau nh\u01b0 Python (<\/span><span style=\"font-weight: 400;\">#!\/usr\/bin\/python3<\/span><span style=\"font-weight: 400;\">), Perl (<\/span><span style=\"font-weight: 400;\">#!\/usr\/bin\/perl<\/span><span style=\"font-weight: 400;\">), Ruby (<\/span><span style=\"font-weight: 400;\">#!\/usr\/bin\/ruby<\/span><span style=\"font-weight: 400;\">) hay Node.js (<\/span><span style=\"font-weight: 400;\">#!\/usr\/bin\/node<\/span><span style=\"font-weight: 400;\">), t\u00f9y thu\u1ed9c v\u00e0o ng\u1eef c\u1ea3nh s\u1eed d\u1ee5ng.<\/span><\/p>\n<h3><b>Metacharacter l\u00e0 g\u00ec? H\u00e3y k\u1ec3 t\u00ean c\u00e1c metacharacter m\u00e0 b\u1ea1n bi\u1ebft<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Metacharacter l\u00e0 c\u00e1c k\u00fd t\u1ef1 \u0111\u1eb7c bi\u1ec7t trong Bash shell (v\u00e0 c\u00e1c shell Unix-like kh\u00e1c) c\u00f3 vai tr\u00f2 quan tr\u1ecdng trong vi\u1ec7c thay \u0111\u1ed5i ho\u1eb7c ki\u1ec3m so\u00e1t h\u00e0nh vi c\u1ee7a c\u00e1c l\u1ec7nh, gi\u00fap t\u0103ng t\u00ednh linh ho\u1ea1t v\u00e0 m\u1ea1nh m\u1ebd khi l\u00e0m vi\u1ec7c v\u1edbi shell. C\u00e1c metacharacter kh\u00f4ng ch\u1ec9 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong shell script m\u00e0 c\u00f2n trong c\u00e1c l\u1ec7nh th\u1ef1c thi tr\u1ef1c ti\u1ebfp t\u1ea1i d\u00f2ng l\u1ec7nh.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Khi s\u1eed d\u1ee5ng c\u00e1c metacharacter, ta c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 nh\u01b0 t\u00ecm ki\u1ebfm, thay th\u1ebf, \u0111i\u1ec1u khi\u1ec3n lu\u1ed3ng d\u1eef li\u1ec7u ho\u1eb7c x\u1eed l\u00fd c\u00e1c t\u1ec7p v\u00e0 th\u01b0 m\u1ee5c m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh ph\u1ee9c t\u1ea1p.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Nh\u1eefng metacharacter ph\u1ed5 bi\u1ebfn g\u1ed3m:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Metacharacter<\/b><\/td>\n<td><b>M\u00f4 T\u1ea3<\/b><\/td>\n<td><b>V\u00ed D\u1ee5<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">*<\/span><\/td>\n<td><span style=\"font-weight: 400;\">K\u00fd t\u1ef1 \u0111\u1ea1i di\u1ec7n m\u1ea1nh m\u1ebd nh\u1ea5t trong Bash. N\u00f3 \u0111\u1ea1i di\u1ec7n cho b\u1ea5t k\u1ef3 chu\u1ed7i k\u00fd t\u1ef1 n\u00e0o, bao g\u1ed3m chu\u1ed7i r\u1ed7ng.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">$ ls *.txt<\/span><\/p>\n<p><span style=\"font-weight: 400;\">=&gt; Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c t\u1ec7p c\u00f3 \u0111u\u00f4i .txt trong th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">?<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u1edbp v\u1edbi b\u1ea5t k\u1ef3 k\u00fd t\u1ef1 \u0111\u01a1n n\u00e0o.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">file?.txt<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">=&gt; T\u00ecm c\u00e1c t\u1ec7p nh\u01b0 <\/span><i><span style=\"font-weight: 400;\">file1.txt<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">fileA.txt<\/span><\/i><span style=\"font-weight: 400;\"> nh\u01b0ng kh\u00f4ng ph\u1ea3i file.txt<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">[]<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Cho ph\u00e9p ch\u1ec9 \u0111\u1ecbnh m\u1ed9t d\u00e3y c\u00e1c k\u00fd t\u1ef1 h\u1ee3p l\u1ec7 m\u00e0 b\u1ea1n mu\u1ed1n t\u00ecm. N\u1ebfu ch\u1ec9 \u0111\u1ecbnh m\u1ed9t d\u00e3y k\u00fd t\u1ef1 (v\u00ed d\u1ee5: 1-9), Bash s\u1ebd kh\u1edbp v\u1edbi b\u1ea5t k\u1ef3 k\u00fd t\u1ef1 n\u00e0o trong ph\u1ea1m vi \u0111\u00f3.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">file[1-3].txt<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">=&gt; T\u00ecm <\/span><i><span style=\"font-weight: 400;\">file1.txt<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">file2.txt<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">file3.txt<\/span><\/i><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">`<\/span><\/td>\n<td><span style=\"font-weight: 400;\">`<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Pipe output: Chuy\u1ec3n k\u1ebft qu\u1ea3 c\u1ee7a l\u1ec7nh b\u00ean tr\u00e1i l\u00e0m \u0111\u1ea7u v\u00e0o cho l\u1ec7nh b\u00ean ph\u1ea3i.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&amp;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ea1y l\u1ec7nh trong ch\u1ebf \u0111\u1ed9 n\u1ec1n (background).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">command &amp;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Redirect output: Chuy\u1ec3n h\u01b0\u1edbng \u0111\u1ea7u ra \u0111\u1ebfn m\u1ed9t t\u1ec7p, ghi \u0111\u00e8 n\u1ebfu t\u1ec7p \u0111\u00e3 t\u1ed3n t\u1ea1i.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">echo &#8220;Hello&#8221; &gt; output.txt<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&gt;&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Redirect output: Chuy\u1ec3n h\u01b0\u1edbng \u0111\u1ea7u ra \u0111\u1ebfn m\u1ed9t t\u1ec7p, b\u1ed5 sung v\u00e0o cu\u1ed1i t\u1ec7p n\u1ebfu t\u1ec7p \u0111\u00e3 t\u1ed3n t\u1ea1i.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">echo &#8220;World&#8221; &gt;&gt; output.txt<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&lt;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Redirect input: \u0110\u1ecdc \u0111\u1ea7u v\u00e0o t\u1eeb m\u1ed9t t\u1ec7p thay v\u00ec b\u00e0n ph\u00edm.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">sort &lt; input.txt<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ea1y nhi\u1ec1u l\u1ec7nh trong c\u00f9ng m\u1ed9t d\u00f2ng l\u1ec7nh, m\u1ed7i l\u1ec7nh c\u00e1ch nhau b\u1eb1ng d\u1ea5u ch\u1ea5m ph\u1ea9y.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">echo &#8220;Hello&#8221;; echo &#8220;World&#8221;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Subshell: Th\u1ef1c thi m\u1ed9t nh\u00f3m l\u1ec7nh trong m\u1ed9t qu\u00e1 tr\u00ecnh con (subshell).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">(cd \/tmp; ls)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">{}<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Grouping commands: Nh\u00f3m c\u00e1c l\u1ec7nh l\u1ea1i v\u1edbi nhau \u0111\u1ec3 th\u1ef1c thi trong c\u00f9ng m\u1ed9t shell.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">{ ls -l; pwd; }<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">!<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Logical NOT: \u0110\u1ea3o ng\u01b0\u1ee3c gi\u00e1 tr\u1ecb c\u1ee7a l\u1ec7nh (d\u00f9ng trong \u0111i\u1ec1u ki\u1ec7n).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">! ls<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">=&gt; N\u1ebfu l\u1ec7nh <\/span><span style=\"font-weight: 400;\">ls<\/span><span style=\"font-weight: 400;\"> kh\u00f4ng th\u00e0nh c\u00f4ng, th\u1ef1c thi c\u00e1c l\u1ec7nh sau.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&amp;&amp;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Logical AND: Ch\u1ea1y l\u1ec7nh th\u1ee9 hai ch\u1ec9 khi l\u1ec7nh \u0111\u1ea7u ti\u00ean th\u00e0nh c\u00f4ng (m\u00e3 tho\u00e1t l\u00e0 0).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">mkdir test &amp;&amp; cd test<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">||<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Logical OR: ch\u1ec9 ch\u1ea1y l\u1ec7nh ti\u1ebfp theo n\u1ebfu l\u1ec7nh tr\u01b0\u1edbc th\u1ea5t b\u1ea1i.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">$ mkdir test || echo &#8220;Directory creation failed&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">=&gt; T\u1ea1o th\u01b0 m\u1ee5c test, nh\u01b0ng n\u1ebfu th\u1ea5t b\u1ea1i, n\u00f3 s\u1ebd in ra th\u00f4ng b\u00e1o l\u1ed7i.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>Hard link v\u00e0 soft link kh\u00e1c nhau th\u1ebf n\u00e0o?<\/b><\/h3>\n<h4><b>Hard Link<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">M\u1ed9t hard link l\u00e0 m\u1ed9t tham chi\u1ebfu kh\u00e1c \u0111\u1ebfn m\u1ed9t t\u1ec7p g\u1ed1c trong h\u1ec7 th\u1ed1ng t\u1ec7p. Th\u1ef1c t\u1ebf, c\u1ea3 hard link v\u00e0 t\u1ec7p g\u1ed1c \u0111\u1ec1u ch\u1ec9 v\u00e0o c\u00f9ng m\u1ed9t inode tr\u00ean h\u1ec7 th\u1ed1ng t\u1ec7p (Inode l\u00e0 c\u1ea5u tr\u00fac d\u1eef li\u1ec7u trong h\u1ec7 th\u1ed1ng t\u1ec7p ch\u1ee9a th\u00f4ng tin v\u1ec1 t\u1ec7p nh\u01b0ng kh\u00f4ng bao g\u1ed3m t\u00ean t\u1ec7p). V\u00ec v\u1eady khi t\u1ec7p g\u1ed1c b\u1ecb x\u00f3a, d\u1eef li\u1ec7u v\u1eabn t\u1ed3n t\u1ea1i mi\u1ec5n l\u00e0 c\u00f2n c\u00f3 \u00edt nh\u1ea5t m\u1ed9t hard link tr\u1ecf t\u1edbi inode \u0111\u00f3.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Gi\u1ea3 s\u1eed b\u1ea1n c\u00f3 m\u1ed9t t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u1edbi n\u1ed9i dung l\u00e0 &#8220;<\/span><i><span style=\"font-weight: 400;\">Hello, World!<\/span><\/i><span style=\"font-weight: 400;\">&#8221; v\u00e0 ta t\u1ea1o m\u1ed9t hard link cho t\u1ec7p n\u00e0y g\u1ecdi l\u00e0 <\/span><i><span style=\"font-weight: 400;\">file_link.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u1edbi c\u00e1c b\u01b0\u1edbc nh\u01b0 sau:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">T\u1ea1o t\u1ec7p g\u1ed1c:<\/span><\/p>\n<pre>echo \"Hello, World!\" &gt; file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3m tra inode c\u1ee7a t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>ls -i file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3:<\/span><\/p>\n<pre>1234567 file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">T\u1ea1o m\u1ed9t hard link <\/span><i><span style=\"font-weight: 400;\">file_link.txt<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>ln file.txt file_link.txt<\/pre>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3m tra inode c\u1ee7a <\/span><i><span style=\"font-weight: 400;\">file_link.txt<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>ls -i file_link.txt<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3:<\/span><\/p>\n<pre>1234567 file_link.txt<\/pre>\n<p><span style=\"font-weight: 400;\">C\u1ea3 <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u00e0 <\/span><i><span style=\"font-weight: 400;\">file_link.txt<\/span><\/i><span style=\"font-weight: 400;\"> \u0111\u1ec1u tr\u1ecf \u0111\u1ebfn c\u00f9ng m\u1ed9t inode, v\u00ec v\u1eady ch\u00fang chia s\u1ebb c\u00f9ng m\u1ed9t d\u1eef li\u1ec7u. N\u1ebfu b\u1ea1n x\u00f3a <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">file_link.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u1eabn c\u00f3 th\u1ec3 truy c\u1eadp \u0111\u01b0\u1ee3c n\u1ed9i dung &#8220;<\/span><i><span style=\"font-weight: 400;\">Hello, World!<\/span><\/i><span style=\"font-weight: 400;\">&#8220;.<\/span><\/p>\n<pre>rm file.txt\r\ncat file_link.txt\r\n# K\u1ebft qu\u1ea3: Hello, World!<\/pre>\n<h4><b>Soft Link (Symbolic Link)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Soft link l\u00e0 m\u1ed9t lo\u1ea1i t\u1ec7p \u0111\u1eb7c bi\u1ec7t ch\u1ee9a \u0111\u01b0\u1eddng d\u1eabn \u0111\u1ebfn t\u1ec7p g\u1ed1c. N\u00f3 ho\u1ea1t \u0111\u1ed9ng nh\u01b0 m\u1ed9t shortcut ho\u1eb7c li\u00ean k\u1ebft \u0111\u1ebfn t\u1ec7p ho\u1eb7c th\u01b0 m\u1ee5c kh\u00e1c. N\u1ebfu t\u1ec7p g\u1ed1c b\u1ecb x\u00f3a ho\u1eb7c di chuy\u1ec3n, soft link s\u1ebd kh\u00f4ng c\u00f2n h\u1ee3p l\u1ec7 v\u00e0 tr\u1edf th\u00e0nh &#8220;broken link&#8221;.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Gi\u1ea3 s\u1eed b\u1ea1n c\u00f3 t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u00e0 b\u1ea1n t\u1ea1o m\u1ed9t soft link c\u00f3 t\u00ean <\/span><i><span style=\"font-weight: 400;\">file_soft_link.txt<\/span><\/i><span style=\"font-weight: 400;\"> tr\u1ecf \u0111\u1ebfn <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> v\u1edbi c\u00e1c b\u01b0\u1edbc:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">T\u1ea1o t\u1ec7p g\u1ed1c:<\/span><\/p>\n<pre>echo \"Hello, World!\" &gt; file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">T\u1ea1o soft link <\/span><i><span style=\"font-weight: 400;\">file_soft_link.txt<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>ln -s file.txt file_soft_link.txt<\/pre>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3m tra <\/span><i><span style=\"font-weight: 400;\">file_soft_link.txt<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre>ls -l file_soft_link.txt<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3:<\/span><\/p>\n<pre>lrwxrwxrwx 1 user user 8 Dec\u00a0 1 12:00 file_soft_link.txt -&gt; file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">N\u1ebfu b\u1ea1n x\u00f3a <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\">, soft link s\u1ebd kh\u00f4ng c\u00f2n h\u1ee3p l\u1ec7:<\/span><\/p>\n<pre>rm file.txt\r\ncat file_soft_link.txt\r\n# K\u1ebft qu\u1ea3: cat: file_soft_link.txt: No such file or directory<\/pre>\n<p><span style=\"font-weight: 400;\">Trong tr\u01b0\u1eddng h\u1ee3p n\u00e0y, <\/span><i><span style=\"font-weight: 400;\">file_soft_link.txt<\/span><\/i><span style=\"font-weight: 400;\"> s\u1ebd tr\u1edf th\u00e0nh m\u1ed9t &#8220;broken link&#8221; v\u00ec t\u1ec7p g\u1ed1c \u0111\u00e3 b\u1ecb x\u00f3a.<\/span><\/p>\n<h4><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa hard link v\u00e0 soft link<\/b><\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Hard link<\/b><\/td>\n<td><b>Soft link<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Tr\u1ecf tr\u1ef1c ti\u1ebfp \u0111\u1ebfn inode c\u1ee7a t\u1ec7p g\u1ed1c<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tr\u1ecf t\u1edbi \u0111\u01b0\u1eddng d\u1eabn c\u1ee7a t\u1ec7p g\u1ed1c<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Tr\u1ecf \u0111\u1ebfn inode c\u1ee7a t\u1ec7p g\u1ed1c<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tr\u1ecf t\u1edbi t\u1ec7p g\u1ed1c th\u00f4ng qua \u0111\u01b0\u1eddng d\u1eabn<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng th\u1ec3 t\u1ea1o link cho th\u01b0 m\u1ee5c (tr\u1eeb c\u00e1c th\u01b0 m\u1ee5c h\u1ec7 th\u1ed1ng nh\u01b0 <\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">..<\/span><span style=\"font-weight: 400;\">)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 t\u1ea1o link cho th\u01b0 m\u1ee5c<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng th\u1ec3 tr\u1ecf \u0111\u1ebfn h\u1ec7 th\u1ed1ng t\u1ec7p kh\u00e1c\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 tr\u1ecf \u0111\u1ebfn h\u1ec7 th\u1ed1ng t\u1ec7p kh\u00e1c\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">N\u1ebfu t\u1ec7p g\u1ed1c b\u1ecb x\u00f3a, c\u00e1c hard link v\u1eabn truy c\u1eadp \u0111\u01b0\u1ee3c d\u1eef li\u1ec7u<\/span><\/td>\n<td><span style=\"font-weight: 400;\">N\u1ebfu t\u1ec7p g\u1ed1c b\u1ecb x\u00f3a, soft link s\u1ebd h\u1ecfng<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ki\u1ec3u t\u1ec7p kh\u00f4ng c\u00f3 ch\u1ec9 th\u1ecb \u0111\u1eb7c bi\u1ec7t<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ki\u1ec3u t\u1ec7p \u0111\u01b0\u1ee3c \u0111\u00e1nh d\u1ea5u b\u1eb1ng k\u00fd t\u1ef1 l khi d\u00f9ng <\/span><span style=\"font-weight: 400;\">ls -l<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong c\u00e1c t\u00e1c v\u1ee5 li\u00ean quan \u0111\u1ebfn l\u01b0u tr\u1eef d\u1eef li\u1ec7u m\u00e0 kh\u00f4ng mu\u1ed1n l\u00e0m m\u1ea5t d\u1eef li\u1ec7u<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Th\u01b0\u1eddng d\u00f9ng \u0111\u1ec3 t\u1ea1o li\u00ean k\u1ebft t\u1ec7p ho\u1eb7c th\u01b0 m\u1ee5c d\u1ec5 d\u00e0ng<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>GUI scripting l\u00e0 g\u00ec? Khi n\u00e0o c\u1ea7n d\u00f9ng GUI scripting?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">GUI scripting l\u00e0 vi\u1ec7c s\u1eed d\u1ee5ng c\u00e1c t\u1eadp l\u1ec7nh (script) \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 nh\u01b0 m\u1edf, \u0111\u00f3ng c\u1eeda s\u1ed5, nh\u1ea5p v\u00e0o c\u00e1c n\u00fat, k\u00e9o v\u00e0 th\u1ea3 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng\u2026 trong m\u00f4i tr\u01b0\u1eddng giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng \u0111\u1ed3 h\u1ecda (Graphical User Interface &#8211; GUI), thay v\u00ec ph\u1ea3i thao t\u00e1c th\u1ee7 c\u00f4ng v\u1edbi chu\u1ed9t v\u00e0 b\u00e0n ph\u00edm.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1c c\u00f4ng c\u1ee5 GUI scripting gi\u00fap m\u00f4 ph\u1ecfng h\u00e0nh \u0111\u1ed9ng c\u1ee7a ng\u01b0\u1eddi d\u00f9ng, th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng khi b\u1ea1n c\u1ea7n t\u01b0\u01a1ng t\u00e1c v\u1edbi \u1ee9ng d\u1ee5ng m\u00e0 kh\u00f4ng th\u1ec3 s\u1eed d\u1ee5ng d\u00f2ng l\u1ec7nh tr\u1ef1c ti\u1ebfp, ch\u1eb3ng h\u1ea1n nh\u01b0 trong c\u00e1c ph\u1ea7n m\u1ec1m kh\u00f4ng c\u00f3 h\u1ed7 tr\u1ee3 CLI (Command Line Interface).<\/span><\/p>\n<h4><b>C\u00e1c tr\u01b0\u1eddng h\u1ee3p c\u1ee5 th\u1ec3 c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng GUI scripting:<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 l\u1eb7p \u0111i l\u1eb7p l\u1ea1i<\/b><span style=\"font-weight: 400;\">: GUI scripting r\u1ea5t h\u1eefu \u00edch \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 m\u00e0 b\u1ea1n ph\u1ea3i th\u1ef1c hi\u1ec7n nhi\u1ec1u l\u1ea7n, v\u00ed d\u1ee5 nh\u01b0 ki\u1ec3m tra email, t\u1ea3i xu\u1ed1ng t\u1ec7p tin ho\u1eb7c x\u1eed l\u00fd c\u00e1c t\u1ec7p tin trong c\u00e1c ph\u1ea7n m\u1ec1m.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ea7n t\u1ed1i \u01b0u h\u00f3a c\u00f4ng vi\u1ec7c v\u00e0 ti\u1ebft ki\u1ec7m th\u1eddi gian<\/b><span style=\"font-weight: 400;\">: Th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 GUI m\u1ed9t c\u00e1ch t\u1ef1 \u0111\u1ed9ng gi\u00fap ti\u1ebft ki\u1ec7m th\u1eddi gian v\u00e0 n\u00e2ng cao n\u0103ng su\u1ea5t, \u0111\u1eb7c bi\u1ec7t khi c\u00f4ng vi\u1ec7c c\u1ea7n ph\u1ea3i thao t\u00e1c v\u1edbi c\u00e1c \u1ee9ng d\u1ee5ng m\u00e0 kh\u00f4ng c\u00f3 giao di\u1ec7n d\u00f2ng l\u1ec7nh.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Thao t\u00e1c c\u00e1c t\u00e1c v\u1ee5 kh\u00f4ng c\u00f3 giao di\u1ec7n d\u00f2ng l\u1ec7nh (CLI)<\/b><span style=\"font-weight: 400;\">: M\u1ed9t s\u1ed1 ph\u1ea7n m\u1ec1m ho\u1eb7c h\u1ec7 th\u1ed1ng kh\u00f4ng c\u00f3 giao di\u1ec7n d\u00f2ng l\u1ec7nh (CLI), v\u00ec v\u1eady GUI scripting cho ph\u00e9p b\u1ea1n t\u01b0\u01a1ng t\u00e1c v\u00e0 t\u1ef1 \u0111\u1ed9ng h\u00f3a nh\u1eefng ph\u1ea7n m\u1ec1m n\u00e0y m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i s\u1eed d\u1ee5ng chu\u1ed9t v\u00e0 b\u00e0n ph\u00edm.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>\u1ee8ng d\u1ee5ng trong ki\u1ec3m th\u1eed ph\u1ea7n m\u1ec1m (Software Testing)<\/b><span style=\"font-weight: 400;\">: GUI scripting c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong ki\u1ec3m th\u1eed t\u1ef1 \u0111\u1ed9ng ph\u1ea7n m\u1ec1m, \u0111\u1eb7c bi\u1ec7t l\u00e0 khi ph\u1ea7n m\u1ec1m c\u00f3 giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng ph\u1ee9c t\u1ea1p. Ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 t\u1ea1o c\u00e1c test script t\u1ef1 \u0111\u1ed9ng \u0111\u1ec3 ki\u1ec3m tra c\u00e1c t\u00ednh n\u0103ng GUI m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i thao t\u00e1c th\u1ee7 c\u00f4ng.<\/span><\/li>\n<\/ul>\n<h3><b>H\u00e3y k\u1ec3 t\u00ean c\u00e1c c\u00f4ng c\u1ee5 GUI scripting ph\u1ed5 bi\u1ebfn trong Linux<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Xdotool:<\/b><span style=\"font-weight: 400;\"> C\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh cho ph\u00e9p m\u00f4 ph\u1ecfng \u0111\u1ea7u v\u00e0o b\u00e0n ph\u00edm v\u00e0 chu\u1ed9t trong m\u00f4i tr\u01b0\u1eddng X11. N\u00f3 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c thao t\u00e1c GUI nh\u01b0 nh\u1ea5p chu\u1ed9t v\u00e0 nh\u1eadp v\u0103n b\u1ea3n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>AutoKey:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t ti\u1ec7n \u00edch t\u1ef1 \u0111\u1ed9ng h\u00f3a GUI d\u1ef1a tr\u00ean Python cho Linux, cho ph\u00e9p t\u1ea1o c\u00e1c script \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c h\u00e0nh \u0111\u1ed9ng GUI ph\u1ee9c t\u1ea1p.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Sikuli:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t c\u00f4ng c\u1ee5 t\u1ef1 \u0111\u1ed9ng h\u00f3a GUI m\u1ea1nh m\u1ebd s\u1eed d\u1ee5ng nh\u1eadn d\u1ea1ng h\u00ecnh \u1ea3nh \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh v\u00e0 t\u01b0\u01a1ng t\u00e1c v\u1edbi c\u00e1c ph\u1ea7n t\u1eed GUI.<\/span><\/li>\n<\/ul>\n<h3><b>C\u00f3 l\u1ec7nh n\u00e0o thay th\u1ebf cho <\/b><span style=\"font-weight: 400;\">echo<\/span><b> trong Bash Shell kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">echo<\/span><span style=\"font-weight: 400;\"> trong Bash shell \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn \u0111\u1ec3 in ra th\u00f4ng tin ho\u1eb7c k\u1ebft qu\u1ea3 t\u1eeb c\u00e1c l\u1ec7nh trong terminal. Tuy nhi\u00ean, \u0111\u00f4i khi s\u1ebd c\u1ea7n s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh thay th\u1ebf cho <\/span><span style=\"font-weight: 400;\">echo<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 t\u01b0\u01a1ng t\u1ef1 nh\u01b0ng c\u00f3 nh\u1eefng \u0111\u1eb7c \u0111i\u1ec3m ri\u00eang bi\u1ec7t ho\u1eb7c ph\u1ee5c v\u1ee5 c\u00e1c m\u1ee5c \u0111\u00edch kh\u00e1c nhau. M\u1ed9t trong nh\u1eefng l\u1ec7nh thay th\u1ebf ph\u1ed5 bi\u1ebfn nh\u1ea5t cho <\/span><span style=\"font-weight: 400;\">echo<\/span><span style=\"font-weight: 400;\"> l\u00e0 l\u1ec7nh <\/span><span style=\"font-weight: 400;\">printf<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1c l\u1ec7nh thay th\u1ebf cho echo:<\/span><\/p>\n<p><b>printf<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p \u0111\u1ecbnh d\u1ea1ng \u0111\u1ea7u ra ch\u00ednh x\u00e1c h\u01a1n echo v\u00e0 t\u01b0\u01a1ng th\u00edch v\u1edbi c\u00fa ph\u00e1p c\u1ee7a ng\u00f4n ng\u1eef C:<\/span><\/p>\n<pre>printf \"Xin ch\u00e0o %s, b\u1ea1n \u0111ang %d tu\u1ed5i\\n\" \"John\" 25<\/pre>\n<p><b>cat:<\/b> C\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ec3 hi\u1ec3n th\u1ecb n\u1ed9i dung c\u1ee7a t\u1ec7p ho\u1eb7c \u0111\u1ea7u v\u00e0o ti\u00eau chu\u1ea9n:<\/p>\n<pre>cat &lt;&lt;EOF\r\n\u0110\u00e2y l\u00e0 v\u0103n b\u1ea3n\r\nnhi\u1ec1u d\u00f2ng\r\nEOF<\/pre>\n<p><b>tput:<\/b> H\u1eefu \u00edch khi b\u1ea1n c\u1ea7n \u0111\u1ecbnh d\u1ea1ng m\u00e0u s\u1eafc v\u00e0 v\u1ecb tr\u00ed con tr\u1ecf trong terminal:<\/p>\n<pre>tput setaf 2 # \u0110\u1eb7t m\u00e0u xanh l\u00e1\r\necho \"V\u0103n b\u1ea3n m\u00e0u xanh l\u00e1\"\r\ntput sgr0 # \u0110\u1eb7t l\u1ea1i \u0111\u1ecbnh d\u1ea1ng<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Bash_Shell_nang_cao\"><\/span><b>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell n\u00e2ng cao<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>N\u00eau t\u1ea7m quan tr\u1ecdng c\u1ee7a l\u1ec7nh sed v\u00e0 awk trong Shell Scripting<\/b><\/h3>\n<h4><b>L\u1ec7nh sed<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> l\u00e0 vi\u1ebft t\u1eaft c\u1ee7a Stream Editor (Tr\u00ecnh bi\u00ean t\u1eadp d\u00f2ng) v\u00e0 l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd \u0111\u1ec3 x\u1eed l\u00fd v\u0103n b\u1ea3n theo d\u00f2ng. <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> cho ph\u00e9p thay \u0111\u1ed5i n\u1ed9i dung c\u1ee7a v\u0103n b\u1ea3n, ch\u00e8n, x\u00f3a v\u00e0 thay th\u1ebf chu\u1ed7i trong m\u1ed9t t\u1ec7p tin ho\u1eb7c trong lu\u1ed3ng \u0111\u1ea7u v\u00e0o (stdin). L\u1ec7nh <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c thay th\u1ebf ho\u1eb7c ch\u1ec9nh s\u1eeda tr\u1ef1c ti\u1ebfp tr\u00ean v\u0103n b\u1ea3n m\u00e0 kh\u00f4ng thay \u0111\u1ed5i t\u1ec7p g\u1ed1c (tr\u1eeb khi \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh ghi l\u1ea1i k\u1ebft qu\u1ea3 v\u00e0o t\u1ec7p).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p t\u1ed5ng qu\u00e1t:<\/span><\/p>\n<pre>sed [t\u00f9y ch\u1ecdn] 'l\u1ec7nh' [t\u1ec7p tin]<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 thay th\u1ebf chu\u1ed7i &#8220;old_string&#8221; th\u00e0nh &#8220;new_string&#8221; trong t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> ta s\u1eed d\u1ee5ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>sed 's\/old_string\/new_string\/' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">C\u00f2n n\u1ebfu mu\u1ed1n thay th\u1ebf t\u1ea5t c\u1ea3 c\u00e1c chu\u1ed7i trong t\u1ec7p, ta th\u00eam k\u00fd hi\u1ec7u <\/span><b>g<\/b><span style=\"font-weight: 400;\"> nh\u01b0 sau:<\/span><\/p>\n<pre>sed 's\/old_string\/new_string\/g' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 x\u00f3a t\u1ea5t c\u1ea3 c\u00e1c d\u00f2ng ch\u1ee9a t\u1eeb kh\u00f3a &#8220;pattern&#8221; trong t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> ta s\u1eed d\u1ee5ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>sed '\/pattern\/d' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">T\u1ea7m quan tr\u1ecdng c\u1ee7a <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\">:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gi\u00fap x\u1eed l\u00fd v\u0103n b\u1ea3n nhanh ch\u00f3ng<\/b><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> gi\u00fap th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c ch\u1ec9nh s\u1eeda v\u0103n b\u1ea3n tr\u00ean d\u00f2ng nhanh v\u00e0 hi\u1ec7u qu\u1ea3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00f4ng vi\u1ec7c<\/b><span style=\"font-weight: 400;\">: C\u00f3 th\u1ec3 s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> trong c\u00e1c script \u0111\u1ec3 thay \u0111\u1ed5i c\u00e1c chu\u1ed7i, s\u1eeda l\u1ed7i ch\u00ednh t\u1ea3, thay th\u1ebf ho\u1eb7c x\u00f3a th\u00f4ng tin t\u1ef1 \u0111\u1ed9ng trong c\u00e1c t\u1ec7p tin m\u00e0 kh\u00f4ng c\u1ea7n can thi\u1ec7p th\u1ee7 c\u00f4ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ti\u1ebft ki\u1ec7m th\u1eddi gian<\/b><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">sed<\/span><span style=\"font-weight: 400;\"> h\u1ed7 tr\u1ee3 thay \u0111\u1ed5i h\u00e0ng lo\u1ea1t d\u1eef li\u1ec7u trong t\u1ec7p m\u00e0 kh\u00f4ng c\u1ea7n m\u1edf t\u1ec7p v\u00e0 ch\u1ec9nh s\u1eeda th\u1ee7 c\u00f4ng.<\/span><\/li>\n<\/ul>\n<h4><strong>L\u1ec7nh awk<\/strong><\/h4>\n<p><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u1ea1nh m\u1ebd d\u00e0nh cho x\u1eed l\u00fd v\u0103n b\u1ea3n, \u0111\u1eb7c bi\u1ec7t l\u00e0 c\u00e1c v\u0103n b\u1ea3n c\u00f3 c\u1ea5u tr\u00fac d\u1ea1ng b\u1ea3ng ho\u1eb7c c\u1ed9t. <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 ph\u00e2n t\u00edch d\u1eef li\u1ec7u, t\u00ednh to\u00e1n v\u00e0 in c\u00e1c k\u1ebft qu\u1ea3 theo y\u00eau c\u1ea7u c\u1ee7a ng\u01b0\u1eddi d\u00f9ng. L\u1ec7nh n\u00e0y c\u00f2n cho ph\u00e9p x\u1eed l\u00fd t\u1eebng tr\u01b0\u1eddng trong m\u1ed9t d\u00f2ng v\u0103n b\u1ea3n, r\u1ea5t h\u1eefu \u00edch khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c t\u1ec7p v\u0103n b\u1ea3n d\u1ea1ng CSV, log file hay d\u1eef li\u1ec7u c\u1ea5u tr\u00fac.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre>awk 'ch\u1ec9 th\u1ecb' [t\u1ec7p tin]<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 in ra c\u1ed9t \u0111\u1ea7u ti\u00ean v\u00e0 c\u1ed9t th\u1ee9 hai t\u1eeb <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> ta s\u1eed d\u1ee5ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>awk '{print $1, $2}' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 t\u00ednh t\u1ed5ng t\u1ea5t c\u1ea3 c\u00e1c gi\u00e1 tr\u1ecb trong c\u1ed9t \u0111\u1ea7u ti\u00ean c\u1ee7a t\u1ec7p <\/span><i><span style=\"font-weight: 400;\">file.txt<\/span><\/i><span style=\"font-weight: 400;\"> ta s\u1eed d\u1ee5ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>awk '{sum += $1} END {print sum}' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 l\u1ecdc v\u00e0 in ra c\u00e1c d\u00f2ng c\u00f3 gi\u00e1 tr\u1ecb trong c\u1ed9t \u0111\u1ea7u ti\u00ean l\u1edbn h\u01a1n 100 ta s\u1eed d\u1ee5ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>awk '$1 &gt; 100' file.txt<\/pre>\n<p><span style=\"font-weight: 400;\">T\u1ea7m quan tr\u1ecdng c\u1ee7a <\/span><span style=\"font-weight: 400;\">awk:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>X\u1eed l\u00fd d\u1eef li\u1ec7u c\u00f3 c\u1ea5u tr\u00fac<\/b><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> r\u1ea5t m\u1ea1nh m\u1ebd khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c t\u1ec7p c\u00f3 c\u1ea5u tr\u00fac r\u00f5 r\u00e0ng, \u0111\u1eb7c bi\u1ec7t l\u00e0 c\u00e1c t\u1ec7p d\u1eef li\u1ec7u d\u1ea1ng b\u1ea3ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00ednh to\u00e1n v\u00e0 th\u1ed1ng k\u00ea<\/b><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> cho ph\u00e9p th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p t\u00ednh, th\u1ed1ng k\u00ea nhanh ch\u00f3ng tr\u00ean c\u00e1c t\u1ec7p v\u0103n b\u1ea3n ho\u1eb7c d\u00f2ng d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ecdc d\u1eef li\u1ec7u th\u00f4ng minh<\/b><span style=\"font-weight: 400;\">: Ngo\u00e0i ra c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 l\u1ecdc ra c\u00e1c d\u00f2ng th\u1ecfa m\u00e3n m\u1ed9t \u0111i\u1ec1u ki\u1ec7n c\u1ee5 th\u1ec3 v\u00e0 ch\u1ec9 in ra nh\u1eefng d\u00f2ng \u0111\u00f3, \u0111i\u1ec1u n\u00e0y gi\u00fap gi\u1ea3m b\u1edbt d\u1eef li\u1ec7u kh\u00f4ng c\u1ea7n thi\u1ebft.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1eadp tr\u00ecnh linh ho\u1ea1t:<\/b> <span style=\"font-weight: 400;\">awk<\/span><span style=\"font-weight: 400;\"> h\u1ed7 tr\u1ee3 c\u00e1c c\u1ea5u tr\u00fac \u0111i\u1ec1u khi\u1ec3n nh\u01b0 <\/span><span style=\"font-weight: 400;\">if<\/span><span style=\"font-weight: 400;\">&#8211;<\/span><span style=\"font-weight: 400;\">else<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">while<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">for<\/span><span style=\"font-weight: 400;\"> v\u00e0 cung c\u1ea5p nhi\u1ec1u h\u00e0m x\u1eed l\u00fd chu\u1ed7i v\u00e0 to\u00e1n h\u1ecdc m\u1ea1nh m\u1ebd.<\/span><\/li>\n<\/ul>\n<h3><b>Crontab l\u00e0 g\u00ec? H\u00e3y tr\u00ecnh b\u00e0y c\u1ea5u tr\u00fac c\u1ee7a Crontab v\u00e0 Crontab entry<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Crontab (vi\u1ebft t\u1eaft c\u1ee7a &#8220;cron table&#8221;) l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 trong h\u1ec7 \u0111i\u1ec1u h\u00e0nh Unix-like (bao g\u1ed3m Linux) d\u00f9ng \u0111\u1ec3 l\u00ean l\u1ecbch th\u1ef1c thi c\u00e1c t\u00e1c v\u1ee5 ho\u1eb7c script v\u00e0o nh\u1eefng th\u1eddi \u0111i\u1ec3m c\u1ee5 th\u1ec3. Crontab ho\u1ea1t \u0111\u1ed9ng gi\u1ed1ng nh\u01b0 m\u1ed9t c\u00f4ng c\u1ee5 l\u00ean l\u1ecbch t\u1ef1 \u0111\u1ed9ng, cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng thi\u1ebft l\u1eadp c\u00e1c t\u00e1c v\u1ee5 s\u1ebd ch\u1ea1y t\u1ef1 \u0111\u1ed9ng v\u00e0o c\u00e1c th\u1eddi \u0111i\u1ec3m \u0111\u00e3 \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh m\u00e0 kh\u00f4ng c\u1ea7n s\u1ef1 can thi\u1ec7p th\u1ee7 c\u00f4ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">N\u00f3i c\u00e1ch kh\u00e1c, cron l\u00e0 m\u1ed9t d\u1ecbch v\u1ee5 (daemon) ch\u1ea1y n\u1ec1n tr\u00ean h\u1ec7 th\u1ed1ng \u0111\u1ec3 th\u1ef1c thi c\u00e1c l\u1ec7nh ho\u1eb7c script v\u00e0o nh\u1eefng kho\u1ea3ng th\u1eddi gian \u0111\u1ecbnh tr\u01b0\u1edbc, ch\u1eb3ng h\u1ea1n nh\u01b0 m\u1ed7i ng\u00e0y, m\u1ed7i tu\u1ea7n ho\u1eb7c m\u1ed7i th\u00e1ng.<\/span><\/p>\n<h4><b>C\u1ea5u tr\u00fac c\u1ee7a Crontab bao g\u1ed3m:<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Cron daemon<\/b><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">cron<\/span><span style=\"font-weight: 400;\">): L\u00e0 ti\u1ebfn tr\u00ecnh ch\u1ea1y n\u1ec1n (background process), th\u1ef1c hi\u1ec7n c\u00e1c c\u00f4ng vi\u1ec7c \u0111\u00e3 \u0111\u01b0\u1ee3c l\u00ean l\u1ecbch trong crontab.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Crontab file<\/b><span style=\"font-weight: 400;\">: L\u00e0 m\u1ed9t t\u1ec7p ch\u1ee9a c\u00e1c t\u00e1c v\u1ee5 (jobs) s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c thi. M\u1ed7i ng\u01b0\u1eddi d\u00f9ng trong h\u1ec7 th\u1ed1ng c\u00f3 th\u1ec3 c\u00f3 m\u1ed9t crontab ri\u00eang bi\u1ec7t.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">M\u1ed7i d\u00f2ng trong t\u1ec7p crontab \u0111\u1ecbnh ngh\u0129a m\u1ed9t t\u00e1c v\u1ee5, v\u00e0 d\u00f2ng n\u00e0y bao g\u1ed3m 5 tr\u01b0\u1eddng th\u1eddi gian v\u00e0 l\u1ec7nh c\u1ea7n th\u1ef1c thi.<\/span><\/p>\n<h4><b>C\u1ea5u tr\u00fac c\u1ee7a m\u1ed9t crontab entry (m\u1ed9t d\u00f2ng trong crontab) c\u00f3 d\u1ea1ng nh\u01b0 sau:<\/b><\/h4>\n<pre>* * * * * \/path\/to\/command<\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">N\u0103m d\u1ea5u <\/span><span style=\"font-weight: 400;\">*<\/span><span style=\"font-weight: 400;\"> \u0111\u1ea1i di\u1ec7n cho c\u00e1c tr\u01b0\u1eddng th\u1eddi gian, theo th\u1ee9 t\u1ef1:<\/span><\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><b>Tr\u01b0\u1eddng<\/b><\/td>\n<td><b>Gi\u00e1 tr\u1ecb h\u1ee3p l\u1ec7<\/b><\/td>\n<td><b>\u00dd ngh\u0129a<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>Ph\u00fat<\/b><\/td>\n<td><span style=\"font-weight: 400;\">0 &#8211; 59<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u0110\u1eb7t ph\u00fat trong m\u1ed7i gi\u1edd<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Gi\u1edd<\/b><\/td>\n<td><span style=\"font-weight: 400;\">0 &#8211; 23<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u0110\u1eb7t gi\u1edd trong ng\u00e0y (t\u1eeb 0 \u0111\u1ebfn 23, v\u00ed d\u1ee5: 0 l\u00e0 12 AM)<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Ng\u00e0y trong th\u00e1ng<\/b><\/td>\n<td><span style=\"font-weight: 400;\">1 &#8211; 31<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ec9 \u0111\u1ecbnh ng\u00e0y trong th\u00e1ng<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Th\u00e1ng<\/b><\/td>\n<td><span style=\"font-weight: 400;\">1 &#8211; 12<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ec9 \u0111\u1ecbnh th\u00e1ng trong n\u0103m<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Ng\u00e0y trong tu\u1ea7n<\/b><\/td>\n<td><span style=\"font-weight: 400;\">0 &#8211; 7<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ng\u00e0y trong tu\u1ea7n (0 &#8211; 7): 0 ho\u1eb7c 7 \u0111\u1ea1i di\u1ec7n cho Ch\u1ee7 nh\u1eadt, 1 cho Th\u1ee9 Hai,&#8230;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 ch\u1ea1y l\u1ec7nh m\u1ed7i ng\u00e0y v\u00e0o l\u00fac 2:30 AM ta d\u00f9ng:<\/span><\/p>\n<pre>30 2 * * * \/path\/to\/command<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 ch\u1ea1y v\u00e0o ph\u00fat 0 c\u1ee7a m\u1ed7i gi\u1edd, ta d\u00f9ng:<\/span><\/p>\n<pre>0 * * * * \/path\/to\/command<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 \u0111\u1ec3 Ch\u1ea1y l\u1ec7nh v\u00e0o m\u1ed7i th\u1ee9 Hai, th\u1ee9 T\u01b0 v\u00e0 th\u1ee9 S\u00e1u l\u00fac 3:00 PM, ta d\u00f9ng c\u00fa ph\u00e1p:<\/span><\/p>\n<pre>0 15 * * 1,3,5 \/path\/to\/command<\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Sau 5 tr\u01b0\u1eddng th\u1eddi gian l\u00e0 l\u1ec7nh mu\u1ed1n th\u1ef1c thi.<\/span><\/li>\n<\/ul>\n<h3><b>H\u00e3y tr\u00ecnh b\u00e0y c\u00e1ch c\u1ea5u h\u00ecnh v\u00e0 qu\u1ea3n l\u00fd crontab trong Linux<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 m\u1edf v\u00e0 ch\u1ec9nh s\u1eeda t\u1ec7p crontab cho ng\u01b0\u1eddi d\u00f9ng hi\u1ec7n t\u1ea1i, ta s\u1eed d\u1ee5ng l\u1ec7nh:<\/span><\/p>\n<pre>crontab -e<\/pre>\n<p><span style=\"font-weight: 400;\">=&gt; T\u1ec7p crontab s\u1ebd m\u1edf trong tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n \u0111\u1ec3 c\u00f3 th\u1ec3 th\u00eam, s\u1eeda ho\u1eb7c x\u00f3a c\u00e1c c\u00f4ng vi\u1ec7c \u0111\u01b0\u1ee3c l\u00ean l\u1ecbch.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 xem c\u00e1c c\u00f4ng vi\u1ec7c \u0111\u00e3 l\u00ean l\u1ecbch trong crontab, ta s\u1eed d\u1ee5ng l\u1ec7nh:<\/span><\/p>\n<pre>crontab -l<\/pre>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 x\u00f3a crontab c\u1ee7a ng\u01b0\u1eddi d\u00f9ng hi\u1ec7n t\u1ea1i:<\/span><\/p>\n<pre>crontab -r<\/pre>\n<p><span style=\"font-weight: 400;\">Ngo\u00e0i ra ta c\u0169ng c\u00f3 th\u1ec3 ch\u1ec9nh s\u1eeda crontab c\u1ee7a ng\u01b0\u1eddi d\u00f9ng kh\u00e1c b\u1eb1ng c\u00e1ch:<\/span><\/p>\n<pre>sudo crontab -u username -e<\/pre>\n<h3><b>H\u00e3y k\u1ec3 t\u00ean c\u00e1c k\u00fd t\u1ef1 \u0111\u1eb7c bi\u1ec7t trong Crontab<\/b><\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>K\u00fd t\u1ef1<\/b><\/td>\n<td><b>T\u00ean g\u1ecdi<\/b><\/td>\n<td><b>\u00dd ngh\u0129a &amp; V\u00ed d\u1ee5<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>*<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Wildcard<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u0110\u1ea1i di\u1ec7n cho t\u1ea5t c\u1ea3 c\u00e1c gi\u00e1 tr\u1ecb trong tr\u01b0\u1eddng \u0111\u00f3.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, <\/span><span style=\"font-weight: 400;\">\u00a0* * * * *<\/span><span style=\"font-weight: 400;\"> c\u00f3 ngh\u0129a l\u00e0 ch\u1ea1y m\u1ed7i ph\u00fat c\u1ee7a m\u1ed7i gi\u1edd, ng\u00e0y, th\u00e1ng v\u00e0 th\u1ee9 trong tu\u1ea7n.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>&#8211;<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Range<\/span><\/td>\n<td><span style=\"font-weight: 400;\">X\u00e1c \u0111\u1ecbnh m\u1ed9t d\u1ea3i gi\u00e1 tr\u1ecb.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">1-5<\/span><span style=\"font-weight: 400;\"> trong tr\u01b0\u1eddng ng\u00e0y c\u00f3 ngh\u0129a l\u00e0 t\u1eeb ng\u00e0y 1 \u0111\u1ebfn ng\u00e0y 5 c\u1ee7a th\u00e1ng.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>,<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Comma<\/span><\/td>\n<td><span style=\"font-weight: 400;\">D\u00f9ng \u0111\u1ec3 ph\u00e2n t\u00e1ch c\u00e1c gi\u00e1 tr\u1ecb.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">1,2,3<\/span><span style=\"font-weight: 400;\"> c\u00f3 ngh\u0129a l\u00e0 ch\u1ea1y v\u00e0o c\u00e1c ng\u00e0y 1, 2 v\u00e0 3.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>\/<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Step\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">D\u00f9ng \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh b\u01b0\u1edbc nh\u1ea3y gi\u1eefa c\u00e1c gi\u00e1 tr\u1ecb.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">*\/5<\/span><span style=\"font-weight: 400;\"> trong tr\u01b0\u1eddng ph\u00fat c\u00f3 ngh\u0129a l\u00e0 ch\u1ea1y m\u1ed7i 5 ph\u00fat m\u1ed9t l\u1ea7n.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>?<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Unknown<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng thay th\u1ebf cho <\/span><span style=\"font-weight: 400;\">*<\/span><span style=\"font-weight: 400;\"> trong c\u00e1c tr\u01b0\u1eddng ng\u00e0y ho\u1eb7c ng\u00e0y trong tu\u1ea7n khi kh\u00f4ng quan tr\u1ecdng (th\u01b0\u1eddng s\u1eed d\u1ee5ng trong c\u00e1c h\u1ec7 th\u1ed1ng nh\u01b0 Quartz Scheduler).<\/span><\/p>\n<p><b>L\u01b0u \u00fd : <\/b><span style=\"font-weight: 400;\">K\u00fd t\u1ef1 <\/span><span style=\"font-weight: 400;\">?<\/span><span style=\"font-weight: 400;\"> th\u01b0\u1eddng kh\u00f4ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong crontab ti\u00eau chu\u1ea9n c\u1ee7a Linux\/Unix m\u00e0 ch\u1ee7 y\u1ebfu \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong c\u00e1c h\u1ec7 th\u1ed1ng l\u1eadp l\u1ecbch nh\u01b0 Quartz Scheduler.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>Shell t\u01b0\u01a1ng t\u00e1c v\u00e0 kh\u00f4ng t\u01b0\u01a1ng t\u00e1c l\u00e0 g\u00ec?<\/b><\/h3>\n<h4><b>Shell t\u01b0\u01a1ng t\u00e1c (Interactive Shell)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">L\u00e0 lo\u1ea1i shell m\u00e0 ng\u01b0\u1eddi d\u00f9ng t\u01b0\u01a1ng t\u00e1c tr\u1ef1c ti\u1ebfp th\u00f4ng qua b\u00e0n ph\u00edm v\u00e0 nh\u1eadn ph\u1ea3n h\u1ed3i ngay l\u1eadp t\u1ee9c. Shell n\u00e0y \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong c\u00e1c phi\u00ean l\u00e0m vi\u1ec7c c\u1ee7a ng\u01b0\u1eddi d\u00f9ng, n\u01a1i c\u00e1c l\u1ec7nh \u0111\u01b0\u1ee3c nh\u1eadp v\u00e0o v\u00e0 k\u1ebft qu\u1ea3 \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1 ngay l\u1eadp t\u1ee9c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1eb7c \u0111i\u1ec3m c\u1ee7a shell t\u01b0\u01a1ng t\u00e1c:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Nh\u1eadp l\u1ec7nh tr\u1ef1c ti\u1ebfp:<\/b><span style=\"font-weight: 400;\"> Ng\u01b0\u1eddi d\u00f9ng g\u00f5 l\u1ec7nh v\u00e0 shell th\u1ef1c thi l\u1ec7nh \u0111\u00f3 ngay l\u1eadp t\u1ee9c, sau \u0111\u00f3 tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u00f3 s\u1ef1 ph\u1ea3n h\u1ed3i:<\/b><span style=\"font-weight: 400;\"> Shell t\u01b0\u01a1ng t\u00e1c lu\u00f4n \u0111\u01b0a ra ph\u1ea3n h\u1ed3i v\u1ec1 k\u1ebft qu\u1ea3 c\u1ee7a c\u00e1c l\u1ec7nh \u0111\u01b0\u1ee3c nh\u1eadp.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ecbch s\u1eed l\u1ec7nh:<\/b><span style=\"font-weight: 400;\"> Shell t\u01b0\u01a1ng t\u00e1c c\u00f3 th\u1ec3 l\u01b0u tr\u1eef l\u1ecbch s\u1eed c\u00e1c l\u1ec7nh ng\u01b0\u1eddi d\u00f9ng \u0111\u00e3 nh\u1eadp v\u00e0 cung c\u1ea5p t\u00ednh n\u0103ng auto-completion (ho\u00e0n th\u00e0nh l\u1ec7nh t\u1ef1 \u0111\u1ed9ng).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ea5u h\u00ecnh v\u00e0 t\u01b0\u01a1ng t\u00e1c:<\/b><span style=\"font-weight: 400;\"> C\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh nh\u01b0 <\/span><span style=\"font-weight: 400;\">.bashrc<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">.bash_profile<\/span><span style=\"font-weight: 400;\"> s\u1ebd \u0111\u01b0\u1ee3c t\u1ea3i v\u00e0 th\u1ef1c thi khi m\u1edf m\u1ed9t shell t\u01b0\u01a1ng t\u00e1c. \u0110i\u1ec1u n\u00e0y cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng t\u00f9y ch\u1ec9nh m\u00f4i tr\u01b0\u1eddng l\u00e0m vi\u1ec7c.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Khi m\u1edf terminal trong Linux, b\u1ea1n s\u1ebd th\u1ea5y m\u1ed9t prompt v\u00e0 c\u00f3 th\u1ec3 nh\u1eadp l\u1ec7nh tr\u1ef1c ti\u1ebfp v\u00e0o \u0111\u00f3. \u0110\u00e2y l\u00e0 m\u1ed9t phi\u00ean shell t\u01b0\u01a1ng t\u00e1c, v\u00ed d\u1ee5:<\/span><\/p>\n<pre>user@linux:~$ ls\r\nDesktop\u00a0 Documents\u00a0 Downloads<\/pre>\n<h4><b>Shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c (Non-Interactive Shell): <\/b><\/h4>\n<p><span style=\"font-weight: 400;\">L\u00e0 lo\u1ea1i shell kh\u00f4ng y\u00eau c\u1ea7u s\u1ef1 nh\u1eadp l\u1ec7nh t\u1eeb ng\u01b0\u1eddi d\u00f9ng. Thay v\u00e0o \u0111\u00f3, n\u00f3 th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 th\u1ef1c thi c\u00e1c script t\u1ef1 \u0111\u1ed9ng m\u00e0 kh\u00f4ng c\u1ea7n s\u1ef1 can thi\u1ec7p c\u1ee7a ng\u01b0\u1eddi d\u00f9ng. Khi m\u1ed9t script shell ch\u1ea1y trong m\u00f4i tr\u01b0\u1eddng kh\u00f4ng t\u01b0\u01a1ng t\u00e1c, n\u00f3 s\u1ebd th\u1ef1c thi c\u00e1c l\u1ec7nh m\u00e0 kh\u00f4ng y\u00eau c\u1ea7u b\u1ea5t k\u1ef3 ph\u1ea3n h\u1ed3i n\u00e0o t\u1eeb ng\u01b0\u1eddi d\u00f9ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1eb7c \u0111i\u1ec3m c\u1ee7a shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng c\u00f3 s\u1ef1 t\u01b0\u01a1ng t\u00e1c tr\u1ef1c ti\u1ebfp:<\/b><span style=\"font-weight: 400;\"> C\u00e1c l\u1ec7nh trong shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c th\u01b0\u1eddng \u0111\u01b0\u1ee3c th\u1ef1c thi t\u1ef1 \u0111\u1ed9ng qua script ho\u1eb7c l\u1ec7nh \u0111\u01b0\u1ee3c g\u1ecdi t\u1eeb m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh kh\u00e1c m\u00e0 kh\u00f4ng c\u1ea7n s\u1ef1 tham gia c\u1ee7a ng\u01b0\u1eddi d\u00f9ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng ph\u1ea3n h\u1ed3i tr\u1ef1c ti\u1ebfp:<\/b><span style=\"font-weight: 400;\"> M\u1eb7c d\u00f9 shell c\u00f3 th\u1ec3 in ra k\u1ebft qu\u1ea3, nh\u01b0ng s\u1ebd kh\u00f4ng y\u00eau c\u1ea7u ng\u01b0\u1eddi d\u00f9ng ph\u1ea3i nh\u1eadp th\u00eam d\u1eef li\u1ec7u ho\u1eb7c l\u1ec7nh.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng t\u1ea3i c\u1ea5u h\u00ecnh nh\u01b0 shell t\u01b0\u01a1ng t\u00e1c:<\/b><span style=\"font-weight: 400;\"> Shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c th\u01b0\u1eddng kh\u00f4ng t\u1ea3i c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh nh\u01b0 <\/span><span style=\"font-weight: 400;\">.bashrc<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">.bash_profile<\/span><span style=\"font-weight: 400;\"> tr\u1eeb khi b\u1ea1n ch\u1ec9 \u0111\u1ecbnh r\u00f5 r\u00e0ng. \u0110i\u1ec1u n\u00e0y gi\u00fap t\u0103ng t\u1ed1c \u0111\u1ed9 th\u1ef1c thi.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u00f9ng cho t\u1ef1 \u0111\u1ed9ng h\u00f3a:<\/b><span style=\"font-weight: 400;\"> Shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn trong c\u00e1c t\u00e1c v\u1ee5 t\u1ef1 \u0111\u1ed9ng nh\u01b0 ch\u1ea1y script cron, t\u1ef1 \u0111\u1ed9ng sao l\u01b0u d\u1eef li\u1ec7u ho\u1eb7c th\u1ef1c thi c\u00e1c t\u00e1c v\u1ee5 h\u1ec7 th\u1ed1ng v\u00e0o th\u1eddi gian \u0111\u1ecbnh k\u1ef3.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Khi ch\u1ea1y m\u1ed9t script shell (ch\u1eb3ng h\u1ea1n nh\u01b0 <\/span><span style=\"font-weight: 400;\">backup.sh<\/span><span style=\"font-weight: 400;\">) t\u1eeb cron ho\u1eb7c t\u1eeb m\u1ed9t file script m\u00e0 kh\u00f4ng ph\u1ea3i g\u00f5 l\u1ec7nh trong terminal, \u0111\u00f3 l\u00e0 m\u1ed9t phi\u00ean shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c. V\u00ed d\u1ee5:<\/span><\/p>\n<p>#!\/bin\/bash<\/p>\n<pre>tar -czf \/backup\/myfiles.tar.gz \/home\/user\/<\/pre>\n<p><span style=\"font-weight: 400;\">N\u1ebfu ch\u1ea1y script b\u1eb1ng crontab:<\/span><\/p>\n<pre>0 2 * * * \/path\/to\/backup.sh<\/pre>\n<p><span style=\"font-weight: 400;\">=&gt; Khi cron th\u1ef1c thi script n\u00e0y v\u00e0o 2:00 AM m\u1ed7i ng\u00e0y th\u00ec \u0111\u00f3 l\u00e0 m\u1ed9t shell kh\u00f4ng t\u01b0\u01a1ng t\u00e1c v\u00e0 kh\u00f4ng c\u00f3 b\u1ea5t k\u1ef3 ph\u1ea3n h\u1ed3i n\u00e0o y\u00eau c\u1ea7u ng\u01b0\u1eddi d\u00f9ng nh\u1eadp l\u1ec7nh hay d\u1eef li\u1ec7u.<\/span><\/p>\n<h3><b>H\u00e3y n\u00eau s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><strong>source<\/strong><b> v\u00e0 <\/b><span style=\"font-weight: 400;\">.\/<\/span><b> khi th\u1ef1c thi m\u1ed9t script trong Bash<\/b><\/h3>\n<h4><strong>L\u1ec7nh .\/<\/strong><\/h4>\n<p><span style=\"font-weight: 400;\">.\/<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 th\u1ef1c thi m\u1ed9t script t\u1eeb terminal trong m\u1ed9t shell m\u1edbi. Khi ch\u1ea1y m\u1ed9t script v\u1edbi <\/span><span style=\"font-weight: 400;\">.\/<\/span><span style=\"font-weight: 400;\">, b\u1ea1n \u0111ang y\u00eau c\u1ea7u shell t\u1ea1o ra m\u1ed9t ti\u1ebfn tr\u00ecnh m\u1edbi \u0111\u1ec3 ch\u1ea1y script \u0111\u00f3. V\u00e0 khi s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">.\/<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 ch\u1ea1y script, script n\u00ean c\u00f3 d\u00f2ng shebang (nh\u01b0 <\/span><span style=\"font-weight: 400;\">#!\/bin\/bash<\/span><span style=\"font-weight: 400;\">) \u1edf \u0111\u1ea7u file \u0111\u1ec3 h\u1ec7 th\u1ed1ng bi\u1ebft s\u1eed d\u1ee5ng tr\u00ecnh th\u00f4ng d\u1ecbch n\u00e0o \u0111\u1ec3 th\u1ef1c thi script.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1eb7c \u0111i\u1ec3m c\u1ee7a <\/span><span style=\"font-weight: 400;\">.\/ <\/span><span style=\"font-weight: 400;\">l\u00e0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ch\u1ea1y trong m\u1ed9t shell m\u1edbi:<\/b><span style=\"font-weight: 400;\"> Khi b\u1ea1n s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">.\/<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 ch\u1ea1y script, m\u1ed9t shell con (subshell) m\u1edbi s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o ra \u0111\u1ec3 th\u1ef1c thi c\u00e1c l\u1ec7nh trong script. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 b\u1ea5t k\u1ef3 thay \u0111\u1ed5i n\u00e0o trong bi\u1ebfn m\u00f4i tr\u01b0\u1eddng ho\u1eb7c c\u00e1c thay \u0111\u1ed5i kh\u00e1c trong script s\u1ebd kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn shell hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ea7n quy\u1ec1n th\u1ef1c thi:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ec3 ch\u1ea1y script b\u1eb1ng <\/span><span style=\"font-weight: 400;\">.\/<\/span><span style=\"font-weight: 400;\">, b\u1ea1n c\u1ea7n ph\u1ea3i c\u1ea5p quy\u1ec1n th\u1ef1c thi cho script. \u0110i\u1ec1u n\u00e0y \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n v\u1edbi l\u1ec7nh <\/span><span style=\"font-weight: 400;\">chmod +x script_name<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn m\u00f4i tr\u01b0\u1eddng shell hi\u1ec7n t\u1ea1i:<\/b><span style=\"font-weight: 400;\"> Khi script k\u1ebft th\u00fac, shell con s\u1ebd k\u1ebft th\u00fac v\u00e0 t\u1ea5t c\u1ea3 c\u00e1c thay \u0111\u1ed5i (nh\u01b0 thay \u0111\u1ed5i bi\u1ebfn m\u00f4i tr\u01b0\u1eddng) s\u1ebd b\u1ecb m\u1ea5t \u0111i.<\/span><\/li>\n<\/ul>\n<h4><strong>L\u1ec7nh source<\/strong><\/h4>\n<p><span style=\"font-weight: 400;\">source<\/span><span style=\"font-weight: 400;\"> (ho\u1eb7c <\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\"> trong m\u1ed9t s\u1ed1 h\u1ec7 th\u1ed1ng) l\u00e0 m\u1ed9t c\u00e2u l\u1ec7nh trong Bash \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 th\u1ef1c thi m\u1ed9t script trong c\u00f9ng m\u1ed9t shell hi\u1ec7n t\u1ea1i. Hay n\u00f3i c\u00e1ch kh\u00e1c l\u00e0 b\u1ea5t k\u1ef3 thay \u0111\u1ed5i n\u00e0o m\u00e0 script th\u1ef1c hi\u1ec7n (nh\u01b0 thay \u0111\u1ed5i bi\u1ebfn m\u00f4i tr\u01b0\u1eddng) s\u1ebd v\u1eabn c\u00f2n hi\u1ec7u l\u1ef1c trong shell hi\u1ec7n t\u1ea1i.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1eb7c \u0111i\u1ec3m c\u1ee7a <\/span><span style=\"font-weight: 400;\">source<\/span><span style=\"font-weight: 400;\">:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ch\u1ea1y trong shell hi\u1ec7n t\u1ea1i:<\/b><span style=\"font-weight: 400;\"> Khi b\u1ea1n s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">source<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 ch\u1ea1y m\u1ed9t script, script s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c thi trong ch\u00ednh shell hi\u1ec7n t\u1ea1i m\u00e0 b\u1ea1n \u0111ang s\u1eed d\u1ee5ng. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 b\u1ea5t k\u1ef3 thay \u0111\u1ed5i n\u00e0o trong m\u00f4i tr\u01b0\u1eddng shell, v\u00ed d\u1ee5 nh\u01b0 thay \u0111\u1ed5i gi\u00e1 tr\u1ecb bi\u1ebfn m\u00f4i tr\u01b0\u1eddng, s\u1ebd \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i v\u00e0 \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn shell hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng c\u1ea7n quy\u1ec1n th\u1ef1c thi:<\/b><span style=\"font-weight: 400;\"> Khi s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">source<\/span><span style=\"font-weight: 400;\">, b\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i c\u1ea5p quy\u1ec1n th\u1ef1c thi cho script. B\u1ea1n ch\u1ec9 c\u1ea7n c\u00f3 quy\u1ec1n \u0111\u1ecdc v\u00e0 vi\u1ebft tr\u00ean script.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f4ng t\u1ea1o ti\u1ebfn tr\u00ecnh m\u1edbi:<\/b><span style=\"font-weight: 400;\"> Kh\u00f4ng c\u00f3 m\u1ed9t shell con n\u00e0o \u0111\u01b0\u1ee3c t\u1ea1o ra khi b\u1ea1n s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">source<\/span><span style=\"font-weight: 400;\">, t\u1ea5t c\u1ea3 c\u00e1c thay \u0111\u1ed5i s\u1ebd x\u1ea3y ra trong shell hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<\/ul>\n<h4><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><strong>source v\u00e0 .\/<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<td><b>Ti\u00eau ch\u00ed<\/b><\/td>\n<td><span style=\"font-weight: 400;\">.\/<\/span><b> (Ch\u1ea1y trong shell con)<\/b><\/td>\n<td><span style=\"font-weight: 400;\">source<\/span><b> (Ch\u1ea1y trong shell hi\u1ec7n t\u1ea1i)<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">M\u00f4i tr\u01b0\u1eddng th\u1ef1c thi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">T\u1ea1o m\u1ed9t shell con m\u1edbi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ea1y trong ch\u00ednh shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">T\u1ea1o ti\u1ebfn tr\u00ecnh m\u1edbi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">T\u1ea1o m\u1ed9t ti\u1ebfn tr\u00ecnh con m\u1edbi khi ch\u1ea1y script<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng t\u1ea1o ti\u1ebfn tr\u00ecnh m\u1edbi, t\u1ea5t c\u1ea3 th\u1ef1c thi trong shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">\u1ea2nh h\u01b0\u1edfng \u0111\u1ebfn m\u00f4i tr\u01b0\u1eddng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng thay \u0111\u1ed5i m\u00f4i tr\u01b0\u1eddng shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i m\u00f4i tr\u01b0\u1eddng shell hi\u1ec7n t\u1ea1i (v\u00ed d\u1ee5, bi\u1ebfn m\u00f4i tr\u01b0\u1eddng)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Quy\u1ec1n th\u1ef1c thi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u1ea7n quy\u1ec1n th\u1ef1c thi (<\/span><span style=\"font-weight: 400;\">chmod +x<\/span><span style=\"font-weight: 400;\">) tr\u00ean file script<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng c\u1ea7n quy\u1ec1n th\u1ef1c thi, ch\u1ec9 c\u1ea7n quy\u1ec1n \u0111\u1ecdc file<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ea1y c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh ho\u1eb7c script \u0111\u1ed9c l\u1eadp<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng khi c\u1ea7n thay \u0111\u1ed5i bi\u1ebfn m\u00f4i tr\u01b0\u1eddng ho\u1eb7c c\u00e0i \u0111\u1eb7t shell<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p<\/span><\/td>\n<td><span style=\"font-weight: 400;\">.\/script_name<\/span><\/td>\n<td><span style=\"font-weight: 400;\">source script_name<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">. script_name<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i bi\u1ebfn m\u00f4i tr\u01b0\u1eddng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn bi\u1ebfn m\u00f4i tr\u01b0\u1eddng c\u1ee7a shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i ho\u1eb7c t\u1ea1o bi\u1ebfn m\u00f4i tr\u01b0\u1eddng cho shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 sau khi script k\u1ebft th\u00fac<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shell con k\u1ebft th\u00fac, thay \u0111\u1ed5i b\u1ecb m\u1ea5t<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i v\u1eabn c\u00f2n t\u1ed3n t\u1ea1i trong shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">V\u00ed d\u1ee5<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1ea1y m\u1ed9t script \u0111\u1ed9c l\u1eadp, kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Thi\u1ebft l\u1eadp alias, bi\u1ebfn m\u00f4i tr\u01b0\u1eddng, ho\u1eb7c h\u00e0m trong shell hi\u1ec7n t\u1ea1i<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><b>Tr\u00ecnh b\u00e0y \u0111\u1ecbnh ngh\u0129a subshell v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng subshell trong Bash.<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Subshell l\u00e0 m\u1ed9t ti\u1ebfn tr\u00ecnh con \u0111\u01b0\u1ee3c t\u1ea1o ra t\u1eeb shell hi\u1ec7n t\u1ea1i (parent shell), c\u00f3 m\u00f4i tr\u01b0\u1eddng v\u00e0 b\u1ed9 nh\u1edb ri\u00eang, d\u00f9ng \u0111\u1ec3 th\u1ef1c thi c\u00e1c l\u1ec7nh m\u00e0 kh\u00f4ng l\u00e0m \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn m\u00f4i tr\u01b0\u1eddng c\u1ee7a shell g\u1ed1c. M\u1ecdi thay \u0111\u1ed5i v\u1ec1 bi\u1ebfn, th\u01b0 m\u1ee5c ho\u1eb7c c\u00e1c c\u1ea5u h\u00ecnh trong subshell s\u1ebd kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn shell cha (parent shell). \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 khi subshell k\u1ebft th\u00fac, t\u1ea5t c\u1ea3 c\u00e1c thay \u0111\u1ed5i trong \u0111\u00f3 s\u1ebd b\u1ecb m\u1ea5t.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u1ed7i subshell c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c ki\u1ec3m tra b\u1eb1ng bi\u1ebfn m\u00f4i tr\u01b0\u1eddng BASH_SUBSHELL \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh m\u1ee9c \u0111\u1ed9 l\u1ed3ng nhau c\u1ee7a subshell.<\/span><\/p>\n<h4><b>C\u00e1ch s\u1eed d\u1ee5ng Subshell trong Bash:<\/b><\/h4>\n<p><span style=\"font-weight: 400;\"><strong>1. Ch\u1ea1y l\u1ec7nh trong Subshell:<\/strong> Ta c\u00f3 th\u1ec3 th\u1ef1c thi m\u1ed9t nh\u00f3m l\u1ec7nh trong subshell b\u1eb1ng c\u00e1ch \u0111\u1eb7t c\u00e1c l\u1ec7nh \u0111\u00f3 v\u00e0o trong d\u1ea5u ngo\u1eb7c \u0111\u01a1n <\/span><span style=\"font-weight: 400;\">( )<\/span><span style=\"font-weight: 400;\">. V\u00ed d\u1ee5: <\/span>(cd \/home\/user; echo &#8220;\u0110ang \u1edf th\u01b0 m\u1ee5c: $(pwd)&#8221;)<\/p>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">cd \/home\/user<\/span><span style=\"font-weight: 400;\"> thay \u0111\u1ed5i th\u01b0 m\u1ee5c trong subshell.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">echo &#8220;\u0110ang \u1edf th\u01b0 m\u1ee5c: $(pwd)&#8221;<\/span><span style=\"font-weight: 400;\"> hi\u1ec3n th\u1ecb th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Tuy nhi\u00ean, sau khi subshell k\u1ebft th\u00fac, th\u01b0 m\u1ee5c l\u00e0m vi\u1ec7c c\u1ee7a shell cha kh\u00f4ng b\u1ecb thay \u0111\u1ed5i.<\/span><\/li>\n<\/ul>\n<p><b>2. Th\u1ef1c thi c\u00e1c l\u1ec7nh song song (Background Tasks)<\/b><span style=\"font-weight: 400;\">: Ta c\u00f3 th\u1ec3 ch\u1ea1y c\u00e1c l\u1ec7nh song song trong subshell b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng d\u1ea5u <\/span><span style=\"font-weight: 400;\">&amp;<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 \u0111\u01b0a l\u1ec7nh v\u00e0o background. V\u00ed d\u1ee5:<\/span><\/p>\n<pre>(sleep 5; echo \"Xong t\u00e1c v\u1ee5 1\") &amp;\r\n(sleep 3; echo \"Xong t\u00e1c v\u1ee5 2\") &amp;\r\nwait<\/pre>\n<p><span style=\"font-weight: 400;\">\u1ede v\u00ed d\u1ee5 n\u00e0y, c\u1ea3 hai subshell s\u1ebd ch\u1ea1y song song, kh\u00f4ng l\u00e0m gi\u00e1n \u0111o\u1ea1n nhau. C\u00f2n <\/span><span style=\"font-weight: 400;\">wait<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 \u0111\u1ee3i cho c\u00e1c ti\u1ebfn tr\u00ecnh n\u00e0y ho\u00e0n th\u00e0nh.<\/span><\/p>\n<p><b>3. L\u00e0m vi\u1ec7c v\u1edbi v\u00f2ng l\u1eb7p trong Subshell<\/b><span style=\"font-weight: 400;\">: Subshell c\u00f2n h\u1eefu \u00edch khi c\u1ea7n ch\u1ea1y v\u00f2ng l\u1eb7p m\u00e0 kh\u00f4ng l\u00e0m thay \u0111\u1ed5i c\u00e1c bi\u1ebfn trong shell cha. V\u00ed d\u1ee5:<\/span><\/p>\n<pre>for i in {1..5}\r\ndo\r\n \u00a0(echo \"Ch\u1ea1y trong subshell: $i\")\r\ndone<\/pre>\n<p><span style=\"font-weight: 400;\">M\u1ed7i l\u1ea7n l\u1eb7p trong v\u00f2ng l\u1eb7p <\/span><span style=\"font-weight: 400;\">for<\/span><span style=\"font-weight: 400;\"> s\u1ebd t\u1ea1o ra m\u1ed9t subshell ri\u00eang bi\u1ec7t, do \u0111\u00f3 kh\u00f4ng l\u00e0m thay \u0111\u1ed5i c\u00e1c bi\u1ebfn trong shell cha.<\/span><\/p>\n<h3><b>T\u00ecnh hu\u1ed1ng n\u00e0o th\u00ec c\u1ea7n s\u1eed d\u1ee5ng subshell?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Khi c\u1ea7n tr\u00e1nh thay \u0111\u1ed5i trong shell cha<\/b><span style=\"font-weight: 400;\">: Ch\u1ec9 s\u1eed d\u1ee5ng subshell khi b\u1ea1n mu\u1ed1n th\u1ef1c thi l\u1ec7nh trong m\u1ed9t m\u00f4i tr\u01b0\u1eddng ri\u00eang bi\u1ec7t m\u00e0 kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn c\u00e1c c\u00e0i \u0111\u1eb7t ho\u1eb7c bi\u1ebfn m\u00f4i tr\u01b0\u1eddng trong shell cha.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Khi c\u1ea7n th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 t\u00e1ch bi\u1ec7t:<\/b><span style=\"font-weight: 400;\"> V\u00ed d\u1ee5 nh\u01b0 thao t\u00e1c v\u1edbi th\u01b0 m\u1ee5c ho\u1eb7c c\u00e1c file m\u00e0 kh\u00f4ng thay \u0111\u1ed5i tr\u1ea1ng th\u00e1i c\u1ee7a shell cha.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Khi c\u1ea7n th\u1ef1c thi c\u00e1c l\u1ec7nh song song<\/b><span style=\"font-weight: 400;\">: C\u00f3 th\u1ec3 s\u1eed d\u1ee5ng subshell \u0111\u1ec3 ch\u1ea1y c\u00e1c l\u1ec7nh \u0111\u1ed3ng th\u1eddi m\u00e0 kh\u00f4ng l\u00e0m gi\u00e1n \u0111o\u1ea1n nhau, gi\u00fap t\u0103ng hi\u1ec7u su\u1ea5t khi th\u1ef1c hi\u1ec7n c\u00e1c c\u00f4ng vi\u1ec7c l\u00e2u d\u00e0i.<\/span><\/li>\n<\/ul>\n<h3><b>Kinh nghi\u1ec7m l\u00e0m vi\u1ec7c c\u1ee7a b\u1ea1n v\u1edbi subshell l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng subshell gi\u00fap t\u00f4i r\u00fat ra m\u1ed9t s\u1ed1 l\u01b0u \u00fd quan tr\u1ecdng:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>V\u1ec1 ph\u1ea1m vi t\u00e1c \u0111\u1ed9ng<\/b><span style=\"font-weight: 400;\">: Khi s\u1eed d\u1ee5ng subshell, c\u00e1c thay \u0111\u1ed5i trong subshell (ch\u1eb3ng h\u1ea1n nh\u01b0 thay \u0111\u1ed5i th\u01b0 m\u1ee5c l\u00e0m vi\u1ec7c ho\u1eb7c thi\u1ebft l\u1eadp bi\u1ebfn m\u00f4i tr\u01b0\u1eddng) s\u1ebd kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn shell cha. \u0110i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 l\u00e0 m\u1ed9t l\u1ee3i th\u1ebf b\u1ea3o m\u1eadt. Tuy nhi\u00ean, \u0111i\u1ec1u n\u00e0y c\u0169ng \u0111\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c c\u00e1c thay \u0111\u1ed5i b\u00ean trong subshell s\u1ebd kh\u00f4ng t\u1ed3n t\u1ea1i sau khi subshell k\u1ebft th\u00fac. Do \u0111\u00f3, n\u1ebfu c\u1ea7n thay \u0111\u1ed5i v\u0129nh vi\u1ec5n m\u00f4i tr\u01b0\u1eddng l\u00e0m vi\u1ec7c (nh\u01b0 thay \u0111\u1ed5i bi\u1ebfn m\u00f4i tr\u01b0\u1eddng) ho\u1eb7c gi\u1eef l\u1ea1i tr\u1ea1ng th\u00e1i sau khi th\u1ef1c thi, t\u00f4i kh\u00f4ng \u01b0u ti\u00ean d\u00f9ng subshell.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Qu\u1ea3n l\u00fd t\u00e0i nguy\u00ean<\/b><span style=\"font-weight: 400;\">: V\u00ec subshell l\u00e0 m\u1ed9t ti\u1ebfn tr\u00ecnh con, n\u1ebfu c\u00f3 qu\u00e1 nhi\u1ec1u ti\u1ebfn tr\u00ecnh con \u0111\u01b0\u1ee3c t\u1ea1o ra trong c\u00e1c v\u00f2ng l\u1eb7p ho\u1eb7c khi th\u1ef1c thi qu\u00e1 nhi\u1ec1u l\u1ec7nh \u0111\u1ed3ng th\u1eddi, h\u1ec7 th\u1ed1ng c\u00f3 th\u1ec3 g\u1eb7p kh\u00f3 kh\u0103n trong vi\u1ec7c qu\u1ea3n l\u00fd t\u00e0i nguy\u00ean. Do \u0111\u00f3, c\u1ea7n s\u1eed d\u1ee5ng ch\u00fang m\u1ed9t c\u00e1ch h\u1ee3p l\u00fd.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Hi\u1ec7u su\u1ea5t:<\/b><span style=\"font-weight: 400;\"> Vi\u1ec7c t\u1ea1o subshell ti\u00eau t\u1ed1n t\u00e0i nguy\u00ean h\u1ec7 th\u1ed1ng do ph\u1ea3i sao ch\u00e9p m\u00f4i tr\u01b0\u1eddng shell cha. Trong c\u00e1c script c\u1ea7n th\u1ef1c thi nhi\u1ec1u l\u1ea7n ho\u1eb7c trong v\u00f2ng l\u1eb7p l\u1edbn, vi\u1ec7c t\u1ea1o qu\u00e1 nhi\u1ec1u subshell c\u00f3 th\u1ec3 \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn hi\u1ec7u su\u1ea5t. Trong nh\u1eefng tr\u01b0\u1eddng h\u1ee3p n\u00e0y, t\u00f4i c\u00e2n nh\u1eafc s\u1eed d\u1ee5ng c\u00e1ch ti\u1ebfp c\u1eadn kh\u00e1c nh\u01b0 group commands v\u1edbi { commands; } thay v\u00ec ( commands ).<\/span><\/li>\n<\/ul>\n<h3><b>Here Documents (heredocs) l\u00e0 g\u00ec trong Bash?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Here Documents, vi\u1ebft t\u1eaft l\u00e0 heredocs, l\u00e0 m\u1ed9t c\u00fa ph\u00e1p trong shell (nh\u01b0 bash, zsh&#8230;) d\u00f9ng \u0111\u1ec3 chuy\u1ec3n nhi\u1ec1u d\u00f2ng v\u0103n b\u1ea3n (multiline) v\u00e0o m\u1ed9t l\u1ec7nh ho\u1eb7c ch\u01b0\u01a1ng tr\u00ecnh, gi\u1ed1ng nh\u01b0 nh\u1eadp li\u1ec7u t\u1eeb t\u1ec7p ho\u1eb7c stdin. N\u00f3i c\u00e1ch kh\u00e1c, khi b\u1ea1n g\u00f5 n\u1ed9i dung tr\u1ef1c ti\u1ebfp v\u00e0o trong script nh\u01b0 th\u1ec3 \u0111\u00f3 l\u00e0 m\u1ed9t t\u1ec7p d\u1eef li\u1ec7u, gi\u00fap d\u1ec5 d\u00e0ng truy\u1ec1n kh\u1ed1i v\u0103n b\u1ea3n cho c\u00e1c l\u1ec7nh nh\u01b0 <\/span><span style=\"font-weight: 400;\">cat<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">tee<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">ssh<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">ftp<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">sql<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre>command &lt;&lt;DELIMITER\r\nn\u1ed9i dung d\u00f2ng 1\r\nn\u1ed9i dung d\u00f2ng 2\r\n...\r\nDELIMITER<\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">command<\/span><span style=\"font-weight: 400;\">: l\u00e0 l\u1ec7nh b\u1ea1n mu\u1ed1n ch\u1ea1y, v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">cat<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">echo<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">tee<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">mysql<\/span><span style=\"font-weight: 400;\">,&#8230;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">DELIMITER<\/span><span style=\"font-weight: 400;\">: l\u00e0 t\u1eeb kh\u00f3a \u0111\u00e1nh d\u1ea5u \u0111i\u1ec3m b\u1eaft \u0111\u1ea7u v\u00e0 k\u1ebft th\u00fac \u0111o\u1ea1n v\u0103n b\u1ea3n (th\u01b0\u1eddng \u0111\u1eb7t l\u00e0 <\/span><span style=\"font-weight: 400;\">EOF<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">END<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">TEXT<\/span><span style=\"font-weight: 400;\">&#8230; tu\u1ef3 ng\u01b0\u1eddi d\u00f9ng \u0111\u1eb7t, mi\u1ec5n tr\u00f9ng kh\u1edbp c\u1ea3 2 ch\u1ed7).<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 ta c\u00f3:<\/span><\/p>\n<pre>cat &lt;&lt;EOF\r\nVi\u1ec7t Nam!\r\nH\u1ed3 Ch\u00ed Minh\r\nEOF<\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">cat<\/span><span style=\"font-weight: 400;\"> l\u00e0 l\u1ec7nh d\u00f9ng \u0111\u1ec3 in ra n\u1ed9i dung.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">N\u1ed9i dung gi\u1eefa hai d\u00f2ng <\/span><span style=\"font-weight: 400;\">EOF<\/span><span style=\"font-weight: 400;\"> s\u1ebd \u0111\u01b0\u1ee3c truy\u1ec1n cho l\u1ec7nh <\/span><span style=\"font-weight: 400;\">cat<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 s\u1ebd l\u00e0:<\/span><\/p>\n<pre>Vi\u1ec7t Nam!\r\nH\u1ed3 Ch\u00ed Minh<\/pre>\n<h3><b>B\u1ea1n th\u01b0\u1eddng \u1ee9ng d\u1ee5ng Heredocs v\u00e0o vi\u1ec7c g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">T\u00f4i th\u01b0\u1eddng s\u1eed d\u1ee5ng<\/span><b> heredocs<\/b><span style=\"font-weight: 400;\"> trong shell script \u0111\u1ec3 x\u1eed l\u00fd c\u00e1c t\u00ecnh hu\u1ed1ng c\u1ea7n l\u00e0m vi\u1ec7c v\u1edbi d\u1eef li\u1ec7u nhi\u1ec1u d\u00f2ng m\u1ed9t c\u00e1ch ti\u1ec7n l\u1ee3i. C\u1ee5 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ch\u00e8n t\u1ec7p c\u1ea5u h\u00ecnh v\u00e0o script<\/b><span style=\"font-weight: 400;\">: S\u1eed d\u1ee5ng heredoc \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng t\u1ea1o c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh, gi\u00fap gi\u1ea3m thi\u1ec3u c\u00f4ng vi\u1ec7c th\u1ee7 c\u00f4ng v\u00e0 ti\u1ebft ki\u1ec7m th\u1eddi gian.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>G\u1eedi d\u1eef li\u1ec7u v\u00e0o m\u1ed9t l\u1ec7nh ho\u1eb7c ch\u01b0\u01a1ng tr\u00ecnh<\/b><span style=\"font-weight: 400;\">: Khi c\u1ea7n truy\u1ec1n m\u1ed9t \u0111o\u1ea1n v\u0103n b\u1ea3n l\u1edbn v\u00e0o m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh (nh\u01b0 cat, ssh, ftp, mysql,&#8230;), t\u00f4i th\u01b0\u1eddng d\u00f9ng heredoc \u0111\u1ec3 vi\u1ebft n\u1ed9i dung tr\u1ef1c ti\u1ebfp trong script m\u00e0 kh\u00f4ng ph\u1ea3i g\u00f5 tay t\u1eebng d\u00f2ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u01b0u tr\u1eef c\u00e1c th\u00f4ng tin d\u1ea1ng nhi\u1ec1u d\u00f2ng<\/b><span style=\"font-weight: 400;\">: Khi c\u1ea7n l\u01b0u tr\u1eef m\u1ed9t kh\u1ed1i v\u0103n b\u1ea3n d\u00e0i trong m\u1ed9t bi\u1ebfn ho\u1eb7c l\u00e0m vi\u1ec7c v\u1edbi m\u1ed9t d\u1eef li\u1ec7u l\u1edbn, heredoc gi\u00fap t\u00f4i l\u00e0m \u0111i\u1ec1u \u0111\u00f3 m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng.<\/span><\/li>\n<\/ul>\n<h3><b>Heredoc c\u00f3 th\u1ec3 x\u1eed l\u00fd bi\u1ebfn v\u00e0 l\u1ec7nh kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00f3 2 tr\u01b0\u1eddng h\u1ee3p:<\/span><\/p>\n<h4><b>Tr\u01b0\u1eddng h\u1ee3p 1: C\u00e2u tr\u1ea3 l\u1eddi l\u00e0 C\u00f3, n\u1ebfu DELIMITER kh\u00f4ng n\u1eb1m trong d\u1ea5u <\/b><b>&#8216;<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 ta c\u00f3:<\/span><\/p>\n<pre>name=\"An\"\r\ncat &lt;&lt;EOF\r\nXin ch\u00e0o $name\r\nH\u00f4m nay l\u00e0: $(date)\r\nEOF<\/pre>\n<p><span style=\"font-weight: 400;\">=&gt; <\/span><span style=\"font-weight: 400;\">$name<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">$(date)<\/span><span style=\"font-weight: 400;\"> s\u1ebd \u0111\u01b0\u1ee3c thay th\u1ebf b\u1eb1ng gi\u00e1 tr\u1ecb th\u1ef1c.<\/span><\/p>\n<h4><b>Tr\u01b0\u1eddng h\u1ee3p 2: C\u00e2u tr\u1ea3 l\u1eddi l\u00e0 Kh\u00f4ng, n\u1ebfu \u0111\u1eb7t DELIMITER trong d\u1ea5u <\/b><b>&#8216;<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 ta c\u00f3:<\/span><\/p>\n<pre>cat &lt;&lt;'EOF'\r\nXin ch\u00e0o $name\r\nEOF<\/pre>\n<p><span style=\"font-weight: 400;\">=&gt; K\u1ebft qu\u1ea3 s\u1ebd in nguy\u00ean v\u0103n <\/span><span style=\"font-weight: 400;\">$name<\/span><span style=\"font-weight: 400;\"> ch\u1ee9 kh\u00f4ng thay th\u1ebf.<\/span><\/p>\n<h3><b>H\u00e3y tr\u00ecnh b\u00e0y m\u1ed9t s\u1ed1 c\u00e1ch m\u00e0 b\u1ea1n s\u1eed d\u1ee5ng l\u1ec7nh n\u1ec1n (background processes)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh n\u1ec1n (background processes) trong Bash l\u00e0 c\u00e1c ti\u1ebfn tr\u00ecnh (processes) \u0111\u01b0\u1ee3c ch\u1ea1y trong n\u1ec1n, kh\u00f4ng l\u00e0m gi\u00e1n \u0111o\u1ea1n c\u00e1c t\u00e1c v\u1ee5 hi\u1ec7n t\u1ea1i trong terminal. Khi m\u1ed9t l\u1ec7nh \u0111\u01b0\u1ee3c th\u1ef1c thi \u1edf ch\u1ebf \u0111\u1ed9 n\u1ec1n, n\u00f3 s\u1ebd ch\u1ea1y \u0111\u1ed9c l\u1eadp v\u1edbi terminal hi\u1ec7n t\u1ea1i v\u00e0 ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 ti\u1ebfp t\u1ee5c nh\u1eadp c\u00e1c l\u1ec7nh kh\u00e1c m\u00e0 kh\u00f4ng b\u1ecb ch\u1eb7n. \u0110\u00e2y l\u00e0 m\u1ed9t t\u00ednh n\u0103ng h\u1eefu \u00edch khi b\u1ea1n mu\u1ed1n ch\u1ea1y c\u00e1c t\u00e1c v\u1ee5 d\u00e0i ho\u1eb7c c\u00e1c ti\u1ebfn tr\u00ecnh kh\u00f4ng c\u1ea7n ph\u1ea3i t\u01b0\u01a1ng t\u00e1c v\u1edbi ng\u01b0\u1eddi d\u00f9ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 c\u00e1ch s\u1eed d\u1ee5ng v\u00e0 qu\u1ea3n l\u00fd ti\u1ebfn tr\u00ecnh n\u1ec1n:<\/span><\/p>\n<h4><b>1. Ch\u1ea1y l\u1ec7nh n\u1ec1n b\u1eb1ng d\u1ea5u <\/b><span style=\"font-weight: 400;\">&amp;<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">C\u00e1ch \u0111\u01a1n gi\u1ea3n nh\u1ea5t \u0111\u1ec3 ch\u1ea1y m\u1ed9t l\u1ec7nh trong n\u1ec1n l\u00e0 th\u00eam d\u1ea5u <\/span><span style=\"font-weight: 400;\">&amp;<\/span><span style=\"font-weight: 400;\"> v\u00e0o cu\u1ed1i l\u1ec7nh. L\u1ec7nh n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c thi \u1edf ch\u1ebf \u0111\u1ed9 n\u1ec1n v\u00e0 terminal s\u1ebd kh\u00f4ng b\u1ecb kh\u00f3a, b\u1ea1n c\u00f3 th\u1ec3 ti\u1ebfp t\u1ee5c nh\u1eadp c\u00e1c l\u1ec7nh kh\u00e1c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre>sleep 30 &amp;<\/pre>\n<p><span style=\"font-weight: 400;\">Khi ch\u1ea1y l\u1ec7nh n\u00e0y, h\u1ec7 th\u1ed1ng s\u1ebd tr\u1ea3 v\u1ec1 m\u1ed9t s\u1ed1 nh\u01b0 [1] 12345, trong \u0111\u00f3 [1] l\u00e0 job ID v\u00e0 12345 l\u00e0 process ID (PID).<\/span><\/p>\n<h4><b>2. <\/b><b>Ch\u1ea1y nhi\u1ec1u l\u1ec7nh n\u1ec1n<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Ta c\u00f3 th\u1ec3 ch\u1ea1y nhi\u1ec1u l\u1ec7nh n\u1ec1n c\u00f9ng l\u00fac b\u1eb1ng c\u00e1ch th\u00eam d\u1ea5u <\/span><span style=\"font-weight: 400;\">&amp;<\/span><span style=\"font-weight: 400;\"> v\u00e0o cu\u1ed1i m\u1ed7i l\u1ec7nh.<\/span><\/p>\n<pre>sleep 60 &amp;\u00a0\r\n\r\nfind \/ -name \"*.log\" &gt; logs.txt 2&gt;\/dev\/null &amp;<\/pre>\n<p><span style=\"font-weight: 400;\">M\u1ed7i l\u1ec7nh s\u1ebd ch\u1ea1y \u0111\u1ed9c l\u1eadp trong n\u1ec1n v\u1edbi job ID kh\u00e1c nhau.<\/span><\/p>\n<h4><b>3. Qu\u1ea3n l\u00fd c\u00e1c ti\u1ebfn tr\u00ecnh n\u1ec1n v\u1edbi l\u1ec7nh <\/b><span style=\"font-weight: 400;\">jobs<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">jobs<\/span><span style=\"font-weight: 400;\"> s\u1ebd li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c ti\u1ebfn tr\u00ecnh n\u1ec1n hi\u1ec7n t\u1ea1i. Ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng l\u1ec7nh n\u00e0y \u0111\u1ec3 ki\u1ec3m tra tr\u1ea1ng th\u00e1i c\u1ee7a c\u00e1c ti\u1ebfn tr\u00ecnh n\u1ec1n m\u00e0 b\u1ea1n \u0111\u00e3 kh\u1edfi \u0111\u1ed9ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre>sleep 60 &amp;\r\njobs<\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 c\u00f3 th\u1ec3 s\u1ebd l\u00e0:<\/span><\/p>\n<pre>[1] 12345<\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3: S\u1ed1 <\/span><span style=\"font-weight: 400;\">[1]<\/span><span style=\"font-weight: 400;\"> l\u00e0 ch\u1ec9 s\u1ed1 c\u1ee7a ti\u1ebfn tr\u00ecnh v\u00e0 <\/span><span style=\"font-weight: 400;\">12345<\/span><span style=\"font-weight: 400;\"> l\u00e0 PID (Process ID).<\/span><\/p>\n<h4><b>4. Chuy\u1ec3n ti\u1ebfn tr\u00ecnh n\u1ec1n sang ch\u1ebf \u0111\u1ed9 foreground v\u1edbi l\u1ec7nh <\/b><span style=\"font-weight: 400;\">fg<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Khi m\u1ed9t l\u1ec7nh \u0111\u01b0\u1ee3c ch\u1ea1y trong n\u1ec1n, ta c\u00f3 th\u1ec3 \u0111\u01b0a ti\u1ebfn tr\u00ecnh \u0111\u00f3 v\u1ec1 l\u1ea1i foreground (ch\u1ebf \u0111\u1ed9 n\u1ec1n) \u0111\u1ec3 ti\u1ebfp t\u1ee5c t\u01b0\u01a1ng t\u00e1c v\u1edbi n\u00f3. Ta c\u00f3 th\u1ec3 d\u00f9ng l\u1ec7nh <\/span><span style=\"font-weight: 400;\">fg<\/span><span style=\"font-weight: 400;\"> theo sau l\u00e0 s\u1ed1 th\u1ee9 t\u1ef1 c\u1ee7a ti\u1ebfn tr\u00ecnh n\u1ec1n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre>fg %job_number<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: L\u1ec7nh sau s\u1ebd \u0111\u01b0a ti\u1ebfn tr\u00ecnh v\u1edbi s\u1ed1 th\u1ee9 t\u1ef1 <\/span><span style=\"font-weight: 400;\">[1]<\/span><span style=\"font-weight: 400;\"> tr\u1edf l\u1ea1i foreground.<\/span><\/p>\n<pre>fg %1<\/pre>\n<h4><b>5. T\u1ea1m d\u1eebng (Suspend) ti\u1ebfn tr\u00ecnh n\u1ec1n v\u00e0 ti\u1ebfp t\u1ee5c v\u1edbi <\/b><span style=\"font-weight: 400;\">bg<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">N\u1ebfu mu\u1ed1n t\u1ea1m d\u1eebng m\u1ed9t ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y trong foreground, c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng t\u1ed5 h\u1ee3p ph\u00edm <\/span><span style=\"font-weight: 400;\">Ctrl + Z<\/span><span style=\"font-weight: 400;\">. Sau \u0111\u00f3, ta c\u00f3 th\u1ec3 ti\u1ebfp t\u1ee5c ti\u1ebfn tr\u00ecnh \u0111\u00f3 trong n\u1ec1n b\u1eb1ng l\u1ec7nh <\/span><span style=\"font-weight: 400;\">bg<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre>bg %job_number<\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 c\u1ee5 th\u1ec3:<\/span><\/p>\n<pre>sleep 100\u00a0 # Ch\u1ea1y l\u1ec7nh \u1edf foreground\r\n# Nh\u1ea5n Ctrl+Z \u0111\u1ec3 t\u1ea1m d\u1eebng\r\nbg %1\u00a0 \u00a0 \u00a0 # Ti\u1ebfp t\u1ee5c ch\u1ea1y l\u1ec7nh n\u00e0y \u1edf background<\/pre>\n<h4><b>6. D\u00f9ng <\/b><strong>disown<\/strong><b> \u0111\u1ec3 t\u00e1ch ti\u1ebfn tr\u00ecnh kh\u1ecfi terminal<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">disown<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00f3a m\u1ed9t ti\u1ebfn tr\u00ecnh kh\u1ecfi danh s\u00e1ch ti\u1ebfn tr\u00ecnh c\u1ee7a terminal, gi\u00fap n\u00f3 ti\u1ebfp t\u1ee5c ch\u1ea1y ngay c\u1ea3 khi terminal b\u1ecb \u0111\u00f3ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre>disown %job_number<\/pre>\n<h3><b>H\u00e3y ph\u00e2n bi\u1ec7t c\u00e1c bi\u1ec3u th\u1ee9c \u0111\u1eb7c bi\u1ec7t trong Bash nh\u01b0 <\/b><span style=\"font-weight: 400;\">$$, $!, &amp;&amp;, ||, &gt;, &gt;&gt;.<\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$$<\/span><span style=\"font-weight: 400;\">: L\u00e0 bi\u1ebfn ch\u1ee9a PID (Process ID) c\u1ee7a ti\u1ebfn tr\u00ecnh hi\u1ec7n t\u1ea1i, t\u1ee9c l\u00e0 s\u1ed1 nh\u1eadn d\u1ea1ng c\u1ee7a shell ho\u1eb7c ti\u1ebfn tr\u00ecnh \u0111ang ch\u1ea1y. V\u00ed d\u1ee5, n\u1ebfu b\u1ea1n ch\u1ea1y m\u1ed9t script, th\u00ec <\/span><span style=\"font-weight: 400;\">$$<\/span><span style=\"font-weight: 400;\"> s\u1ebd tr\u1ea3 v\u1ec1 PID c\u1ee7a script \u0111\u00f3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">$!<\/span><span style=\"font-weight: 400;\">: Bi\u1ebfn n\u00e0y ch\u1ee9a PID c\u1ee7a ti\u1ebfn tr\u00ecnh n\u1ec1n cu\u1ed1i c\u00f9ng \u0111\u01b0\u1ee3c ch\u1ea1y. N\u1ebfu b\u1ea1n ch\u1ea1y m\u1ed9t l\u1ec7nh \u1edf ch\u1ebf \u0111\u1ed9 n\u1ec1n (s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">&amp;<\/span><span style=\"font-weight: 400;\">), <\/span><span style=\"font-weight: 400;\">$!<\/span><span style=\"font-weight: 400;\"> s\u1ebd l\u01b0u tr\u1eef PID c\u1ee7a ti\u1ebfn tr\u00ecnh n\u1ec1n \u0111\u00f3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">&amp;&amp;<\/span><b> (AND logic)<\/b><span style=\"font-weight: 400;\">: Th\u1ef1c thi l\u1ec7nh ph\u00eda sau ch\u1ec9 khi l\u1ec7nh ph\u00eda tr\u01b0\u1edbc th\u1ef1c thi th\u00e0nh c\u00f4ng (tr\u1ea3 v\u1ec1 m\u00e3 tho\u00e1t 0).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">||<\/span><b> (OR logic)<\/b><span style=\"font-weight: 400;\">: Th\u1ef1c thi l\u1ec7nh ph\u00eda sau ch\u1ec9 khi l\u1ec7nh ph\u00eda tr\u01b0\u1edbc th\u1ea5t b\u1ea1i (tr\u1ea3 v\u1ec1 m\u00e3 tho\u00e1t kh\u00e1c 0).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">&gt;<\/span><span style=\"font-weight: 400;\">: D\u00f9ng \u0111\u1ec3 chuy\u1ec3n h\u01b0\u1edbng \u0111\u1ea7u ra c\u1ee7a m\u1ed9t l\u1ec7nh \u0111\u1ebfn m\u1ed9t t\u1ec7p, v\u00e0 n\u1ebfu t\u1ec7p \u0111\u00f3 \u0111\u00e3 t\u1ed3n t\u1ea1i, n\u00f3 s\u1ebd b\u1ecb ghi \u0111\u00e8.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">&gt;&gt;<\/span><span style=\"font-weight: 400;\">: D\u00f9ng \u0111\u1ec3 chuy\u1ec3n h\u01b0\u1edbng \u0111\u1ea7u ra c\u1ee7a m\u1ed9t l\u1ec7nh \u0111\u1ebfn m\u1ed9t t\u1ec7p, nh\u01b0ng n\u00f3 s\u1ebd ghi th\u00eam (append) thay v\u00ec ghi \u0111\u00e8 t\u1ec7p \u0111\u00f3.<\/span><\/li>\n<\/ul>\n<h3><b>Khi so s\u00e1nh chu\u1ed7i trong Bash, s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa [[ $string == &#8220;efg*&#8221; ]] v\u00e0 [[ $string == efg* ]] l\u00e0 g\u00ec?<\/b><\/h3>\n<p><strong>[[ $string == &#8220;efg*&#8221; ]]<\/strong><span style=\"font-weight: 400;\">: D\u1ea5u <\/span><span style=\"font-weight: 400;\">*<\/span><span style=\"font-weight: 400;\"> trong d\u1ea5u ngo\u1eb7c k\u00e9p s\u1ebd ch\u1ec9 so s\u00e1nh theo \u0111\u00fang k\u00fd t\u1ef1 v\u00e0 t\u00ecm ki\u1ebfm ch\u00ednh x\u00e1c chu\u1ed7i <\/span><span style=\"font-weight: 400;\">&#8220;efg*&#8221;<\/span><span style=\"font-weight: 400;\">. Kh\u00f4ng c\u00f3 ph\u00e9p wildcards \u1edf \u0111\u00e2y.<\/span><\/p>\n<p><strong>[[ $string == efg* ]]<\/strong><span style=\"font-weight: 400;\">: D\u1ea5u <\/span><span style=\"font-weight: 400;\">*<\/span><span style=\"font-weight: 400;\"> ngo\u00e0i d\u1ea5u ngo\u1eb7c k\u00e9p l\u00e0 ph\u00e9p wildcards, c\u00f3 th\u1ec3 thay th\u1ebf b\u1ea5t k\u1ef3 chu\u1ed7i n\u00e0o, do \u0111\u00f3 n\u00f3 t\u00ecm ki\u1ebfm t\u1ea5t c\u1ea3 c\u00e1c chu\u1ed7i b\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">efg<\/span><span style=\"font-weight: 400;\">. V\u00ed d\u1ee5:<\/span><\/p>\n<pre>$ string=\"efg123\"\r\n$ [[ $string == \"efg*\" ]]\r\n# Output:\r\nFalse\u00a0 (Kh\u00f4ng kh\u1edbp v\u00ec d\u1ea5u * kh\u00f4ng ph\u1ea3i l\u00e0 wildcard)\r\n$ [[ $string == efg* ]]\r\n# Output:\r\nTrue\u00a0 (Kh\u1edbp v\u00ec d\u1ea5u * l\u00e0 wildcard)<\/pre>\n<h3><b>H\u00e3y ph\u00e2n bi\u1ec7t c\u00e1ch s\u1eed d\u1ee5ng c\u1ee7a l\u1ec7nh grep v\u00e0 find trong Bash.\u00a0<\/b><\/h3>\n<p><strong>grep<\/strong><span style=\"font-weight: 400;\">: L\u00e0 l\u1ec7nh d\u00f9ng \u0111\u1ec3 t\u00ecm ki\u1ebfm v\u0103n b\u1ea3n trong c\u00e1c t\u1ec7p, t\u00ecm c\u00e1c d\u00f2ng c\u00f3 ch\u1ee9a chu\u1ed7i t\u00ecm ki\u1ebfm v\u00e0 in ra c\u00e1c d\u00f2ng \u0111\u00f3. V\u00ed d\u1ee5:<\/span><\/p>\n<p>$ grep &#8220;Hello&#8221; file.txt<\/p>\n<p># Output: Hi\u1ec3n th\u1ecb t\u1ea5t c\u1ea3 c\u00e1c d\u00f2ng trong file.txt ch\u1ee9a t\u1eeb &#8220;Hello&#8221;<\/p>\n<pre>$ grep \"Hello\" file.txt\r\n# Output: Hi\u1ec3n th\u1ecb t\u1ea5t c\u1ea3 c\u00e1c d\u00f2ng trong file.txt ch\u1ee9a t\u1eeb \"Hello\"<\/pre>\n<p><strong>find<\/strong><span style=\"font-weight: 400;\">: L\u00e0 l\u1ec7nh d\u00f9ng \u0111\u1ec3 t\u00ecm ki\u1ebfm t\u1ec7p ho\u1eb7c th\u01b0 m\u1ee5c trong h\u1ec7 th\u1ed1ng d\u1ef1a tr\u00ean c\u00e1c ti\u00eau ch\u00ed nh\u1ea5t \u0111\u1ecbnh nh\u01b0 t\u00ean t\u1ec7p, quy\u1ec1n truy c\u1eadp, k\u00edch th\u01b0\u1edbc, th\u1eddi gian s\u1eeda \u0111\u1ed5i,&#8230; V\u00ed d\u1ee5:<\/span><\/p>\n<pre>$ find \/home\/user -name \"*.txt\"\r\n# Output: Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c t\u1ec7p c\u00f3 \u0111u\u00f4i .txt trong th\u01b0 m\u1ee5c \/home\/user<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><b>T\u1ed5ng k\u1ebft<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Bash Shell kh\u00f4ng ch\u1ec9 l\u00e0 c\u00f4ng c\u1ee5 thi\u1ebft y\u1ebfu \u0111\u1ec3 qu\u1ea3n tr\u1ecb h\u1ec7 th\u1ed1ng m\u00e0 c\u00f2n l\u00e0 m\u1ed9t ph\u1ea7n quan tr\u1ecdng trong c\u00e1c k\u1ef3 ph\u1ecfng v\u1ea5n cho c\u00e1c v\u1ecb tr\u00ed nh\u01b0 DevOps, l\u1eadp tr\u00ecnh vi\u00ean Linux v\u00e0 qu\u1ea3n tr\u1ecb vi\u00ean h\u1ec7 th\u1ed1ng. Vi\u1ec7c chu\u1ea9n b\u1ecb tr\u01b0\u1edbc v\u00e0 th\u1ef1c h\u00e0nh c\u00e1c c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n v\u1ec1 Bash Shell s\u1ebd gi\u00fap b\u1ea1n t\u1ef1 tin h\u01a1n khi \u0111\u1ed1i di\u1ec7n v\u1edbi nh\u00e0 tuy\u1ec3n d\u1ee5ng. B\u00ean c\u1ea1nh nh\u1eefng ch\u1ee7 \u0111\u1ec1 \u0111\u01b0\u1ee3c nh\u1eafc t\u1edbi trong b\u00e0i, vi\u1ec7c chu\u1ea9n b\u1ecb th\u00eam v\u1ec1 nh\u1eefng kinh nghi\u1ec7m th\u1ef1c ti\u1ec5n trong vi\u1ec7c s\u1eed d\u1ee5ng Bash Shell s\u1ebd nh\u00e0 tuy\u1ec3n d\u1ee5ng th\u1ea5y \u0111\u01b0\u1ee3c kh\u1ea3 n\u0103ng \u00e1p d\u1ee5ng ki\u1ebfn th\u1ee9c v\u00e0o c\u00e1c t\u00ecnh hu\u1ed1ng th\u1ef1c t\u1ebf, c\u0169ng nh\u01b0 s\u1ef1 ch\u1ee7 \u0111\u1ed9ng v\u00e0 tinh th\u1ea7n c\u1ea7u ti\u1ebfn c\u1ee7a b\u1ea1n trong c\u00f4ng vi\u1ec7c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ITviec hy v\u1ecdng b\u00e0i vi\u1ebft tr\u00ean \u0111\u00e3 ph\u1ea7n n\u00e0o gi\u00fap b\u1ea1n b\u1ed5 sung v\u00e0 \u00f4n l\u1ea1i c\u00e1c ki\u1ebfn th\u1ee9c v\u1ec1 Bash Shell\u00a0 v\u00e0 gi\u00fap b\u1ea1n t\u1ef1 tin h\u01a1n trong c\u00f4ng vi\u1ec7c v\u00e0 c\u00e1c cu\u1ed9c ph\u1ecfng v\u1ea5n s\u1eafp t\u1edbi.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bash Shell l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd v\u00e0 kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean ho\u1eb7c qu\u1ea3n tr\u1ecb vi\u00ean h\u1ec7 th\u1ed1ng n\u00e0o l\u00e0m vi\u1ec7c v\u1edbi Linux. Khi tham gia ph\u1ecfng v\u1ea5n, nh\u1eefng c\u00e2u h\u1ecfi v\u1ec1 Bash Shell c\u00f3 th\u1ec3 xu\u1ea5t hi\u1ec7n \u1edf nhi\u1ec1u c\u1ea5p \u0111\u1ed9 kh\u00e1c nhau, t\u1eeb nh\u1eefng c\u00e2u h\u1ecfi [&hellip;]<\/p>\n","protected":false},"author":209,"featured_media":87214,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109,105],"tags":[],"class_list":["post-87181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it","category-phong-van-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p - ITviec Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p\" \/>\n<meta property=\"og:description\" content=\"Bash Shell l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd v\u00e0 kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean ho\u1eb7c qu\u1ea3n tr\u1ecb vi\u00ean h\u1ec7 th\u1ed1ng n\u00e0o l\u00e0m vi\u1ec7c v\u1edbi Linux. Khi tham gia ph\u1ecfng\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-24T13:25:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2016\/10\/homepage3-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"940\" \/>\n\t<meta property=\"og:image:height\" content=\"492\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"M\u1ef9 Duy\u00ean\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"M\u1ef9 Duy\u00ean\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"72 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p - ITviec Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/","og_locale":"vi_VN","og_type":"article","og_title":"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p","og_description":"Bash Shell l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd v\u00e0 kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean ho\u1eb7c qu\u1ea3n tr\u1ecb vi\u00ean h\u1ec7 th\u1ed1ng n\u00e0o l\u00e0m vi\u1ec7c v\u1edbi Linux. Khi tham gia ph\u1ecfng","og_url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-05-24T13:25:58+00:00","og_image":[{"width":940,"height":492,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2016\/10\/homepage3-1.png","type":"image\/png"}],"author":"M\u1ef9 Duy\u00ean","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"M\u1ef9 Duy\u00ean","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"72 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/"},"author":{"name":"M\u1ef9 Duy\u00ean","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/73733c0725c7e39e696a896bd1abe2d7"},"headline":"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p","datePublished":"2025-05-24T13:25:58+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/"},"wordCount":13758,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/cau-hoi-phong-van-bash-shell-vippro-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT","Ph\u1ecfng v\u1ea5n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/","url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/","name":"Top 20+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell th\u01b0\u1eddng g\u1eb7p - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/cau-hoi-phong-van-bash-shell-vippro-scaled.png","datePublished":"2025-05-24T13:25:58+00:00","inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-bash-shell\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/cau-hoi-phong-van-bash-shell-vippro-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/cau-hoi-phong-van-bash-shell-vippro-scaled.png","width":640,"height":337,"caption":"c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Bash Shell - itviec blog"},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/73733c0725c7e39e696a896bd1abe2d7","name":"M\u1ef9 Duy\u00ean","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Author_Duyen-Tran-120x120.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Author_Duyen-Tran-120x120.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Author_Duyen-Tran-120x120.jpg","caption":"M\u1ef9 Duy\u00ean"},"url":"https:\/\/itviec.com\/blog\/author\/my-duyen\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/209"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=87181"}],"version-history":[{"count":0,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87181\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/87214"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=87181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=87181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=87181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}