How to add an alias to a command in terminal?












31















By typing a manually specified command in terminal I want to execute some other command.



How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of file?










share|improve this question




















  • 2





    See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

    – Takkat
    Jun 22 '12 at 17:40
















31















By typing a manually specified command in terminal I want to execute some other command.



How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of file?










share|improve this question




















  • 2





    See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

    – Takkat
    Jun 22 '12 at 17:40














31












31








31


7






By typing a manually specified command in terminal I want to execute some other command.



How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of file?










share|improve this question
















By typing a manually specified command in terminal I want to execute some other command.



How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of file?







command-line bashrc alias






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 25 '17 at 4:34









Zanna

50.9k13136241




50.9k13136241










asked Jun 22 '12 at 14:49









Rootical V.Rootical V.

4352712




4352712








  • 2





    See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

    – Takkat
    Jun 22 '12 at 17:40














  • 2





    See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

    – Takkat
    Jun 22 '12 at 17:40








2




2





See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

– Takkat
Jun 22 '12 at 17:40





See also here: askubuntu.com/questions/1414/how-to-create-a-permanent-alias

– Takkat
Jun 22 '12 at 17:40










7 Answers
7






active

oldest

votes


















38














alias new_name='old command'


To create a permanent alias you have to edit the .bashrc file in your home directory.



More info here



More .bashrc files here






share|improve this answer





















  • 1





    There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

    – dobey
    Jun 22 '12 at 15:40











  • Changed it. ty.

    – OrangeTux
    Jun 23 '12 at 7:04



















12














On the bash command line it is simply a case of typing:



alias my_command="Command to run"


For example to create a short command run a long listing you could do:



alias ll="ls -l"


The quotes are not required if you are not adding switches to the aliased command.






