search
HomeSystem TutorialLINUX5 super amazing shell aliases to use on Linux

5 super amazing shell aliases to use on Linux

Feb 05, 2024 am 11:35 AM
linuxlinux tutoriallinux systemlinux commandshell scriptgood promiseGetting started with linuxlinux learning

If you are not taking full advantage of Shell abbreviations, you are wasting valuable time. Typing the same thing over and over again is boring, monotonous, and inefficient. Why memorize lengthy commands when you can simplify them?

在 Linux 上使用的5个超级神奇的 Shell 别名

Abbreviations are a way of giving a name to a command, a series of commands, or a short piece of text. You can chain multiple commands together, or pass a long list of arguments to frequently used commands and give them shorter names. Abbreviations are useful if you type the same thing often and want an easier name to remember.

Using abbreviations can save time when executing commonly used commands. And, you'll never forget the correct parameters again, since you can build them into abbreviations. If set up correctly, abbreviations can do some truly magical things.

In this post, I want to share with you the abbreviations that I use every day as an engineer. These abbreviations are my absolute lifesaver. They have become my muscle memory and I honestly can’t imagine life without them.

1、Git status

alias gg='git status'

Simple, yes. Efficient? You can't imagine. If you count the number of times git status is called every day, you might be a little shocked. This is a very common command in Git repositories. It shows which files are ready for commit, which branch you are on, and a lot of other valuable information.

Typing git status might not seem too crazy, but see how long it takes? Look at the way your fingers dance across the keyboard. There's a space, and the characters themselves are spaced out in a specific pattern that's prone to error. Once you mess up, you need to start over. So much time wasted. Just abbreviate it.

Typing gg is much faster, if you make a typo then maybe consider a typing course...

2. Run Pylint

alias pll='pylint -f colorized'

Whether you love it or hate it, code inspectors are essential. Like it or not, no engineer is perfect. We all make mistakes at some point. You need to perform inspections on your code, so making it simple and easy is crucial.

I write a lot of Python code, so I rely heavily on Pylint for code inspection. I also like to run Pylint with colored output, sometimes with other custom parameters. It's not fun typing this stuff over and over again. Set it to a short abbreviation and it's now even more interesting.

You can pass different format types, ignore files, checkers, and different .rc files. Basically, anything you can pass to a normal command can be put in an abbreviation. That's the power of it, because you can set up the code inspector to your liking without having to remember or re-enter all those options.

3. Log in to ECR

alias ecr_login='aws ecr get-login-password --region  | docker login --username AWS --password-stdin '

If you often use Docker images and also use ECR, then this unique command will be better than bread. Logging into ECR is very tedious. You have to chain all these commands together and use specific credentials to let Docker log in. It's a real pain if you don't remember that command. Then you have to look it up, which wastes a lot of time.

Just set the login command to a concise and clear alias. If you work in multiple ECR regions, you can even alias based on region. Set up a login alias for the East Coast, the West Coast and even beyond. The world is your oyster, now you can log in quickly and easily.

Don't forget to add your own zone and ECR URI to the above command to make it work properly.

4、运行Ansible

alias apb='cd  && ansible-playbook -i 

对我来说,运行Ansible playbooks是日常工作。我每天运行多个play,并且经常重复执行。尤其是当我正在构建新的角色或与Ansible中的条件逻辑作斗争时。谁不喜欢将YAML作为代码呢?

能够使用我需要的基本标志运行Ansible非常重要。重新输入一长串参数需要很长时间。当然,你可以按上箭头重用之前执行的命令,但这并不总是最方便的选项。如果你转而切换到编辑文件,现在又要按两次上箭头。这很容易在开发过程中被忽略,然后你又得重新输入一遍。

只需给它取个别名。

这还可以让你有机会确保你是否在使用ansible.cfg文件(如果有的话)。在上面的命令别名中,我们进入了我们的仓库并在该上下文中运行。这是因为我们的Ansible配置位于那里。一旦你进入那个目录,它会自动使用该配置。

如果有其他的清单文件,你也可以传入它们。如果你有一些跨多个环境的全局清单,这将非常有帮助。

5、缩短常用命令

alias tf='terraform'
alias k='kubectl'

这是我最近开始实施的最后一个建议。起初我觉得这并不是必要的,但一旦你开始使用一两个字母的命令而不是七八个字母的命令,就会有很大的不同。我每天都经常使用terraform和kubectl。

这些命令是另一个例子,它们的名称很烦人。它们容易出错,而将它们设为别名非常简单。给自己一个方便,现在就将它们缩短,这样你就可以忘记它们的拼写。

我还鼓励你查看其他你经常输入的单词命令。可能有一些你一遍又一遍地输入的命令可以从缩短中受益。

现在,去给命令设置别名吧!

The above is the detailed content of 5 super amazing shell aliases to use on Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
How to Make a USB Drive Mount Automatically in LinuxHow to Make a USB Drive Mount Automatically in LinuxApr 30, 2025 am 10:04 AM

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Apr 30, 2025 am 09:57 AM

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Best Linux Tools for AI and Machine Learning in 2025Best Linux Tools for AI and Machine Learning in 2025Apr 30, 2025 am 09:44 AM

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

5 Best Lightweight Linux Distros Without a GUI5 Best Lightweight Linux Distros Without a GUIApr 30, 2025 am 09:38 AM

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res

How to Install Wine 10.0 in RedHat DistributionsHow to Install Wine 10.0 in RedHat DistributionsApr 30, 2025 am 09:32 AM

Wine 10.0 stable version release: Running Windows applications on Linux to a higher level Wine, this open source and free application, allows Linux users to run Windows software and games on Unix/Linux operating systems, ushering in the release of the 10.0 stable version! This version has been provided with source code and binary package downloads, and supports various distributions such as Linux, Windows and Mac. This edition embodies a year of hard work and over 8,600 improvements, bringing many exciting improvements. Key highlights include: Enhanced support for Bluetooth devices. Improve support for HID input devices. Optimized performance of 32-bit and 64-bit applications.

How to Install and Configure SQL Server on RHELHow to Install and Configure SQL Server on RHELApr 30, 2025 am 09:27 AM

This tutorial guides you through installing SQL Server 2022 on RHEL 8.x or 9.x, connecting via the sqlcmd command-line tool, database creation, and basic querying. Prerequisites Before beginning, ensure: A supported RHEL version (RHEL 8 or 9). Sudo

How to Install Thunderbird 135 on a Linux DesktopHow to Install Thunderbird 135 on a Linux DesktopApr 30, 2025 am 09:26 AM

Mozilla Thunderbird 135: Powerful cross-platform mail client Mozilla Thunderbird is a free, open source, cross-platform email, calendar, news, chat and contact management client designed to efficiently handle multiple email accounts and news sources. On February 5, 2025, Mozilla released the Thunderbird 135 version, introducing a number of new features, performance improvements and security fixes. Thunderbird 135 main features: XZ Packaging for Linux Binaries: Smaller files, faster unpacking, and better integration with modern distributions. Cookie storage support: when creating space

How to Lock Files for Renaming or Deleting in LinuxHow to Lock Files for Renaming or Deleting in LinuxApr 30, 2025 am 09:11 AM

This guide demonstrates how to protect files on Linux from accidental renaming or deletion using simple commands. We'll use the file important.txt in /home/user/ as an example. Method 1: Using chattr for Immutability The chattr command modifies fil

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function