Wednesday, May 26, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to suppress output of systemctl?

Posted: 26 May 2021 10:20 AM PDT

How to suppress output of systemctl?

I have tried systemctl --quiet, systemctl -q, and even systemctl 2>&1 1>/dev/null, none of these seem to work when testing for service is disabled when said service is already disabled?

systemctl -q is-disabled dhcpcd

Setting up sftp on multiple ports in my centos machine

Posted: 26 May 2021 10:17 AM PDT

I have a Centos machine version centos-release-7-9.2009.1.el7.centos.x86_64. I am trying to change the sftp port, which is currently the default port 22. I was able to follow the article https://www.thegeekdiary.com/how-to-configure-separate-port-for-ssh-and-sftp-on-centos-rhel/ and was able to set sftp to port 22 and ssh to port 2222. I have existing users using the machine and this change will affect them. I am trying to set sftp on both 22 and 2222 port and keep ssh on port 22. Is it possible to do that by any means. I have searched online but could not find much help regarding that.

how to run script automatically when certain applications are opened

Posted: 26 May 2021 10:07 AM PDT

i want to run a bash script whenever i open vlc i tried to put the alias of vlc to my script and open vlc but this only works when opened from terminal i want my script to run even when vlc is opened using GUI

The Compress menu item in Gnome. Where can I look to try to fix it?

Posted: 26 May 2021 10:00 AM PDT

In the Gnome file manager in CentOS 7, the context menu has many 'Compress' options. However none seem to work, all with various symptoms:

  • .zip generates no file at all
  • .tar generates an empty tarball no matter the input
  • .7z generates a corrupt file that can't be read by the archive manager

Without moaning that everything in Linux is supplied broken, where can I look to start solving these issues?

How to remove four random characters before the .extension from various files using a for loop?

Posted: 26 May 2021 10:08 AM PDT

I am working on an undergraduate research project that is heavy in bioinformatics, and I am going down a pipeline of file processing. Some background: I am working with shotgun metagenomic data which is very large swatches of A,T,G,C (nucleotides in a DNA sample), and from what I gather, some qualifiers. I have gone through a few steps of the pipeline already which trimmed and cleaned up the files some, along with adding some qualifiers. The important thing is that these reads are mostly paired end reads, meaning two files reading the nucleotides right to left and left to right.

Prior to this, I had crammed my head with basically only biology and ecology so I don't really have any context for coding or how/why to do things or common practices/functions, etc. You get the point.

That said, I taught myself very basic for loops and string manipulation in UNIX, making some bash files that ran through different folders using different modules and functions. Here is example code:

cd ~/ncbi/public/sra/indian    for forward_read_file in *_1.fastq    do  rev=_2  reverse_read_file=${forward_read_file/_1/$rev}  perl /home/gomeza/shared/sharm646-2021-02-24-09_22/Softwares/NGSQCToolkit_v2.3.3/Trimming/AmbiguityFiltering.pl -i ${forward_read_file} -irev ${reverse_read_file} -c 1 -t5 -t3    rm ${forward_read_file} ${reverse_read_file}  done    #CAMEROON  cd ~/ncbi/public/sra/cameroon    for forward_read_file in *_1.fastq    do  rev=_2  reverse_read_file=${forward_read_file/_1/$rev}  perl /home/gomeza/shared/sharm646-2021-02-24-09_22/Softwares/NGSQCToolkit_v2.3.3/Trimming/AmbiguityFiltering.pl -i ${forward_read_file} -irev ${reverse_read_file} -c 1 -t5 -t3    rm ${forward_read_file} ${reverse_read_file}  done   

and so on for many folders. I used string manipulation to get each iteration of the for loop to call the paired paired end files, and then some arguments and parameters for the module I'm using.

The big issue I am running into now is that I can't think of a way to pair the paired end files for my next step in the pipeline as they have four random characters right before the extension, and I cant predict them. They don't contain meaninful data, so my plan is to delete them from the filenames and proceed as I have been.

Here are examples of the problem files:The issue is the four characters at the end of the string. If I get rid of those I can do the string manipulation as usual.

The issue is the four characters at the end of the string. If I get rid of those I can do the string manipulation as usual. My mentor recommended I use the FIND or CUT functions somehow, and talked about using the return of the find as a variable to manipulate, but I feel like that would still run into the same issue.

