Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Aliases in SUSE LINUX Shell, Study notes of Linux skills

What aliases are in the context of the suse linux system and how they allow users to create shortcuts for commands and their options or create new commands. It covers how to view and remove aliases, as well as how to define new aliases for the current shell or make them persistent.

Typology: Study notes

2021/2022

Uploaded on 09/12/2022

xyzxyz
xyzxyz 🇮🇳

4.8

(24)

309 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
.
Define Aliases
Defining aliases allows you to create shortcuts for commands and
their options or to create commands with entirely different names.
On a SUSE LINUX system, whenever you enter the commands dir,
md, or ls, for instance, you use aliases.
You can find out about the aliases defined on your system by using
the command alias.
This will show you that dir, for instance, is an alias for ls -l and md
is an alias for mkdir -p.
The following are examples of aliases that define new commands:
To see whether a given command is an alias for something else, use
the type command.
For each command specified, type will tell you whether it is a
Built-in shell command
A regular command
A function
An alias
For regular commands, the output of type lists the path to the
corresponding executable. For aliases, it lists the elements aliased:
tux@da10:~> alias md
alias md='mkdir -p'
tux@da10:~> alias dir
alias dir='ls -l'
tux@da10:~> type -a ls
ls is aliased to `/bin/ls $LS_OPTIONS'
ls is /bin/ls
pf3

Partial preview of the text

Download Understanding Aliases in SUSE LINUX Shell and more Study notes Linux skills in PDF only on Docsity!

.

Define Aliases

Defining aliases allows you to create shortcuts for commands and their options or to create commands with entirely different names.

On a SUSE LINUX system, whenever you enter the commands dir , md , or ls , for instance, you use aliases.

You can find out about the aliases defined on your system by using the command alias.

This will show you that dir , for instance, is an alias for ls -l and md is an alias for mkdir -p.

The following are examples of aliases that define new commands:

To see whether a given command is an alias for something else, use the type command.

For each command specified, type will tell you whether it is a  Built-in shell command  A regular command  A function  An alias

For regular commands, the output of type lists the path to the corresponding executable. For aliases, it lists the elements aliased:

tux@da10:~> alias md alias md='mkdir -p' tux@da10:~> alias dir alias dir='ls -l'

tux@da10:~> type -a ls ls is aliased to `/bin/ls $LS_OPTIONS' ls is /bin/ls

.

The above example shows that ls is an alias although, in this case, it is only used to add some options to the command.

The -a option is used to show both the contents of the alias and the path to the original ls command. The output shows that ls is always run with the options stored in the variable LS_OPTIONS.

These options cause ls to list different file types in different colors (among other things).

Most of the aliases used on a system-wide basis are defined in the file /etc/bash.bashrc.

Aliases are defined by using the alias command and can be removed by using the unalias command.

For example, entering

unalias ls

removes the alias for ls, causing ls to stop coloring its output.

The following is the syntax for defining aliases:

alias alias_name =’ command options

An alias defined in this way is only valid for the current shell and will not be inherited by subshells, as in the following:

tux@da1:~> alias ps="echo Hello" tux@da1:~> ps Hello tux@da1:~> bash tux@da1:~> ps PID TTY TIME CMD 858 pts/0 00:00:00 bash 895 pts/1 00:00:00 bash ...