User Tools

Site Tools


alias

Alias

Return to Pseudonym, Linux Commands, Python glossary, Python lingo, Python

Python alias - alias - “An alternative name for an object. For example, in a = []; b = a the variable b is an alias to the list bound to a.” (FlntPy 2022)

Snippet from Wikipedia: Alias

Alias may refer to:

  • Pseudonym, a fictitious name that a person or group assumes for a particular purpose
    • Pen name, a pseudonym adopted by an author and printed on the title page or by-line of their works in place of their real name
    • Stage name, a pseudonym used by performers and entertainers
  • Nickname, a substitute for the proper name of a familiar person, place or thing
  • Code name, a code word or name used, sometimes clandestinely, to refer to another name, word, project, or person
Snippet from Wikipedia: Alias (command)

In computing, alias is a command in various command-line interpreters (shells), which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. alias is available in Unix shells, AmigaDOS, 4DOS/4NT, FreeDOS, KolibriOS, Windows PowerShell, ReactOS, and the EFI shell. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility.

An alias will last for the life of the shell session. Regularly used aliases can be set from the shell's rc file (such as .bashrc) so that they will be available upon the start of the corresponding shell session. The alias commands may either be written in the config file directly or sourced from a separate file.

An alias is simply that - another name with which to refer to a command. Aliases allow you to create shorter or more familiar names for commonly used commands. Another benefit lies in being able to not only alias the command, but the first few arguments, as well. Aliases were introduced by csh and later incorporated in bash and others.

The exact syntax used to set an alias depends on your shell. For Bourne-type shells (ksh, bash, etc., though not sh), the syntax is:

$ alias ''name''=''command''
If the command has arguments, then quotes (single or double) must be used:
$ alias ''name''="''command'' ''argument'' ..."
For csh-type shells (csh, tcsh, etc.), quotes aren't needed:
$ alias ''name'' ''command'' [''arguments'' ...]
As you can see, the main differences are the equals sign after the name of the alias and whether quotes are needed. When issued without arguments, alias prints a list of the currently defined aliases.

When issued at the command line an alias only takes effect for that shell. To make it permanant, the alias must be saved in one of the shell configuration files. For bash, they are ordinarily placed in the ~/.bashrc file for per-user configuration, or in /etc/profile for all users. For tcsh, the file ~/.tcshrc is the right place, or /etc/login for all users.

Examples

A simple alias for DOS users:

$ alias dir="ls -l"

Here is an example of a complicated alias:

$ alias topcom='sort ~/.bash_history | uniq -ci | sort -r | less'
This alias makes it is easy to look for frequently used commands that might merit being turned into yet more aliases.

Here is an another example to see mounted partitions:

$ alias mnt='mount | grep -i /dev/[h,s]d[a..g] | sort'

Shell functions can accomplish the same effect as aliases, but the latter are simpler. Unlike functions, they do not permit variable substitution.

For instance even something as simple as:

$ bak () { cp -a $1 $1.bak }
cannot be defined as an alias due to the variable “$1”.

Setting an alias

To set an alias persistently for all users, all shells (ksh, bash, …) and all type of shells (login shells and non-login shells) you need to

  • modify /etc/profile

:for logIn shells

  • modify /etc/bash_bashrc

:for non-login bash shells

remove an alias

Use unalias

Bibliography

See also

Linux Command

Fair Use Sources