share|improve this answer

































    7














    To make permanent changes you can put your aliases separetely in ~/.bash_aliases






    share|improve this answer





















    • 1





      Don't forget to run source ~/.bash_aliases for the change to take effect.

      – Stoyan Dimov
      Nov 30 '18 at 10:40



















    2














    You can either use the alias built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash and skip down to the ALIASES section, for documentation on aliases in bash.






    share|improve this answer































      1














      To learn about aliasing: visit http://www.mediacollege.com/linux/command/alias.html



      To make the changes permanent (i.e. to be read everytime you start a shell) add the alias commands you typed in the terminal to the file ~/.bashrc file.






      share|improve this answer































        1














        I write a GUI for adding/editing alias commands. You can also use it from commandline like this:



        addalias -add "sinstall" "sudo apt-get install"


        https://github.com/isamert/addalias






        share|improve this answer































          0














          You can directly create a file in your home for collecting all the aliases .bash_profile by writing nano ~.bash_profile and simply write on the file the commands/shortcuts you want to create, for example:



          alias edbp='nano ~/.bash_profile'


          and then validate it sourcing the file, so running



          source ~.bash_profile


          Remember that every time you modify your document you have to run again source ~.bash_profile






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f154640%2fhow-to-add-an-alias-to-a-command-in-terminal%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            38














            alias new_name='old command'


            To create a permanent alias you have to edit the .bashrc file in your home directory.



            More info here



            More .bashrc files here






            share|improve this answer





















            • 1





              There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

              – dobey
              Jun 22 '12 at 15:40











            • Changed it. ty.

              – OrangeTux
              Jun 23 '12 at 7:04
















            38














            alias new_name='old command'


            To create a permanent alias you have to edit the .bashrc file in your home directory.



            More info here



            More .bashrc files here






            share|improve this answer





















            • 1





              There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

              – dobey
              Jun 22 '12 at 15:40











            • Changed it. ty.

              – OrangeTux
              Jun 23 '12 at 7:04














            38












            38








            38







            alias new_name='old command'


            To create a permanent alias you have to edit the .bashrc file in your home directory.



            More info here



            More .bashrc files here






            share|improve this answer















            alias new_name='old command'


            To create a permanent alias you have to edit the .bashrc file in your home directory.



            More info here



            More .bashrc files here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 25 '17 at 4:35









            Zanna

            50.9k13136241




            50.9k13136241










            answered Jun 22 '12 at 14:59









            OrangeTuxOrangeTux

            3,59782452




            3,59782452








            • 1





              There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

              – dobey
              Jun 22 '12 at 15:40











            • Changed it. ty.

              – OrangeTux
              Jun 23 '12 at 7:04














            • 1





              There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

              – dobey
              Jun 22 '12 at 15:40











            • Changed it. ty.

              – OrangeTux
              Jun 23 '12 at 7:04








            1




            1





            There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

            – dobey
            Jun 22 '12 at 15:40





            There is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.

            – dobey
            Jun 22 '12 at 15:40













            Changed it. ty.

            – OrangeTux
            Jun 23 '12 at 7:04





            Changed it. ty.

            – OrangeTux
            Jun 23 '12 at 7:04













            12














            On the bash command line it is simply a case of typing:



            alias my_command="Command to run"


            For example to create a short command run a long listing you could do:



            alias ll="ls -l"


            The quotes are not required if you are not adding switches to the aliased command.






            share|improve this answer






























              12














              On the bash command line it is simply a case of typing:



              alias my_command="Command to run"


              For example to create a short command run a long listing you could do:



              alias ll="ls -l"


              The quotes are not required if you are not adding switches to the aliased command.






              share|improve this answer




























                12












                12








                12







                On the bash command line it is simply a case of typing:



                alias my_command="Command to run"


                For example to create a short command run a long listing you could do:



                alias ll="ls -l"


                The quotes are not required if you are not adding switches to the aliased command.






                share|improve this answer















                On the bash command line it is simply a case of typing:



                alias my_command="Command to run"


                For example to create a short command run a long listing you could do:



                alias ll="ls -l"


                The quotes are not required if you are not adding switches to the aliased command.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 15 '13 at 18:44









                Radu Rădeanu

                118k35250325




                118k35250325










                answered Jun 22 '12 at 15:00









                AdamAdam

                27616




                27616























                    7














                    To make permanent changes you can put your aliases separetely in ~/.bash_aliases






                    share|improve this answer





















                    • 1





                      Don't forget to run source ~/.bash_aliases for the change to take effect.

                      – Stoyan Dimov
                      Nov 30 '18 at 10:40
















                    7














                    To make permanent changes you can put your aliases separetely in ~/.bash_aliases






                    share|improve this answer





















                    • 1





                      Don't forget to run source ~/.bash_aliases for the change to take effect.

                      – Stoyan Dimov
                      Nov 30 '18 at 10:40














                    7












                    7








                    7







                    To make permanent changes you can put your aliases separetely in ~/.bash_aliases






                    share|improve this answer















                    To make permanent changes you can put your aliases separetely in ~/.bash_aliases







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 25 '17 at 4:36









                    Zanna

                    50.9k13136241




                    50.9k13136241










                    answered Mar 25 '13 at 8:35









                    Yann SagonYann Sagon

                    211135




                    211135








                    • 1





                      Don't forget to run source ~/.bash_aliases for the change to take effect.

                      – Stoyan Dimov
                      Nov 30 '18 at 10:40














                    • 1





                      Don't forget to run source ~/.bash_aliases for the change to take effect.

                      – Stoyan Dimov
                      Nov 30 '18 at 10:40








                    1




                    1





                    Don't forget to run source ~/.bash_aliases for the change to take effect.

                    – Stoyan Dimov
                    Nov 30 '18 at 10:40





                    Don't forget to run source ~/.bash_aliases for the change to take effect.

                    – Stoyan Dimov
                    Nov 30 '18 at 10:40











                    2














                    You can either use the alias built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash and skip down to the ALIASES section, for documentation on aliases in bash.






                    share|improve this answer




























                      2














                      You can either use the alias built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash and skip down to the ALIASES section, for documentation on aliases in bash.






                      share|improve this answer


























                        2












                        2








                        2







                        You can either use the alias built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash and skip down to the ALIASES section, for documentation on aliases in bash.






                        share|improve this answer













                        You can either use the alias built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash and skip down to the ALIASES section, for documentation on aliases in bash.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 22 '12 at 14:58









                        dobeydobey

                        32.8k33686




                        32.8k33686























                            1














                            To learn about aliasing: visit http://www.mediacollege.com/linux/command/alias.html



                            To make the changes permanent (i.e. to be read everytime you start a shell) add the alias commands you typed in the terminal to the file ~/.bashrc file.






                            share|improve this answer




























                              1














                              To learn about aliasing: visit http://www.mediacollege.com/linux/command/alias.html



                              To make the changes permanent (i.e. to be read everytime you start a shell) add the alias commands you typed in the terminal to the file ~/.bashrc file.






                              share|improve this answer


























                                1












                                1








                                1







                                To learn about aliasing: visit http://www.mediacollege.com/linux/command/alias.html



                                To make the changes permanent (i.e. to be read everytime you start a shell) add the alias commands you typed in the terminal to the file ~/.bashrc file.






                                share|improve this answer













                                To learn about aliasing: visit http://www.mediacollege.com/linux/command/alias.html



                                To make the changes permanent (i.e. to be read everytime you start a shell) add the alias commands you typed in the terminal to the file ~/.bashrc file.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jun 22 '12 at 14:58









                                drake01drake01

                                2,68511213




                                2,68511213























                                    1














                                    I write a GUI for adding/editing alias commands. You can also use it from commandline like this:



                                    addalias -add "sinstall" "sudo apt-get install"


                                    https://github.com/isamert/addalias






                                    share|improve this answer




























                                      1














                                      I write a GUI for adding/editing alias commands. You can also use it from commandline like this:



                                      addalias -add "sinstall" "sudo apt-get install"


                                      https://github.com/isamert/addalias






                                      share|improve this answer


























                                        1












                                        1








                                        1







                                        I write a GUI for adding/editing alias commands. You can also use it from commandline like this:



                                        addalias -add "sinstall" "sudo apt-get install"


                                        https://github.com/isamert/addalias






                                        share|improve this answer













                                        I write a GUI for adding/editing alias commands. You can also use it from commandline like this:



                                        addalias -add "sinstall" "sudo apt-get install"


                                        https://github.com/isamert/addalias







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Aug 14 '14 at 12:51









                                        isamertisamert

                                        465




                                        465























                                            0














                                            You can directly create a file in your home for collecting all the aliases .bash_profile by writing nano ~.bash_profile and simply write on the file the commands/shortcuts you want to create, for example:



                                            alias edbp='nano ~/.bash_profile'


                                            and then validate it sourcing the file, so running



                                            source ~.bash_profile


                                            Remember that every time you modify your document you have to run again source ~.bash_profile






                                            share|improve this answer




























                                              0














                                              You can directly create a file in your home for collecting all the aliases .bash_profile by writing nano ~.bash_profile and simply write on the file the commands/shortcuts you want to create, for example:



                                              alias edbp='nano ~/.bash_profile'


                                              and then validate it sourcing the file, so running



                                              source ~.bash_profile


                                              Remember that every time you modify your document you have to run again source ~.bash_profile






                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                You can directly create a file in your home for collecting all the aliases .bash_profile by writing nano ~.bash_profile and simply write on the file the commands/shortcuts you want to create, for example:



                                                alias edbp='nano ~/.bash_profile'


                                                and then validate it sourcing the file, so running



                                                source ~.bash_profile


                                                Remember that every time you modify your document you have to run again source ~.bash_profile






                                                share|improve this answer













                                                You can directly create a file in your home for collecting all the aliases .bash_profile by writing nano ~.bash_profile and simply write on the file the commands/shortcuts you want to create, for example:



                                                alias edbp='nano ~/.bash_profile'


                                                and then validate it sourcing the file, so running



                                                source ~.bash_profile


                                                Remember that every time you modify your document you have to run again source ~.bash_profile







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jan 24 at 15:02









                                                Erik PillonErik Pillon

                                                1012




                                                1012






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f154640%2fhow-to-add-an-alias-to-a-command-in-terminal%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Human spaceflight

                                                    Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

                                                    張江高科駅