In shells, an alias is an alternate name for a command. For instance, "ll" is an alias for "ls -l" on many systems.

learn more… | top users | synonyms

62
votes
6answers
111k 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 ...
38
votes
4answers
14k 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?
35
votes
2answers
9k 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' ...
21
votes
6answers
7k 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?
20
votes
4answers
13k 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
20
votes
4answers
33k 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), ...
18
votes
1answer
19k views

How to remove an alias?

I want to remove gs alias from my PC. When type gs it will open the Ghost Script. But I checked everywhere in the home directory .alias .bash_aliases .bashrc I also overwrite the gs with my custom ...
16
votes
7answers
2k 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 ...
15
votes
3answers
357 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 ...
11
votes
5answers
1k views

How can I run original command that aliased with same name?

An alias for ls command in ~/.bashrc file aliased with this one: alias ls='ls --color=auto' then, when I run ls command in terminal aliased ls(ls --color=auto) runs. but my question is how can I ...
11
votes
6answers
14k views

How to add an alias to a command in terminal?

By typing a manually specified command in terminal i want to do some. 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 file?
9
votes
2answers
1k 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 ...
9
votes
2answers
10k 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 ...
8
votes
4answers
564 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 ...
8
votes
2answers
782 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?
7
votes
5answers
590 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 ...
7
votes
1answer
900 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 ...
6
votes
3answers
3k views

Is there a way to echo an alias?

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 ...
6
votes
2answers
1k 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"?
6
votes
2answers
174 views

Is there a way to shorten(not remove) the path displayed in the terminal by an alias

I want something like this: "vivek@grishma:~/xxx/yyy/zzz/src$" to be shown as "vivek@grishma:datasource$" where I would somehow have predefined "datasource" to be an alias for the long path above. ...
5
votes
2answers
5k views

How to protecting cd command to deal with parentheses?

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 ...
5
votes
3answers
170 views

How do I make a custom path identifier?

To define what I mean by "custom path identifier", I mean a short set of character(s) that represent a whole path, and example of this would be the ~, if you type cd ~ in your Terminal Emulator it ...
5
votes
2answers
196 views

How to easily make an alias command permanent? [duplicate]

I search everywhere and almost everyone was suggesting to open the ~/.bashrc or ~/.bash_aliases, then put the alias command there, I created a function name palias as permanent alias function and put ...
4
votes
2answers
132 views

Create alias with paramater in the middle

I want to create an alias for grep like this: grep argX ~/myfile where argX is a parameter and myfile is always the same. How can I do this?
4
votes
6answers
225 views

Overriding a executable to add a default flag

Here's my boggle. I use gmplayer to play all my videos. 99.9% of the time everything works fine but in that 1-in-1000 case, a video might be corrupted. gmplayer plays the video but it cries like an ...
4
votes
1answer
2k 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/esecutable ...
4
votes
2answers
372 views

Working directory when running command

I've got an executable, let's call it exec. It lives in a directory, for the sake of argument called dir. Let's say it's at the filesystem root. I can run this executable by doing cd /dir ./exec ...
4
votes
2answers
164 views

How can I create something similar to an alias, that does properly expand to the initial command?

I have set up aliases for apt-get update, apt-get install, and so on. Thats quite convenient. But what I really would like to have is something like this: type agi TAB vi and have it automatically ...
4
votes
1answer
6k views

