The gateway to the terminal in the Linux system

Source: Internet
Author: User

Demand:

Login to the Linux host via SSH, the host can only execute specific scripts or programs, how to constrain?


    1. First configure/ETC/BASH.BASHRC The file will be executed each time the new shell is opened;

    2. Add the Execute script or program path to the BASH.BASHRC file;

    3. For a script or program, you cannot have a statement that exits the program, and it should remain in the script or program in exceptional cases.


such as adding

Python3 ~/my_python_project/my_jump/main/main.py

To BASH.BASHRC, each time a shell is started, only the corresponding Python code is executed. Note To open the file with root privileges.


Appendix

The role of other bash profiles

/etc/profile: This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects the shell settings from the configuration file of the/ETC/PROFILE.D directory.
/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use, when the user logs on, the file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.
~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
~/.bash_logout: Executes the file each time it exits the system (exiting the Bash shell).

In addition, the variables set in/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, etc. (local) only inherit variables from/etc/profile, they are "parent-child" relationships.


This article is from the "Kaman" blog, make sure to keep this source http://3155037.blog.51cto.com/3145037/1959706

The gateway to the terminal in the Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.