Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to shorten

sudo http_proxy="http://proxy:port" apt-get ______ 


sudo rep apt-get ________

Is this possible to implement in Ubuntu?


So I added

alias rapt-get="http_proxy="" apt-get"

to my ~/.bash_aliases. I have other working aliases in this file.

If I type rapt-get in the terminal, I get:

apt 0.8.16~exp12ubuntu10 for amd64 compiled on Apr 20 2012 10:19:39
Usage: apt-get [options] command
       apt-get [options] install|remove pkg1 [pkg2 ...]
       apt-get [options] source pkg1 [pkg2 ...]

apt-get is a simple command line interface for downloading and installing packages. The most frequently used commands are update and install.


update - Retrieve new lists of packages
upgrade - Perform an upgrade
install - Install new packages (pkg is libc6 not libc6.deb)
remove - Remove packages
autoremove - Remove automatically all unused packages
purge - Remove packages and config files
source - Download source archives
build-dep - Configure build-dependencies for source packages
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
clean - Erase downloaded archive files
autoclean - Erase old downloaded archive files
check - Verify that there are no broken dependencies
changelog - Download and display the changelog for the given package
download - Download the binary package into the current directory


-h  This help text.
-q  Loggable output - no progress indicator
-qq No output except for errors
-d  Download only - do NOT install or unpack archives
-s  No-act. Perform ordering simulation
-y  Assume Yes to all queries and do not prompt
-f  Attempt to correct a system with broken dependencies in place
-m  Attempt to continue if archives are unlocatable
-u  Show a list of upgraded packages as well
-b  Build the source package after fetching it
-V  Show verbose version numbers
-c=? Read this configuration file
-o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual pages for more information and options.
This APT has Super Cow Powers. Seems to be working. But if i type `sudo rapt-get update`, I get 

sudo: rapt-get: command not found

(Sorry for the formatting issues, I'm on through mobile and can't see the formatting bar)

share|improve this question
One of the problems may be the use of " in the alias. To use a " in your command, prepend it with a "\" so that it looks like this alias rapt-get="http_proxy=\"\" apt-get" – i08in Feb 24 '13 at 23:27

You can also make an sh script that reads input, inserts it into the command and runs it. I would upload a file like that for you, but I do not have access to my computer.

share|improve this answer

This depends on your /etc/sudoers settings as well. For starters, as pointed out, the alias won't even be available within the sudo context. However, you could adjust your alias to say:

alias rapt-get='http_proxy="" sudo apt-get'

i.e. include the variable that you set for this invocation. If you wanted sudo to take this over from the user's context you'll have to edit /etc/sudoers in order to add the variable name to the env_check or env_keep setting. Quoting man sudoers:

By default, the env_reset option is enabled. This causes commands to be executed with a minimal environment containing TERM, PATH, HOME, MAIL, SHELL, LOGNAME, USER and USERNAME in addition to variables from the invoking process permitted by the env_check and env_keep options. This is effectively a whitelist for environment variables.

share|improve this answer

~/.bashrc adds aliases for you, and only you

sudo runs as root. Even though you may have administrator access, your user is not root.

So, add your alias to ~root/.bashrc (generally this is /root/.bashrc).

If you'd like to add this alias for all users, add it to /etc/profile

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.