How to see the command attached to a bash alias?

1

Answer #: 1

The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.

$ type ls ls is aliased to `ls --color=auto' $ type rm rm is /bin/rm $ type cd cd is a shell builtin $ type psgrep psgrep is a function psgrep () { ps -ef | { read -r; echo "$REPLY"; grep --color=auto "$@" } }

Answer #: 2

Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.

Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.

Answer #: 3

I really like Ctrl+Alt+E as I learned from this answer. It “expands” the currently typed command line, meaning it performs alias expansion (amongst other things).

What does that mean? It turns any alias, that might be currently written on the command...

0 0
2

Introduction

The more you operate on the command line, the more you will find that the majority of the commands you use are a very small subset of the available commands. Most tasks are habitual and you may run these the same way every day.

While the makers of many of the most common command utilities have attempted to eliminate extraneous typing by using shortened names (think of how many keystrokes you save daily by typing "ls" instead of "list" and "cd" instead of "change-directory"), these are not ubiquitous. Additionally, many people always run commands with the same few options enabled every time.

Luckily, bash allows us to create our own shortcuts and time-savers through the use of aliases and shell functions. In this guide, we'll discuss how to make use of these and give you some useful examples to get you started in the right direction.

How To Declare a Bash Alias

Declaring aliases in bash is very straight forward. It's so easy that...

0 0
3


I LIKE it!!!---so much more concise than mine...

No manual entry for alias. {Ubuntu 9.10}

@jwl17330536

Sorry I did not know that is what you called it.

@pixellany So the BASH script in /bin would work or is there something wrong or stupid about that?

Thanks.

The is nothing wrong or stupid about a script--unless of course it's not written correctly....

www.google.com

does (I promise you that it is very easy. I am just not going to do your google search for you and tell you. I don't remember the exact command. [Sadly])

Quote:

Again, I promise you that an alias is way easier!

Indeed not. You have to look at

man bash

, since

alias

is a shell built-in. I'd not consider the possibility to make scripts...

0 0
4

An alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display a list of all defined aliases. You can add user-defined aliases to ~/.bashrc file. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.

More about aliases

The general syntax for the alias command for the bash shell is as follows:

Task: List aliases

Type the following command:

Sample outputs:

alias ..='cd ..' alias amazonbackup='s3backup' alias apt-get='sudo apt-get' ...

By default alias command shows a list of aliases that are defined for the current user.

Task: Define / create an alias (bash syntax)

To create the alias use the following syntax:

In this example, create the alias c for the commonly used clear command, which clears the...

0 0
5
...
0 0
6

A UNIX shell is essentially the API between the user, the kernel, and the system hardware. The shell is very important on any UNIX or Linux system and is one of the most vital aspects to learn proper systems administration and security. Typically driven by a CLI, the shell can literally make or break your system. The open source bash shell that this article examines is one of the most powerful, practical, and extensible shells available. In this article, you will learn the basic techniques of bash scripting, its everyday uses, and methods for employing it to create near-bulletproof shell scripts.

History of the bash shell

The Bourne Again Shell (bash) got its start in 1987, when it was written as a GNU project that many Linux distributions quickly adopted. Currently, many different versions of bash are freely available.

One of the more positive aspects of bash is its built-in security features. Bash keeps a record of what the user has typed...

0 0
7

What is the Bash Shell?

Bash's Configuration Files

Modifying the Bash Shell with the set Command

Useful Commands and Features

Aliasing Commands

Altering the Command Prompt Look and Information

CDargs - Shell Bookmarks

Basic and Extended Bash Completion

Links

Contributions

Translations



What is the Bash Shell?

The GNU Bourne-Again SHell (BASH) incorporates features from the C Shell (csh) and the Korn Shell (ksh) and conforms to the POSTIX 2 shell specifications. It provides a Command Line Interface (CLI) for working on *nix systems and is the most common shell used on Linux systems. Useful bash features will be the subject of the rest of this document.


Bash's Configuration Files

Because what I want to say here has already been written I will quote the section entitled "Files...

0 0
8

Not long time ago I have rediscovered an old friend - Bash Alias. We got acquainted at the beginning of my computer science studies, when I visited a course held by Cisco, “Linux Essentials” or something similar, where the trainer mentioned at one point what were aliases and how handy they could be. Well 12 years later, and I still had not got that, until recently, when a flash of illumination struck me and since then I’ve been using them extensively in my everyday developer life. In this post I will present a short introduction to aliases and after that my way of using them.

What are aliases?

So what are aliases? According to The Linux Documentation Project - “A Bash alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. If, for example, we include alias lm="ls -l | more" in the ~/.bashrc file, then each lm typed at the command-line will automatically be replaced by a ls -l | more. This can...

0 0
9

Working in commandline offers speed and convenience. The downside is you will have to remember all the commands and some of them are long and can affect your productivity. Fortunately, we can create shortcuts to commands that can significantly speedup the work.

In Ubuntu, a user can create a “.bash_aliases” file that contains the list of all shortcuts or aliases to your frequently used commands. First of all, make sure that you have the .bashrc file in your home directory:

cd ~ ls -al

Check to see if you have a .bashrc file. If you have it then open the file in nano or your favorite text editor and look for the following lines:

if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi

Make sure that they are uncommented (no # symbol in front of the lines). If you do not find the .bashrc file in your home directory then follow this post to create it.

Now create a .bash_aliases file in your home directory and start adding your aliases to the file. Below...

0 0
10

The average linux users use the terminal commands for many tasks and some certain commands are very frequently used. For example, if you are a user of Ubuntu, you have to type " sudo apt-get install" every time you want to install a new package or the command "xset dpms force off" to turn off the desktop/laptop monitor. To save time, you can create shortcuts for these commands by adding aliases into the bash configuration file (~/.bashrc or /etc/bash.bashrc). The syntax to use aliases is:

alias shortcut-command="regular-command"

For example:

alias install="sudo apt-get install" alias monitoroff="xset dpms force off" alias poweroff="sudo shutdown -h now"

After adding these lines into the bash configuration file and log out and log in again, you can use the new aliases. For example, to install new packages, you can use the following command after you used the above aliases:

install package1 package2

Tags:

alias for commands, sortcuts for...
0 0
11

To make aliases of OSX/Unix commands in your bash shell on OS X 10.9, 10.8 and 10.7, it is done via your .bash_profile file which lives in your home account directory, if the file does not already exist, just create one.

Launch Terminal from the /Application/Utilities folder

Go to your home directory by just entering cd followed by the ‘return’ key to enter the command:

cd

List your home directory contents including invisible files to see if the file already exists, use:

ls -la drwxr-xr-x+ 18 ladmin staff 612 Jul 14 09:21 . drwxr-xr-x 6 root admin 204 Jul 3 18:28 .. -rw------- 1 ladmin staff 3 Jun 2 12:53 .CFUserTextEncoding -rw-r--r--@ 1 ladmin staff 6148 Jul 14 09:01 .DS_Store drwx------ 5 ladmin staff 170 Jul 3 18:44 .Trash -rw------- 1 ladmin staff 1157 Jul 14 08:59 .bash_history drwx------+ 5 ladmin staff 170 Jul 14 08:33 Desktop drwx------+ 6 ladmin staff 204 Jun 2 13:48 Documents drwx------+ 8 ladmin staff 272 Jul 3 18:10 Downloads drwx------+ 29...
0 0
12
alias Man Page | Bash | SS64.com

Create an alias, aliases allow a string to be substituted for a word when it is used as the first word of a simple command.

Syntax alias [-p] [name[=value] ...] unalias [-a] [name ... ] Key -p Print the current values -a Remove All aliases

If arguments are supplied, an alias is defined for each name whose value is given.

If no value is given, alias will print the current value of the alias.

Without arguments or with the -p option, alias prints the list of aliases on the standard output in a form that allows them to be reused as input.

The value cannot contain any positional parameters ($1 etc), if you need to do that use a shell function instead.

The name can not be 'alias' or 'unalias'.

unalias can be used to remove each name from the list of defined aliases.

Make an alias permanent

Use your favorite text editor to create a file called ~/.bash_aliases, and type the...

0 0
13

If you don’t know how to set up aliases in Linux, you should be very happy you have reached this page! Aliases are one of the most time-saving devices known to man. An alias is a way to make a complicated command or set of commands simple. This is best demonstrated by an example.

In web development or computer programming, there are a lot of times you need to recompile some source file. Below we are recompiling a less file and looking at the tail of the result.

Note: The example below can be generalized to any set of commands.

Wouldn’t it be easier to just type something like the following?

Luckily for us, this is simple to do in the bash-shell.

1. Open your .bashrc.

Your .bashrc file is located in your user directory. Open it in your favorite text editor.

2. Go to the end of the file.

In vim, you can accomplish this just by hitting “G” (please note that it is capital).

3. Add the alias.

A simple way to...

0 0
14
How to make bash aliases on Ubuntu -

If you ever wonder how to make shortcut for some Linux commands? Can I do that? Yes, you can easily by making an alias for it.

Creating aliases to use in the command line is a simple way to make linux commands easy to access and simplicity when use the shell. So, you can save the time.

The screenshot pic below is result of this tutorial:



1. What is an alias?

An alias is shortcut for quickly accessing linux commands line. You can specify any name you like for a command. Example if you do not like using 'sudo apt-get update' , you can make it to 'sagu', 'apdet' or whatever you like.


2. How to do that?

The first thing you will need to do if open your .bashrc file located in your home directory. Throw the command below in a terminal:

gedit .bashrc

That command will bring up gedit text editor with bashrc content. Next locate alias definitions. Maybe you will need to...

0 0
15

Send a Plaintext body email with one plaintext attachment with mailx:

( /usr/bin/uuencode attachfile.txt myattachedfilename.txt; /usr/bin/echo "Body of text" ) | mailx -s 'Subject' youremail@gmail.com

Below is the same command as above, without the newlines

( /usr/bin/uuencode /home/el/attachfile.txt myattachedfilename.txt; /usr/bin/echo "Body of text" ) | mailx -s 'Subject' youremail@gmail.com

Make sure you have a file /home/el/attachfile.txt defined with this contents:

Government discriminates against programmers with cruel/unusual 35 year prison sentences for making the world's information free, while bankers that pilfer trillions in citizens assets through systematic inflation get the nod and walk free among us.

If you don't have uuencode read this: http://unix.stackexchange.com/questions/16277/how-do-i-get-uuencode-to-work

On Linux, Send HTML body email with a PDF attachment with sendmail:

Make sure you have ksh installed: yum info...

0 0
16

A builtin is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off a separate process -- or because a particular builtin needs direct access to the shell internals.

A builtin may be a synonym to a system command of the same name, but Bash reimplements it internally. For example, the Bash echo command is not the same as /bin/echo, although their behavior is almost identical.

A keyword is a reserved word, token or operator. Keywords have a special meaning to the shell, and indeed are the building blocks of the shell's syntax. As examples, for, while, do, and ! are keywords. Similar to a builtin, a keyword is hard-coded into Bash, but unlike a builtin, a keyword is not in itself a command, but a subunit of a command construct.

I/O

echo

prints (to stdout) an expression or variable (see Example 4-1).

An echo...

0 0
17
mount

Mount a filesystem, usually on an external device, such as a floppy or CDROM. The file /etc/fstab provides a handy listing of available filesystems, partitions, and devices, including options, that may be automatically or manually mounted. The file /etc/mtab shows the currently mounted filesystems and partitions (including the virtual ones, such as /proc).

mount -a mounts all filesystems and partitions listed in /etc/fstab, except those with a noauto option. At bootup, a startup script in /etc/rc.d (rc.sysinit or something similar) invokes this to get everything mounted.

The versatile mount command can even mount an ordinary file on a block device, and the file will act as if it were a filesystem. Mount accomplishes that by associating the file with a loopback device. One application of this is to mount and examine an ISO9660 filesystem image before burning it onto a CDR.

Example 17-7. Checking a...

0 0
18

You can always do fdisk -l which seems to work pretty well, even on strange setups such as EC2 xvda devices. How fdisk -l works is something I would love to know myself.

Here is a dump for a m1.large instance:

root@ip-10-126-247-82:~# fdisk -l Disk /dev/xvda1: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/xvda1 doesn't contain a valid partition table Disk /dev/xvda2: 365.0 GB, 365041287168 bytes 255 heads, 63 sectors/track, 44380 cylinders, total 712971264 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/xvda2 doesn't contain a valid partition table Disk /dev/xvda3: 939 MB, 939524096 bytes 255 heads, 63...
0 0
19

3.1. Introduction

A Unix shell provides an interface that lets the user interact with the operating system by running commands. But a shell is also a fairly rich programming language: there are constructs for flow control, alternation, looping, conditionals, basic mathematical operations, named functions, string variables, and two-way communication between the shell and the commands it invokes.

Shells can be used interactively, from a terminal or terminal emulator such as xterm, and non-interactively, reading commands from a file. Most modern shells, including bash, provide command-line editing, in which the command line can be manipulated using emacs- or vi-like commands while it's being entered, and various forms of a saved history of commands.

Bash processing is much like a shell pipeline: after being read from the terminal or a script, data is passed through a number of stages, transformed at each step, until the shell finally executes a command and...

0 0