Ubuntu 14 在 /etc/apt/sources.list.d 下创建文件

Ubuntu 14 creating file under /etc/apt/sources.list.d

我正在尝试在 Ubuntu 14 上安装 postgree,如下所述: http://www.postgresql.org/download/linux/ubuntu/

并尝试在 /etc/apt/sources.list.d 目录中创建文件:

sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list

但出现此错误:

bash: /etc/apt/sources.list.d/pgdg.list: Permission denied

我应该怎么做?

您应该参考 this answered question :“重定向是在 sudo 启动之前由 shell 完成的。”