Is it possible to put commands in /etc/motd? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern) Come Celebrate our 10 Year Anniversary!Run a script in /etc/motdWhat is the difference between a 'Login' and an 'Interactive' bash shellStop ssh login from printing motd from the client?Display different motd file based on groupShowing total progress in rsync: is it possible?protocol version mismatch — is your shell clean?There are two MOTD's shown when I login to my server using SSHHow to make a dynamic motd-module in Puppet?Re-install motd after /motd-update directory has been cleanedUnable/remove last login information from MOTD when login using a shell into Linux /Slackware 13.37/Showing the IP in the banner before login
How to compare two different files line by line in unix?
Electrolysis of water: Which equations to use? (IB Chem)
Why are my pictures showing a dark band on one edge?
Google .dev domain strangely redirects to https
In musical terms, what properties are varied by the human voice to produce different words / syllables?
Should a wizard buy fine inks every time he want to copy spells into his spellbook?
What's the point of the test set?
Why can't I install Tomboy in Ubuntu Mate 19.04?
macOS: Name for app shortcut screen found by pinching with thumb and three fingers
What does 丫 mean? 丫是什么意思?
Antipodal Land Area Calculation
What is the meaning of 'breadth' in breadth first search?
Putting class ranking in CV, but against dept guidelines
Dyck paths with extra diagonals from valleys (Laser construction)
What does it mean that physics no longer uses mechanical models to describe phenomena?
Why are vacuum tubes still used in amateur radios?
Sliceness of knots
What order were files/directories output in dir?
Project Euler #1 in C++
A term for a woman complaining about things/begging in a cute/childish way
Karn the great creator - 'card from outside the game' in sealed
How does Belgium enforce obligatory attendance in elections?
Is there hard evidence that the grant peer review system performs significantly better than random?
What to do with repeated rejections for phd position
Is it possible to put commands in /etc/motd?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Run a script in /etc/motdWhat is the difference between a 'Login' and an 'Interactive' bash shellStop ssh login from printing motd from the client?Display different motd file based on groupShowing total progress in rsync: is it possible?protocol version mismatch — is your shell clean?There are two MOTD's shown when I login to my server using SSHHow to make a dynamic motd-module in Puppet?Re-install motd after /motd-update directory has been cleanedUnable/remove last login information from MOTD when login using a shell into Linux /Slackware 13.37/Showing the IP in the banner before login
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Can I put shell commands in the /etc/motd
login banner file? I have tried:
$(uptime)
and
`uptime`
Is this possible?
linux motd
add a comment |
Can I put shell commands in the /etc/motd
login banner file? I have tried:
$(uptime)
and
`uptime`
Is this possible?
linux motd
add a comment |
Can I put shell commands in the /etc/motd
login banner file? I have tried:
$(uptime)
and
`uptime`
Is this possible?
linux motd
Can I put shell commands in the /etc/motd
login banner file? I have tried:
$(uptime)
and
`uptime`
Is this possible?
linux motd
linux motd
edited Dec 20 '12 at 16:30
ewwhite
175k78371727
175k78371727
asked Dec 19 '12 at 4:09
JustinJustin
1,888114368
1,888114368
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
/etc/motd
is only read and not executed, so technically speaking, you cannot put shell commands in there.
However, it's possible to execute a shell script at login time that will have the same result. This is usually achieved by adapting the /etc/profile
script that is executed each time a user logs in. A useful practice is to put the command you want to be executed in a script named /etc/motd.sh
and call this script from /etc/profile
, usually at about the end of it.
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
You can place themotd.sh
script inside/etc/profile.d/
with permissions755
. This way you wouldn't need to call it from/etc/profile
.
– Itay Grudev
May 31 '16 at 19:28
add a comment |
In Ubuntu servers there is a program called update-motd
from package libpam-modules
:
UNIX/Linux system adminstrators often communicate important information
to console and remote users by maintaining text in the file /etc/motd,
which is displayed by the pam_motd(8) module on interactive shell
logins.
Traditionally, this file is static text, typically installed by the
distribution and only updated on release upgrades, or overwritten by
the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
This collection of scripts lives under /etc/update-motd.d/
. For more information see this wiki page.
Another alternative to generating /etc/motd
, instead of having a script run at login is to have a cron job. Certainly it is not the same, but I have met this approach sometimes in the past.
1
Related askubuntu post. Force withsudo run-parts /etc/update-motd.d/
.
– Pablo Bianchi
Oct 3 '17 at 22:25
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex thanuptime
).
– ayman
Oct 15 '17 at 1:41
add a comment |
Yes, it's possible... Sorta.
Look up creating a dynamic MOTD. This is an abbreviated form of this documented process.
Do I just need to addsession optional pam_motd.so
to/etc/pam.d/login
then make/etc/motd
executable?
– Justin
Dec 19 '12 at 4:21
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to/etc/profile
, so this is equivalent to Tonin's answer.
– Andre Holzner
Apr 4 '14 at 7:14
add a comment |
protected by HopelessN00b Mar 10 '16 at 10:48
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
/etc/motd
is only read and not executed, so technically speaking, you cannot put shell commands in there.
However, it's possible to execute a shell script at login time that will have the same result. This is usually achieved by adapting the /etc/profile
script that is executed each time a user logs in. A useful practice is to put the command you want to be executed in a script named /etc/motd.sh
and call this script from /etc/profile
, usually at about the end of it.
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
You can place themotd.sh
script inside/etc/profile.d/
with permissions755
. This way you wouldn't need to call it from/etc/profile
.
– Itay Grudev
May 31 '16 at 19:28
add a comment |
/etc/motd
is only read and not executed, so technically speaking, you cannot put shell commands in there.
However, it's possible to execute a shell script at login time that will have the same result. This is usually achieved by adapting the /etc/profile
script that is executed each time a user logs in. A useful practice is to put the command you want to be executed in a script named /etc/motd.sh
and call this script from /etc/profile
, usually at about the end of it.
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
You can place themotd.sh
script inside/etc/profile.d/
with permissions755
. This way you wouldn't need to call it from/etc/profile
.
– Itay Grudev
May 31 '16 at 19:28
add a comment |
/etc/motd
is only read and not executed, so technically speaking, you cannot put shell commands in there.
However, it's possible to execute a shell script at login time that will have the same result. This is usually achieved by adapting the /etc/profile
script that is executed each time a user logs in. A useful practice is to put the command you want to be executed in a script named /etc/motd.sh
and call this script from /etc/profile
, usually at about the end of it.
/etc/motd
is only read and not executed, so technically speaking, you cannot put shell commands in there.
However, it's possible to execute a shell script at login time that will have the same result. This is usually achieved by adapting the /etc/profile
script that is executed each time a user logs in. A useful practice is to put the command you want to be executed in a script named /etc/motd.sh
and call this script from /etc/profile
, usually at about the end of it.
edited Dec 20 '12 at 17:08
answered Dec 20 '12 at 16:43
ToninTonin
1,5991429
1,5991429
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
You can place themotd.sh
script inside/etc/profile.d/
with permissions755
. This way you wouldn't need to call it from/etc/profile
.
– Itay Grudev
May 31 '16 at 19:28
add a comment |
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
You can place themotd.sh
script inside/etc/profile.d/
with permissions755
. This way you wouldn't need to call it from/etc/profile
.
– Itay Grudev
May 31 '16 at 19:28
3
3
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
it's not a common practise to use /etc/motd.sh
– user130370
Dec 20 '12 at 16:51
1
1
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
@EricDANNIELOU Yes, one can use whatever script name he/she wants. I just removed the common adjective that was not appropriate. Still, having it named this way makes it easy to spot and know what purpose it serves.
– Tonin
Dec 20 '12 at 17:18
1
1
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
There seems to be a way of using cron to regularly replace the static motd message: md3v.com/create-a-linux-server-status-motd I think that this profile script seems to be a better way, less moving parts.
– CMCDragonkai
May 30 '14 at 1:42
4
4
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
Putting output like a MOTD in your profile is likely to break sftp.
– Stuart P. Bentley
Aug 17 '14 at 20:54
4
4
You can place the
motd.sh
script inside /etc/profile.d/
with permissions 755
. This way you wouldn't need to call it from /etc/profile
.– Itay Grudev
May 31 '16 at 19:28
You can place the
motd.sh
script inside /etc/profile.d/
with permissions 755
. This way you wouldn't need to call it from /etc/profile
.– Itay Grudev
May 31 '16 at 19:28
add a comment |
In Ubuntu servers there is a program called update-motd
from package libpam-modules
:
UNIX/Linux system adminstrators often communicate important information
to console and remote users by maintaining text in the file /etc/motd,
which is displayed by the pam_motd(8) module on interactive shell
logins.
Traditionally, this file is static text, typically installed by the
distribution and only updated on release upgrades, or overwritten by
the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
This collection of scripts lives under /etc/update-motd.d/
. For more information see this wiki page.
Another alternative to generating /etc/motd
, instead of having a script run at login is to have a cron job. Certainly it is not the same, but I have met this approach sometimes in the past.
1
Related askubuntu post. Force withsudo run-parts /etc/update-motd.d/
.
– Pablo Bianchi
Oct 3 '17 at 22:25
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex thanuptime
).
– ayman
Oct 15 '17 at 1:41
add a comment |
In Ubuntu servers there is a program called update-motd
from package libpam-modules
:
UNIX/Linux system adminstrators often communicate important information
to console and remote users by maintaining text in the file /etc/motd,
which is displayed by the pam_motd(8) module on interactive shell
logins.
Traditionally, this file is static text, typically installed by the
distribution and only updated on release upgrades, or overwritten by
the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
This collection of scripts lives under /etc/update-motd.d/
. For more information see this wiki page.
Another alternative to generating /etc/motd
, instead of having a script run at login is to have a cron job. Certainly it is not the same, but I have met this approach sometimes in the past.
1
Related askubuntu post. Force withsudo run-parts /etc/update-motd.d/
.
– Pablo Bianchi
Oct 3 '17 at 22:25
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex thanuptime
).
– ayman
Oct 15 '17 at 1:41
add a comment |
In Ubuntu servers there is a program called update-motd
from package libpam-modules
:
UNIX/Linux system adminstrators often communicate important information
to console and remote users by maintaining text in the file /etc/motd,
which is displayed by the pam_motd(8) module on interactive shell
logins.
Traditionally, this file is static text, typically installed by the
distribution and only updated on release upgrades, or overwritten by
the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
This collection of scripts lives under /etc/update-motd.d/
. For more information see this wiki page.
Another alternative to generating /etc/motd
, instead of having a script run at login is to have a cron job. Certainly it is not the same, but I have met this approach sometimes in the past.
In Ubuntu servers there is a program called update-motd
from package libpam-modules
:
UNIX/Linux system adminstrators often communicate important information
to console and remote users by maintaining text in the file /etc/motd,
which is displayed by the pam_motd(8) module on interactive shell
logins.
Traditionally, this file is static text, typically installed by the
distribution and only updated on release upgrades, or overwritten by
the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is
dynamically assembled from a collection of scripts at login.
This collection of scripts lives under /etc/update-motd.d/
. For more information see this wiki page.
Another alternative to generating /etc/motd
, instead of having a script run at login is to have a cron job. Certainly it is not the same, but I have met this approach sometimes in the past.
answered Jun 26 '15 at 8:55
WtowerWtower
494510
494510
1
Related askubuntu post. Force withsudo run-parts /etc/update-motd.d/
.
– Pablo Bianchi
Oct 3 '17 at 22:25
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex thanuptime
).
– ayman
Oct 15 '17 at 1:41
add a comment |
1
Related askubuntu post. Force withsudo run-parts /etc/update-motd.d/
.
– Pablo Bianchi
Oct 3 '17 at 22:25
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex thanuptime
).
– ayman
Oct 15 '17 at 1:41
1
1
Related askubuntu post. Force with
sudo run-parts /etc/update-motd.d/
.– Pablo Bianchi
Oct 3 '17 at 22:25
Related askubuntu post. Force with
sudo run-parts /etc/update-motd.d/
.– Pablo Bianchi
Oct 3 '17 at 22:25
1
1
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex than
uptime
).– ayman
Oct 15 '17 at 1:41
This also minimizes the startup login lag since you don't have to evaluate a script at login (assuming it gets more complex than
uptime
).– ayman
Oct 15 '17 at 1:41
add a comment |
Yes, it's possible... Sorta.
Look up creating a dynamic MOTD. This is an abbreviated form of this documented process.
Do I just need to addsession optional pam_motd.so
to/etc/pam.d/login
then make/etc/motd
executable?
– Justin
Dec 19 '12 at 4:21
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to/etc/profile
, so this is equivalent to Tonin's answer.
– Andre Holzner
Apr 4 '14 at 7:14
add a comment |
Yes, it's possible... Sorta.
Look up creating a dynamic MOTD. This is an abbreviated form of this documented process.
Do I just need to addsession optional pam_motd.so
to/etc/pam.d/login
then make/etc/motd
executable?
– Justin
Dec 19 '12 at 4:21
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to/etc/profile
, so this is equivalent to Tonin's answer.
– Andre Holzner
Apr 4 '14 at 7:14
add a comment |
Yes, it's possible... Sorta.
Look up creating a dynamic MOTD. This is an abbreviated form of this documented process.
Yes, it's possible... Sorta.
Look up creating a dynamic MOTD. This is an abbreviated form of this documented process.
edited Apr 14 at 2:59
Stewi
32
32
answered Dec 19 '12 at 4:12
ewwhiteewwhite
175k78371727
175k78371727
Do I just need to addsession optional pam_motd.so
to/etc/pam.d/login
then make/etc/motd
executable?
– Justin
Dec 19 '12 at 4:21
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to/etc/profile
, so this is equivalent to Tonin's answer.
– Andre Holzner
Apr 4 '14 at 7:14
add a comment |
Do I just need to addsession optional pam_motd.so
to/etc/pam.d/login
then make/etc/motd
executable?
– Justin
Dec 19 '12 at 4:21
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to/etc/profile
, so this is equivalent to Tonin's answer.
– Andre Holzner
Apr 4 '14 at 7:14
Do I just need to add
session optional pam_motd.so
to /etc/pam.d/login
then make /etc/motd
executable?– Justin
Dec 19 '12 at 4:21
Do I just need to add
session optional pam_motd.so
to /etc/pam.d/login
then make /etc/motd
executable?– Justin
Dec 19 '12 at 4:21
4
4
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Iain
Dec 19 '12 at 12:10
The dynamic MOTD link essentially says you can add commands which print a message to
/etc/profile
, so this is equivalent to Tonin's answer.– Andre Holzner
Apr 4 '14 at 7:14
The dynamic MOTD link essentially says you can add commands which print a message to
/etc/profile
, so this is equivalent to Tonin's answer.– Andre Holzner
Apr 4 '14 at 7:14
add a comment |
protected by HopelessN00b Mar 10 '16 at 10:48
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?