Home  >  Article  >  Computer Tutorials  >  How to let all users print specified prompt information when logging in in Linux

How to let all users print specified prompt information when logging in in Linux

王林
王林forward
2024-02-19 17:12:24805browse

How to let all users print specified prompt information when logging in in Linux

In the Linux system, through configuration files and scripts, you can display the specified prompt information when all users log in. Next, we will introduce several commonly used implementation methods.

Method 1: Modify the /etc/issue file

  • Open the terminal and use a text editor (such as vi or nano) to edit the /etc/issue file with root permissions.
  • sudo vi /etc/issue
  • Add the prompt information you want to display at the end of the file, for example:
  • Welcome to My Linux System!
    Please be aware that all activities are monitored.
  • Save and close the file.
  • Now, when the user logs in, the system will display the prompt information added in the /etc/issue file.

    Method 2: Use the /etc/profile file

  • Open the terminal and use a text editor (such as vi or nano) to edit the /etc/profile file with root permissions.
  • sudo vi /etc/profile
  • Add the following code at the end of the file:
  • echo "Welcome to My Linux System!"
    echo "Please be aware that all activities are monitored."
  • Save and close the file.
  • Now, when the user logs in, the system will execute the code added in the /etc/profile file and display the corresponding prompt information.

    Method 3: Use /etc/update-motd.d/script

  • Open a terminal and use a text editor (such as vi or nano) to edit the /etc/update-motd.d/99-custom-message file with root permissions.
  • sudo vi /etc/update-motd.d/99-custom-message
  • Add the following code to the file:
  • #!/bin/sh
    echo "Welcome to My Linux System!"
    echo "Please be aware that all activities are monitored."
  • Save and close the file.
  • Grant execution permission to script:
  • sudo chmod +x /etc/update-motd.d/99-custom-message

    Now, when the user logs in, the system will execute the /etc/update-motd.d/99-custom-message script and display the corresponding prompt information.

    Method 4: Use the /etc/motd file

  • Open the terminal and use a text editor (such as vi or nano) to edit the /etc/motd file with root permissions.
  • sudo vi /etc/motd
  • Add the prompt information you want to display in the file, for example:
  • Welcome to My Linux System!
    Please be aware that all activities are monitored.
  • Save and close the file.
  • Now, when the user logs in, the system will display the prompt information added in the /etc/motd file.

    The above is the detailed content of How to let all users print specified prompt information when logging in in Linux. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete