Skip to content

Ubuntu Tips#

Disable Silent Boot#

  • Open and edit the grub file with path as below:
1
sudo gedit /etc/default/grub
  • Then find the GRUB_CMDLINE_LINUX_DEFAULT and edit it as below.
1
GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=skip"

Apply Unity Login Screen On 22.04#

Setup Unity Login Style#

  • Install lightdm and unity-greeter
1
sudo apt install lightdm unity-greeter
  • Then you will see a display manager screen. Choose Ok --> choose lightdm.
  • Once installed, restart your computer and you’ll see the new login screen.
  • Configure LightDM login screen:
  • Open terminal (Ctrl+Alt+T) and run command to install dconf-editor if you don’t have it:
1
sudo apt install dconf-editor
  • Next, run command to grant lightdm user privilege to access control list:
1
xhost +SI:localuser:lightdm

Finally launch dconf editor via lightdm:

1
sudo -u lightdm dconf-editor
  • When it opens, navigate to “com/canonical/unity-greeter“ to change login background.

How to Restore Gnome Login Screen:#

  • To revert back the original GDM display manager. Firstly, open terminal and run command to disable LightDM:
1
sudo systemctl disable lightdm.service
  • Then launch the configure screen by running the command below:
1
sudo dpkg-reconfigure lightdm
  • This time choose gdm3 to handle the login screen and hit Enter.
  • Finally, remove lightdm as well as its dependency packages via command:
1
sudo apt remove --autoremove lightdm unity-greeter

Disable Automatic Airplane Mode When Lib Is Open#

  • For laptop user, there could be a quite annoying issue that the Airplane Mode automatically turns on when lid is opened on HP laptop.

Create service to remap the scancode#

  • Firstly, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to create a service file and edit via Gedit text editor:
1
sudo gedit /etc/systemd/system/hp-keycodes.service
  • When file opens, paste below lines and save it.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[Unit]  
Description=HP setkeycodes fix

[Service]  
Type=oneshot  
Restart=no  
RemainAfterExit=no  
ExecStart=/usr/bin/setkeycodes e057 240 e058 240

[Install]  
WantedBy=rescue.target  
WantedBy=multi-user.target  
WantedBy=graphical.target

Enable the service#

1
2
sudo systemctl daemon-reload
sudo systemctl enable hp-keycodes.service

Undo the changes#

1
2
sudo systemctl disable hp-keycodes.service
sudo rm /etc/systemd/system/hp-keycodes.service

Fix Team and Slack Sharing Desktop Ubuntu 22.04#

  • If you are using Ubuntu 22.04 for working you may facing the issue with sharing Desktop with black screen in Team and Slack meetings. So to fix this issue you need to disable wayland as below.
1
sudo gedit /etc/gdm3/custom.conf
  • Then set the config below.
WaylandEnable=false
  • Then reboot your computer and test sharing your screen on Team and Slack again.
  • Note: If you are using a NVIDIA GeForce Graphic card. So please check what is the additional driver that you are using.
  • If Nouveau display driver as in the image below. Please don't restart your computer now.

 #zoom

  • Let's go to Setting -> Color -> ADd Profile -> Standard Space - SRGB

 #zoom

  • Then now, you can restart your computer and test sharing your screen on Team and Slack again.

  • You can view more information in links below:

Enable Control Fan Speed For NVIDIA Graphic Card#

  • If you are using a NVIDA Graphc Card on Ubuntu you will see that fans of the NVIDIA Graphic Card will not run and if also can't set GPU fan speed as in the image below. You will get the error Failed to set new Fan Speed.

 #zoom

  • Now, to handle this issue. Let's go to the directory below.
cd /./etc/X11/
  • Then let's open file Xwrapper.config and make sure this file contains two line below.
