通常我们可以~/.bashrc使用这个命令来获取文件
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
但是如果我在 shell 脚本中编写并执行它,则什么也不会发生。为什么?
有没有办法做到这一点?
我的脚本:
#!/bin/bash
chmod a+x ~/.bashrc
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
也试过.(dot) 而不是source. 结果一样。
我将如何使这个/media/De Soft/mongodb/binPATH 变量永久化?
每个人都在说“export PATH=$PATH:media/De\ Soft/mongodb/bin对您的~/.profile, 或.bashrc, 或.zshenv取决于您的外壳”。
我不知道什么是~/.profile、 或.bashrc、 或.zshenv。他们实际上是做什么的?
我将如何添加export PATH=$PATH:my/path到我的 .profile/.bashrc/.zshenv?
我正在使用带有默认终端的 64 位 Ubuntu 14.04 LTS。
登录和非登录 shell 定义为:
su - $USER # will give you a login shell
bash # will give you a non-login shell
Run Code Online (Sandbox Code Playgroud)
/etc/profile 不会为非登录 shell 调用,例如当您启动 konsole (kde) 时。/etc/profile 仅为登录 shell 调用。
这是为什么?请解释一下,因为我喜欢了解其原理。
刚刚安装了 Ubuntu 14.04.1 LTS。
根据.profile,
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash, if ~/.bash_profile or ~/.bash_login exists.
Run Code Online (Sandbox Code Playgroud)
没有 ~/.bash_profile 或 ~/.bash_login。
打开终端时似乎没有来源 .profile 。
我有 Ubuntu 14.04.2。我想让所有用户自动拥有一组特定的别名。我在个人 .bashrc 中设置了别名,但我不想手动将它们复制到其他用户中。理想情况下,它也应该为新创建的用户自动设置这些。
我想将我所有的登录配置集中在我的~/.bash_profile. ~/.bashrc默认情况下有一个那里,但我用一个~/.bash_profile.
但是,当我登录时,在~/.bash_profile获取源之前的某些内容并显示以下内容:
Linux ubnt10-dev1 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Fri May 9 12:17:39 EDT 2014
System load: 0.01 Processes: 74
Usage of /: 5.5% of 18.58GB Users logged in: 0
Memory usage: 4% IP address for eth0: 123.x.x.x
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
New …Run Code Online (Sandbox Code Playgroud) 为什么当我尝试将一个函数仅在一行中写入.bashrc文件时,
list(){ ls -a }
Run Code Online (Sandbox Code Playgroud)
我得到错误?
bash: /home/username/.bashrc: line num: syntax error: unexpected end of file
Run Code Online (Sandbox Code Playgroud)
但是当我用多行写它时可以吗?
list(){
ls -a
}
Run Code Online (Sandbox Code Playgroud) 通过在终端中键入手动指定的命令,我想执行一些其他命令。
如何为命令添加别名?我可以在终端的帮助下做到这一点还是应该编辑某种文件?
我需要将以下行添加到 Ubuntu 中 .bashrc 文件的末尾。如何使用脚本自动添加这些行。如果我运行脚本,它会自动在 .bashrc 文件的末尾插入行。
export APP="/opt/tinyos-2.x/apps"
export TOS="/opt/tinyos-2.x/tos"
Run Code Online (Sandbox Code Playgroud) 到目前为止,我曾经在bash.bashrc文件中设置环境变量。最近我被告知要使用该/etc/environment文件。嗯,两者都工作正常。
那么,它们之间有什么区别呢?
我用谷歌搜索了这个,我发现“bashrc 用于特定的用户和环境,系统范围”。这里的系统范围是什么意思?/etc/bash.bashrc我猜也在系统范围内应用更改。如果我错了,请纠正我。任何形式的帮助将不胜感激..