{"id":196,"date":"2011-09-18T16:53:00","date_gmt":"2011-09-18T16:53:00","guid":{"rendered":"http:\/\/pheonixsolutions.com\/?p=196"},"modified":"2026-04-27T09:27:57","modified_gmt":"2026-04-27T03:57:57","slug":"root-login-alert","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/root-login-alert\/","title":{"rendered":"How to Enable Root Login Alerts on a Linux Server"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Monitoring root access is critical for maintaining server security. By enabling root login alerts, you can receive instant email notifications whenever someone logs in as the root user. This helps in detecting unauthorized access and improves overall system auditing on your Linux server.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, ensure the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You have <strong>root or sudo access<\/strong> to the server<\/li>\n\n\n\n<li>A <strong>mail service (like sendmail\/postfix)<\/strong> is properly configured on the server<\/li>\n\n\n\n<li>You have a valid <strong>email address<\/strong> to receive alerts<\/li>\n\n\n\n<li>Basic familiarity with Linux command line editors<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps to Enable Root Login Alerts<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Login to Server<\/strong><br>Access your server via SSH and switch to root user:<br><code>$ su -<\/code><\/li>\n\n\n\n<li><strong>Navigate to Root Directory<\/strong><br>$ <code>cd \/root<\/code><\/li>\n\n\n\n<li><strong>Edit .bashrc File<\/strong><br>Open the file using an editor:<br>$ <code>pico .bashrc<\/code><\/li>\n\n\n\n<li><strong>Add Alert Command<\/strong><br>Scroll to the end of the file and add the following line:<br>$ <code>echo 'ALERT \u2013 Root Shell Access (YourServerName) on:' `date` `who` | mail -s \"Alert: Root Access from `who | cut -d\"(\" -f2 | cut -d\")\" -f1`\" you@yourdomain.com <\/code><br>Replace:\n<ul class=\"wp-block-list\">\n<li><strong>YourServerName<\/strong> \u2192 Your actual server name<\/li>\n\n\n\n<li><strong><a href=\"mailto:you@yourdomain.com\">you@yourdomain.com<\/a><\/strong> \u2192 Your email address<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Save the File<\/strong><br>Press:\n<ul class=\"wp-block-list\">\n<li><code>Ctrl + X<\/code><\/li>\n\n\n\n<li>Then <code>Y<\/code><\/li>\n\n\n\n<li>Press <code>Enter<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Enabling root login alerts is a simple yet effective way to enhance server security. By receiving real-time notifications, you can quickly identify and respond to any unauthorized or unexpected root access, helping safeguard your system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Monitoring root access is critical for maintaining server security. By enabling root login alerts, you can receive instant email [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-3a","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":3,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":10050,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions\/10050"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}