{"id":1500,"date":"2014-04-23T23:29:07","date_gmt":"2014-04-23T16:29:07","guid":{"rendered":"http:\/\/www.itersdesktop.com\/?p=1500"},"modified":"2014-04-24T02:16:59","modified_gmt":"2014-04-23T19:16:59","slug":"tao-cac-lenh-tat-trong-linux","status":"publish","type":"post","link":"https:\/\/www.itersdesktop.com\/vi\/2014\/04\/23\/tao-cac-lenh-tat-trong-linux\/","title":{"rendered":"T\u1ea1o c\u00e1c l\u1ec7nh t\u1eaft trong linux"},"content":{"rendered":"<p><\/p>\n<p>Th\u1ef1c ra kh\u00e1i ni\u1ec7m ch\u00ednh x\u00e1c: t\u1ea1o b\u00ed danh cho c\u00e1c l\u1ec7nh. Tuy nhi\u00ean, kh\u00e1i ni\u1ec7m b\u00ed danh alias kh\u00f3 hi\u1ec3u n\u00ean t\u00f4i mu\u1ed1n gi\u1ea3i th\u00edch r\u00f5 h\u01a1n tr\u01b0\u1edbc khi \u0111i v\u00e0o t\u00ecm hi\u1ec3u chi ti\u1ebft c\u00e1ch t\u1ea1o nh\u1eefng l\u1ec7nh t\u1eaft (variant).<\/p>\n<p>L\u1ea5y m\u1ed9t v\u00ed d\u1ee5 minh h\u1ecda nh\u01b0 sau:<\/p>\n<p>L\u1ec7nh ls s\u1eed d\u1ee5ng th\u01b0\u1eddng xuy\u00ean. N\u1ebfu ls kh\u00f4ng c\u00f3 tham s\u1ed1 s\u1ebd hi\u1ec7n th\u1ecb n\u1ed9i dung trong th\u01b0 m\u1ee5c hi\u1ec7n t\u1ea1i theo d\u1ea1ng ngang, ch\u1ec9 t\u00ean t\u1eadp tin v\u00e0 th\u01b0 m\u1ee5c. Tuy nhi\u00ean, n\u1ebfu c\u1ea7n hi\u1ec3n th\u1ecb th\u00f4ng tin chi ti\u1ebft v\u1ec1 ng\u00e0y gi\u1edd t\u1ea1o t\u1eadp tin (ho\u1eb7c th\u01b0 m\u1ee5c), quy\u1ec1n h\u1ea1n, ng\u01b0\u1eddi s\u1edf h\u1eefu n\u1ed9i dung \u0111\u00f3 v.v&#8230; th\u00ec b\u1ea1n ph\u1ea3i th\u00eam c\u00e1c tham s\u1ed1, v\u00ed ls -Bhl. T\u00f4i \u0111\u1eb7t t\u00ecnh hu\u1ed1ng: th\u01b0\u1eddng s\u1eed d\u1ee5ng ls -Bhl n\u00ean mu\u1ed1n g\u00f5 nhanh thay v\u00ec ph\u1ea3i g\u00f5 \u0111\u1ea7y \u0111\u1ee7 nh\u01b0 th\u1ebf th\u00ec ll (2 ch\u1eef l) ho\u1eb7c l (1 ch\u1eef l) thay ch\u1eb3ng h\u1ea1n.<\/p>\n<p>\u0110\u1ec3 l\u00e0m nh\u01b0 th\u1ebf ta c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n b\u1eb1ng l\u1ec7nh alias:<\/p>\n<pre>alias ll=\"ls -Bhl\"<\/pre>\n<p>T\u1ea1i Terminal, b\u1ea1n ch\u1ec9 vi\u1ec7c g\u00f5 ll l\u00e0 th\u1ef1c hi\u1ec7n \u0111\u01b0\u1ee3c ls -Bhl. Th\u1ef1c ch\u1ea5t khi g\u00f5 l\u1ec7nh ll, m\u00e1y t\u00ednh s\u1ebd g\u1ecdi l\u1ec7nh ls -Bhl. V\u00ec v\u1eady m\u00e0 ll \u0111\u01b0\u1ee3c xem nh\u01b0 l\u00e0 m\u1ed9t b\u00ed danh c\u1ee7a ls -Bhl.<\/p>\n<p><figure id=\"attachment_1443\" aria-describedby=\"caption-attachment-1443\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-1443\" alt=\"alias demo\" src=\"http:\/\/itersdesktop.com\/wp-content\/uploads\/2014\/04\/alias-demo-620x330.png\" width=\"620\" height=\"330\" \/><figcaption id=\"caption-attachment-1443\" class=\"wp-caption-text\">Minh h\u1ecda d\u00f9ng l\u1ec7nh alias \u0111\u1ec3 t\u1ea1o c\u00e1c l\u1ec7nh t\u1eaft nhanh<\/figcaption><\/figure><br \/>\nL\u1ec7nh <code>alias<\/code> c\u00f3 t\u00e1c d\u1ee5ng trong phi\u00ean b\u1ea3n l\u00e0m vi\u1ec7c c\u1ee7a Terminal ngay sau \u0111\u00f3. Trong tr\u01b0\u1eddng h\u1ee3p m\u1edf m\u1ed9t Tab m\u1edbi ho\u1eb7c New Terminal th\u00ec b\u00ed danh \u0111\u00f3 kh\u00f4ng c\u00f3 hi\u1ec7u l\u1ef1c (kh\u00f4ng s\u1eed d\u1ee5ng \u0111\u01b0\u1ee3c). V\u00ec v\u1eady, th\u00f4ng th\u01b0\u1eddng ng\u01b0\u1eddi ta s\u1ebd \u0111\u1eb7t c\u00e1c b\u00ed danh trong c\u00e1c file ~\/.bashrc ho\u1eb7c ~\/.bash_profiles. Sau \u0111\u00e2y l\u00e0 m\u1ed9t v\u00ed d\u1ee5 minh h\u1ecda:<\/p>\n<pre>\r\n# http:\/\/www.tldp.org\/LDP\/abs\/html\/sample-bashrc.html\r\n#============================================================\r\n#\r\n#  ALIASES AND FUNCTIONS\r\n#\r\n#  Arguably, some functions defined here are quite big.\r\n#  If you want to make this file smaller, these functions can\r\n#+ be converted into scripts and removed from here.\r\n#\r\n#============================================================\r\n\r\n#-------------------\r\n# Personnal Aliases\r\n#-------------------\r\n\r\nalias rm='rm -i'\r\nalias cp='cp -i'\r\nalias mv='mv -i'\r\n# -> Prevents accidentally clobbering files.\r\nalias mkdir='mkdir -p'\r\n\r\nalias h='history'\r\nalias j='jobs -l'\r\nalias which='type -a'\r\nalias ..='cd ..'\r\n\r\n# Pretty-print of some PATH variables:\r\nalias path='echo -e ${PATH\/\/:\/\\\\n}'\r\nalias libpath='echo -e ${LD_LIBRARY_PATH\/\/:\/\\\\n}'\r\n\r\nalias du='du -kh'    # Makes a more readable output.\r\nalias df='df -kTh'\r\n\r\n#-------------------------------------------------------------\r\n# The 'ls' family (this assumes you use a recent GNU ls).\r\n#-------------------------------------------------------------\r\n# Add colors for filetype and  human-readable sizes by default on 'ls':\r\nalias ls='ls -h --color'\r\nalias lx='ls -lXB'         #  Sort by extension.\r\nalias lk='ls -lSr'         #  Sort by size, biggest last.\r\nalias lt='ls -ltr'         #  Sort by date, most recent last.\r\nalias lc='ls -ltcr'        #  Sort by\/show change time,most recent last.\r\nalias lu='ls -ltur'        #  Sort by\/show access time,most recent last.\r\n\r\n# The ubiquitous 'll': directories first, with alphanumeric sorting:\r\nalias ll=\"ls -lv --group-directories-first\"\r\nalias lm='ll |more'        #  Pipe through 'more'\r\nalias lr='ll -R'           #  Recursive ls.\r\nalias la='ll -A'           #  Show hidden files.\r\nalias tree='tree -Csuh'    #  Nice alternative to 'recursive ls' ...\r\n\r\n#-------------------------------------------------------------\r\n# Tailoring 'less'\r\n#-------------------------------------------------------------\r\n\r\nalias more='less'\r\nexport PAGER=less\r\nexport LESSCHARSET='latin1'\r\nexport LESSOPEN='|\/usr\/bin\/lesspipe.sh %s 2>&-'\r\n                # Use this if lesspipe.sh exists.\r\nexport LESS='-i -N -w  -z-4 -g -e -M -X -F -R -P%t?f%f \\\r\n:stdin .?pb%pb\\%:?lbLine %lb:?bbByte %bb:-...'\r\n\r\n# LESS man page colors (makes Man pages more readable).\r\nexport LESS_TERMCAP_mb=$'\\E[01;31m'\r\nexport LESS_TERMCAP_md=$'\\E[01;31m'\r\nexport LESS_TERMCAP_me=$'\\E[0m'\r\nexport LESS_TERMCAP_se=$'\\E[0m'\r\nexport LESS_TERMCAP_so=$'\\E[01;44;33m'\r\nexport LESS_TERMCAP_ue=$'\\E[0m'\r\nexport LESS_TERMCAP_us=$'\\E[01;32m'\r\n\r\n#-------------------------------------------------------------\r\n# Spelling typos - highly personnal and keyboard-dependent :-)\r\n#-------------------------------------------------------------\r\n\r\nalias xs='cd'\r\nalias vf='cd'\r\nalias moer='more'\r\nalias moew='more'\r\nalias kk='ll'\r\n<\/pre>\n<h3><span style=\"color:#000066\">T\u00e0i li\u1ec7u tham kh\u1ea3o<\/span><\/h3>\n<p>[1] <a href=\"http:\/\/community.linuxmint.com\/tutorial\/view\/891\">Use alias to create shortcuts for commands<\/a>, truy c\u1eadp ng\u00e0y 23-04-2014.<br \/>\n[2] <a href=\"http:\/\/www.tldp.org\/LDP\/abs\/html\/sample-bashrc.html\">Sample bashrc<\/a>, truy c\u1eadp ng\u00e0y 23-04-2014.<\/p>","protected":false},"excerpt":{"rendered":"<p>Th\u1ef1c ra kh\u00e1i ni\u1ec7m ch\u00ednh x\u00e1c: t\u1ea1o b\u00ed danh cho c\u00e1c l\u1ec7nh. Tuy nhi\u00ean, kh\u00e1i ni\u1ec7m b\u00ed danh alias kh\u00f3 hi\u1ec3u n\u00ean t\u00f4i mu\u1ed1n gi\u1ea3i th\u00edch r\u00f5 h\u01a1n tr\u01b0\u1edbc khi&hellip; <\/p>\n","protected":false},"author":2,"featured_media":1534,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[174,189,223,176],"tags":[455,451,453,454,452],"class_list":["post-1500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-terminal","category-tips-tricks","category-ubuntu","tag-bashrc-file","tag-alias-for-commands","tag-create-alias-for-commands","tag-create-shortcuts-for-commands","tag-shortcuts-for-commands"],"_links":{"self":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/1500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/comments?post=1500"}],"version-history":[{"count":16,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/1500\/revisions"}],"predecessor-version":[{"id":1536,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/posts\/1500\/revisions\/1536"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/media\/1534"}],"wp:attachment":[{"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/media?parent=1500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/categories?post=1500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/vi\/wp-json\/wp\/v2\/tags?post=1500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}