The alias built-in in shells, used to define shortcuts for frequently used commands.

learn more… | top users | synonyms

0
votes
1answer
167 views

SUSE Linux 12 - configuring IP alias

I want to setup an IP address alias on a network card. I created a file /etc/sysconfig/network/ifcfg-ens160 and its contents are: BOOTPROTO='static' STARTMODE='onboot' IPADDR='192.168.0.113' ...
14
votes
1answer
658 views

How can I `alias sudo !!`?

I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints sudo: !!: command not found If I use double quotes, it substitutes ...
5
votes
2answers
201 views

Why does !! inside an alias not work?

I have this alias set in my system /etc/bashrc file: alias root="sudo !!" The intention of this being to run the last used command using sudo of course. When used, it of course appears to ...
4
votes
2answers
2k views

Escaping quotes in zsh alias

Following on from this question about stripping newlines out of text, I want to turn this into a zsh alias as follows: alias striplines=' awk " /^$/ {print \"\n\"; } /./ {printf( \" %s \",$0);}"' ...
1
vote
3answers
55 views

Creating an alias for a bash script

So I have tried experimented and created an alias in .bashrc. However, when I test out the command I get: [rkahil@netmon3 ~]$ menu -bash: menu: command not found Here is what I have in the .bashrc ...
1
vote
1answer
56 views

Resolve nested aliases to their source commands

I've made several aliases for my convenience.But now I need to be helpful by sending a useful command and it is full of aliases.I've tried doing type u but all it returns is up && ap upgrade ...
0
votes
1answer
23 views

How should I change root@mydomain when I send from mail() php function?

I've installed sendmail in Ubuntu as below: apt-get install sendmail Then I sent an Email to test, I received Email from root <root@mydomain>. I checked the content of /etc/aliases, but it ...
16
votes
2answers
438 views

How to retrieve lost aliases?

Let me start by saying I know this was dumb. Time and Linux make fools of us all. I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I ...
8
votes
4answers
301 views

Do you prefer bash scripts or aliases for shortcuts?

I have a ~/bin directory (which is on my PATH) where I store a lot of little 1 or 2 line scripts. Some of them just cd into a directory and run a command on a file, like vim or something. But I also ...
1
vote
3answers
64 views

Extend one alias in second alias

It is possible to do this: alias tm=cd /opt/tomcat alias tmbin=tm/bin $ tmbin $pwd /opt/tomcat/bin ?? I know that I can do: alias tmbin=tm;cd bin
1
vote
0answers
49 views

alias Not able to execute source command

I am trying to define a following alias in my .aliases file. alias sett 'cleartool setview viewXYZ_!*; cd /path_dir1/dir2/; source ./env/script-name' I use it as sett myview on commnd prompt when I ...
6
votes
1answer
290 views

Mailman / Postfix Configuration Assistance

I am writing for some help regarding Postfix configuration. I cannot seem to get Postfix configured properly to transfer mail to the mailing list installed on the same server. I followed many steps ...
2
votes
1answer
59 views

Why are aliases missing inside of bash command?

When I run in my terminal: alias a list with all my aliases (defined in ~/bashrc and ~/.bash_aliases files) will be displayed on my terminal. That's nice and as expected! But when I run: bash -c ...
57
votes
24answers
8k views

Quick directory navigation in the terminal

I would like to frequently switch between directories that are in totally unrelated paths, for example /Project/Warnest/docs/ and ~/Dropbox/Projects/ds/test/. But I don't want to type cd ...
83
votes
13answers
29k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
5
votes
4answers
92 views

Have xargs use alias instead of binary

Bash 4.2 on CentOS 6.5: In my ~/.bash_profile I have a bunch of aliases, including: alias grep='grep -n --color=always' so that I can get color highlighting and print line numbers automatically ...
0
votes
1answer
312 views

Using alias in another script (ksh)

I'm writing a ksh script, and I'd like to use a command define by an alias in my .profile file, in my script. I tried this command in the folder containing my script, and it works. However, in my ...
4
votes
1answer
128 views

Is there some way to make alias expansion work inside if…fi on Bash?

