Linux Crash Course - Bash Aliases

25,014
3
Published 2021-10-06
Aliases in Bash enable you to essentially create your own commands, or even just simplify existing ones. In this video, I'll explain what aliases are, and I'll show you some of my personal favorites. At the end, I'll show you how to make your aliases persist between sessions.

🎓 CROWDSTRIKE CRASH SURVIVOR T-SHIRT
Commemorate the largest outage in history with the latest addition to the LLTV merch shop.
Get yours here ➜ learnlinux.link/crash-shirt

🎓 BRAND NEW UDEMY COURSES AVAILABLE!
Check out my new courses on Udemy and learn something new!
• Getting Started with Ansible ➜ learnlinux.link/ansible
• LPI Linux Essentials Complete Workshop ➜ learnlinux.link/linux-essentials

🐧 SUPPORT LINUX LEARNING!
• Grab some Linux swag ➜ merch.learnlinux.tv/
• Become a Channel Member ➜ learnlinux.link/member
• Become a Patron ➜ learnlinux.link/patron
• 5% discount on LPI exam vouchers ➜ learnlinux.link/lpi-voucher
• Check out my latest book ➜ ubuntuserverbook.com/
• Grab an awesome Pi-powered KVM ➜ learnlinux.link/tinypilot
• Jay's Gear - Server, Computer and Video Production Stuff ➜ learnlinux.link/amazon
Note: Royalties and/or commission is earned from each of the above links

#*⏰ TIME CODES*
00:00 - Intro
01:08 - The alias command
03:27 - Removing an alias
04:46 - Alias example 1: Simplify the output of the df command
07:14 - Alias example 2: Simplify the output of the mount command
08:31 - Alias example 3: Showing your external IP
09:22 - Alias example 4: Simplifying the installation of packages
10:47 - Alias example 5: Simplifying the command for upgrading packages
11:53 - Alias example 6: Running an Internet speed test
13:36 - Alias example 7: Checking CPU and memory usage
14:51 - Retaining aliases even after closing your session

Video Specific Links
- Official blog post for this video ➜ www.learnlinux.tv/?p=1054

Stand-Alone Tutorials
• OpenSSH Guide ➜ linux.video/ssh
• How to better secure OpenSSH ➜ linux.video/secure-ssh
• 10 Linux Terminal Tips and Tricks to Enhance Your Workflow ➜ linux.video/cli-tricks-1
• Over 15 Terminal Tricks You Should Learn ➜ linux.video/cli-tricks-2

Full Courses from Learn Linux TV
• Linux Crash Course series ➜ linux.video/cc
• Learn how to exit use tmux ➜ linux.video/tmux
• Learn how to use vim ➜ linux.video/vim
• Bash Scripting Series ➜ linux.video/bash
• Proxmox VE Cluster Full Course ➜ linux.video/pve
• Learn Ansible ➜ linux.video/ansible

🌐 LEARN LINUX TV ON THE WEB
• Main site ➜ www.learnlinux.tv/
• Community ➜ community.learnlinux.tv/
• Official Github Account ➜ github.com/LearnLinuxTV
• Enterprise Linux Security Podcast ➜ enterpriselinuxsecurity.show/
• The Homelab Show Podcast ➜ thehomelab.show/
• Jay on Udemy ➜ www.udemy.com/user/jay-lacroix-3
• Jay on Twitter ➜ x.com/JayTheLinuxGuy
• Content Ethics ➜ www.learnlinux.tv/content-ethics
• Request Assistance ➜ www.learnlinux.tv/request-assistance

⚠️ DISCLAIMER
Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. Always make sure you have written permission before working with any infrastructure and that you are compliant with all company rules, change control procedures, and local laws.

#bash #linux #cli

