polaryeti Posted June 23, 2023 Share Posted June 23, 2023 I've read tidbits of pages from around 10 books, and I can safely say I am even more confused than before. Earlier I'd just set everything in .bashrc file. LOL. Say I've scenarios like these: 1) I want to set system variables for user "jacky", what should I use? 2) I want to set system variables for all users, what should I use? 3) I want to set alias for user "jacky", what should I use? 4) I want to set alias for all users, what should I use? What are interactive/non-interactive login/non-login shells? I've asked chatgpt but it gave me convoluted reply. So, it was not very clear. Quote Link to comment https://forums.phpfreaks.com/topic/316996-not-understanding-when-to-use-~bashrc-etcprofile-~bash_profile-or-~profile/ Share on other sites More sharing options...
requinix Posted June 23, 2023 Share Posted June 23, 2023 1/2. What do you mean by "system variable"? 3/4. What do you mean by "alias"? 5. Interactive means you can do stuff, non-interactive means you can't do stuff, and non-login means you can't even log in. Is there something specific about those terms that you think you're missing? Quote Link to comment https://forums.phpfreaks.com/topic/316996-not-understanding-when-to-use-~bashrc-etcprofile-~bash_profile-or-~profile/#findComment-1609945 Share on other sites More sharing options...
gizmola Posted June 23, 2023 Share Posted June 23, 2023 You won't get one answer because conventions vary by linux distribution can vary by shell bourne shell tends to be a base System scripts do things at boot time and runlevel changes bash is a backwards compatible with sh, but has many extra features Config works with sh/bash/ksh/csh, but anything you do should be bourne shell syntax Other shells have become popular, and are even the default on newer os's (as in OSX now defaulting to zsh) If you're using a newer shell like zsh or fish, then they typically have their own config files you need to research Long story short: Read the /etc/profile script and the /etc/bashrc script. Often one or both will include scripts in a directory like /etc/profile.d If that is already working, you should place scripts that customize things for all users in that directory rather than modifying the /etc/profile or /etc/bashrc script directly. Individual settings should be done in the user's home directory use ~/.profile or ~/.bashrc Aliases are not part of the bourne shell, so you are utilizing a shell specific extension Bash often supports other files like ~/.bash_aliases As for types of shells: Login shell facilitates login, and will run commands in the files mentioned previously An interactive shell is connected to a tty so that the user can interact with it. It will also have certain default settings like job control enabled A non-interactive shell is used for scripts, since the user will not be interacting This old serverfault thread provides a good summary of the configuration files loaded. Quote Link to comment https://forums.phpfreaks.com/topic/316996-not-understanding-when-to-use-~bashrc-etcprofile-~bash_profile-or-~profile/#findComment-1609947 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.