How can I remove these characters safely using a for loop? Or whatever you think would work best.

Thank you!

Debian: Files not shown in mounted drive, but is shown in LiveCD

Posted: 26 May 2021 09:33 AM PDT

I installed xfce4-Buster-Debian, and during the install, I selected manual partitioning and chose to mount a drive containing some files to a specific location. For that drive, of course I chose not to format the drive. After Debian was instolled on a different partition, and booting to the OS, I see no files in the mounting directory. The directory shows up in the place I expect, but when I cd into it and ls -la, there is nothing in that dir. But according to GParted, the data is occupying the space.

I booted to the LiveCD, and the files do show up there.

What possible causes are there of this behaviour?

Play music folder in cmus (without adding to library)

Posted: 26 May 2021 09:30 AM PDT

How can I consecutively play the music files in a folder with cmus from the Browser View?

I don't want to add them to the library first or create a playlist. Just play, what's there.

enter image description here

Portable name of C++ compiler (and linker)

Posted: 26 May 2021 09:37 AM PDT

cc is the POSIX name of the C compiler. Is there a general name of the C++ compiler (and linker). Notice that g++ also adds some libraries, that will not be included when using plain gcc or ld.

Changing key binding one specific key

Posted: 26 May 2021 08:48 AM PDT

How can I change key bindings for a single key? I know that there are software like xmodmap and so on, but with this I can't map my key bindings, because with xmodmap I first have to press the keys that I want to change, but I can't because the key f doesn't work anymore. So I just want to change f (which doesn't work) to another, more useless key. How to do that? Thx

How to connect to wifi hotspot on Ubuntu 20.04?

Posted: 26 May 2021 09:00 AM PDT

I have one laptop where I created a wifi hotspot to another. I know my wifi network and password. But when I tried to connect to it from another computer, it says "Connection failed Activation of network connection failed". I also tried nmcli from command line but it said: "Secrets were required, but not provided". How can I debug the problem?

Unable to mount USB CD Drive

Posted: 26 May 2021 09:49 AM PDT

I have a Linux machine running CentOS7 that does not have a built-in CD drive. I need to copy files from a CD onto the computer, so I'm using a USB CD drive. I cannot get the computer to recognize the device and mount the CD.

The device doesn't show up in /dev, but I've been able to identify the device using sudo lshw -short, with the following output:

/0/100/14/0/8/1 storage Dell DVD+/-RW Drive DW316

Without the -short, the only other interesting info I see is that the device is always listed as -usb UNCLAIMED, regardless of which USB port I use.

I tried mounting the device using the command sudo mount /0/100/14/0/8/1 /mnt but returned the error "Special device does not exist".

I also looked at the info from lsblk and fdisk -l, but there were no changes when plugging or unplugging the CD reader.

What else should I do to mount this CD? I was able to use the CD reader on a Windows machine, so I know the device is working.

Appending directory name to contents of tar.gz directory in the shell

Posted: 26 May 2021 08:09 AM PDT

I have a directory of compressed directories, like this:

MainDirectory/FolderA.tar.gz  MainDirectory/FolderB.tar.gz  

Within each directory, some of the files have the same name. Ex.

MainDirectory/FolderA.tar.gz/file1.fasta  MainDirectory/FolderA.tar.gz/file2.fasta  MainDirectory/FolderB.tar.gz/file1.fasta  MainDirectory/FolderB.tar.gz/file1.fasta  

I need to decompress each directory, rename each file with the name of the directory, and then recompress the individual files. My desired output is:

MainDirectory/FolderA_file1.fasta.bz2  MainDirectory/FolderA_file2.fasta.bz2  MainDirectory/FolderB_file1.fasta.bz2  MainDirectory/FolderB_file1.fasta.bz2  

I came up with this code, but it renames the files to have a literal $f in:

cd MainDirectory/  for f in *.tar.gz      do      tar -xvzf $f --transform 's,^,${f},'       pbzip2 *.fastq       done  

Output:

MainDirectory/'${f}file1.fastq.bz2'  MainDirectory/'${f}file2.fastq.bz2'  

Please may you help me convert the command so it prepends the files with the actual folder name instead? Thank you.

