bash 修改 /etc/profile linux
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26136710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
modifying /etc/profile linux
提问by PepeHands
I need to change the greeting of user, which is logging in. So I modifyed file /etc/profile
. In this greeting I need to know, which shell this user use and tell it to user. The problem is that then I change my shell on zsh
or csh
it doesnt work. Even if I just type in this file echo $SHELL
it do nothing. As I think, when I use csh
and zsh
this file (/etc/profile
) doesnt run at all. How can I fix this problem?
我需要更改正在登录的用户的问候语。所以我修改了文件/etc/profile
. 在此问候语中,我需要知道该用户使用哪个 shell 并将其告诉用户。问题是,然后我更改了我的外壳,zsh
否则csh
它不起作用。即使我只是输入这个文件,echo $SHELL
它也什么都不做。因为我觉得,当我使用csh
与zsh
这个文件(/etc/profile
所有)犯规运行。我该如何解决这个问题?
Thanks you, sorry for my English)
谢谢你,对不起我的英语)
回答by isedev
You should start by reading the manpage of every shell on your system.
您应该首先阅读系统上每个 shell 的联机帮助页。
There are different flavours of shells. Each flavours uses slightly different (per session and per shell, per site and per user) initialisation files. For example:
有不同口味的贝壳。每种风格使用略有不同的(每个会话和每个 shell、每个站点和每个用户)初始化文件。例如:
sh
(andbash
) use/etc/profile
and~/.profile
bash
also uses~/.bash_profile
,~/.bashrc
,~/.bash_logout
csh
uses/etc/.login
and~/.cshrc
sh
(和bash
)使用/etc/profile
和~/.profile
bash
还使用~/.bash_profile
,~/.bashrc
,~/.bash_logout
csh
使用/etc/.login
和~/.cshrc
etc...
等等...
The above list is not meant to be exhaustive. It is to illustrate you will need to check the exact behaviour of each shell that is used on your system and configure it appropriately.
以上列表并非详尽无遗。这是为了说明您需要检查系统上使用的每个 shell 的确切行为并对其进行适当的配置。
You also need to consider whether you want to change system-wide behaviour (corresponding to initialisation files under /etc
) or user-specific behaviour (corresponding to initialisation files in the user's home directory).
您还需要考虑是要更改系统范围的行为(对应于 下的初始化文件/etc
)还是用户特定的行为(对应于用户主目录中的初始化文件)。
For certain shells, there's also per-session (i.e. once per login) and per-shell settings (e.g. for every terminal window). A good example is ~/.bash_login
(executed once per login) and ~/.bashrc
(executed for every shell - e.g. terminal window).
对于某些 shell,还有每个会话(即每次登录一次)和每个 shell 设置(例如每个终端窗口)。一个很好的例子是~/.bash_login
(每次登录执行一次)和~/.bashrc
(为每个 shell 执行 - 例如终端窗口)。
回答by Panciz
They both execute different files:
它们都执行不同的文件:
From fro zsh http://zsh.sourceforge.net/Guide/zshguide02.html
来自 zsh http://zsh.sourceforge.net/Guide/zshguide02.html
Now here's a list of the startup files and when they're run. You'll see they fall into two classes: those in the /etc directory, which are put there by the system administrator and are run for all users, and those in your home directory, which zsh, like many shells, allows you to abbreviate to a `~'.
现在这里是启动文件的列表以及它们何时运行。你会看到它们分为两类:那些在 /etc 目录中,由系统管理员放在那里并为所有用户运行,以及在你的主目录中,像许多 shell 一样,zsh 允许你缩写到一个`~'。
/etc/zshenv
Always run for every zsh.
~/.zshenv
Usually run for every zsh (see below).
/etc/zprofile
Run for login shells.
~/.zprofile
Run for login shells.
/etc/zshrc
Run for interactive shells.
~/.zshrc
Run for interactive shells.
/etc/zlogin
Run for login shells.
~/.zlogin
for csh http://unixhelp.ed.ac.uk/CGI/man-cgi?csh+1
对于 csh http://unixhelp.ed.ac.uk/CGI/man-cgi?csh+1
A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login.
登录外壳程序从执行系统文件 /etc/csh.cshrc 和 /etc/csh.login 中的命令开始。
You can make a soft link to point to the same file:
您可以创建一个软链接以指向同一个文件:
ln -s /etc/profile /etc/zshenv
ln -s /etc/profile /etc/csh.login
回答by arslion
I have modified my etc/profile file to start a python script on startup. now my program is running but there is a black screen, because my program has a while True loop in it and now I am not able to stop it. Kindly tell me how to stop the program, I have tried ctrl+C but nothing happened.
我修改了我的 etc/profile 文件以在启动时启动 python 脚本。现在我的程序正在运行但出现黑屏,因为我的程序中有一个 while True 循环,现在我无法停止它。请告诉我如何停止程序,我试过 ctrl+C 但什么也没发生。