Little Girl's Mostly Linux Blog

Alias


Alias

This page was last updated on July 18, 2009.

Create a temporary alias

You can create a temporary alias that is valid only for the current session and will be forgotten by the system when you close the terminal window. To do this:

  1. Open a terminal window.
  2. Check if the name is already being used by the system by typing this command, replacing name with the name you’d like to give the alias:
  3. which name
  4. If the name is already being used, pick another name and repeat Step 2 with the new name. If it’s not being used, go to the next step.
  5. Type this command, replacing name with the name you’d like to give the alias and replacing command with the command you’d like the alias to perform:
  6. alias name='command'
    • For example,:
    • alias details='ls -l'

      Now I can type details instead of ls -l to see a detailed listing of files in a directory.

Create a personal alias list

To create your own alias list:

  1. Open a text editor and type the command for each alias on a separate line.
    • Example:
    • alias1='command1'
      alias2='command2'
      alias3='command3'
      alias4='command4'
      
  2. Save the file as myaliaslist wherever you’d like to keep it. For the sake of this example, let’s say you saved it to the /home/username/ directory.
  3. Open the .bashrc file in your /home/username/ directory with a text editor. Note that hidden files must be turned on in your file manager for this file to be visible.
  4. Type this line at the bottom of the file to source your alias list:
  5. source /home/username/myaliaslist
  6. Save the file.
  7. Close the text editor.

Now any time you open a terminal window, the aliases you have defined will be available for you to use.

Check which aliases you have defined

Type this command in a terminal window to check if you have any aliases defined in your .bashrc file:

alias


Obligatory Happy Ending

And they all lived happily ever after. The end.

Back to top

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.