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

王林
Release: 2024-02-19 17:12:24
forward
804 people have browsed it

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
    Copy after login
  • 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.
    Copy after login
    Copy after login
  • 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
    Copy after login
  • 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."
    Copy after login
  • 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
    Copy after login
  • Add the following code to the file:
  • #!/bin/sh
    echo "Welcome to My Linux System!"
    echo "Please be aware that all activities are monitored."
    Copy after login
  • Save and close the file.
  • Grant execution permission to script:
  • sudo chmod +x /etc/update-motd.d/99-custom-message
    Copy after login

    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
    Copy after login
  • 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.
    Copy after login
    Copy after login
  • 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!

    Related labels:
    source:mryunwei.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template