우분투에서 motd(Message of the Day) 메시지를 비활성화하는 방법(.hushlogin)
Ubuntu에서 motd(Message of the Day) 메시지를 비활성화하는 방법 중 하나는 .hushlogin 파일을 사용하는 것입니다. 이 파일은 사용자의 홈 디렉터리에 만들어지며 사용자가 로그인할 때 motd 메시지를 표시하지 않도록 합니다.
- 터미널 로그인
ssh test-server
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-30-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sun May 22 12:54:54 PM KST 2022
System load: 0.0
Usage of /: 24.1% of 44.97GB
Memory usage: 64%
Swap usage: 1%
Processes: 262
Users logged in: 0
IPv4 address for br-3d8ea60954a0: 192.168.224.1
IPv4 address for br-a7ad4eb9f84c: 172.18.0.1
IPv4 address for docker0: 172.17.0.1
IPv4 address for ens160: 172.30.1.217
* Super-optimized for small spaces - read how we shrank the memory
footprint of MicroK8s to make it the smallest full K8s around.
https://ubuntu.com/blog/microk8s-memory-optimisation
0 updates can be applied immediately.
Last login: Fri May 20 20:36:24 2022 from 172.30.1.217
testuser@test-server:~$
.hushlogin 파일을 사용하여 motd 메시지를 비활성화
1 터미널을 열고 사용자의 홈 디렉터리로 이동합니다. 예를 들어, 사용자의 홈 디렉터리로 이동하려면 다음과 같이 명령을 실행합니다.
cd ~
2 .hushlogin 파일을 생성하거나 편집합니다. 만약 파일이 이미 존재하지 않는다면 다음 명령어를 사용하여 파일을 생성합니다.
touch .hushlogin
만약 파일이 이미 존재한다면 다음과 같이 파일을 편집하거나 생성할 수 있습니다.
vim .hushlogin
위 명령어는 nano 편집기를 사용하는 예시입니다. 다른 텍스트 편집기를 사용해도 무방합니다.
3 .hushlogin 파일을 저장하고 닫습니다.
4 이제 motd 메시지가 사용자의 로그인 시에 표시되지 않아야 합니다.
.hushlogin 파일을 생성하면 사용자가 로그인할 때 motd 메시지를 비활성화할 수 있습니다. 이 파일을 제거하면 다시 motd 메시지가 표시됩니다.
/etc/update-motd.d/ 디렉터리에 있는 스크립트를 사용하여 시스템 정보를 비활성화
Ubuntu에서 /etc/update-motd.d/ 디렉터리에 있는 스크립트를 사용하여 시스템 정보를 비활성화하려면 해당 스크립트를 비활성화하거나 수정해야 합니다. 이 디렉터리에 있는 스크립트는 로그인 시에 모티드(Message of the Day) 메시지를 생성하는 데 사용됩니다.
1 /etc/update-motd.d/ 디렉터리의 스크립트를 확인합니다. 이 디렉터리에는 다양한 스크립트가 포함되어 있으며 각각 다른 시스템 정보를 표시합니다.
$ ls -l /etc/update-motd.d/*
-rwxr-xr-x 1 root root 1220 Oct 15 2021 /etc/update-motd.d/00-header
-rwxr-xr-x 1 root root 1157 Oct 15 2021 /etc/update-motd.d/10-help-text
lrwxrwxrwx 1 root root 46 Feb 18 2023 /etc/update-motd.d/50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x 1 root root 5023 Oct 15 2021 /etc/update-motd.d/50-motd-news
-rwxr-xr-x 1 root root 84 Sep 20 2022 /etc/update-motd.d/85-fwupd
-rwxr-xr-x 1 root root 106 Jul 17 2021 /etc/update-motd.d/88-esm-announce
-rwxr-xr-x 1 root root 218 Jan 21 2023 /etc/update-motd.d/90-updates-available
-rwxr-xr-x 1 root root 263 Feb 8 2023 /etc/update-motd.d/91-contract-ua-esm-status
-rwxr-xr-x 1 root root 558 Feb 10 2023 /etc/update-motd.d/91-release-upgrade
-rwxr-xr-x 1 root root 165 Feb 19 2021 /etc/update-motd.d/92-unattended-upgrades
-rwxr-xr-x 1 root root 379 Jan 21 2023 /etc/update-motd.d/95-hwe-eol
-rwxr-xr-x 1 root root 111 Aug 18 2020 /etc/update-motd.d/97-overlayroot
-rwxr-xr-x 1 root root 142 Jan 21 2023 /etc/update-motd.d/98-fsck-at-reboot
-rwxr-xr-x 1 root root 144 Jan 21 2023 /etc/update-motd.d/98-reboot-required
2 불필요한 스크립트를 비활성화하려면 해당 스크립트의 실행 권한을 제거합니다. 예를 들어, 스크립트 이름이 50-motd-news라면 다음 명령어를 사용하여 실행 권한을 제거할 수 있습니다
sudo chmod -x /etc/update-motd.d/*
이렇게 하면 해당 스크립트가 더 이상 실행되지 않습니다.
3. 필요한 경우 /etc/update-motd.d/ 디렉터리의 스크립트를 직접 편집하여 원하는 내용을 제어할 수 있습니다. 스크립트를 수정하려면 sudo 권한이 필요합니다.
4. 모티드 메시지를 재생성하려면 다음 명령어를 실행합니다.
sudo run-parts /etc/update-motd.d/
이렇게 하면 /etc/update-motd.d/ 디렉터리에 있는 스크립트를 실행하지 않게 되며, 시스템 정보가 메시지에 표시되지 않습니다. 필요한 경우 해당 디렉터리의 스크립트를 활성화하거나 편집하여 원하는 메시지를 나타낼 수 있습니다.
motd(/etc/motd) 파일을 설정하는 방법
- echo 명령어로 /etc/motd 파일 생성
echo "hello!" > /etc/motd
사용자가 로그인할 때 /etc/motd 파일에 설정한 메시지가 표시됩니다.
- 터미널 로그인
ssh test-server
hello!
Last login: Sun May 22 18:56:41 2022 from 172.30.1.217
testuser@test-server:~$
주의: /etc/motd 파일은 시스템 업데이트나 재부팅 후에도 변경 내용이 유지됩니다. 원할 경우 언제든지 이 파일을 수정하여 메시지를 변경하거나 업데이트할 수 있습니다.
'리눅스' 카테고리의 다른 글
.bashrc 파일을 생성하는 방법 (1) | 2023.09.14 |
---|---|
Cloudflare 프록시 환경에서 Nginx의 액세스 로그에 클라이언트의 실제 IP 주소를 남기는 방법 (0) | 2023.09.13 |
우분투에서 Docker 데몬의 로그를 관리하는 방법 (0) | 2023.09.13 |
Kafka Broker 및 ZooKeeper의 버전을 확인하는 방법 (0) | 2023.09.12 |
CentOS 7에서 ImageMagick을 설치하고 테스트하는 방법 (0) | 2023.09.12 |