vendredi 12 avril 2024

Stop auto-upgrade in Ubuntu

 The simplest way to do this would be to disable every auto-upgrade. Here's how you can do it on Ubuntu 18.04 and 20.04:

  1. Open Terminal (if this is an Ubuntu Server installation, just SSH into the thing)
  2. Edit Apt's 20auto-upgrades file to disable everything:
sudo vi /etc/apt/apt.conf.d/20auto-upgrades
  1. Ensure everything is set to 0. If done correctly, you'll have a file that looks like this:
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

mardi 5 mars 2024

Poppler-qt5

 poppler-qt5 is keg-only, which means it was not symlinked into /opt/homebrew,

because it conflicts with poppler.


If you need to have poppler-qt5 first in your PATH, run:

  echo 'export PATH="/opt/homebrew/opt/poppler-qt5/bin:$PATH"' >> ~/.zshrc


For compilers to find poppler-qt5 you may need to set:

  export LDFLAGS="-L/opt/homebrew/opt/poppler-qt5/lib"

  export CPPFLAGS="-I/opt/homebrew/opt/poppler-qt5/include"


For pkg-config to find poppler-qt5 you may need to set:

  export PKG_CONFIG_PATH="/opt/homebrew/opt/poppler-qt5/lib/pkgconfig"

  export PKG_CONFIG_PATH="/opt/homebrew/opt/poppler-qt5/share/pkgconfig"

=

mercredi 28 février 2024

Mapping keyboard in Ubuntu

mgirond@emys:/etc$ localectl list-keymaps
Failed to read list of keymaps: No such file or directory
mgirond@emys:/etc$ localectl
   System Locale: LANG=fr_FR.UTF-8
       VC Keymap: n/a
      X11 Layout: us
       X11 Model: pc105
wget https://mirrors.edge.kernel.org/pub/linux/utils/kbd/kbd-2.6.4.tar.gz -O /tmp/kbd-2.6.4.tar.gz
cd /tmp/ && tar xzf kbd-2.6.4.tar.gz
sudo mkdir /usr/share/keymaps/
sudo cp -Rp /tmp/kbd-2.6.4/data/keymaps/* /usr/share/keymaps/
localectl list-keymaps | grep -i fr
localectl set-keymap mac-fr-legacy
mgirond@emys:/tmp$ localectl status
   System Locale: LANG=fr_FR.UTF-8
       VC Keymap: mac-fr-legacy
      X11 Layout: us
       X11 Model: pc105

Other solution: List of available keyboard is
cat /usr/share/X11/xkb/rules/base.lst

cd /etc/default/
sudo nano keyboard
and change 
XKBLAYOUT="us"
to (or something else !)

XKBLAYOUT="fr"

Note that the mapping is not perfect with Mac keyboard; you can use option + ascii number to get the missing characters


To take into account the change
setupcon -k


mardi 20 février 2024

Force running update in Ubuntu in noninteractive mode

 Or do 

sudo dpkg-reconfigure debconf --frontend=noninteractive

or

export DEBIAN_FRONTEND=noninteractive

or 

sudo DEBIAN_FRONTEND=noninteractive apt-get -y -q update

-y, --yes, --assume-yes

Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package or removing an essential package, occurs then apt-get will abort.

-q, --quiet

Quiet. Produces output suitable for logging, omitting progress indicators.

Another solution

sudo vi /etc/needrestart/needrestart.conf

And change #$nrconf{restart} = 'i';

to 

$nrconf{restart} = 'a';


mercredi 21 juin 2023

Bad permission in sudoers files prevents to connect or use sudo

# If you have this message:

sudo: /etc/sudoers.d/rules is world writable

# connect in root 

su

# Then do

chmod 0755 /etc/sudoers.d/rules


To create a root password, do:

sudo passwd root

jeudi 1 juin 2023

Do not show a volume in finder (MacOSX)

 From https://www.idownloadblog.com/2016/12/02/how-to-hide-mounted-volumes-from-desktop-finder/


1) Ensure the volume that you want to hide is mounted and visible in the Finder, desktop, or Disk Utility.

2) Make a note of the chosen name of your volume, for example, Time Machine or Storage.

3) Launch Terminal and type the following command, replacing “Drive Name” with the name of your own volume, which you noted earlier (keep the quote marks):

sudo SetFile -a V /Volumes/"Drive Name"

4) Enter your password when prompted.

Note: Install command line developer tools if you’re prompted to do that.

5) In terminal: killall Finder

To revert :

sudo SetFile -a v /Volumes/"Drive Name"
killall Finder

lundi 3 avril 2023

Search a text within the file content in Unix and R

 In UNIX:

grep -rnw '.' -e 'texttosearch'

To search within the current directory '.' or 'path" to search in the path.
The options
-r means "recursive"
-e is the pattern to search for
-n Each output line is preceded by its relative line number in the file, starting at line 1.
-w The expression is searched for as a word (as if surrounded by ‘[[:<:]]’ and ‘[[:>:]]

Do not hesitate to do a man grep to see the dozens of options!


In R, a equivalent using "brut force" (without recursive option) is found in the package HelpersMG (https://CRAN.R-project.org/package=HelpersMG) :
inside(
  text = stop("A text to be searched for is necessary"),
  path = ".",
  pattern = "*\\.R$",
  showallfilenames = FALSE,
  ...,
  fixed = TRUE,
  ignore.case = FALSE
)