Fun with the find command

This is to find and replace in file in the sources.list.d 

  • sudo find /etc/apt/sources.list.d -type f -exec sed -i 's/bookworm/trixie/g' {} \; 

 

 

Parameter expansion (fast, built-in)

host2=${host%%.*} 

  • ${var%%pattern} = remove the longest match of pattern from the end.

  • Pattern .* means “a dot followed by anything”.

  • So this removes the first dot and everything after it, leaving what’s before the first dot.

  • POSIX-portable and no subprocess → fastest.

Examples

  • host="server.example.com"host2="server"

  • host="server"host2="server" (no dot to strip)

  • host=".hidden"host2="" (everything from the first dot is removed)

Tip: ${host%.*} would remove only up to the last dot (shortest match), giving server.example for server.example.com.

Finding if the folder is pointing to a Symlink

Run these from your normal user and then again after sudo bash:

 ls -ld /srv/salt 

readlink -f /srv/salt

Displaying the logical and physical path with "pwd".

The locical way

pwd -L  

The Physical way

pwd -P

 

To create a desktop icon om rocky 9

To activate the icon display in gnome on Rocky 9

Open the Activities overview and search for "Extensions".

Launch the Extensions application. 

Locate the Desktop Icons extension and toggle it to ON.

If the Extensions application isn't installed, you can add it:

sudo dnf install gnome-shell-extension-desktop-icons

  1. Create the “.desktop” Launcher
  2. Cd to the Desktop
  3. Vim a new file with the name of the icon.desktop
    1. Vim firefox.desktop
  4. Enter this in the file (this is just an example)

    [Desktop Entry]

    Version=1.0

    Type=Application

    Name=Firefox

    #Comment=Description of MyApp

    Exec=/usr/bin/firefox # or firefox %u

    Icon=/usr/share/icons/HighContrast/16x16/apps/firefox.png # or forefox

    Terminal=false

    Categories= Network;WebBrowser;\

Need to “chmod” the .desktop

  1. Chmod +x ~/Desktop/firefox.desktop

     

  2. Mark it as trusted 

    Via GUI:

    Right-click the icon and select Allow Launching

    Via CLI:

    gio set ~/Desktop/<icon_name>.desktop metadata::trusted true

    1. If you need to launch it via CLI
      1. gio launch ~/Desktop/Firefox.desktop

For commun app like Firefox, you can use this shortcut:

  • cp /usr/share/applications/firefox.desktop ~/Desktop/
  • chmod +x ~/Desktop/firefox.desktop
  • gio set ~/Desktop/firefox.desktop metadata::trusted true