Search This Blog

2024/10/31

Ubuntu : How to clean up space from logs ?

Clean accumulated .deb files from /var/cache/apt/archives

Move .deb files to external drive
cd /var/cache/apt/archives
sudo mv *.deb /media/sangram/Elements/Ubuntu22.4LTSAPTArchieve/
ls -lh .

Run autoclean
sudo apt-get autoclean

Truncate System,Kernel & Auth Logs:
sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/auth.log
sudo truncate -s 0 /var/log/kern.log

Remove Apt Cache:
sudo truncate -s 0 /var/log/apt/history.log
sudo truncate -s 0 /var/log/apt/term.log

cd /var/log/apt
sudo rm -rf *.gz
ls -lh /var/log/apt/

Restart rsynclog servicea
sudo systemctl restart rsyslog


Ubuntu : How to Upgrade from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS ?

Make sure your current system is fully up-to-date:
sudo apt update && sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove

Run the following command to make sure your upgrade tool is up-to-date:
sudo apt install update-manager-core

Begin the upgrade process by running:
sudo do-release-upgrade

Check for Available Upgrades:
sudo do-release-upgrade -d

2024/10/30

Ubuntu:add-apt-repoitory error - "could not find a distribution template"

Error on adding apt repository

sudo add-apt-repository ppa:forkotov02/ppa