Why echo "MYPASSWORD" | sudo -kS ls does not work on debian on Beaglebone

Posted: 26 May 2021 08:49 AM PDT

I am running a Beaglebone on Debian (4.14.108-ti-r113). I need to run a root command from the debian user. I tried many things that still result in error.

Some attempts:

$ echo "MYPASSWORD" | sudo -kS ls    [sudo] password for debian: Sorry, try again.  [sudo] password for debian:   sudo: 1 incorrect password attempt      $ sudo -S <<< MYPASSWORD ls  [sudo] password for debian: Sorry, try again.  [sudo] password for debian:   sudo: 1 incorrect password attempt    $ echo -e "MYPASSWORD\n"|sudo -S   [sudo] password for debian: Sorry, try again.  [sudo] password for debian:   sudo: 1 incorrect password attempt  

Note: MYPASSWORD does not contain $, only a-to-z characters

Any idea?

sed: find pattern and replace for another pattern in the same line

Posted: 26 May 2021 08:12 AM PDT

I have a file with gene_id and gene names in one line. I want to replace the word after gene_id with the word after gene or after product or after sprot (if some of it missed).

Here is an example of a line:

chrM    Gnomon  CDS 8345    8513    .   +   1   gene_id "cds-XP_008824843.3"; transcript_id "cds-XP_008824843.3"; Parent "rna-XM_008826621.3"; Dbxref "GeneID:103728653_Genbank:XP_008824843.3"; Name "XP_008824843.3"; end_range "8513,."; gbkey "CDS"; gene "semaphorin-3F"; partial "true"; product "semaphorin-3F"; protein_id "XP_008824843.3"; sprot "sp|Q13275|SEM3F_HUMAN";  chrM    StringTie   exon    2754    3700    .   +   .   gene_id "cds-YP_007626758.1"; transcript_id "cds-YP_007626758.1"; Parent "gene-ND1"; Dbxref "Genbank:YP_007626758.1,Gene "ID:15088436"; Name "YP_007626758.1"; Note "TAAstopcodoniscompletedbytheadditionof3'AresiduestothemRNA"; gbkey "CDS"; gene "ND1"; product "NADHdehydrogenasesubunit1"; protein_id "YP_007626758.1"; transl_except "(pos:3700..3700%2Caa:TERM)"; transl_table "2";  

I tried to make it with sed:

sed -E 's/[^gene_id] .*?;/[^gene] .*?;|[^sprot] .*?;|[^product] .*?;/g'  

But the results were incorrect:

chrM    Gnomon  CDS 8345    8513    .   +   1   gene_id "cds-XP_008824843.3"[^gene] .*?;|[^sprot] .*?;|[^product] .*?;  chrM     StringTie       exon    2754    3700    .       +       .       gene_id "cds-YP_007626758.1"[^gene] .*?;|[^sprot] .*?;|[^product] .*?;  

But I want to save all line, but with another word after gene_id, like this:

chrM    Gnomon  CDS 8345    8513    .   +   1   gene_id "semaphorin-3F"; transcript_id "cds-XP_008824843.3"; Parent "rna-XM_008826621.3"; Dbxref "GeneID:103728653_Genbank:XP_008824843.3"; Name "XP_008824843.3"; end_range "8513,."; gbkey "CDS"; gene "semaphorin-3F"; partial "true"; product "semaphorin-3F"; protein_id "XP_008824843.3"; sprot "sp|Q13275|SEM3F_HUMAN";  chrM     StringTie       exon    2754    3700    .       +       .       gene_id "ND1"; transcript_id "cds-YP_007626758.1"; Parent "gene-ND1"; Dbxref "Genbank:YP_007626758.1,Gene "ID:15088436"; Name "YP_007626758.1"; Note "TAAstopcodoniscompletedbytheadditionof3'AresiduestothemRNA"; gbkey "CDS"; gene "ND1"; product "NADHdehydrogenasesubunit1"; protein_id "YP_007626758.1"; transl_except "(pos:3700..3700%2Caa:TERM)"; transl_table "2";  

Or like this (if another missed):