Check this script: #!/bin/bash if true;then alias WeirdTest='uptime';shopt -s expand_aliases WeirdTest fi WeirdTest The first time WeirdTest is executed it says "command not found".
0
votes
1answer
469 views

Why alias does not work in AIX (korn shell, .profile)?

I have these files in my home directory: drwxr-xr-x 3 meuser staff 256 Oct 12 13:11 . drwxr-xr-x 102 bin bin 4096 Sep 30 12:28 .. -rw------- 1 meuser staff ...
1
vote
2answers
45 views

alias for a command using !! to recall the last command [duplicate]

This is a follow-up question to Execute a line of commands with one sudo If you want to redo the same command with sudo !! after doing a command like this: echo "something">/path/file You ...
6
votes
2answers
176 views

Aliases interpretation

I have a few aliases in .bash_aliases. I defined c alias as follows, but it does not work as it should: ... alias cd='cd; ls -r --time=atime' alias c='cd' ... In .bashrc there is a line: alias ...
-1
votes
1answer
28 views

Make an alias that does an alias command

I have to make an alias that will do the alias command. It has to "replace" the alias command and the user has to feel no difference..
0
votes
1answer
42 views

How to get the same ls with colors working on both OSX and Ubuntu?

When I want color in Ubuntu I do alias ls='ls --color=always' but on OSX this gives an error ls: illegal option -- - and I need to do alias ls ='ls -G' How can I create an alias with the same ...
16
votes
4answers
4k views

How can I create an alias for a git [action] command (which includes spaces)?

Most of my my aliases are of this form: alias p='pwd' I want to alias git commit so that it does git commit -v But trying to create an alias with a space gives an error: $ alias 'git commit'='git ...
1
vote
1answer
797 views

ssh into a server using .ssh/config alias & run an alias on the server in the same time

On my laptop Inside ~/.ssh/config file I have this: Host <serverAlias> HostName 127.0.0.1 #Server IP User <username> PreferredAuthentications publickey IdentityFile ...
0
votes
1answer
23 views

KSH script missinterpreting alias stored in SQL oracle DB