Error :
Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 363, in <module> addaptrepo = AddAptRepository() File "/usr/bin/add-apt-repository", line 41, in __init__
self.distro.get_sources(self.sourceslist) File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 91, in get_sources raise
NoDistroTemplateException( aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Neon/jammy

Actually some files in /etc/*-release got modified when you
tried to install some package in my case i try to add Kde-Neon
repository but not installed Kde Neon.

To rectify this we need to set these two files (lsb-release
& os-release) to Ubuntu default.

For that follow following instructions.

Run
sudo nano /etc/*-release

First File:(lsb-release)

    DISTRIB_ID=ubuntu     DISTRIB_RELEASE=22.04     DISTRIB_CODENAME=jammy     DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"

Second File:(os-release)
PRETTY_NAME="Ubuntu 22.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
LOGO=start-here


Reboot The Computer

After Reboot try

sudo add-apt-repository ppa:forkotov02/ppa
sudo apt update
sudo apt install qmmp-qt6 qmmp-plugin-pack-

In my case i was able to add apt repository without any
problem after doing above procedure.


Ubuntu/Apt:Trying to overwrite file which is also in package

While doing routine apt upgrade you encountered error

similar to below
dpkg: error processing archive /var/cache/apt/archives/qt6-base_6.7.2-0zneon+22.04+jammy+release+build2_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libQt6Core.so.6', which is also in package libqt6core6:amd64 6.2.4+dfsg-2ubuntu1.1

Complete Error:
Preparing to unpack .../qt6-base_6.7.2-0zneon+22.04+jammy+release+build2_amd64.deb ...
Unpacking qt6-base (6.7.2-0zneon+22.04+jammy+release+build2) ...
dpkg: error processing archive /var/cache/apt/archives/qt6-base_6.7.2-0zneon+22.04+jammy+release+build2_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libQt6Core.so.6', which is also in package libqt6core6:amd64 6.2.4+dfsg-2ubuntu1.1
Preparing to unpack .../qt6-declarative_6.7.2-0zneon+22.04+jammy+release+build3_amd64.deb ...
Unpacking qt6-declarative (6.7.2-0zneon+22.04+jammy+release+build3) ...
Errors were encountered while processing:
/var/cache/apt/archives/qt6-base_6.7.2-0zneon+22.04+jammy+release+build2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then identify the file & do force overwrite for it like below
sudo dpkg -i --force-overwrite /var/cache/apt/archives/qt6-base_6.7.2-0zneon+22.04+jammy+release+build2_amd64.deb
Then
sudo apt-get -f install

2024/10/28

WSL : Install Linux GUI App on Windows 11

If wsl is not installed  then run    
    wsl --install

If already installed then run
    wsl --update

Need restart of WSL for the update to take effect
    wsl --shutdown


Install Linux GUI App
    sudo apt update

    sudo apt install gnome-text-editor
    sudo apt install gimp
    sudo apt install nautilus
    sudo apt install vlc
    sudo apt install x11-apps


    Install Google Chrome
        cd /tmp
        wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
        sudo apt install --fix-missing ./google-chrome-stable_current_amd64.deb

    Install Microsoft Edge
        sudo apt install software-properties-common apt-transport-https wget
        wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
        sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
        sudo apt install microsoft-edge-dev

    Install Node.js
        curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
        nvm ls
        nvm install --lts

    Suppose You installed VLC as mentioned above,then you can search in normal
    window start menu it has mentioned that "VLC Media Player(Ubuntu)"

    Now open the VLC & download sample mp3 fileto download folder of Windows.

    You can access the Downloaded File from Launched VLC Player in
        /mnt/c/Users/sangram

    How to access WSL File in Window App Like Explorer ?    
       In Explorer below This PC & Network there is Icon
       on Linux from here you can navigate further
       Path can be
            \\wsl.localhost\Ubuntu\home\sangram

2024/10/27

Ubuntu:Key is stored in legacy trusted.gpg keyring

First run

sudo apt update

If you get message saying "Key is stored in legacy
trusted.gpg keyring like below"

Fetched 1,701 kB in 4s (422 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable'
to see them.
W: http://archive.neon.kde.org/user/dists/bionic/InRelease:
Key is
stored in legacy trusted.gpg keyring
(/etc/apt/trusted.gpg), see the DEPRECATION
                section in apt-key(8) for details.

Then you can get rid of this message using following
procedure

cd /etc/apt
sudo cp trusted.gpg trusted.gpg.d

Now run
sudo apt update

You will not get "Key is stored in legacy trusted.gpg
keyring like below" message

2024/10/23

Ubuntu :How to install Arduino IDE ?

Download the Installable AppImage file

cd /home/sangram/Applications
wget https://downloads.arduino.cc/arduino-ide/arduino-ide_2.3.3_Linux_64bit.AppImage

Make AppImage Executable

chmod +x arduino-ide_2.3.3_Linux_64bit.AppImage

In Ubuntu 22.04 or higher

sudo add-apt-repository universe
sudo apt install libfuse2


Create /etc/udev/rules.d/99-arduino.rules file
and add following content to it

SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", GROUP="plugdev", MODE="0666"

Add Launcher

nano ~/.local/share/applications/arduino-ide.desktop

Add Following Content to it

[Desktop Entry]
Version=1.0
Name=Arduino IDE
Exec=/home/sangram/Applications/arduino-ide_2.3.3_Linux_64bit.AppImage
Terminal=false
Icon=/home/sangram/Applications/arduino-ide.png
Type=Application
Categories=Utility;Development;

Clear Icon Cache
gtk-update-icon-cache ~/.icons
gtk-update-icon-cache /usr/share/icons/hicolor

For Gnome:
gsettings reset org.gnome.shell app-picker-layout

2024/10/20

Ubuntu: Troubleshooting Installation of dotnet-sdk-8.0

If you try to install Dotnet 8.0 in Ubuntu you get following
error


The following packages have unmet dependencies: dotnet-host-7.0 :
Conflicts: dotnet-host E: Error, pkgProblemResolver::Resolve generated breaks,
this may be caused by held packages.

Lets Troubleshoot it

Remove all repositaries related to microsoft most of the time you added for mssql & vscode

sudo rm -f /etc/apt/sources.list.d/mssql-release.list
sudo rm /etc/apt/sources.list.d/microsoft-prod.list.save


Now remove all dotnet related installed packages

sudo apt purge dotnet-sdk* dotnet-host* dotnet* aspnetcore* netstandard*

Try installing again

sudo apt update
sudo apt install dotnet-sdk-8.0

You can remove this package as

sudo apt-get remove dotnet-sdk-6.0

You cam upgrade from this package by

sudo apt upgrade dotnet-sdk-8.0

Confirm installed packages
dotnet --info

You can confirm list of SDK
dotnet --list-sdk


List runtimes
dotnet --list-runtimes

Ubuntu : Disable Pro Upgrade Messages

Whenever you try to upgrade ubuntu through command line using
sudo apt upgrade
you see message regarding Ubuntu Pro
e.g.
sangram@sangram-Inspiron-14-5430:/etc/apt/sources.list.d$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:

You dont want to see this message then


1) Activate the Pro repository.
This repository is not public and is free for up to five machines.
You'll need to create an account (email, username, password) to access it,
which provides additional security updates. To proceed,
register at https://ubuntu.com/pro to obtain your personal token,
then execute the following command:

sudo pro attach your-personal-token

This is the recommended approach by Ubuntu.

2) Remove the advertisement.
Run this command to disable the advertisement:

sudo dpkg-divert --divert /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak
--rename --local /etc/apt/apt.conf.d/20apt-esm-hook.conf

This will create a .bak suffix for the configuration file,
effectively disabling it. This method will remain effective
even after future apt upgrades.

To verify that the changes have taken effect, run apt upgrade. If successful,
the additional text should no longer appear.

Let me know if you need any further adjustments!

2024/10/19

Ubuntu: Using Samba to share Apt Cache archives across local network

We will copy apt cache archive and create a folder

that can accessed over network using samba.

create directory inside /home/sangram my username

mkdir -p /home/sangram/cache/apt/archives

Copy all deb files from archive

sudo mv /var/cache/apt/archives/*.deb /home/sangram/cache/apt/archives

Create a user sadmin for purpose of software installtion

Create a New User
sudo adduser --no-create-home sadmin
sudo adduser sadmin

I kept password say "sangram" for user sadmin

You can delete sadmin user by following command

sudo deluser --remove-home sadmin
groupdel sadmin

you can switch user to samin as follows

su sadmin

Add the User to the sudo Group
sudo usermod -aG sudo sadmin

List groups to which sadmin belongs
groups sadmin

Then add sadmin to samba group & set samba password

sudo smbpasswd -a sadmin

Add user sadmin to groups
sudo usermod -aG sambashare sadmin

Change Ownership of /home/sangram/cache/apt/archives folder to sadmin

sudo chown -R sangram:sambashare /home/sangram/cache/
sudo chmod 775 /home/sangram/cache/apt/archives

List users added to samba group
sudo pdbedit -L

Edit smb.conf to make folder /home/sangram/cache/apt/archives
available over network.

sudo nano /etc/samba/smb.conf

Add following to end of file

[SharedAptCacheArchives]
path = /home/sangram/cache/apt/archives
browsable = yes
writable = yes
guest ok = no
read only = no
create mask = 0755
directory mask = 0755
force create mode = 0755

Add following to global section
usershare owner only = false

how to test smb.conf configuration is correct
testparm

Restart samba service:

sudo systemctl restart smbd nmbd

If My Machine Ip Address is 192.168.0.122 then smb://192.168.0.122/SharedAptCacheArchives
will be network url

Mount Shared SharedAptCacheArchives folder

cd /mnt

sudo mkdir SharedAptCacheArchives

sudo chmod 750 /home/sangram
sudo chown sangram:sambashare /home/sangram


sudo chmod -R 755 /mnt/SharedAptCacheArchives
sudo chown -R sangram:sambashare /mnt/SharedAptCacheArchives

sudo mount -t cifs //192.168.0.122/SharedAptCacheArchives /mnt/SharedAptCacheArchives -o sec=ntlmv2,username=sadmin,password=sangram,vers=3.0,uid=$(id -u sadmin),gid=$(id -g sadmin)

If mounted successfully then /mnt/SharedAptCacheArchives will acts as if
this folder contain all debian files in it from /home/sangram/cache/apt/archives

Enable Required Services (troubleshooting):

sudo systemctl enable systemd-networkd-wait-online

sudo systemctl enable networkd-dispatcher.service

sudo systemctl enable systemd-networkd.service

sudo systemctl enable NetworkManager-wait-online.service

systemctl status networkd-dispatcher.service systemd-networkd.service

View Logs of error in mounting at
sudo dmesg | tail -n 20

You can also view mounted filesystems by checking the /proc/mounts file
cat /proc/mounts

Check Folder Permission

cd /home/sangram/cache/apt/archives/
ls *.deb -ld .

To test our setting we will use smbclient as follows

List all shared folderson the ip address (Machine)
smbclient -L //192.168.0.122 -U sadmin

You can check if our setup worked or not by using smbclient.
After login run "ls"command to verify files are there.

smbclient //192.168.0.122/SharedAptCacheArchives -U sadmin
smbclient //192.168.0.122/SharedAptCacheArchives -U sangram

Logs of error while mounting can be viewed by following query:
sudo dmesg | tail -n 20

2024/10/18

Ubuntu : How to use ftp package repositary

In soucres.list mostly all package repositoies are https or
http but we can also use ftp package repositary.

Lets first edit our sources.list

sudo nano /etc/apt/sources.list

add following to it
deb ftp://ftp.ubuntu.com/ubuntu/ focal main universe

save & exit.

But By Default in ubuntu repository need to be https or http

to use ftp with it run following command

echo 'Dir::Bin::Methods::ftp "ftp";' | sudo tee -a /etc/apt/apt.conf.d/99local-ftp

Now run

sudo apt-get update

Now it will use ftp url also.

2024/10/16

MATLAB - Adding missing launcher in UBUNTU

Add Missing Launcher for MatLab in Ubuntu

Launch Terminal

1.download your own icon-

sudo wget
http://upload.wikimedia.org/wikipedia/commons/2/21/
Matlab_Logo.png -O /usr/share/icons/matlab.png

2.create launcher file
sudo touch /usr/share/applications/matlab.desktop

3.edit launcher file

sudo nano /usr/share/applications/matlab.desktop

4.add following into the launcher file.

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Icon=/usr/share/icons/matlab.png
Name=MATLAB R2014a
Comment=Start MATLAB - The Language of Technical Computing
Exec=/usr/local/MATLAB/R2024b/bin/matlab -desktop
Categories=Development;

Save & lauch matlab from icon.

Lets write simple script to display triangle as follows

Create Following Script in MatLab& Run.

clc
clear all
close all
x=[0,1,2]
y=[0,1,0]
plot(x,y,'Color','blue','LineWidth',1);
area(x,y,'FaceColor','green');


Now save it & run,IF you got low level graphic error then

cd /usr/local/MATLAB/R2024b/bin

now launch matlab as

./matlab -softwareopengl

Now Try to run script if this time script render
triangle then

In Matlab terminal

opengl('save','software')

This will add prefernces to matlab wrt opengl

Exit & launch Matlab from Launcher instead of command line &
recheck if it is rendering Triangle as previously.