Skip to content
  • About
  • Cart
  • Checkout
  • Contact
  • Cookie Policy
  • Copyright Policy
  • Daily Free Giveaways
  • Disclaimer/Privacy Policy
  • Games
    • ABC Wordgame
    • Adrenoid
    • Bongo Ball
    • BRU
    • Mystic Temple
    • Pac-Xon
    • Pacman
    • Pirate Gem
    • SokoZone
    • Space Invaders
    • Super Mario Crossover
    • Tetris
    • Treasure Chain
  • Get Me A Password
  • Giveaways and Freebies
  • My account
  • Newsletter
  • Shop
  • Sitemap
I Have A PC

Tech Tutorials, Linux & Windows Tips

  • Home
  • Tech
  • Apps
  • Linux
  • Windows
  • Misc
  • Digital Wellness
  • Sitemap
  • About
  • Contact
I Have A PC

Tech Tutorials, Linux & Windows Tips

How To Setup Email Notifications For Root Login To Ubuntu Server

  • adminadmin
  • March 4, 2013
  • Linux, Linux Mint, Ubuntu

Having a root access to Linux server through SSH isn’t exactly a good idea in terms of security but in case if it is unavoidable then it can be helpful to setup a monitoring system that can email notifications immediately whenever root access is done.

To do this on an Ubuntu server :

1. First install an email routing program like sendmail by logging into the server with root credentials and typing :

[cc lang=”bash”]

apt-get install sendmail

[/cc]

installsendmail

2. After this, the .bashrc file needs to be edited for root. This file is the one that is read and all the commands in it are executed upon root login. Type :

[cc lang=”bash”]

cd /root

nano .bashrc

[/cc]

editrootbashrc

 

 

(The ls -a command will show all the hidden files with .bashrc being one of them.) Scroll down to the last line of .bashrc file and add the following :

[cc lang=”bash”]

echo ‘ALERT – Root Shell Access (yourserverIPaddress) on:’ `date` `who` | mail -s “Alert: Root Login From `who | cut -d”(” -f2 | cut -d”)” -f1`” [email protected]

[/cc]

editrootbashrc2

 

Save the changes and logout.

Now log back in as root via ssh, after a minute or two there will be an email notification at the specified email address stating that root login to server has occured from a specific IP address with timestamp.

root2

 

 

 

By the way, to completely disable root login via SSH, please refer to the earlier post on setting up Ubuntu SSH server here. To get more familiar with different Linux commands, please refer to our Linux command line basics primer here.

Cheers.

excel custom list settings
Previous Post How To Create A Custom List In Excel 2010
Next Post The Use Of Email Accounts : Funny
Use of email accounts : funny
No results
  • Bluesky
  • Email
  • Facebook
  • Twitter

A List of Giveaways

Free Giveaways

Free E-Books

Linux Command Line Cheatsheet
Linux Command Line Basics
Linux Shell Scripting Primer

Archives

Related Posts

10 useful linux devops commands

10 Useful Linux Commands that Every DevOps Should Know

  • July 15, 2026
understanding the wc command in linux

Demystifying wc: The Hidden Power of Linux’s Word Count Command

  • July 13, 2026
df command in linux

Linux Command to Quickly Check Your Free Disk Space 

  • June 8, 2026

Trending now

chrome 101
Google Chrome:Toggle On-Device Generative AI
SwifDoo PDF Anniversary Sale: iPhone 17 Giveaway & 84% Off
df command in linux
Linux Command to Quickly Check Your Free Disk Space 
cbackup professional giveaway
CBackup Premium Giveaway: Cloud Backup and Storage
Copyright © 2026 - WordPress Theme by CreativeThemes