sudo gedit Xwrapper.config
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Xwrapper.config (Debian X Window System server wrapper configuration file)
#
# This file was generated by the post-installation script of the
# xserver-xorg-legacy package using values from the debconf database.
#
# See the Xwrapper.config(5) manual page for more information.
#
# This file is automatically updated on upgrades of the xserver-xorg-legacy
# package *only* if it has not been modified since the last upgrade of that
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command as root:
#   dpkg-reconfigure xserver-xorg-legacy
allowed_users=anybody
needs_root_rights=yes
  • Then let's save this file and logout and login again.
  • Now, when you open NVIDIA setting again, and you now can set the new fan speed

 #zoom

Issue Can't Open Ubuntu Software#

  • If you face the issue can't open Ubuntu Software or Postman, just simply run the command below to reinstall Ubuntu Software.
sudo apt install --reinstall gnome-software

Fix Broken Installs#

  • You have broken Installs. To fix it open terminal and run the following commands.
1
2
3
4
sudo apt-get clean

sudo apt-get install -f
sudo dpkg --configure -a

Using SCP#

  • Using SCP to Download a file from remote machine.
1
scp user@host:<remote path> <local path>
1
scp duc@192.168.1.18:/home/duc/notes/"sample/ file.txt" /home/duc/Documents/notes
  • Using SCP to Download a folder from remote machine
1
scp -r user@host:<remote path> <local path>
1
scp duc@192.168.1.18:/home/duc/notes /home/duc/Documents/notes/
  • Using SCP to Upload a file to remote machine.
1
scp <local path> user@host:<remote path>
1
scp /home/duc/Documents/notes/"sample/ file.txt" duc@192.168.1.18:/home/duc/notes/
  • Using SCP to Upload a folder to remote machine
1
scp -r <local path> user@host:<remote path>
1
scp /home/duc/Documents/notes duc@192.168.1.18:/home/duc/

Fix Error Can not Open Terminal In Virtual Box#

  • If you can not open the Terminal of Ubuntu in Virtual Box. You can do some steps below.
  • Firstly go to Setting --> Region & Language
  • Next go to section My Account
    • change Language to `English (United States).
    • change Formats to United States.
  • Next go to section Login Screen
    • change Language to `English (United States).
    • change Formats to United States.
  • Finally Reboot the Ubuntu Virtual Machine.

Fix Can Not Copy & Paste From Parent Machine To Virtual Machine#

  • In Ubuntu Virtual Box choose Devices then choose Insert Guest Additions CD Image...
  • Then open injected Image Disk and run commands below.
1
su root
1
sudo usermod -a -G sudo vboxuser
1
su vboxuser
  • Then run command below to install tools.
1
sudo ./VBoxLinuxAdditions.run
  • Finally reboot the Ubuntu virtual machine then you can copy & paste between parent and Ubuntu virtual machine.

Fix Can Not Start Virtual Machine In Virtual Box#

  • When you start the virtual machine in the virtual box, after upgrading Ubuntu to the higher version, if you got the error as below.
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing '/sbin/vboxconfig' as root.
  • So you can run the commands below to fix it.
1
2
sudo apt install --reinstall virtualbox-dkms && sudo apt install libelf-dev
sudo /sbin/vboxconfig

Update Ubuntu Software App#

  • Run command below to update Ubuntu Software app after upgraded Ubuntu version to 24.04.
1
sudo snap refresh

To Kill A Process With Pid#

sudo kill <PID>

Fix Issue Can't Update kubernetes With Apt Update In Ubuntu 22.04#

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo apt update

Upgrade Ubuntu 22.04 To 24.04#

  • Upgrade to Ubuntu 24.04 LTS from Ubuntu 22.04.4.
    • Can not upgrading directly from Ubuntu 22.04.4 to 24.04 LTS using the do-release-upgrade command because the official upgrade path isn’t available yet.
    • So upgraded Ubuntu 22.04.4. to Ubuntu 23.10 and then upgraded Ubuntu 23.10 to 24.04 LTS.

Fix Can Not Open Chrome on Ubuntu 24.04#

  • Remove the old configuration.
1
rm ~/.config/google-chrome/ -rf