Code Monkey home page Code Monkey logo

bash's Introduction

Get started

git pull https://github.com/jintonic/bash.git
cd bash
./install

Understand BASH configuration files

BASH provides login/non-login and interactive/non-interactive shells. Here are some examples:

  • login shell:
    • login from console (interactive)
    • ssh (interactive)
    • non-interactive shell with --login option (non-interactive)
  • non-login shell:
    • open a new terminal emulator inside X (interactive)
    • invoke bash from command line (interactive)
    • scp (non-interactive)
    • run bash script (non-interactive)

A login shell loads the system configuration file /etc/profile first, and then try to load user configuration files in the following order:

  1. ~/.bash_profile
  2. ~/.bash_login
  3. ~/.profile

If one of the above is found, the rest will be ignored.

A non-login shell loads only ~/.bashrc.

The non-login interactive shell is the mostly used one, e.g. open an xterm and start type in command. $PATH and aliases should be available for this type of shells. They hence need to be set in ~/.bashrc. A login interactive shell needs also $PATH and aliases. ~/.bashrc hence needs to be sourced inside ~/.profile.

A non-login non-interactive shell will load ~/.bashrc, but doesn't need fancy stuff such as aliases in it, the following command needs to be put at the beginning of ~/.bashrc before stuff that aren't needed in a non-interactive shell:

# If not running interactively, just set PATH
PATH=.:~/bin:$PATH
[ -z "$PS1" ] && return

A shell script started with #!/bin/sh doesn't load any configuration files. If it is invoked in an interactive shell, it inherits all the setup from that shell. If it is invoked in a non-interactive shell, it loads nothing.

bash's People

Contributors

jintonic avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.