Using Linux alias command to create an substituted for Linux command.

 

Using Linux alias command to create an substituted for Linux command.

 

   Using Linux alias command to allow a string of Linux command ( long line of command ) to be substituted for a simple word command on fedora core system.

 

Linux command name:  alias

 

  Sometime you need to issue log line of command, this string of command is hard to remember and may waste your valuable time. The best example of alias command is the Fedora Core 'll' command. Make note that the 'll' command actually a 'ls' command include with some 'ls' command options.  The example below show how we could make alias to command and the use of alias.

 

Linux Command Description:

   alias command allow a string of Linux command (long line of command) to be substituted for a simple word command.

 

Linux Command type:

   Bash Builtins Command.

 

[root@fedora ~]# type -t alias

builtin

 

Using alias.

 

Using 'alias' command with no arguments or with the -p option prints the list of aliases in the form alias NAME=VALUE on standard output:

 

Execute 'alias' command with no urguments:

 

[root@fedora ~]# alias

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

Execute ' alias ' command with -p option:

 

[root@fedora ~]# alias -p

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

'alias' command can be use to check the Linux command to see if it has an alias:

 

[root@fedora ~]# alias ll

alias ll='ls -l --color=tty'

 

[root@fedora ~]# alias rm

alias rm='rm -i'

 

[root@fedora ~]# alias dir

-bash: alias: dir: not found

 

Create alias to Linux command.

 

   The example below show the step by step to using alias command to make or create an alias (simple word command substituted) to Linux 'shutdown' command:

 

[root@fedora ~]# alias offline='shutdown -h now'

 

To check new added alias for Linux 'shutdown' command:

 

[root@fedora ~]# alias offline

alias offline='shutdown -h now'

 

[root@fedora ~]# alias

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

alias mv='mv -i'

alias offline='shutdown -h now'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

Now try issue the 'offline' command:

 

[root@fedora ~]# offline

 

Broadcast message from root (pts/1) (Thu Jan 12 23:33:52 2006):

 

The system is going down for system halt NOW!

[root@fedora ~]#

 

The 'offline' command above actually run as a Linux 'shutdown -h now' command.

 

To remove an alias form the lists of alias, use the Linux 'unalias' command.  To make an alias permanent on our Linux system, edit the ".bashrc" (hidden file) on your home directory and add the alias for the Linux command:

 

Edited  example of ".bashrc" file:

 

----------------

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias offline='shutdown -h now'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

---------------

 

Short usage synopsis.

 

[root@fedora ~]# help -s alias

alias: alias [-p] [name[=value] ... ]

 

Helpful information about builtin commands:

 

[root@fedora ~]# help alias

alias: alias [-p] [name[=value] ... ]

'alias' with no arguments or with the -p option prints the list of aliases in the form alias NAME=VALUE on standard output.  Otherwise, an alias is defined for each NAME whose VALUE is given. A trailing space in VALUE causes the next word to be checked for alias substitution when the alias is expanded. Alias returns true unless a NAME is given for which no alias has been defined.

 

On-line manuals in the "Info format":

 

[root@fedora ~]# info alias

 alias [-p] [name[=value] ...]

Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded.  For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.

 

Keywords: using Linux alias command, add alias, adding alias command, edit linux command, permanent alias command, string of Linux command, long line of command, substituted for a Linux command, command alias, make alias to command.

 

aaaaaaaaaaa