Ubuntu tips and tricks: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Add categories: Linux, Reference)
(Template migration to LLM-Optimized Wiki Template)
Line 1: Line 1:
{{Status
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}


== apt-key deprecation warning when updating system: "Key is stored in legacy trusted.gpg keyring" ==
{{TOC}}
$ sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.d
 
== Overview ==
 
Ubuntu tips and tricks에 대한 기술 문서입니다.
 
=== Summary ===
 
* 무엇인가? - Ubuntu tips and tricks
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
 
---
 
== Purpose ==
 
이 문서가 존재하는 이유
 
* Goal: Ubuntu tips and tricks에 대한 기술 정보 제공
* Scope: Ubuntu tips and tricks의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장


== Disable Ubuntu scaning processes / candidates after package upgrades ==
---
Disable line that containes apt-pinvoke at /etc/apt/apt.conf.d/99needrestart<ref>https://serverfault.com/questions/1101391/disable-ubuntu-22-04s-scaning-processes-candidates-after-package-upgrades</ref>


== How to disable "Pending kernel upgrade" message?<ref>https://askubuntu.com/questions/1349884/how-to-disable-pending-kernel-upgrade-message</ref> ==
== Key Concepts ==
To disable "Pending kernel upgrade" via command line:


vim /etc/needrestart/needrestart.conf then uncomment this line
{| class="wikitable"
! Concept
! Description
! Related
|-
| Ubuntu tips and tricks
| HPC/서버 환경에서 중요한 기술 개념
| [[Linux]], [[Server]]
|}


<nowiki>#</nowiki>$nrconf{kernelhints} = -1;
---


== Detailed Explanation ==


$ sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.d
Disable line that containes apt-pinvoke at /etc/apt/apt.conf.d/99needrestart<ref>https://serverfault.com/questions/1101391/disable-ubuntu-22-04s-scaning-processes-candidates-after-package-upgrades</ref>
To disable "Pending [[kernel]] upgrade" via command line:
vim /etc/needrestart/needrestart.conf then uncomment this line
<nowiki>#</nowiki>$nrconf{kernelhints} = -1;
Or just replace them in one line:
Or just replace them in one line:
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf
== Check Secure Boot enabled or not ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ mokutil --sb-state
$ mokutil --sb-state
Line 32: Line 66:
         ....
         ....
     Signature Algorithm
     Signature Algorithm
        ...
</syntaxhighlight>


== Disable Ubuntu Pro marketing on APT updates<ref>https://ociotec.com/disable-ubuntu-pro-marketing-on-apt-updates/</ref> ==
---
This behaviour is configured via APT config file: <code>/etc/apt/apt.conf.d/20apt-esm-hook.conf</code>


So if we want to disable we need to delete it or just change its extension (more reversible):
== Best Practices ==


<code>sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak</code>
* 최신 버전 사용 권장
* 공식 문서 참고
* 테스트 환경에서 먼저 검증


== Set default text editor ==
---
<syntaxhighlight lang="bash">
$ sudo update-alternatives --config editor (on Ubuntu)
...
  Selection    Path                Priority  Status
------------------------------------------------------------
  0            /bin/nano            40        auto mode
  1            /bin/ed            -100      manual mode
  2            /bin/nano            40        manual mode
* 3            /usr/bin/vim.basic  30        manual mode
  4            /usr/bin/vim.tiny    15        manual mode


Press <enter> to keep the current choice[*], or type selection number: <enter the number>
== References ==
</syntaxhighlight>
 
== glibcxx_3.4.26 not found ==
<syntaxhighlight lang="bash">
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-9
sudo apt install libstdc++6


</syntaxhighlight>
* [https://wiki.hpcmate.com Ubuntu tips and tricks]


== Dealing with Old kernel ==
---
<syntaxhighlight lang="bash">
# get current running kernel
$export kv=$(uname -r | awk -F '-virtual' '{ print $1}')


# list all other installed kernel
== Related Pages ==
$dpkg --list | egrep -i 'linux-image|linux-headers' | awk '/ii/{ print $2}' | egrep -v "$kv"


# remove other kernels
* [[Linux]]
$sudo dpkg -r $(dpkg --list | egrep -i 'linux-image|linux-headers' | awk '/ii/{ print $2}' | egrep -v "$kv")
* [[Server]]
* [[Hardware]]
* [[Network]]


---
</syntaxhighlight>


== Remove GUI packages ==
<syntaxhighlight lang="bash">
#To remove x11 and everything that uses it, including all configuration:
$sudo apt-get purge -y libx11.* libqt.* libgtk.* xserver-xorg-core X11-* libwayland-*
$apt-get purge $(apt-cache depends gnome | grep Depends | awk '{print $2}')
$sudo apt-get autoremove -y
</syntaxhighlight>
== Switching boot target to text ==
<syntaxhighlight lang="bash">
$systemctl get-default                  #Find which target unit is used by default
$sudo systemctl set-default multi-user.target  #To change boot target to the text mode
$sudo systemctl reboot                  #Reboot the system
</syntaxhighlight>
== The following packages have been kept back<ref>https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it</ref> ==
There are 3 categories of reasons for packages being kept back during <code>apt upgrade</code>
* It is marked as held back
<code>apt-mark</code> can do this:
<code>sudo apt-mark hold <package></code>
To list all packages marked on hold or find out if a package is on hold use:
<apt-mark showhold
apt-mark showhold <package>
To remove a hold on a package and allow it to be upgraded:
<code>sudo apt-mark unhold <package></code>
* <code>apt</code> detects a dependency change
This will tell you the current and candidate upgrade versions of the package:
<code>$ apt list <package></code>
we can figure out the changed dependencies with <code>apt show</code>:
<code>apt show <package>=<old version> <package>=<new version></code>
The important parts are the <code>Depends</code> and <code>Recommends</code> package lists. If there are new packages in those lists in the new version of the kept back package, apt won't automatically upgrade it
# To upgrade the package and install any new "Recommended" packages (i.e. as if newly installed with apt install <package>, use --with-new-pkgs:<syntaxhighlight lang="bash">
$sudo apt upgrade --with-new-pkgs <package>
(Tip: add --dry-run to see what will happen before doing it)
</syntaxhighlight>
# To upgrade the package without installing any newly added "Recommended" packages, use --only-upgrade.
<syntaxhighlight lang="bash">
$sudo apt install --only-upgrade <package>
</syntaxhighlight>
* Phased updates<br />You can check for phased updates with: <code>sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade --dry-run</code>
== The following security updates require Ubuntu Pro with 'esm-infra' enabled ==
the file <code>/etc/apt/apt.conf.d/20apt-esm-hook.conf</code> provides the hook that calls the marketing message generation. Removing that is an option<ref>https://askubuntu.com/questions/1452299/im-getting-the-message-the-following-security-updates-require-ubuntu-pro-with</ref>
<code>sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /var/tmp</code>
after then  run <code>apt upgrade</code> the message does not show
== How to cleanly remove x11<ref>https://raspberrypi.stackexchange.com/questions/12670/how-to-cleanly-remove-x11</ref> ==
<syntaxhighlight lang="bash">
sudo apt purge 'x11-*'
sudo apt autoremove
</syntaxhighlight>
== apt-get update “the following signatures couldn’t be verified because the public key is not available” ==
<syntaxhighlight lang="bash">
$ sudo apt update
Err:5 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B53DC80D13EDEF05
 
#need to add the missing Key B53DC80D13EDEF05
$sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05
Executing: /tmp/apt-key-gpghome.xfmtcCbrXz/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05
gpg: key B53DC80D13EDEF05: 1 duplicate signature removed
gpg: key B53DC80D13EDEF05: public key "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)" imported
gpg: Total number processed: 1
gpg:              imported: 1
#now update will be successful
</syntaxhighlight>
== References ==
<references />
[[Category:Linux]]
[[Category:Linux]]
 
[[Category:Guide]]
[[Category:Reference]]

Revision as of 15:17, 16 July 2026

Template:Status

Template:TOC

Overview

Ubuntu tips and tricks에 대한 기술 문서입니다.

Summary

  • 무엇인가? - Ubuntu tips and tricks
  • 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
  • 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시

---

Purpose

이 문서가 존재하는 이유

  • Goal: Ubuntu tips and tricks에 대한 기술 정보 제공
  • Scope: Ubuntu tips and tricks의 개념, 사용법, 설정
  • Non-goals: 다른 주제로의 확장

---

Key Concepts

Concept Description Related
Ubuntu tips and tricks HPC/서버 환경에서 중요한 기술 개념 Linux, Server

---

Detailed Explanation

$ sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.d Disable line that containes apt-pinvoke at /etc/apt/apt.conf.d/99needrestart[1] To disable "Pending kernel upgrade" via command line: vim /etc/needrestart/needrestart.conf then uncomment this line #$nrconf{kernelhints} = -1; Or just replace them in one line: sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf

$ mokutil --sb-state
SecureBoot disabled
Platform is in Setup Mode

Ubuntu secure boot information<syntaxhighlight lang="bash">

$ mokutil --list-enrolled [key 1] SHA1 Fingerprint: 76:a0:92:06:58:00:bf:37:69:01:c3:72:cd:55:a9:0e:1f:de:d2:e0 Certificate:

   Data:
       Version: 3 (0x2)
       ....
   Signature Algorithm

---

Best Practices

  • 최신 버전 사용 권장
  • 공식 문서 참고
  • 테스트 환경에서 먼저 검증

---

References

---

Related Pages

---