chrM    Gnomon  CDS 8345    8513    .   +   1   gene_id "sp|Q13275|SEM3F_HUMAN"; transcript_id "cds-XP_008824843.3"; Parent "rna-XM_008826621.3"; Dbxref "GeneID:103728653_Genbank:XP_008824843.3"; Name "XP_008824843.3"; end_range "8513,."; gbkey "CDS"; gene "semaphorin-3F"; partial "true"; product "semaphorin-3F"; protein_id "XP_008824843.3"; sprot "sp|Q13275|SEM3F_HUMAN";  chrM     StringTie       exon    2754    3700    .       +       .       gene_id "ND1"; transcript_id "cds-YP_007626758.1"; Parent "gene-ND1"; Dbxref "Genbank:YP_007626758.1,Gene "ID:15088436"; Name "YP_007626758.1"; Note "TAAstopcodoniscompletedbytheadditionof3'AresiduestothemRNA"; gbkey "CDS"; gene "ND1"; product "NADHdehydrogenasesubunit1"; protein_id "YP_007626758.1"; transl_except "(pos:3700..3700%2Caa:TERM)"; transl_table "2";  

Any help will be very much appreciated.

How to check runtime log for a batch job submitted using `at` command?

Posted: 26 May 2021 08:12 AM PDT

I submit the batch job in Ubuntu 20.

at now -f myscript.sh  

I get an email with a log when the job is completed. But for a time-spending job, I would like to see progress during the execution. How can I do that?

How to add FreeBSD 13 to Grub 2 boot loader

Posted: 26 May 2021 09:55 AM PDT

I have Windows 10, Ubuntu 21.04 and FreeBSD 13 (UFS) installed on my SSD. I'm able to load Windows 10 or Ubuntu via GRUB 2.04. However, I cannot make FreeBSD load from the GRUB menu. I've tried different configurations.

My partitions:

  • hd3,gpt3 - EFI
  • hd3,gpt7 - FreeBSD's UFS2
  • hd3,gpt9 - FreeBSD's swap

enter image description here

Some of the configurations I've tried:

set root=(hd3,gpt3)  chainloader /efi/freebsd/loader.efi  

-does nothing. chainloader just returns without any message or action.

insmod ufs2  set root=(hd3,gpt7)  kfreebsd /boot/kernel/kernel  kfreebsd_loadenv /boot/device.hints  set kFreeBSD.vfs.root.mountfrom=ufs:/dev/nvme0n1p7  set kFreeBSD.vfs.root.mountfrom.options=rw  set kFreeBSD.hw.psm.synaptics_support=1  

-returns error like "cannot find file /boot/kernel/kernel".

I've tried to list the directories in the path /boot/kernel/kernel, but with no success. I don't understand why. ls $root shows the description of the partition. However, ls /boot doesn't display anything except error like "directory not found".

I'm sure my FreeBSD partition is ok. I was able to work with it right after setup. I did reinstall FreeBSD just in case, but it didn't help.

Please advise.

Print a pattern from single long line

Posted: 26 May 2021 08:44 AM PDT

For below question, I have tried numerous grep/egrep,awk,cut commands but with no luck.

I have a file with only one long line (below is only sample). We want to grep below pattern from below file content:

Pattern to be printed:

o.buildVersion="2.5.1.162"  

Note- 2.5.1.162 is the unknown part, I only know o.buildVersion exists.

