> ## Documentation Index
> Fetch the complete documentation index at: https://docs.idocs.fyi/llms.txt
> Use this file to discover all available pages before exploring further.

# Display Login Information on Ubuntu Console

> Custom Information on Ubuntu Login.

To display custom information to users after they log into an Ubuntu system via the console or SSH, you can use several standard approaches. The most common and effective methods are:

* Using `/etc/motd` (Message of the Day)
* Customizing shell profile files (`.bashrc`, `.profile`)
* Creating system-wide scripts in `/etc/profile.d/`

This document explains each method in detail.

## Method 1: Using `/etc/motd` (Message of the Day)

The `/etc/motd` file displays a message to users **after successful login**.

### Step 1: Edit the `/etc/motd` File

```
sudo nano /etc/motd
```

### Step 2: Add Custom Information

```
********************************************************************
* Welcome to the server!                                           *
*                                                                  *
* System Information:                                              *
* - Hostname: $(hostname)                                          *
* - Date: $(date)                                                  *
* - Uptime: $(uptime -p)                                           *
* - Users: $(who | wc -l) users logged in                          *
********************************************************************
```

> ⚠️ **Note:**\
> `/etc/motd` does **not** evaluate shell commands.\
> Variables like `$(hostname)` will appear as plain text unless you use `/etc/update-motd.d/` scripts.

### Step 3: Save and Exit

Press `Ctrl + X`, then `Y`, and press `Enter`.

## Method 2: Using Shell Profile Files (`.bashrc` / `.profile`)

Shell profile files allow you to run commands automatically when a user logs in.

### Step 1: Edit Profile File

#### For a Specific User

```
nano ~/.bashrc
```

#### For All Users (Global)

```
sudo nano /etc/bash.bashrc
```

### Step 2: Add Login Message Script

```
echo "********************************************************************"
echo "* Welcome to the server!                                           *"
echo "*                                                                  *"
echo "* System Information:                                              *"
echo "* - Hostname: $(hostname)                                          *"
echo "* - Date: $(date)                                                  *"
echo "* - Uptime: $(uptime -p)                                           *"
echo "* - Users: $(who | wc -l) users logged in                          *"
echo "********************************************************************"
```

> ✅ **Best for:**
>
> * Dynamic output
> * Per-user customization

### Step 3: Save and Exit

Press `Ctrl + X`, then `Y`, and press `Enter`.

## Method 3: Using a Custom Script in `/etc/profile.d/` (Recommended)

Scripts placed in `/etc/profile.d/` run automatically for **all users** during login.

### Step 1: Create a Custom Script

```
sudo nano /etc/profile.d/welcome.sh
```

### Step 2: Add Script Content

```
#!/bin/bash

echo "********************************************************************"
echo "* Welcome to the server!                                           *"
echo "*                                                                  *"
echo "* System Information:                                              *"
echo "* - Hostname: $(hostname)                                          *"
echo "* - Date: $(date)                                                  *"
echo "* - Uptime: $(uptime -p)                                           *"
echo "* - Users: $(who | wc -l) users logged in                          *"
echo "********************************************************************"
```

### Step 3: Make the Script Executable

```
sudo chmod +x /etc/profile.d/welcome.sh
```
