- An alias is a user-defined shortcut for a command or a series of commands. It allows you to substitute a longer command with a shorter, more memorable string.
- Create a temporary alias by using the alias command followed by the shortcut and the command you want it to replace.
- name: The name of the alias. command: The command or sequence of commands the alias represents. Basic Examples. Simple Aliases: Copy.
- To create an alias for a command you simply specify an alias name and set it to the command.
- In computing, alias is a command in various command-line interpreters (shells), which enables a replacement of a word by another string.
- Alias functions similarly to a shortcut command and has the same functionality as the full command that helps you use and remember commands.
- ...you need to do is type the word alias then use the name you wish to use to execute a command followed by "=" sign and quote the command you wish to alias.
- Think of the ‘alias’ command in Linux as a shortcut – a way to create your own commands that can represent long or complex commands.
- This might be helpful if used when creating an alias, but it is, of course, redundant when the alias command is used without arguments.
- Repetitively typing or copying the same command lowers productivity and introduces a hassle you can easily avoid with the alias command.
Alias — команда, которая позволяет создавать ярлыки для существующих команд. Это облегчает запоминание и ускоряет выполнение.
Синтаксис команды alias:
alias синоним="команда". синоним — короткая команда (алиас), которая будет использоваться для запуска команды. команда — команда, которая будет запускаться при вызове синонима. Записывается в двойных или одинарных кавычках.
Примеры создания псевдонимов:
Вывод списка файлов: alias ll="ls -la". То есть, вместо выполнения ls -la теперь достаточно выполнить команду ll.
Подключение по ssh к определённому серверу: alias serv="ssh -p 1234 pingvinus@192.168.0.123".
По умолчанию псевдонимы сохраняются только в текущем сеансе. Чтобы сохранить их на постоянной основе, нужно прописать выполнение команд alias в файл .bashrc.
Удалить созданный псевдоним можно с помощью команды unalias. Удаление происходит только в текущей сессии терминала.
Факты
- Платформа: