How to Set Linux/Unix

Command Aliases

(examples for user
'run control' files)

Home > RefInfo menu > Computer topics menu >

Handy Commands and Scripts menu >

This 'How to Set Linux/Unix Command Aliases' page

More alias examples and info may be added,
if I re-visit or use this page.

INTRODUCTION :

Below is information on setting command aliases --- to make it easy to call up a rather long command with just a few characters, typed at a terminal prompt.

A command alias is usually set by using an 'alias' command in a 'run-control' (rc) file in the user's home directory.

The name of the 'rc' file is typically

  • '.bashrc' or
  • '.profile' or
  • '.bash_aliases' (for example, in Ubuntu 9.10)

The 'rc' file is usually a 'dot' file --- a 'hidden' file --- in the user's home directory.

The image at the top of this page shows that you can open a terminal and type the command 'alias' --- and the aliases that have been set in your various 'run control' and 'profile' files will be shown in the terminal.


Some handy aliases to add to a
'~/.bashrc' or '~/.bash_aliases' or '~/.profile' file :

Statements (and comments) like the following can be entered (or pasted) in a user's 'run control' file.

The comment lines explain what most of these aliases are intended to do.


######## Added Aliases.

######## To list files.

## To provide a sorted list of directories-ONLY of the current directory.
alias lsd="ls -F | grep '/$'"

## To provide a sorted list of 'regular' (non-directory) files
## of the current directory.
alias lsf="ls -F | grep -v '/$'"

## To provide a sorted list of directories of the current directory,
## followed by a sorted list of (other) files of the current directory.
alias lss="lsd;lsf"

######## To list files - with hidden files:

## To provide a sorted list of directories-only of the current directory,
## including 'hidden' directories.
alias lsad="ls -a -F | grep '/$'"

## To provide a sorted list of non-directory files of the current directory,
## including 'hidden' files.
alias lsaf="ls -a -F | grep -v '/$'"

## To provide a sorted list of directories of the current directory,
## including 'hidden' directories ---
## followed by a sorted list of (other) files of the current directory,
## including 'hidden' files.
alias lsas="lsad;lsaf"

######## To quick-change to frequently used directories:

## To provide a quick way to change to a commonly used
## (development) directory.
alias cdtk='cd ~/dev/tkGUIs/'


Shell considerations :

Most of these samples are intended to run with the Bourne or the Korn shells (command interpreters), as well as with the Bash shell (command interpreter). Most of these samples employ commands (and their parameters) available to all three interpreters, so the scripts (and aliases) will generally run in any of these three shells (command interpreters).

In fact, the Korn and Bash command interpreters are offshoots of the Bourne shell (command interpreter).


Here is a link to help search for more information on setting command aliases for use at command-line prompts.

Bottom of this
How to Set Linux/Unix Command Aliases page.

To return to a previously visited web page location, click on the Back button of your web browser a sufficient number of times. OR, use the History-list option of your web browser.
OR ...

< Go to Top of Page, above. >

Page was created 2009 Oct 28.(As part of a commands-and-scripts menu page.)
Page was changed 2017 Sep 18. (Split this info into a separate page.)
Page was changed 2018 Sep 01. (Added css and javascript to try to handle text-size for smartphones, esp. in portrait orientation.)