All Comments (21)
  • pro tip: use backslash in front of a command to temporarily bypass its alias (if any). eg: \ls
  • 30+ year Net/Sys Admin here. I stopped using/making individual script files years ago in favor of using Aliases. This lets me keep all of my most used/custom bash scripts either as Aliases or Bash Functions in one Bash Setup Script (BSS). I keep my BSS synced to the Cloud so that it's available on all machines I access/use.
  • @ewancox4895
    I have many aliases that I've accumulated over the years, so I created a separate file named .aliases then source it in my .zshrc file, as below; source ~/.config/.aliases I find it easier to keep track and share between my systems that way, plus it's synched to my Nextcloud and allows me to retain system specific .bashrc and .zshrc files, while having common alias listings.
  • Perfect timing Jay, I was just going to look up some info on these lol
  • For the speedtest...there is actually a package in the repository for both apt and pacman...not sure about others...which is called speedtest-cli ... That's the cli for Ookla speedtest and it essentially does the same thing
  • @WC1376C22
    Jay....you are on a rampage!!! Another great product. "It's the little things." -someone at some point in time.
  • I really appreciate these videos. I'm using Pop on a system 76 laptop, but I prefer Cinnamon to Gnome. Because of this I need to use the command line to change graphics modes. I do this infrequently, so I need to web search the command each time. Simplifying this with an easily remembered alias is much easier.
  • what an amazing tutorial! i thoroughly enjoyed as a non-coder. thank you so much!
  • @mlongval
    Thanks for all your great content. You are a very good teacher. Cheers!
  • @fixer1140
    I came looking for charcoal and I found gold. Thank you so much Jay.
  • @DL-xf3ur
    Thanks as always Jay! Great video.
  • Greetings Jay! Super Awesome Video! I got my Alias start with you and Joe Collins 4 years ago. Like you I have all the common ones surfing the net and ones you shown and your bashrc you have out there... :-) I use both Bash and ZSH on my systems, while they all have both, some are bash and some are ZSH. So I create a .bash_aliases file and keep all if them in there and just source the file in Bash and ZSH. I have just the basics in both RC files and the rest in the .bash_aliases file. My top 4 are as follow... ---------------------- ## Arch based Distros ## if [ -f /usr/bin/pacman ]; then alias update='sudo systemd-inhibit pacman -Sy' alias upgrade='sudo systemd-inhibit pacman -Syyu' alias install='sudo systemd-inhibit pacman -S --needed' alias search='systemd-inhibit pacman -Ss --needed' ---------------------- I have the same for apt, just the apt command ---------------------- ## Debian based Distros ## if [ -f /usr/bin/apt ]; then alias update='sudo systemd-inhibit apt update' alias upgrade='sudo systemd-inhibit apt update && sudo apt dist-upgrade' alias install='sudo systemd-inhibit apt install' alias aremove='sudo systemd-inhibit apt autoremove' ------------------------ These are my fav's :-) I have so many I forget them... LOL Thanks for the video Jay! LLAP P.S. How's the new job going... :-)
  • @bulcub
    bro! thank you for these GEMS!! helps make my NEWBIE Life using Linux less of a headache.
  • @AlexanderGarzon
    For the df alias, I will explude "overlay" too, quite common nowadays because docker. So: df -h -x squashfs -x tmpfs -x devtmpfs -x overlay
  • @Acece665
    Thanks very informative. I like to add aliases to ~/.bash_aliases to make backing up easy. Also having an alias like: alias addalias='nano ~/.bash_aliases' is pretty handy too.
  • @davidodo1268
    Amazing content, well explained and easy to understand. Please make more advanced videos on bash aliases for actually hacking commands on kali linux
  • @toranshaw4029
    Ta for this video. Created i for installing apt packages and s for Snaps. Also added update for update && upgrade. Very useful. 👍
  • @matthieujoly
    Love this, i'm also a great alias user. Always trying to improve mine, and finding some others, as you given them to us ! Thanks.. Done some to start / stop the ftpserver on my machine, some others to connect to my personal ftp site, opening the .zshrc file directly with vim, sourcing the .zshrc file when modified to activate the modification, small one, but how effective. Doing some other that are aliases within other aliases. If needed, i can use them if required. Multiple renaming... whatever possible!! you're right, you're just limited by your imagination. This is one i found useful, instead of having a visual plugin.. only in the terminal : alias meteo='curl wttr.in'