Python: Python Variables, Python Data Types, Python Control Structures, Python Loops, Python Functions, Python Modules, Python Packages, Python File Handling, Python Errors and Exceptions, Python Classes and Objects, Python Inheritance, Python Polymorphism, Python Encapsulation, Python Abstraction, Python Lists, Python Dictionaries, Python Tuples, Python Sets, Python String Manipulation, Python Regular Expressions, Python Comprehensions, Python Lambda Functions, Python Map, Filter, and Reduce, Python Decorators, Python Generators, Python Context Managers, Python Concurrency with Threads, Python Asynchronous Programming, Python Multiprocessing, Python Networking, Python Database Interaction, Python Debugging, Python Testing and Unit Testing, Python Virtual Environments, Python Package Management, Python Data Analysis, Python Data Visualization, Python Web Scraping, Python Web Development with Flask/Django, Python API Interaction, Python GUI Programming, Python Game Development, Python Security and Cryptography, Python Blockchain Programming, Python Machine Learning, Python Deep Learning, Python Natural Language Processing, Python Computer Vision, Python Robotics, Python Scientific Computing, Python Data Engineering, Python Cloud Computing, Python DevOps Tools, Python Performance Optimization, Python Design Patterns, Python Type Hints, Python Version Control with Git, Python Documentation, Python Internationalization and Localization, Python Accessibility, Python Configurations and Environments, Python Continuous Integration/Continuous Deployment, Python Algorithm Design, Python Problem Solving, Python Code Readability, Python Software Architecture, Python Refactoring, Python Integration with Other Languages, Python Microservices Architecture, Python Serverless Computing, Python Big Data Analysis, Python Internet of Things (IoT), Python Geospatial Analysis, Python Quantum Computing, Python Bioinformatics, Python Ethical Hacking, Python Artificial Intelligence, Python Augmented Reality and Virtual Reality, Python Blockchain Applications, Python Chatbots, Python Voice Assistants, Python Edge Computing, Python Graph Algorithms, Python Social Network Analysis, Python Time Series Analysis, Python Image Processing, Python Audio Processing, Python Video Processing, Python 3D Programming, Python Parallel Computing, Python Event-Driven Programming, Python Reactive Programming.

Variables, Data Types, Control Structures, Loops, Functions, Modules, Packages, File Handling, Errors and Exceptions, Classes and Objects, Inheritance, Polymorphism, Encapsulation, Abstraction, Lists, Dictionaries, Tuples, Sets, String Manipulation, Regular Expressions, Comprehensions, Lambda Functions, Map, Filter, and Reduce, Decorators, Generators, Context Managers, Concurrency with Threads, Asynchronous Programming, Multiprocessing, Networking, Database Interaction, Debugging, Testing and Unit Testing, Virtual Environments, Package Management, Data Analysis, Data Visualization, Web Scraping, Web Development with Flask/Django, API Interaction, GUI Programming, Game Development, Security and Cryptography, Blockchain Programming, Machine Learning, Deep Learning, Natural Language Processing, Computer Vision, Robotics, Scientific Computing, Data Engineering, Cloud Computing, DevOps Tools, Performance Optimization, Design Patterns, Type Hints, Version Control with Git, Documentation, Internationalization and Localization, Accessibility, Configurations and Environments, Continuous Integration/Continuous Deployment, Algorithm Design, Problem Solving, Code Readability, Software Architecture, Refactoring, Integration with Other Languages, Microservices Architecture, Serverless Computing, Big Data Analysis, Internet of Things (IoT), Geospatial Analysis, Quantum Computing, Bioinformatics, Ethical Hacking, Artificial Intelligence, Augmented Reality and Virtual Reality, Blockchain Applications, Chatbots, Voice Assistants, Edge Computing, Graph Algorithms, Social Network Analysis, Time Series Analysis, Image Processing, Audio Processing, Video Processing, 3D Programming, Parallel Computing, Event-Driven Programming, Reactive Programming.


Python Glossary, Python Fundamentals, Python Inventor: Python Language Designer: Guido van Rossum on 20 February 1991; PEPs, Python Scripting, Python Keywords, Python Built-In Data Types, Python Data Structures - Python Algorithms, Python Syntax, Python OOP - Python Design Patterns, Python Module Index, pymotw.com, Python Package Manager (pip-PyPI), Python Virtualization (Conda, Miniconda, Virtualenv, Pipenv, Poetry), Python Interpreter, CPython, Python REPL, Python IDEs (PyCharm, Jupyter Notebook), Python Development Tools, Python Linter, Pythonista-Python User, Python Uses, List of Python Software, Python Popularity, Python Compiler, Python Transpiler, Python DevOps - Python SRE, Python Data Science - Python DataOps, Python Machine Learning, Python Deep Learning, Functional Python, Python Concurrency - Python GIL - Python Async (Asyncio), Python Standard Library, Python Testing (Pytest), Python Libraries (Flask), Python Frameworks (Django), Python History, Python Bibliography, Manning Python Series, Python Official Glossary - Python Glossary, Python Topics, Python Courses, Python Research, Python GitHub, Written in Python, Python Awesome List, Python Versions. (navbar_python - see also navbar_python_libaries, navbar_python_standard_library, navbar_python_virtual_environments, navbar_numpy, navbar_datascience)


Cloud Monk is Retired (for now). Buddha with you. © 2005 - 2024 Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


alias.txt · Last modified: 2023/12/09 17:25 by Losang Jinpa PhD MCSE/MCT Python-DevOps