{"id":446,"date":"2018-10-15T12:36:40","date_gmt":"2018-10-15T12:36:40","guid":{"rendered":"http:\/\/linuxresellerwebhosting.in\/blog\/?p=446"},"modified":"2018-10-15T12:39:03","modified_gmt":"2018-10-15T12:39:03","slug":"how-to-add-command-alias-name-in-linux","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-add-command-alias-name-in-linux\/","title":{"rendered":"How to add Command Alias Name In Linux"},"content":{"rendered":"<p><strong>Hi All !<\/strong><\/p>\n<p>Today we are going to see about command alias in Linux. You can create command alias for often used lengthy command to save your time.<\/p>\n<p><strong>Syntax :<\/strong><\/p>\n<p>Alias short cut name = &#8216;Customer command&#8217;.<\/p>\n<p><strong>Ex : alias ll = &#8216;ls -l&#8217;.<\/strong><\/p>\n<p>You may seen the &#8220;ll&#8221; command to list files\/directory which is alias name of &#8220;ls -l&#8221;.<\/p>\n<p><strong>Methods :<\/strong><br \/>\nThere are two methods for adding alias name that is<\/p>\n<ol>\n<li>Temporary Alias<\/li>\n<li>Permanent Alias<\/li>\n<\/ol>\n<p><strong>Temporary Alias :<\/strong><\/p>\n<p>Temporary alias names are created via alias command in user&#8217;s terminal. Like<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">root@vps ~]# alias ll='ls -l'\r\n[root@vps ~]#<\/pre>\n<p>On above alias is command, ll is alias name &amp; &#8216;ls -l&#8217; custom command.<\/p>\n<p>These command will be removed once server rebooted since those temporary alias.<\/p>\n<p><strong>Permanent Alias :<\/strong><\/p>\n<p>To keep <strong>aliases<\/strong> between sessions, you can save them in your user\u2019s shell configuration profile file. This can be:<\/p>\n<ul>\n<li>Bash \u2013 <strong>~\/.bashrc<\/strong><\/li>\n<li>ZSH \u2013 <strong>~\/.zshrc<\/strong><\/li>\n<li>Fish \u2013 <strong>~\/.config\/fish\/config.fish<\/strong><\/li>\n<\/ul>\n<p>The syntax you should use is practically the same as creating a temporary alias. The only difference comes from the fact that you will be saving it in a file this time. So for example, in bash, you can open <strong>.bashrc<\/strong> file with your favorite editor like this:<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">root@vps ~]# vi ~\/.bashrc<\/pre>\n<p>ind a place in the file, where you want to keep the aliases. For example, you can add them in the end of the file. For organizations purposes you can leave a comment before your aliases something like this:<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># User specific aliases and functions\r\n\r\nalias rm='rm -i'\r\nalias cp='cp -i'\r\nalias mv='mv -i'<\/pre>\n<p>Save the file. The file will be automatically loaded in your next session<\/p>\n<p>To remove an alias added via the command line can be unaliased using unalias command.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true\">[root@vps ~]# unalias alias_name<\/pre>\n<p>Hope this will be helpful \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi All ! Today we are going to see about command alias in Linux. You can create command alias for<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[1],"tags":[],"class_list":["post-446","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=446"}],"version-history":[{"count":5,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/446\/revisions"}],"predecessor-version":[{"id":451,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/446\/revisions\/451"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}