man sudo
doesn't let me understand the differences.
Mario Palumbo's questions
After creating the timidity.service
file and the related symlink to start the service automatically at system reboot, I rebooted the system and gave the following input:
sudo systemctl status timidity
Output:
× timidity.service - TiMidity++ Daemon
Loaded: loaded (/lib/systemd/system/timidity.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-10-07 16:34:46 CEST; 50s ago
Process: 635 ExecStart=/usr/bin/timidity -iA Os (code=exited, status=1/FAILURE)
Main PID: 635 (code=exited, status=1/FAILURE)
CPU: 31ms
ott 07 16:34:46 netcom-Vostro-15-3510 systemd[1]: Started TiMidity++ Daemon.
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: jack_client_new: deprecated
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: Cannot connect to server socket err = No such file or directory
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: Cannot connect to server request channel
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: jack server is not running or cannot be started
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ott 07 16:34:47 netcom-Vostro-15-3510 timidity[635]: Couldn't open output device
ott 07 16:34:46 netcom-Vostro-15-3510 systemd[1]: timidity.service: Main process exited, code=exited, status=1/FAILURE
ott 07 16:34:46 netcom-Vostro-15-3510 systemd[1]: timidity.service: Failed with result 'exit-code'.
My username is associated with the audio
group.
Symlink:
/usr/lib/systemd/system/multi-user.target.wants/timidity.service
Service:
/usr/lib/systemd/system/timidity.service
Contains:
[Unit]
Description=TiMidity++ Daemon
After=sound.target
Requires=sound.target
[Service]
ExecStart=/usr/bin/timidity -iA Os
Type=simple
[Install]
WantedBy=multi-user.target
I also tried changing the "timidity.service" file to the following:
[Unit]
Description=TiMidity++ Daemon
After=pulseaudio.service
Requires=pulseaudio.service
[Service]
ExecStart=/usr/bin/timidity -iA Os
Type=simple
[Install]
WantedBy=multi-user.target
But after rebooting the system again, the error is the same.
Trying to start the service manually from the terminal with the system already started, the service starts correctly.
What am I doing wrong?
As for:
$ dpkg -f <deb-file> <field>
there is something that likewise:
$ apt-cache show <package> <field>
returns me a field of a package?
For example, assuming I have discord already installed and its .deb archive in the current directory, I run the commands:
$ dpkg -f ./discord.deb Version
$ apt-cache show discord Version
Outputs I'd like:
0.0.27
0.0.27
Actual output:
0.0.27
... # discord package unwanted long output
N: Unable to locate package Version
I'd like a solution that makes use of the apt-cache or dpkg command itself.
In the absence of such a solution, then I accept the usual parser.
How do I solve?
EDIT 1:
I only want to display the installed version of a package.
In the folder /etc/apt/sources.list.d
I have the file:
google-chrome-repo.list:
deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main
deb-src [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main
and in the folder /usr/share/keyrings
i have a file named google-chrome-keyring.gpg
If I install google-chrome:
sudo apt-get install google-chrome-stable
That annoying second file is created in /etc/apt/sources.list.d
with the name google-chrome.list
, with content:
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
and the file in the /etc/apt/trusted.gpg.d
folder named google-chrome.gpg
If I don't delete the annoying autogenerated file /etc/apt/sources.list.d/google-chrome.list
, then the command:
sudo apt-get purge google-chrome-stable
will give the following error:
E: Conflicting values set for option Signed-By regarding source https://dl.google.com/linux/chrome/deb/ stable: /usr/share/keyrings/google-chrome-keyring.gpg !=
E: The list of sources could not be read.
My goal instead is to be able to do apt-get install
and apt-get purge
of google-chrome as many times as I want, without first having to delete the autogenerated file each time.
How can i get this?
Is there a way to make apt-get
ignore that file?
The solutions proposed in other topics like delete that file
are not really functional.
I want to be able to use apt-get
directly as written above and not scripts or substitute functions.
It would be nice if there were some Dpkg::Options::=
like:
Of multiple coincident files in "sources.list.d", only consider the oldest one (the one created first).
This example script:
cat <<- EOF | bash -c
command1 args
command2 args
command3 args
command4 args
command5 args
EOF
Returns: bash: -c: option requires an argument
How do I use bash -c with here-document?
Referring to the link:
How to separate system icons in top bar
I would like to separate the system icons in the top bar, that is wifi, bluetooth, sound and battery, to have 4 different clickable icons.
Of this type, I have not found an extension compatible with Gnome 42.
Is there one compatible with Gnome 42?
I refer to the syntax used by GRUB2, for example when you start a pendrive and you are presented with the GRUB2 terminal.
I would like to redirect the output of the lsmod command to a file in some persistent filesystem (e.g. to view later outside GRUB).
The word command > file
does not work unlike the Linux Shell.
What is the equivalent for GRUB2?
There is nothing on the internet to give me the answer, otherwise I would not have posted the question here.
The OS with Ubuntu 20.04.3 LTS Desktop 64-bit
is located in the gpt2 partition with the filesystem NTFS.
This is the structure of the gpt1 partition with the filesystem FAT32:
.
├── boot
│ └── grub
│ └── grub.cfg
└── efi
└── boot
├── bootx64.efi
├── grubx64.efi
└── mmx64.efi
4 directories, 4 files
This is the grub menù of the NTFS partition (default grub.cfg):
if loadfont /boot/grub/font.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
fi
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set timeout=5
menuentry "Ubuntu" {
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash ---
initrd /casper/initrd
}
menuentry "Ubuntu (safe graphics)" {
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash nomodeset ---
initrd /casper/initrd
}
menuentry "OEM install (for manufacturers)" {
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed only-ubiquity quiet splash oem-config/enable=true ---
initrd /casper/initrd
}
grub_platform
if [ "$grub_platform" = "efi" ]; then
menuentry 'Boot from next volume' {
exit 1
}
menuentry 'UEFI Firmware Settings' {
fwsetup
}
fi
If the grub.cfg file (FAT32 partition) contains:
search --no-floppy --set=root --fs-uuid 2E92F36515DD4A5A
chainloader /EFI/BOOT/BOOTx64.EFI
boot
After making a choice from the grub selection menu, placed in the default grub.cfg file (NTFS partition) which is the same as the default contained within an iso image of Ubuntu 20.04.3 LTS Desktop 64-bit
, the error message appears:
error: can't allocate initrd.
Press any key to continue...
I have to underline that the NTFS partition bootloader starts correctly with the chainloader
command, otherwise I would not have seen the grub selection menu, it is the initrd
command that gives an error.
If instead the grub.cfg file (FAT32 partition) contains:
search --no-floppy --set=root --fs-uuid 2E92F36515DD4A5A
configfile /boot/grub/grub.cfg
After the selection menu, everything works correctly, therefore the initrd command no longer gives an error.
What's wrong with running the NTFS partition bootloader to boot initrd
using the default grub.cfg file inside it?
I have tested that if partition 2 has Windows, using chainloader
everything works correctly.
UPDATE 1:
I tried to swap partitions, the error persists.
UPDATE 2:
I would like to get more detailed error output from the initrd
command but I don't know how to do it.
I have tried
linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed nosplash debug ignore_loglevel ---
initrd /casper/initrd
but the error output is still the same, no rows added.
UPDATE 3:
Summarizing and clarifying what I am going to do, I from the partition with FAT32 do the chainload of the bootloader located on the NTFS partition.
If I boot the NTFS partition directly from BIOS, everything works, if instead I chainload starting from the FAT32 partition, problems appear.
Everything works correctly even if I call the menu of the grub.cfg (NTFS partition) using the configfile
command rather than the chainloader
command inside the grub.cfg
file of the FAT32 partition, of which I have already shown the lines it contains.
UPDATE 4:
I am going to use the chainloader
command anyway for generalization reasons, even being able to use the configfile
command that would solve the problem, because I would have the possibility to execute the same command both to start a partition with Windows and Ubuntu.
UPDATE 5:
The ntfs
module is already built into the bootloader of both partitions. The lsmod
command confirmed this. In any case I have tried to insert insmod ntfs
in the grub.cfg
files of both partitions and, as expected, the error does not change.
UPDATE 6:
I don't boot NTFS partition directly from BIOS, because UEFI on older computers cannot read NTFS directly.
UPDATE 7:
I HAVE DISCOVERED AN ERROR! Before I didn't notice it because it lasts a fraction of a second. But with a video from the phone, which I had to set to 60 fps to be able to catch the error, I recorded it, then took it to the PC, from the PC I took a screenshot of that video fragment, then rotated it and cropped with gimp.
The error is as follows:
error: can't find command `grub_platform`.
Here is the screenshot:
If I enter the command:
set +m
at the end of the .bashrc file, when I run the command:
echo $-
the option m
is missing as it should be, but...
If I enter the command:
{ sync & } 2> /dev/null
and then I press enter again without entering any commands, although I removed the m
option, the output still appears:
[1]+ Done sync
and only when I rerun the command from the terminal:
set +m
then the output is no longer shown. In other words, this command has effect only if executed from the terminal.
The question is:
How do I make it work when placed in .bashrc file?
I have attempted to create a UEFI pen drive that installs Ubuntu 20.04 LTS Desktop 64-bit.
The exFAT
partition gpt2
contains the entire Ubuntu 20.04 LTS system image.
The FAT32
partition gpt1
contains the following files:
.
├── boot
│ └── grub
│ └── x86_64-efi
│ └── exfat.mod
└── EFI
└── BOOT
├── BOOTX64.EFI
├── grub.cfg
├── grubx64.efi
└── mmx64.efi
5 directories, 5 files
where the grub.cfg
file contains the following lines:
insmod exfat
search --no-floppy --set=root --fs-uuid 7026-67D5
configfile /boot/grub/grub.cfg
After changing the Secure Boot
method from Deployed Mode
to Audit Mode
, the default grub.cfg
file of the exfat
partition is called correctly from the grub.cfg
file of the FAT32
partition.
In fact, the correct installation options appear.
After selecting the Ubuntu
option, loops endlessly and pressing the ESC
key I realize that the cause is an unspecified error: stdin: invalid argument
, which is repeated many times.
What could be the cause of this error?
UPDATE 1: Even disabling secure boot completely, the same error appears.
UPDATE 2: Waiting for some time, the following message appeared:
Unable to find a medium container a live file system
Attempt interactive netboot from a URL?
yes no (default yes): _
UPDATE 3:
I found that if instead of having the partition in exFAT, I have it in NTFS, the problem doesn't appear. From this I deduce that despite the insmod exfat
command, passed to the partition with that filesystem, the initrd.lz file does not support the exfat file system.
In fact, I also performed this other test to have an almost total confirmation of this thing:
insmod exfat
search --no-floppy --set=root --fs-uuid 7026-67D5
chainloader /efi/boot/bootx64.efi
boot
and I got the error message:
Failed to find fs: Unsupported
Failed to load image \efi\boot\grubx64.efi: Unsupported
start_image() returned Unsupported
If there is a Windows image in the exfat partition instead of Ubuntu, the bootloader starts correctly.
Is there a way to implement exfat support inside of bootx64.efi and initrd.lz files?
I need to use udisksctl
.
I tried the classic method /dev/sda?*
already seen on the internet:
udisksctl mount -b /dev/sda?*
or
udisksctl unmount -b /dev/sda?*
/dev/sda?*
in my case is equivalent to /dev/sda1 /dev/sda2
but udisksctl
only mounts or unmounts the first partition listed /dev/sda1
.
How can I make it mount or unmount all partitions at once?
I have installed "cinnamon-desktop-environment" on Ubuntu 20.04 LTS Desktop 64-bit.
I am attaching a video in which I open any dropdown menu. Any dropdown menu of any application suffers the same problem:
I also tried on Linux Mint 20.1, same problem. If the click is very short, the drop-down menu remains open, if I hold down slightly more and then release, the drop-down menu closes.
How can I fix it?
compgen -c | sort -b | uniq | less
Shows also functions and keywords (luckily no aliases), I instead want all that are not keywords, functions or aliases. In few words only the commands.
If command name match with function name, keyword name or alias name; the command name must not be omitted.
For example the google-chrome.list file and the skype-stable.list file in the /etc/apt/sources.list.d folder are overwritten when using this command:
sudo apt -y install google-chrome-stable skypeforlinux
The original skype-stable.list file contains:
deb [signed-by=/usr/share/keyrings/skypeforlinux-archive-keyring.gpg] https://repo.skype.com/deb stable main
deb-src [signed-by=/usr/share/keyrings/skypeforlinux-archive-keyring.gpg] https://repo.skype.com/deb stable main
The overwritten skype-stable.list file contains:
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
The original google-chrome.list file contains:
deb [signed-by=/usr/share/keyrings/google-archive-keyring.gpg] http://dl.google.com/linux/chrome/deb stable main
deb-src [signed-by=/usr/share/keyrings/google-archive-keyring.gpg] http://dl.google.com/linux/chrome/deb stable main
The overwritten google-chrome.list file contains:
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
How can I avoid this?
For example I have this output:
string1 anynameveryveryverylong string2
string1 othernameveryveryverylong string2
I want truncate the name to the first ten characters:
string1 anynamever string2
string1 othernamev string2
a pseudo regex can be:
perl -pe "s/([^\t]+\t)([^\t]+)\t/\1\2{10}\t/g"
How do i get this?
I have this text file or sdout:
text1
text2
text1
text2
text1
text2
I have this code:
perl -pe "s/text2\n\z/text3/s" text.txt #Note the modifier "/s"
I with \z expect him to understand that this is the last line before the eof and consequently I expect:
text1
text2
text1
text2
text1
text3
But instead it returns:
text1
text3text1
text3text1
text3 #without final newline
What am I doing wrong?
I want to show all lines before a match, not only 10, or 7, or 14 for example, as explained in How do I fetch lines before/after the grep result in bash?.
How can I do it? It doesn't matter if the matched line is included or not.
For example, instead of:
... | grep -B 10 -- "foo"
I want:
... | grep -B -- "foo"
But this last code doesn't work.
I have to add a space after the # to every occurrence, only if the # is at the beginning of the line and after the # there is at least one character that is not the space. For example this code:
echo "# ok" | sed "s|^#[^ ]|# |g"
Returns # ok
as expected, but this code:
echo "#ok" | sed "s|^#[^ ]|# |g"
Returns # k
and not # ok
as expected.
How do I get the # ok
output?
Edit:
This is the code that solves my problem, thanks to @FedonKadifeli:
echo -e "#ok\n# ok\n #ok\n#ok #ok\n##ok #ok"
Returns:
#ok
# ok
#ok
#ok #ok
##ok #ok
This code:
echo -e "#ok\n# ok\n #ok\n#ok #ok\n##ok #ok" | sed -r 's|^#(#*)([^[:space:]#])|#\1 \2|g'
Returns:
# ok
# ok
#ok
# ok #ok
## ok #ok