I have stored the path of my file in a table with as an alias (as the complete path was too long for the table's field). However, in my KSH script, when I am doing : nomtmp=`sqlplus -S bla/bla ...
1
vote
0answers
55 views

postfix expand ldap group AND afterwards resolve alias

We have a postfix server which has the user config stored in a openldap directory. Recently we also implemented ldap groups which are expanded by postfix. This works fine, unless the group expands to ...
7
votes
2answers
227 views

alias vs export for simple commands

For simple commands like less, is it better to make an alias or to export the options? Is there any benefit of one over the other? For example, if I want less to always use the -R option to show raw ...
1
vote
3answers
62 views

Why doesn't my command work when aliased?

I use ps -ef | grep catalina | grep -v grep to print the tomcat process running on the system: kshitiz 7099 1 0 May11 ? 00:02:29 /usr/lib/jvm/jdk1.8.0/bin/java ...
0
votes
1answer
43 views

Set alias which doesn't send specified text? [closed]

EDIT I set a alias task in ~/.bashrc. The following: alias join="clear; screen -ls; screen -rx [<ID_OF_THE_RUNNING_SCREEN> quit]" If i the task join is executed, the following has to ...
0
votes
3answers
109 views

How to create a permanent alias without resourcing the .bashrc-like file?

I really like bash aliases, it annoys me that every time I want to add a new alias I have type two commands: echo "alias \"short-cmd\"='long-command'" >> ~/.bash_aliases source ~/.bash_aliases ...
10
votes
2answers
237 views

How to document my custom bash functions and aliases?

Problem: I have multiple bash functions and aliases. I can't remember all of them off the top of my head, so I usually end up opening my .bash_functions and .bash_aliases files to find what I need. ...
4
votes
2answers
44 views

Generating commands with variable expansion in a loop

I want to create local aliases while I work in certain directories. For example, I would like to have the following in a file named local_alias alias foo='bar' I wanted to write a cleanup script to ...
1
vote
2answers
81 views

find command throws errors when inside function

I can run the following command in bash without any errors: $ find /d/Code/Web/Development/Source/ \( -name '*.cs' -o -name '*.cshtml' \) -exec grep -IH UserProfileModel {} \; I wrote a function in ...
3
votes
2answers
137 views

Preventing accidental directory deletion. Making an alias that contains options?

I use an alias to prevent me from accidentally deleting files, and I would like to do something similar for directories. For files, I have the following added to my .bashrc: alias rm="rm -i" I ...
0
votes
2answers
48 views

How can I cp different files to an alias that is changing

I would like to be able to replace cp x.x ~/some/long/directory/that/is/deeply/nested/ with cp x.x s1 where s1 is an alias that points to /some/long/directory/that/is/deeply/nested/ However the ...
0
votes
1answer
21 views

Whitelist virtual_alias_maps

I have one mailbox in postfix and several aliases to it. Is it possible to create whitelists for specific alias in order to allow only the addresses from the list to send messages. For example: ...
2
votes
4answers
494 views

What are commands to find shell keywords, built in functions and user defined functions?

I was discussing with my friend on how the commands are parsed in the shell, and he told me that bash searches the command in following order List of aliases List of shell keywords List of ...
4
votes
1answer
155 views

Help writing bash function as one-line alias

How do I write this as an alias? p() { DIR=~/projects/$@ pushd "$DIR" } This is as far as I got, but it's piping stdin to pushd instead of xargs: alias p="xargs printf ~/projects/%s | ...
6
votes
1answer
81 views

What are the side effects of having several UNIX users share one UID?

The sys-apps/shadow package on my GNU / Linux system comes with a useradd command that supports an option that I have previously overlooked: --non-unique. For the sake of convenience when shellig home ...
2
votes
3answers
47 views

How can I use an “alias” for the destination directory when copying?

I frequently edit startup files such as my .bashrc file Then I copy them to another direction such as ~/Dropnot/level1/setups/bash1 Is there any way I can cp such files to the above location with ...
11
votes
4answers
1k views

How can I find a rogue alias declaration?

I'm trying to find where a specific alias has been declared. I've searched all the usual places I know to look for aliases: ~/.bashrc ~/.bash_profile /etc/bashrc /etc/profile With no luck. I know ...
31
votes
6answers
22k views

Why doesn't my Bash script recognize aliases?

In my ~/.bashrc file reside two definitions: commandA, which is an alias to a longer path commandB, which is an alias to a Bash script I want to process the same file with these two commands, so I ...
3
votes
1answer
44 views

Customize bash to always include a certain parameter

When using the "ls" command, bash prints in the following format: file1 file2 file3 file4 file5 file6 file7 file8 But when given the parameter "-1", it prints: file1 file2 file3 etc... Is there ...
7
votes
5answers
178 views

How can I “stack” shell aliases?

In my .profile (sourced in sh emulation mode from my .zshrc) I have the following snippet: if [ -f /usr/bin/pacmatic ]; then alias pacman=pacmatic fi # Colorized Pacman output alias ...
1
vote
0answers
14 views

sticky alias command [duplicate]

I want to have the alias inst to be used instead of installpkg /tmp/ and then install packages by inst <pkg name>. But in normal alias define, We can not stick alias name to the package name and ...
0
votes
3answers
64 views

Assigning a command to variable

I assign command ls to my variable my_File but when I run it as $my_File it does not work. Can you please explain why? #!/bin/bash my_File='ls -f | grep -v '\/'' $my_File
2
votes
3answers
172 views

Simplified navigation in terminal

I know IDEs are the wave of the future, but I always find myself coding in vim in a Linux terminal. Old dog. New tricks. Anyway, navigation becomes challenging when dealing with long package names. ...
18
votes
1answer
2k views

Aliases vs functions vs scripts

This site says, "Shell functions are faster [than aliases]. Aliases are looked up after functions and thus resolving is slower. While aliases are easier to understand, shell functions are preferred ...
0
votes
0answers
23 views

User made host aliases [duplicate]

I would like to set up aliases for hosts /etc/hosts style, but I don't have root privileges. Would I be able to set these up from within my /home directory? How?