Questions tagged [alias]
In shells, an alias is an alternate name for a command. For instance, "ll" is an alias for "ls -l" on many systems.
411
questions
556
votes
6
answers
419k
views
How to see the command attached to a bash alias?
Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?
532
votes
10
answers
1.2m
views
How do I create a permanent Bash alias?
I would like to create an alias to rm command in order to have a confirmation message after executing this command. So I am creating an alias like this alias rm='rm -i'. But as far as I know this is a ...
385
votes
3
answers
513k
views
How do I remove an alias?
I want to remove gs alias from my PC. When I type gs it will open GhostScript. But I checked everywhere in the home directory .alias .bash_aliases .bashrc
I also overwrite the gs with my custom ...
235
votes
8
answers
113k
views
Aliases not available when using sudo
I was playing around with aliases today and I noticed that aliases don't seem to be available whilst using sudo:
danny@kaon:~$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
...
202
votes
11
answers
378k
views
How to run an alias in a shell script?
I have an executable file mpiexec, whose full path is ~/petsc-3.2-p6/petsc-arch/bin/mpiexec. Since I want to execute this command in different directories (without having to retype the entire path), ...
115
votes
6
answers
196k
views
Bypass the yes/no prompt in 'apt-get upgrade'
In order avoid typing out all of the apt-get commands when updating my computer I have made a simple alias command to do it. But I really want to be able to just type in my alias and let it do its ...
94
votes
1
answer
223k
views
How to make a permanent alias in oh-my-zsh?
In my .zshrc I tried to make a few aliases .I looked into a lot of places, but I couldn't find out a way that worked. I used this code below:
# Set personal aliases, overriding those provided by oh-...
73
votes
4
answers
128k
views
How can I preset aliases for all users?
I have Ubuntu 14.04.2. I want to make it so all users automatically have a specific set of aliases. I have my aliases set in my personal .bashrc, but I don't want to have to manually copy them into ...
55
votes
5
answers
79k
views
What command is the alias ll for?
Can someone tell me what terminal command the alias ll is for? All I can find online is many people saying that it is an alias for ls -l or ls -la or ls -ltr. But that's simply wrong. The result looks ...
51
votes
8
answers
119k
views
How to add an alias to a command in terminal?
By typing a manually specified command in terminal I want to execute some other command.
How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of ...
50
votes
3
answers
65k
views
Is there a way to echo an alias? [duplicate]
I have set some aliases in my .bashrc file and for some reason one of them does not behave as expected.
Since I don't remember the exact command assigned to that alias, I would like to see the ...
41
votes
4
answers
66k
views
Can I pass arguments to an alias command?
I want to know if I can pass an argument with an alias command.
for example:
alias d="dmesg | grep -iw usb | tail -5"
Now d will print the last 5 lines. If I want to use d to print a ...
37
votes
6
answers
45k
views
How can I create an alias for cd and ls?
I frequently run the ls command after running the cd command. How can I create an alias (like cs) for this operation?
36
votes
5
answers
11k
views
How can I run the original command that I also have aliased with same name?
I have an alias for the ls command in my ~/.bashrc file aliased with this one:
alias ls='ls --color=auto'
When I run the ls command in a terminal, the aliased ls (ls --color=auto) runs.
My question ...
30
votes
2
answers
54k
views
Understanding .bashrc and .bash_profile
On a server when I login as root I see .bashrc (Ubuntu 10.10).
On my Mac I have a .bash_profile
Does Ubuntu always have only a .bashrc file and not .bash_profile? (I'm just confused, so asking, I ...
30
votes
3
answers
35k
views
Multi line alias in bash
I have the following script. It's a simple test case where a is any string value and b is supposed to be a path.
#!/bin/bash
alias jo "\
echo "please enter values "\
read a \
read -e b \
echo "My ...
27
votes
4
answers
56k
views
How save my "alias" entries forever [duplicate]
I want to save my alias commands forever like the default ones when I type "alias" so I don't retype them every time I leave my bash
27
votes
6
answers
92k
views
bash: alias: alias: not found
When I log in, I see the error:
bash: alias: alias: not found
If I source my .bashrc file, the message appears again.
What is causing this?
23
votes
10
answers
12k
views
Which aliases do you find most useful or helpful to your Ubuntu experience?
Since first becoming an Ubuntu user I have developed a growing list of aliases, and there are some that I cannot imagine being without. This makes me think that there are probably still tons of ...
23
votes
2
answers
55k
views
How can I protect parentheses passed to a cd command? [duplicate]
I asked here how to make cd protect spaces. Tab completion is great, but sometimes you paste the path from the clipboard so this is useful.
The solution breaks with parentheses however. No matter how ...
22
votes
5
answers
24k
views
Create alias for ssh connecting
I'd like to speed up connecting to specific servers.
I have the servers let's say:
123.123.123.1
123.123.123.2
123.123.123.3
I normally connect with the following:
ssh -p 12345 [email protected]....
22
votes
3
answers
66k
views
How to find aliases?
Where can I find a list/file of all aliases created in Ubuntu 17.04?
I mean shortcuts for commands most frequently used and more.
20
votes
3
answers
12k
views
What does the l command do?
There is a command l available on my machine which appears to do nothing. which l also produces no output. Is this a real command, and does it actually do anything?
19
votes
3
answers
4k
views
My .bashrc alias not run in .desktop file
I've added the following line to the .bashrc file:
alias midos="sh /home/erkanmdr/Belgeler/midos/midos.sh"
This command works fine in the terminal and tty.
But not working in my .desktop shortcut ...
18
votes
4
answers
151k
views
How do I add an additional IP address to an interface in Ubuntu 14
I want to have the wired interface simultaneously obtain a DHCP address, and also alias a fixed address so I can communicate with a device with a fixed IP address on a different subnet over the same ...
17
votes
1
answer
6k
views
Bash alias -=... (alias name should be a simple dash) not working
I want to create an alias for cd - which should be just a dash (-).
I tried without success:
alias -='cd -' # bash: alias: -=: Invalid option
alias \-='cd -' # bash: alias: -=: Invalid option
...
17
votes
2
answers
4k
views
Why doesn't the "watch" command work on an alias?
I made my customized alias command and tried to use it with alias, but my alias was not recognized while concatenated with the watch command.
So I tried to make a thread of it and fortunately, this ...
16
votes
2
answers
35k
views
How can I create an alias so that when I enter "kt" it executes "killall gnome-terminal"?
How can I create an alias so that when I enter "kt" it executes "killall gnome-terminal"?
16
votes
5
answers
28k
views
Why is setting alias in .profile not working?
I have this as the last line in my .profile:
alias gl="cd /home/jrenner/glances/glances"
yet even after reboot I get command not found when typing gl. What is happening? I am logged in as the ...
16
votes
1
answer
18k
views
Why doesn't my alias work over ssh?
I have an alias defined in my .bashrc
alias l.='ls -d .* --color=auto'
It's very useful :) but it doesn't work via ssh:
$ ssh localhost l.
bash: l.: command not found
Why is that?
14
votes
4
answers
2k
views
Alias to go to newest folder in a folder
We have robot results created into separate folders in format of "result-yyyy-mm-dd-hh-mm-ss" and I currently have this in my bash_aliases
alias res="VAR=$(ls --directory /path/to/...
14
votes
1
answer
12k
views
Should I put an alias in .bashrc or .profile?
I want the following alias to be available each time I open a shell:
export ZONE="us-eastern1-c"
export INSTANCE_NAME="myInstance"
alias gc='gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -...
13
votes
1
answer
4k
views
Removing ghostscript alias
I'm using zsh which uses gs as an alias for git status. But on Ubuntu, gs is an alias for ghostscript. I tried uninstalling ghostscript, but then I get this instead:
The program 'gs' is currently not ...
12
votes
2
answers
35k
views
Location of "~/.bash_aliases"
I want to make permanent aliases in Terminal, and I have read this answer on how to do it: https://askubuntu.com/a/5278/364819
But I have got a small problem, I have found the code:
if [ -f ~/....
12
votes
4
answers
7k
views
Can I use cd../.. as an alias name?
I am using Windows and Ubuntu in parallel and do console stuff on both of them.
On Windows I can do a
C:\Users\Thomas>cd..\..
C:\>
However, on Linux this does not work, neither with ...
12
votes
3
answers
37k
views
alias of nodejs as node on 14.04
I installed nodejs with apt-get on 14.04
When I do nodejs -v
v0.10.25
and when i do node -v
node : command not found.
So I want to alias of nodejs to node
I inserted a line in ~/.bashrc
alias ...
12
votes
2
answers
10k
views
SSH with a user alias?
This question is not a duplicate. Please read it before you mark it as such.
Is it possible to assign nicknames or aliases to users on a Linux sever and SSH into the server using the nicknames? I am ...
12
votes
1
answer
9k
views
Aliases: difference between .bash_rc, .bash_aliases and /usr/local/bin
Playing around with Terminal, I noticed that there are many ways to create permanent aliases.
I'm a Linux newbie, and from what I know, doing:
sudo ln -s /path/to/executable /usr/local/bin/...
11
votes
2
answers
16k
views
"syntax error near unexpected token" after editing .bashrc
I'm trying to access the clipboard but when I input source ~/.bashrc in the terminal I get this error:
bash: /home/taran/.bashrc: line 2: syntax error near unexpected token ('
bash: /home/taran/....
11
votes
3
answers
983
views
Can I use '!!' in aliases or scripts?
In the Terminal I can use !! which will reference my previous command. Is it possible to use this in an alias? I have tried it, but what happens is that the double exclamation marks are interpreted ...
11
votes
2
answers
3k
views
What does the first '.' mean in '. ~/.bashrc'? [duplicate]
I saw a post about fix your alias in .bashrc.
And he says after you put your alias in .bashrc , you need to use:
. ~/.bashrc
I do not quite understand what the first dot(' . ') does here. What's ...
11
votes
2
answers
34k
views
add alias to root
I need to execute a command for my system to search for new sd cards and to be able to execute it I need to execute it as root. Simply using sudo with the command does not work. This is not a question ...
11
votes
3
answers
16k
views
Where is the alias for "ll" defined?
I often find myself using ll which is an alias.
$ type ll
ll is an alias for ls -lh
I always wondered where this was defined as it works both on bash, zsh but not on sh:
# THIS IS SH
$ ll
sh: 1: ll:...
10
votes
4
answers
2k
views
Prevent all commands from being defined as an alias
Is there a way to prevent all commands from being defined as an alias?
For example a user shouldn't be able to define rm or any other command (Ubuntu default commands) as an alias name.
10
votes
2
answers
1k
views
Show Shell Function in Ubuntu Terminal
Over the years I've moved away from using aliases to defining functions in a .functions file that I source at the time of launching the shell. This works fine, but one feature of alias that I miss is ...
10
votes
3
answers
3k
views
how to 'not' execute alias [duplicate]
I have set few aliases in .bashrc file. I need those aliases most of the time, but sometimes I need to run those command without options set in that particular alias.
How to not execute alias command?...
10
votes
1
answer
16k
views
Aliases don't work after restart terminal
I have create few new aliases in ~/.bashrc then run source ~/.bashrc and it worked. But after restart terminal it does not work. I looked back and found the advice: create ~/.bash_aliases and in ~/....
10
votes
2
answers
4k
views
What is the correct way to create alias to snap package in Ubuntu 16.04?
TL;DR
How to create system wide alias to snap package in Ubuntu 16.04?
More details
I would like to install Blender as a snap. I found, that there is blender-tpaw package which can be installed. ...
9
votes
5
answers
23k
views
Run program from anywhere without changing directory
I wish to create an alias, which runs program x, without changing the current directory I am in. What I have now is:
alias x = "cd /home/path_to_x && ./x"
This works, but changes my ...
9
votes
2
answers
3k
views
Create multiple shell aliases at once
I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?
alias at|cart|cst '/bin/cat'