2

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?

Thanks you, sorry for my English)

2
  • For zsh edit /etc/zsh/zprofile or /etc/zsh/zshrc Commented Oct 1, 2014 at 8:01
  • 1
    Just a friendly word of advice... when modifying it, keep a second Terminal window open logged in as root, and as you modify it, test it in another Terminal window and if you mess it up you will still be logged in and able to correct any mistakes... Commented Oct 1, 2014 at 8:08

3 Answers 3

5

You should start by reading the manpage of every shell on your system.

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:

  • sh (and bash) use /etc/profile and ~/.profile
  • bash also uses ~/.bash_profile, ~/.bashrc, ~/.bash_logout
  • csh uses /etc/.login and ~/.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.

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).

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).

2
  • ok, ty, but there is any way to understand with shell this user use and not modify files for all shells?
    – PepeHands
    Commented Oct 1, 2014 at 8:07
  • 1
    sure, check the user's default shell in /etc/passwd - that is the shell the user will get when logging in (however, it does not guarantee that the user won't invoke another shell after logging in).
    – isedev
    Commented Oct 1, 2014 at 8:10
2

They both execute different files:

From fro 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/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

A login shell begins by executing commands from the system files /etc/csh.cshrc and /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
2
  • So does it mean I have to modify files for each shell he can use?
    – PepeHands
    Commented Oct 1, 2014 at 8:08
  • 1
    No , if you use the soft ln ln -s you can have a single file (ex. /etc/profile) and different links to it.
    – Panciz
    Commented Oct 1, 2014 at 8:09
0

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.

1
  • I think you'd better ask a separate question. You will get a fast and well writen asnwer (I hope). I'm not sure I understood your problem correctly but I think I don't know the answer.
    – PepeHands
    Commented Feb 24, 2016 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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