File Content:

    t(t,n){var o=e.call(this,t,n,C.a.FRAMEWORKIDENTIFIER)||this;return o._logger=n,o.resourceBasePath="",o.buildVersion="2.5.1.162".replace(/(\.(?=[^.]*$))(.+)/,""),o.resourceBasePath=t.Cluster.UTIL.getResourceBasePath(),o}return W(t,e),t.prototype.ngOnInit=function(){this._logger.trace("Inside AboutUsComponent!")},t.prototype.ngOnDestroy=function(){this.dispose()},t=X([Object(l.d)({selector:"ignio-about-us",template  

Passing date command into a variable?

Posted: 26 May 2021 10:08 AM PDT

Ok so my problem is as followed, I wish to pass this :-

echo $(($(date +%s%N)/1000000))  

Into a variable "a" to it can be added to an array, something like this :-

a=$(($(date +%s%N)/1000000))  

The reason I am doing this is a would like 4 random digits to play with (Random numbers). I have produced this bash script to show an example.

#!/bin/bash  for (( c=0; c<=10; c++))  do          echo $(($(date +%s%N)/1000000))          sleep .5  done  

Which outputs :- (Ignore the first 9 digits)

1622001937610  1622001938249  1622001938758  1622001939267  1622001939774  1622001940282  1622001940790  1622001941299  1622001941807  1622001942315  1622001942823  

Now I wanted to add the results of just one instance of this into an array, index from the last 9th digit to receive 4 random digits based on nano second time.

How ever I don't seem to have full grasped the syntax used within bash to achieve the result. Could I possible call date +%s%N)/1000000 straight into an array? As my idea was to create and empty array and then just append the result into the array, and index from the 9th number. And pass the result into a second variable from there I can work on.

Just learning to turn the result of date +%s%N)/1000000 into a variable would be of great help.

Sorry to be a pain. Any thank you in advanced.

How to read tokens from an input file to delete files mentioned there

Posted: 26 May 2021 09:10 AM PDT

I am creating a script that deletes files using the config which contains Folder and File_Prefix.

  • This will be the config file: config.txt

    /local/FolderA,App  /local/FolderB,Log  /local/FolderC,File  
  • This is my script:

    file="local/config.txt"  while IFS="," read -r folder prefix;  do      find %s -name %s* -type f -exec rm {} \ "$folder" "$prefix";  done < "$file"  

However it is not working properly. Can you help in troubleshooting? I am having troubling assigning the values from IFS command.

Fetch repository data parallel

Posted: 26 May 2021 08:48 AM PDT

If I give out a "zypper up" or "apt-get update", the repository datas are fetched in linear order.

The big Question: Why? Why cannot we speed up the update process by starting all the repository data download parallel?

I am not talking about package updates, just repo infos.

Can't install CentOs virtualbox guest addition

Posted: 26 May 2021 09:05 AM PDT

I'm using Manjaro Linux, and I have CentOS 7 installed in VirtualBox. When I try to install VirtualBox Guest Additions, I get the following error.

CentOS 7 Guest Additions Error

The the content of /var/log/VBoxGuestAdditions.log follows.

The content of /var/log/vboxadd-install.log follows.

enter image description here

Any help, please?

xrandr scaling: blurry fonts when downscaling

Posted: 26 May 2021 10:03 AM PDT

Is there any option to downscale the monitor without getting blurry fonts?

I am forced to work on 1366x768 monitor at the moment, which is painful due to low amount of content I can pack on my screen (I'm coding).

I've tried

> $ xrandr --output LVDS1 --scale 1.2x1.2 --panning <new scaled resolution> [±master ●●]

which helped a bit, but fonts look just super-bad. Any option for this?

Is there any decent speech recognition software for Linux?

Posted: 26 May 2021 10:10 AM PDT

The short version of the question: I am looking for a speech recognition software that runs on Linux and has decent accuracy and usability. Any license and price is fine. It should not be restricted to voice commands, as I want to be able to dictate text.


More details:

I have unsatisfyingly tried the following:

All the above-mentioned native Linux solutions have both poor accuracy and usability (or some don't allow free-text dictation but only voice commands). By poor accuracy, I mean an accuracy significantly below the one the speech recognition software I mentioned below for other platforms have. As for Wine + Dragon NaturallySpeaking, in my experience it keeps crashing, and I don't seem to be the only one to have such issues unfortunately.

On Microsoft Windows I use Dragon NaturallySpeaking, on Apple Mac OS X I use Apple Dictation and DragonDictate, on Android I use Google speech recognition, and on iOS I use the built-in Apple speech recognition.

Baidu Research released yesterday the code for its speech recognition library using Connectionist Temporal Classification implemented with Torch. Benchmarks from Gigaom are encouraging as shown in the table below, but I am not aware of any good wrapper around to make it usable without quite some coding (and a large training data set):

System Clean (94) Noisy (82) Combined (176)
Apple Dictation 14.24 43.76 26.73
Bing Speech 11.73 36.12 22.05
Google API 6.64 30.47 16.72
wit.ai 7.94 35.06 19.41
Deep Speech 6.56 19.06 11.85

Table 4: Results (%WER) for 3 systems evaluated on the original audio. All systems are scored only on the utterances with predictions given by all systems. The number in the parentheses next to each dataset, e.g. Clean (94), is the number of utterances scored.

There exist some very alpha open-source projects:

I am also aware of this attempt at tracking states of the arts and recent results (bibliography) on speech recognition. as well as this benchmark of existing speech recognition APIs.


I am aware of Aenea, which allows speech recognition via Dragonfly on one computer to send events to another, but it has some latency cost:

enter image description here

I am also aware of these two talks exploring Linux option for speech recognition:

Into which directory should I install programs in Linux?

Posted: 26 May 2021 09:45 AM PDT

I want to install a program in Linux and run it as a daemon. (Team Speak 3 in this case, but the question is general in nature). There is no package provided, only tarred binaries. Where in directory structure should I put such a program by convention?

On the web I found that /opt is for "optional addon apps", while /usr is for "user programs". I found one tutorial suggesting /opt while the other sugested /usr.

So which one is "more correct"?

How do I deal with a certificate based transparent proxy in Arch Linux?

Posted: 26 May 2021 10:12 AM PDT

I have setup an Arch Linux VM at work, and my company uses a transparent (cut-through) proxy with a self-signed certificate and requires authentication. Whenever I try to install any packages through pacman I get the following error (e.g. trying to install lynx)

error: failed retrieving file 'lynx-2.8.7-6-x86_64.pkg.tar.xz' from mirrors.kernel.org : SSL certificate problem: self signed certificate in certificate chain

It will throw this error for every mirror I have defined in /etc/pacman.d/mirrorlist. I have similar problems trying to use any other HTTP/S clients such as curl, but I do not have any issues with FTP (primarily because my company only monitors ports 80 and 443).

What I've tried already...

  • Placing my companies self signed CA certificate in /usr/share/ca-certificates, and /etc/ca-certificates
  • Setting http_proxy and https_proxy to point to my company's proxy server with my credentials
  • Talked to the person who manages our proxy server, but he doesn't know anything about Linux, so doesn't have a clue where to begin.

For now, when I need to install something or access the Internet, I'm opening an SSH tunnel to my home server to get around this.

Below is the output of openssl s_client -CApath /etc/ca-certificates -showcerts -connect mirrors.kernel.org:443

  CONNECTED(00000003)  depth=0 C = US, ST = California, L = San Jose, O = The Linux Kernel Organization, CN = *.kernel.org  verify error:num=20:unable to get local issuer certificate  verify return:1  depth=0 C = US, ST = California, L = San Jose, O = The Linux Kernel Organization, CN = *.kernel.org  verify error:num=27:certificate not trusted  verify return:1  depth=0 C = US, ST = California, L = San Jose, O = The Linux Kernel Organization, CN = *.kernel.org  verify error:num=21:unable to verify the first certificate  verify return:1  ---  Certificate chain   0 s:/C=US/ST=California/L=San Jose/O=The Linux Kernel Organization/CN=*.kernel.org     i:/C=US/ST=MyCompanyState/L=MyCompanyCity/O=MyCompanyName/OU=IT/CN=MyCompanyProxyServer/emailAddress=Admin@MyCompany.com  -----BEGIN CERTIFICATE-----  ... blah blah blah  -----END CERTIFICATE-----  ---  Server certificate  subject=/C=US/ST=California/L=San Jose/O=The Linux Kernel Organization/CN=*.kernel.org  issuer=/C=US/ST=MyCompanyState/L=MyCompanyCity/O=MyCompanyName/OU=IT/CN=MyCompanyProxyServer/emailAddress=Admin@MyCompany.com  ---  No client certificate CA names sent  ---  

Note I could probably try to simply use FTP mirrors instead, but that doesn't really solve the problem for other HTTP/S applications (e.g. curl).

Script to delete files older than 6 months

Posted: 26 May 2021 08:38 AM PDT

Setting up a monthly cron job to be run via a script.

The script is to rotate a file each month as it gets too big and rename the old one. When a file is older than six months, I wanted it to be deleted.

Looking to run this script once a month. Is that possible to get the old one deleted?

Please let me know if that isn't clear enough.

obtaining kernel build tree

Posted: 26 May 2021 08:01 AM PDT

Could anyone explain me what the kernel build tree is?

What files does it include?

How can I obtain it from a cross-compiled kernel source (e.g. 3.4.0)?

No comments:

Post a Comment