A few favorite alias commands

Forum Forums General Tips and Tricks A few favorite alias commands

  • This topic has 15 replies, 6 voices, and was last updated Dec 2-4:56 am by Brian Masinick.
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #94540
    Moderator
    Brian Masinick

      @PPC wrote an excellent tutorial about using the terminal.

      I like to use the terminal too, but I’m not a great typist. Fortunately, most decent shell interfaces (Bash is one example), include a command called alias, which allows you to use shorter commands (as short as one, two, or three characters, more if you wish) to get fast access to your favorite commands.

      Here are a few of my favorite alias commands, which I put into my “hidden file”, .bashrc:

      #
      # File: .bashrc
      #
      # Author:
      #  Brian W. Masinick
      # Purpose:
      #  Defines variables, aliases, and functions for shortening typing
      #  and tasks.  Used with the Bourne Again Shell, bash, from the GNU
      #  project of the Free Software Foundation.
      
       alias c="clear;pwd"
       alias cls=clear
       alias lo='clear;  kill -1 0'
       alias inst='sudo apt-get update; sudo apt-get install $@'
       alias ugb='sudo apt-get update; sudo apt-get dist-upgrade; sudo update-grub'
       alias ug='sudo apt-get update; sudo apt-get dist-upgrade'
       alias ur='sudo apt-get autoremove'
       alias rb='sudo reboot'
       alias pow='sudo poweroff'

      --
      Brian Masinick

      #94544
      Member
      banned
        Helpful
        Up
        0
        ::

        Ah – Shortcuts to shortcuts 🙂

        #94545
        Member
        andyprough
          Helpful
          Up
          0
          ::

          Take down the network cards:
          alias macdw=’sudo ip link set dev wlan0 down’
          alias macde=’sudo ip link set dev eth0 down’

          Change the MAC address to a random one with the ‘macchanger’ program:
          alias maccw=’sudo macchanger -e wlan0′
          alias macce=’sudo macchanger -e eth0′

          Bring the network cards back up:
          alias macuw=’sudo ip link set dev wlan0 up’
          alias macue=’sudo ip link set dev eth0 up’

          Combine them all into one mega-alias (card down, mac change, card back up):
          alias macchw=’macdw && maccw && sleep 4 && macuw’
          alias macche=’macde && macce && sleep 4 && macue’

          #94549
          Member
          calciumsodium
            Helpful
            Up
            0
            ::
            alias y=ytfzf
            alias p=pavucontrol
            alias g=google-chrome-stable
            alias un=unplugdrive.sh
            alias li=links2
            alias ly=lynx
            alias lw=librewolf
            alias up="sudo apt update && sudo apt install google-chrome-stable librewolf"
            alias liq="sudo apt update && sudo apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64"
            
            #94596
            Moderator
            Brian Masinick
              Helpful
              Up
              0
              ::

              Good ones!

              I’m happy to see others making good use of alias commands and also sharing with the community.

              --
              Brian Masinick

              #94598
              Member
              sybok
                Helpful
                Up
                0
                ::

                Update system, SSH login with forwarding (compressed) graphics, change to a set folder

                alias deb_update='echo "sudo apt update/dist-upgrade/autoclean"; sudo apt update && sudo apt dist-upgrade && sudo apt autoclean'
                alias sybokser='ssh -XC sybok@<server>'
                alias miscdir='cd /data/Audio/Misc/'

                And a final one that sometimes pops out to remind me of my mischievous sense of humour.
                alias exot='echo "Did you mean *exit*? Be more careful when you type!"'

                #94606
                Moderator
                Brian Masinick
                  Helpful
                  Up
                  0
                  ::

                  This is what I appreciate about sharing our alias definitions – each of us have certain things we choose to do and we abbreviate and speed access using aliases that are personally meaningful.

                  --
                  Brian Masinick

                  #94624
                  Member
                  blur13
                    Helpful
                    Up
                    0
                    ::

                    I’d love to share my fav aliases but Wordfence wont let me.

                    EDIT: attached as text file, maybe a moderator can insert the text into my post.

                    Alias text:

                    alias db=”dropbox start -i”
                    alias ds=”dropbox status”
                    alias dst=”dropbox stop”
                    alias chrome=”google-chrome-stable”
                    alias update=”sudo apt update && sudo apt dist-upgrade -V”
                    alias cc=”antiX-cli-cc”
                    alias aptix=”sudo /usr/local/bin/cli-aptiX –pause”
                    alias gcal=”gcalcli calw –military –monday”
                    alias mem=”sudo /usr/local/bin/ps_mem”
                    alias duu=”du -sh * | sort -h”
                    alias q=”exit”
                    alias vol=”amixer get Master -M | grep -oE -m1 “[[:digit:]]*%””
                    alias n=”nnn -eAr”
                    alias win=”sudo grub-reboot 3″
                    alias yr=”wget https://www.yr.no/en/content/2-2673730/meteogram.svg && inkview meteogram.svg && rm meteogram.svg”
                    alias m=”micro”
                    alias alpine=”alpine -if INBOX”
                    alias primary2clip=”xsel -p | xsel -i -b”
                    alias clip2primary=”xsel -b | xsel -i -p”
                    alias unplugdrive=”sudo unplugdrive.sh”

                    alias linksd=”cp ~/.links2/dark ~/.links2/html.cfg && cp ~/.links2/dark2 ~/.links2/links.cfg”
                    alias linksl=”cp ~/.links2/light ~/.links2/html.cfg && cp ~/.links2/light2 ~/.links2/links.cfg”

                    • This reply was modified 5 months, 1 week ago by blur13.
                    Attachments:
                    #94628
                    Moderator
                    Brian Masinick
                      Helpful
                      Up
                      0
                      ::

                      @blur13: I was able to successfully add your alias text file contents; impressive alias list!
                      You have nearly as many alias commands as I do; (I only shared a few of my favorites).
                      I continue to be impressed with the way each of us has our own unique collection of handy aliases,
                      and it’s very interesting to see the diverse collection of alias tools and our equally diverse
                      ways to use our fine distribution.

                      I hope we see even more of these; I’m really enjoying the contributions; thank you all!

                      --
                      Brian Masinick

                      #94629
                      Moderator
                      Brian Masinick
                        Helpful
                        Up
                        0
                        ::

                        Here are a few more alias commands that I didn’t share earlier:

                        alias m=’more’
                        alias pd=’pwd’
                        alias pdw=’pwd’
                        alias pow=’sudo poweroff’
                        alias rb=’sudo reboot’
                        alias re=’fc -e -‘
                        alias rw=’rwho | sort +1′
                        alias sd=’cd’
                        alias type=’cat’
                        alias ya=’sudo ping -c2 yahoo.com’
                        alias zaphist=’rm -f /home/masinick/.bwm_history’

                        • This reply was modified 5 months, 1 week ago by Brian Masinick.

                        --
                        Brian Masinick

                        #94631
                        Moderator
                        Brian Masinick
                          Helpful
                          Up
                          0
                          ::

                          As I look through several of my old, unused alias commands, many of them are no longer in active use.
                          I’ve been able to use around 2/3 of these alias commands on MANY systems, but the truth is that the overall list was originally created when I was using the Korn Shell on my work UNIX workstation. Later, I added a couple aliases when I started using the Bash Shell to allow me to go between the Korn and Bash shells; about 90% of them worked on either environment and around 10% were shell-specific, but as I can readily see here, some of them no longer apply to some of the Linux distributions I use today. I just removed a few on this instance of antiX; in time I’ll may do a general cleanup across all of my systems s and distributions, but that’s not a must do; extra aliases take up a little space, but if I happen to execute an alias that doesn’t work, the only consequence is occasionally running into a “command not found” or a sequence that simply doesn’t work.

                          That’s the beauty of alias commands nevertheless; it’s been 25 years of pushing these around to various systems and the most commonly used aliases work fine; the ones that don’t work haven’t caused a moment of issue because I’ve not even typed in or executed a handful of them.

                          --
                          Brian Masinick

                          #94632
                          Member
                          andyprough
                            Helpful
                            Up
                            0
                            ::

                            alias type=’cat’

                            Why do you use ‘type’ for ‘cat’? Is that some old unix thing Brian?

                            #94634
                            Moderator
                            Brian Masinick
                              Helpful
                              Up
                              0
                              ::

                              Excellent catch! I was wondering if anyone would have any questions about some of the alias definitions.

                              At one time, I had multiple workstations running multiple operating systems. At one point, I had VAX/VMS and/or OpenVMS, Windows NT, and multiple variations of Digital’s ULTRIX or Digital UNIX. Because of that, I’d often create either shortcuts or alias names that would perform similar functions, regardless of which platform I happened to be using. Also because we had really good networking, I could run systems across the complex, or even multiple units in my cubicle from either the same or different workstation keyboards, so I had a tendency to write things duplicated. VMS happened to have a type command – interestingly I think I had a VMS command definition for “cat” to equate to their type command too. Overall I probably standardized more on UNIX names because though I used both a lot, I actually had UNIX experience 3 years longer than my initial VMS experience.

                              --
                              Brian Masinick

                              #94647
                              Member
                              andyprough
                                Helpful
                                Up
                                0
                                ::

                                I was wondering if anyone would have any questions about some of the alias definitions.

                                The rest made sense. It took me a minute to see that “zaphist” meant “zap history”. Fun fact – if you duckduckgo “zaphist”, the results are a few posts about a clothing line along with your own post on this forum from February 2021, Brian.

                                We both have ping aliases. Mine is
                                [code]alias png=”ping gnu.org”[/code]
                                How does yahoo work for you? Is it reliable? I used to ping twitter.com because it was so fast, but then I saw someone argue in favor of gnu.org for better stability and I’ve stuck with it.

                                #94649
                                Moderator
                                Brian Masinick
                                  Helpful
                                  Up
                                  0
                                  ::

                                  I use Yahoo Mail, one of the reasons I have yahoo in a networking test.
                                  I also have a Google check that I added years later.

                                  --
                                  Brian Masinick

                                Viewing 15 posts - 1 through 15 (of 16 total)
                                • You must be logged in to reply to this topic.