Undertanding .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? (just confused so asking, I realize ...
4
votes
1answer
2k 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 ...
4
votes
1answer
342 views

How to run some alias command in bash's non-interactive mode

I want to run some alias command in bash's non-interactive mode. But seems Ubuntu ignore BAHS_ENV. How can I make it work? la is a alias command. And I tested in other linux. it is work fine. Just ...
4
votes
1answer
223 views

How can you mirror an autocomplete function in your own aliases (in 14.04)

I have a bunch of aliases that I've used on my 12.04 machine. example: alias pssh="tsocks ssh" alias pscp="tsocks scp" alias prdp="tsocks xfreerdp ..........SOMETHING ...." These aliases are ...
3
votes
1answer
261 views

Why doesn't this command work as an alias?

I've been using the following command to list the ten largest files, at any depth, under the current directory: find -type f -size +10M -exec ls -gGsSh1 {} + | awk 'NR<=10 {print $0}' (I use awk ...
3
votes
1answer
247 views

Saw an interesting command but can't alias it

Saw an command from this post http://askubuntu.com/a/266839/75967 that I would like to alias find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less I assume the less or the | is ...
3
votes
1answer
868 views

Bash aliases - how do I run a file in a different folder without losing my current location?

I have a nice little bash alias in my .bashrc folder that allows me to start Tomcat running without having to cd into the folder first, e.g. alias startTomcat="cd ~/apache-tomcat-7.0.34/bin/ ...
3
votes
1answer
258 views

When I open Terminal it says command alias not found and closes

I was messing around in Terminal (bad idea, I know, but I'm usually pretty good with it) and now it does what the title says. I know about pressing Control-C to stop it from running, but how do I just ...
3
votes
2answers
3k views

Differences between fish and bash to pass commandline arguments to alias functions?

From the answers to my other question here i learned about the possibility to pass commandline arguments to a alias function in Bash. In Fish i can edit an alias by editing the file config.fish in ...
3
votes
1answer
207 views

Aliases - able to pass arguments?

I want to make an alias in my .bashrc or .bashrc_aliases file (probably the latter). Specifically, I want to call the clang command for my *.c file I'm writing. What I'm looking for is best summed up ...
3
votes
1answer
3k views

Ubuntu alias not applied in bashrc

I am under Ubuntu 12.04 LTS. I have added such line to ~/.bashrc alias myconf="sudo nano /opt/nginx/conf/sites-available/efiling" I tried with single quotes too: alias myconf='sudo nano ...
3
votes
2answers
150 views

Batch Starting Servers

How I can create a batch alias for bash? I need to do this: cd /somefolder bundle exec unicorn -p 3000 rackup faye.ru -s thin -E production bundle and rackup - this is 2 servers for example I ...
3
votes
2answers
62 views

Create an alias to a desidred directory to use within terminal [duplicate]

I constantly need to type cd /home/geo/Geant4/geant4.10.00.p02-install/lib/Geant4-10.0.2 How do i create an alias to that directory so I could just type cd $geant (or any other word i decide to ...
3
votes
1answer
674 views

Autocomplete on .bash_aliases commands?

I have a whole bunch of aliased commands in .bash_aliases The most generic examples are alias apt-update="sudo apt-get update" alias apt-upgrade="sudo apt-get dist-upgrade" but then I also have ...
3
votes
2answers
464 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 me logged on as root. Simply using sudo with the command does not work. This is not a ...
3
votes
3answers
846 views

How to run source on terminal start up?

I have alias ready on .bash_aliases. Problem I'm having right now is that I need to run source ~/.<filename> first before I can execute the alias command. My question would be how do I run ...
2
votes
1answer
141 views

Is there a way to alias the command cd so that it protects the arguments?

When I run cd My folder There is an error because I have not protected the string. bash: cd: My: No such file or directory But this works fine cd "My folder" Is there a way to redefine cd as an ...
2
votes
3answers
227 views

How to check if alias is not replacing an actual command?

How can I know if an alias I make (in .bash_aliases) is not replacing an actual command by same name? I don't want to do such things by accident. (I looked in "Questions that may already have your ...
2
votes
2answers
131 views

How to add a password option in CLI?

I've googled extensively but haven't found how to add a password option so I don't have to type it in manually. I've created the following alias: alias int='sudo service network-manager restart' ...
2
votes
2answers
127 views

How do I create an alias that displays the contents of a `history list`?

How do I create a new alias command called cet103demo which displays the contents of the bash history list one page at a time, and also making sure the new alias is automatically loaded when the ...
2
votes
1answer
700 views

Why must I do `. .bash_profile` every time I create a new alias?

Every time I add a new alias in my .bash_profile file, I found that I must do the command . .bash_profile in my terminal to make it work. Why does the alias not work automatically?
2
votes
2answers
71 views

Problem in creating alias, get strange messages

[Reviewers: note that the question was completely rewritten after the close votes.] I recently found how I can define aliases for bash in the ~/.bashrc. But since I tried that, I see the followig ...