Is it possible to put commands in /etc/motd? The 2019 Stack Overflow Developer Survey Results...
Arduino Pro Micro - switch off LEDs
ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?
Wall plug outlet change
Problems with Ubuntu mount /tmp
Windows 10: How to Lock (not sleep) laptop on lid close?
Do warforged have souls?
Match Roman Numerals
Working through the single responsibility principle (SRP) in Python when calls are expensive
Simulating Exploding Dice
What's the point in a preamp?
How did passengers keep warm on sail ships?
Does Parliament need to approve the new Brexit delay to 31 October 2019?
Are my PIs rude or am I just being too sensitive?
Is every episode of "Where are my Pants?" identical?
How to delete random line from file using Unix command?
Cooking pasta in a water boiler
In horse breeding, what is the female equivalent of putting a horse out "to stud"?
The following signatures were invalid: EXPKEYSIG 1397BC53640DB551
How to test the equality of two Pearson correlation coefficients computed from the same sample?
What can I do if neighbor is blocking my solar panels intentionally?
He got a vote 80% that of Emmanuel Macron’s
Python - Fishing Simulator
Does Parliament hold absolute power in the UK?
What aspect of planet Earth must be changed to prevent the industrial revolution?
Is it possible to put commands in /etc/motd?
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm 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
174k78371726
174k78371726
asked Dec 19 '12 at 4:09
JustinJustin
1,883114368
1,883114368
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
3
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,5891429
1,5891429
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
3
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
3
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 33 mins ago
Stewi
31
31
answered Dec 19 '12 at 4:12
ewwhiteewwhite
174k78371726
174k78371726
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
3
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
3
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
3
3
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?