Announcement

Collapse
No announcement yet.

How do I create aliases?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] How do I create aliases?

    I know I can look it up, but since we are on the subject :-) how do you go about creating aliases and what is the su alias you both agree to.

    Michel

    #2
    hear is a list of useful ones http://www.kubuntuforums.net/showthr...l-bash-aliases

    when you see one you like just copy the line to a terminal and hit enter ,,,,thats it now it is an alias .

    like
    Code:
    alias su='sudo -i'
    VINNY
    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    Comment


      #3
      Or add the line to ~/.bashrc to make it be reapplied when you login

      Comment


        #4
        Originally posted by james147 View Post
        Or add the line to ~/.bashrc to make it be reapplied when you login
        O ya ,,,,,forgot that would be temporary sorry

        VINNY
        i7 4core HT 8MB L3 2.9GHz
        16GB RAM
        Nvidia GTX 860M 4GB RAM 1152 cuda cores

        Comment


          #5
          I think also you can make the file ~/.bash_aliases and have them in their , will test this now ,

          VINNY
          i7 4core HT 8MB L3 2.9GHz
          16GB RAM
          Nvidia GTX 860M 4GB RAM 1152 cuda cores

          Comment


            #6
            Take a look at your .bashrc file. You will see:
            Code:
            # Alias definitions.# You may want to put all your additions into a separate file like
            # ~/.bash_aliases, instead of adding them here directly.
            # See /usr/share/doc/bash-doc/examples in the bash-doc package.
            
            
            if [ -f ~/.bash_aliases ]; then
                . ~/.bash_aliases
            fi
            When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.

            Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:


            alias name=command

            This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
            Windows no longer obstructs my view.
            Using Kubuntu Linux since March 23, 2007.
            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

            Comment


              #7
              Originally posted by Snowhog View Post
              Take a look at your .bashrc file. You will see:
              Code:
              # Alias definitions.# You may want to put all your additions into a separate file like
              # ~/.bash_aliases, instead of adding them here directly.
              # See /usr/share/doc/bash-doc/examples in the bash-doc package.
              
              
              if [ -f ~/.bash_aliases ]; then
                  . ~/.bash_aliases
              fi
              When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.

              Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:


              alias name=command

              This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
              yes this is working out just fine ......did not even half to log out after making the .bash_aliases file with one alias per line ,just close and reopen the terminal .

              VINNY
              i7 4core HT 8MB L3 2.9GHz
              16GB RAM
              Nvidia GTX 860M 4GB RAM 1152 cuda cores

              Comment


                #8
                Originally posted by vinnywright View Post
                yes this is working out just fine ......did not even half to log out after making the .bash_aliases file with one alias per line ,just close and reopen the terminal .

                VINNY
                You don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:
                Code:
                source ~/.bash_aliases
                Windows no longer obstructs my view.
                Using Kubuntu Linux since March 23, 2007.
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #9
                  Originally posted by Snowhog View Post
                  You don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:
                  Code:
                  source ~/.bash_aliases
                  live and learn , nice

                  VINNY
                  i7 4core HT 8MB L3 2.9GHz
                  16GB RAM
                  Nvidia GTX 860M 4GB RAM 1152 cuda cores

                  Comment


                    #10
                    Originally posted by Snowhog View Post
                    You don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:
                    Code:
                    source ~/.bash_aliases
                    I make that an alias.
                    alias reload='source ~/.bashrc'

                    Comment


                      #11
                      Mine is: alias ua='source ~/.bash_aliases'

                      Most of my aliases use less keystrokes (saves time) than the actual command.
                      Windows no longer obstructs my view.
                      Using Kubuntu Linux since March 23, 2007.
                      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                      Comment


                        #12
                        Originally posted by Snowhog View Post
                        Mine is: alias ua='source ~/.bash_aliases'

                        Most of my aliases use less keystrokes (saves time) than the actual command.
                        I try to do that to, but more importantly I need something I can remember. reload is easy to remember and is still shorter that the original command. I used to try to make very short commands, but couldnt remember them and got confused alot.

                        Comment


                          #13
                          One I use a lot, and in my .bash_aliases, is:

                          alias a='clear && alias | more'

                          Windows no longer obstructs my view.
                          Using Kubuntu Linux since March 23, 2007.
                          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                          Comment


                            #14
                            Originally posted by michel View Post
                            what is the su alias you both agree to.
                            The immediately apparent difference between 'sudo -sH' and 'sudo -i' is the $PWD, the former keeps the current working directory (comparable to 'su') while the latter switches to root's home directory (comparable to 'su -', 'su -l' or 'su --login')...of course you can set an alias for both.
                            Last edited by kubicle; Nov 24, 2012, 10:16 PM.

                            Comment


                              #15
                              Originally posted by Snowhog View Post
                              Take a look at your .bashrc file. You will see:
                              Code:
                              # Alias definitions.# You may want to put all your additions into a separate file like
                              # ~/.bash_aliases, instead of adding them here directly.
                              # See /usr/share/doc/bash-doc/examples in the bash-doc package.
                              
                              
                              if [ -f ~/.bash_aliases ]; then
                                  . ~/.bash_aliases
                              fi
                              When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.

                              Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:


                              alias name=command

                              This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
                              Thanks for the clarifications I get most of it except the saving as .bash_aliases if you could give a concrete example I would appreciate it.

                              Thanks to all the other feedback and clarifications.

                              Michel

                              Comment

                              Working...
                              X