{"id":514,"date":"2020-04-30T00:48:00","date_gmt":"2020-04-30T04:48:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=514"},"modified":"2024-02-02T15:32:09","modified_gmt":"2024-02-02T20:32:09","slug":"linux-alias-command","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/linux-alias-command\/","title":{"rendered":"Linux alias command"},"content":{"rendered":"\n<p>The alias command assigns a command or set of commands to a string. Aliases are generally used to simply typing a long command or to execute an option to a command by default.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ alias aelog='tail -f \/var\/log\/apache2\/error.log'\n$ alias rm='rm -i'<\/code><\/pre>\n\n\n\n<p>Now, when we type the command aelog on commandline, it would run tail -f \/var\/log\/apache2\/error.log. This is a time saving technique. rm deletes without asking for confirmation. Since we generally like to confirm before deleting anything, creating the alias on second line would now cause the -i option to run by default. The -i option requires the user to confirm the deletion of every single file and directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">List aliases<\/h3>\n\n\n\n<p>To see a list of aliases in your system, type the alias command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ alias<\/code><\/pre>\n\n\n\n<p><strong>output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alias aelog='tail -f \/var\/log\/apache2\/error.log'\nalias egrep='egrep --color=auto'\nalias fgrep='fgrep --color=auto'\nalias grep='grep --color=auto'\nalias l='ls -CF'\nalias la='ls -A'\nalias ll='ls -alF'\nalias ls='ls --color=auto'\nalias rm='rm -i'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Making your aliases permanent<\/h3>\n\n\n\n<p>When you restart your computer, your aliases are lost. To solution to avoid this annoyance is to write your aliases in ~\/.bashrc or the rc file of your shell if you are using another shell. Restart you command terminal and your aliases would work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Removing aliases<\/h3>\n\n\n\n<p>To remove an alias, use the unalias command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ unalias aelog<\/code><\/pre>\n\n\n\n<p>If your aliases are written in your ~\/.bashrc, an alias removed by unalias would reappear after reboot. To remove it permanently, delete the alias form ~\/.bashrc file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The alias command assigns a command or set of commands to a string. Aliases are generally used to simply typing a long command or to execute an option to a command by default. Now, when we type the command aelog on commandline, it would run tail -f \/var\/log\/apache2\/error.log. This is a time saving technique. rm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[35],"class_list":["post-514","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=514"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/514\/revisions"}],"predecessor-version":[{"id":515,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/514\/revisions\/515"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}