• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

alias Command Examples in Linux

by admin

The alias command is used to customize the shell environment by generating command-line aliases. Aliases are shorthand for longer expressions. Using aliases, you can create a short string that represents a longer command with various options and arguments. For example, you can create an alias called myls that executes the ls – al command.

The Bash shell maintains a list of aliases that you can view by using the alias command by itself. You can also remove aliases using the unalias command. By default, aliases are only maintained for the current shell and for the user that created them. To have them persist, add the appropriate alias command to .bashrc or .bash_aliases, which is called by .bashrc.

Syntax

The syntax of the alias command is:

# alias [alias name[='command with options']

alias Command Examples

1. List all aliases:

# alias

2. Create a generic alias:

# alias word="command"

3. View the command associated to a given alias:

# alias word

4. Remove an aliased command:

# unalias word

5. Turn `rm` into an interactive command:

# alias rm="rm --interactive"

6. Create `la` as a shortcut for `ls –all`:

# alias la="ls --all"

Filed Under: Linux

Some more articles you might also be interested in …

  1. git rebase Command Examples
  2. CentOS / RHEL 6,7 : How to disable or delete virbr0 interface
  3. RHEL 7 – RHCSA Notes (Cheat Sheets)
  4. “az storage” Command Examples
  5. pw-cli Command Examples in Linux
  6. How to control resource (cgroup) with systemd for user process group in CentOS/RHEL 7
  7. Linux OS Service ‘o2cb’
  8. wall: command not found
  9. How to use perf tool for tracing similar to dtrace
  10. dotnet build: Builds a .NET application and its dependencies

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright