Monday, September 27, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Are there commercial/freeware/script systems that could back up (daily/weekly/monthly) to S3?

Posted: 27 Sep 2021 10:23 AM PDT

I used to backup 10 important machines (CentOS/RHEL) using rsnap to physical HDDs.
I'd like to migrate this backup so its target would be an AWS/S3 bucket.

Do I have to reinvent the wheel, or are there commercial/freeware/script systems that could back up (daily/weekly/monthly) to S3?

Are these files really Malware?

Posted: 27 Sep 2021 10:09 AM PDT

When running LMD (maldet), it found the following as malware -->

{YARA}r57shell_php_php : /usr/local/chkrootkit/chkrootkit    {YARA}r57shell_php_php : /home/sbembenek/.config/google-chrome/Default/Sync Data/LevelDB/000742.log  

It's hard to believe chkrootkit is malware, but why is it coming up on the list?

And I'm unclear about the chrome log file being on there as well.

thanks!

Visualizing encrypted file wihout saving decrypted version

Posted: 27 Sep 2021 09:58 AM PDT

I am learning how to decrypt secret image files using gpg. In the example below I am encrypting (and then visualizing) a photo called kermit.png. So far I was able to do this as follows:

gpg -d kermit.png.gpg >> kermit_decrypted.png  xdg-open kermit_decrypted.png  

Now the problem is that I do not want to save a decrypted version of my image, because then I will have to remember to delete it using shred -u kermit_decrypted.png or something of this sort. Instead, I would prefer to simply pipe the output of gpg -d kermit.png.gpg into an image viewer. Of course the issue is that my image viewer (viewnior) does not accept this output as its input.

How to go around this?

How to kill proccess running more than x seconds by process name?

Posted: 27 Sep 2021 10:01 AM PDT

I would like to kill all chrome process that are running more than 30 seconds.

at the moment i'm using this command below, but it kills all chrome.

killall -9 chrome

devops golang vs python vs ruby [closed]

Posted: 27 Sep 2021 09:34 AM PDT

I've recently got a job as devops engineer and that's because I've mastered terraform/aws and due to my prior linux experience, but the thing is that I don't know how to code (excluding scripting in bash/zsh etc.) My question is, what do you guys suggest is best for DevOps stuff, I really like and enjoy Golang, but I think Python is the way to "go".

Can't run identical .py file under Apache

Posted: 27 Sep 2021 09:25 AM PDT

I set up Apache webserver on my Pi. I got all my permissions set and was able to run a "hello world" python program.

The JavaScript:

function hellowWorld(){                 $.ajax({                             url: "cgi/helloworld.py",                         dataType: "json",                     type: "post",                         error: ajaxError,                         success: function(json){                        console.log(json.msg);              }       });          }  

The python:

#!/usr/bin/python3    import json  import cgi    header=0    def hw():          jData={              "msg":"hello world"          }          return ("Content-type: application/json\r\n\r\n"+json.dumps(jData))               print( hw() )  

Then, I literally copied helloworld.py to a new file called defaults.py and tested it, but I get an error 500.

function loadDefaults(){                    $.ajax({                             url: "cgi/defaults.py",                           dataType: "json",                     type: "post",                         error: ajaxError,                         success: function(json){                                              console.log(json.msg);              }       });          }  

As far as I can tell, these 2 .py files have exactly the same permissions.

264069 -rwxr-xr-x 1 root root 208 Sep 27 11:00 defaults.py  264068 -rwxr-xr-x 1 root root 193 Sep 27 11:00 helloworld.py  

Why will one run but not the other?

Create a script that creates thousand directories with thousand files in it ie. Each should have content i am a file1 file2...file1000

Posted: 27 Sep 2021 09:10 AM PDT

Make 1000 directories Each directory should have one file In each file content to be written : I'm file1....file1000

Where are my Environment Variables? (Searched all ordinary places)

Posted: 27 Sep 2021 09:32 AM PDT

I want to unset one environment variable and I have searched all these places:

~/.bashrc  ~/.profile  /etc/profile  /etc/environment  ~/.bash_profile  /etc/bash.bashrc  /etc/profile.d/  

As you can see, I have done my homework, but not only I can't find this specific environment variable, I am not able to find the majority of environment variables that env command shows either.

btw, I am using Debian 10.

PS:as this question has been asked numerous times on different forums, I guide anyone that has this question to use the function provided by @terdon in one of the answers. Unfortunately that doesn't solve my problem. But it definitely works in ordinary situations.

How to find a file in current working directory without opening the file in vim

Posted: 27 Sep 2021 08:46 AM PDT

When there is a unit test error in the Java project it shows me the class name. Since it is java class name and the file name is the same I can just append .java. So right now I can add the current working directory to the path option and find the file quite easily.

:set path+=**  :find MyClass.java  

However, I'm planning to

  • read the file under the cursor
  • check if the file exist in the current working directory
  • prompt user to select an existing window or split the view
  • then open the file

I can expand('<cfile>') to get the class name or file path but I cannot find a way to :find MyClass.java without opening the file.

How to allow multiple keyboard layouts and variants on Gnome login?

Posted: 27 Sep 2021 08:22 AM PDT

First of all, I am not sure any more: Does Gnome Shell (version 40) allow switching keyboard layouts on the login screen, at all?

As for configuring it, there is some confusion around a "login screen" in the settings centre, that appears for several users, but that one only allows setting language and formats, as of today.

Then, the Fedora Docs mention how to set keyboard layout for the login screen, but for one layout only.

According to localectl's manpage, it's possible to set a toggle keymap as a second parameter, so localectl set-keymap de-neo us-intl resulted in the following for me

[andy@fedora ~]$ localectl status     System Locale: LANG=de_DE.UTF-8         VC Keymap: de-neo  VC Toggle Keymap: us-intl        X11 Layout: de       X11 Variant: neo  

Looked great, but even after reboot Gnome's login screen did not offer me to switch to the US layout.

It seems that the parameters for set-x11-keymap do not allow multiple keymaps.

sed giving invalid arithmetic operator error

Posted: 27 Sep 2021 08:34 AM PDT

sed keeps giving invalid arithmetic operator error. I am trying to assign the output of sed to a variable.

This one works,

var=$(sed  -e 's/"currentGeneration":5010/"currentGeneration":5011/'  <<< $content )  

but when I try to do the same with variable instead of 5010 and 5011, it fails with invalid arithmetic operator

var=$((sed  -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/'  <<< $content ))  

I tried below also but it won't substitute anything.

var=$(sed  -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/'  <<< $content )  

I am pretty sure I am missing something basic. Learning shell scripting on the job :(

How to use persistent ALSA devices?

Posted: 27 Sep 2021 09:02 AM PDT

I followed this guide to set the default device like this:

create /etc/asound.conf with following:

defaults.pcm.card 1  defaults.ctl.card 1  

But I have the problem that the ALSA card numbers are not deterministic across reboots.

So I followed this guide to change the name of my USB sound cards to something predictable. Essentially it says:

Create a file in /lib/udev/rules.d/ with a name like 85-my-usb-audio.rules and contents like the following:

DEVPATH=="/devices/pci0000:00/0000:00:12.2/usb1/1-4/1-4.3/1-4.3:1.0/sound/card?", ATTR{id}="MyDev_A"  

Using the devices Use the ID string where you would otherwise use the card number, such as

aplay -D default:MyDev_A something.wav  

And then I changed my /etc/asound.conf to:

defaults.pcm.card MyDev_A  defaults.ctl.card MyDev_A  

I also tried

defaults.pcm.card "MyDev_A"  defaults.ctl.card "MyDev_A"  

But when running for example aplay, I get errors:

ALSA lib conf.c:1207:(parse_value) card is not a string  ALSA lib conf.c:1887:(_snd_config_load_with_include) _toplevel_:2:0:Invalid argument  ALSA lib conf.c:3650:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it  ALSA lib conf.c:3572:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument  ALSA lib conf.c:4026:(snd_config_update_r) hooks failed, removing configuration  aplay: device_list:281: control open (0): Invalid argument  

unable to expand the variables inside ssh

Posted: 27 Sep 2021 10:03 AM PDT

I'm trying to search for the file of the format : "installation_xx_int_${type}_*log" of the current date inside the remote server using below command:

ssh user@hostname 'file=$(find ~ -type f -name "installation_xx_int_${type}_*log" -mtime -1 -exec basename "{}" \;); cat "$file"' > ~/$file  

but, the problem here is that the variables: ${type} and $file are not getting expanded inside ssh command , therefore unable to redirect the output of the file from remote server to my server.

If there's any other method to achieve this in more simpler way, please let us know!

Many thanks in advance!

I have removed 'head' manually - how do I reinstall it?

Posted: 27 Sep 2021 09:58 AM PDT

It seems that I've removed head manually from my /usr/bin/ a couple of months ago. Now that I chance to need it I don't have it. How do I reinstall it without reinstalling the whole distro? My environment: Ubuntu 20.04 LTS Desktop.

`/dev/fuse` is huge

Posted: 27 Sep 2021 08:04 AM PDT

I am running a bit low on storage. After running df -h I saw the following:

/dev/fuse       250G   512  250G   1%  

Should I try to shrink it? Is it ok for the /dev/fuse to be that large?

Please note, that I run on Windows + Ubuntu 20.04 dual-boot, so maybe it is Windows. I have 1TB SSD on my laptop, but the sum of all the sizes of the output of df -h is definitely less than 1TB, so probably it is not.

EDIT: after restarting the system, the /dev/fuse disappeared for some reason.

full output of df -h:

udev            7.7G     0  7.7G   0% /dev  tmpfs           1.6G  2.4M  1.6G   1% /run  /dev/nvme0n1p6   83G   65G   14G  83% /  tmpfs           7.7G  306M  7.4G   4% /dev/shm  tmpfs           5.0M  4.0K  5.0M   1% /run/lock  tmpfs           7.7G     0  7.7G   0% /sys/fs/cgroup  /dev/loop2      209M  209M     0 100% /snap/code/74  /dev/loop4      100M  100M     0 100% /snap/core/11420  /dev/loop3      209M  209M     0 100% /snap/code/75  /dev/loop6       56M   56M     0 100% /snap/core18/2074  /dev/loop1      128K  128K     0 100% /snap/bare/5  /dev/loop5      100M  100M     0 100% /snap/core/11606  /dev/loop7      242M  242M     0 100% /snap/gnome-3-38-2004/70  /dev/loop8       62M   62M     0 100% /snap/core20/1081  /dev/loop9       62M   62M     0 100% /snap/core20/1026  /dev/loop0      1.3M  1.3M     0 100% /snap/axel/77  /dev/loop10     219M  219M     0 100% /snap/gnome-3-34-1804/66  /dev/loop11     219M  219M     0 100% /snap/gnome-3-34-1804/72  /dev/loop13     768K  768K     0 100% /snap/gnome-characters/726  /dev/loop12     2.5M  2.5M     0 100% /snap/gnome-calculator/884  /dev/loop14     640K  640K     0 100% /snap/gnome-logs/103  /dev/loop15      33M   33M     0 100% /snap/snapd/12883  /dev/loop16     243M  243M     0 100% /snap/gnome-3-38-2004/76  /dev/loop17     384K  384K     0 100% /snap/gnome-characters/708  /dev/nvme0n1p1  256M   35M  222M  14% /boot/efi  /dev/loop18     2.3M  2.3M     0 100% /snap/gnome-system-monitor/157  /dev/loop19      56M   56M     0 100% /snap/core18/2128  /dev/nvme0n1p7  153G  140G  5.0G  97% /home  /dev/loop20     2.5M  2.5M     0 100% /snap/gnome-calculator/826  /dev/loop21     256K  256K     0 100% /snap/jq/6  /dev/loop22      33M   33M     0 100% /snap/snapd/13170  /dev/loop23     308M  308M     0 100% /snap/telegram-desktop/3149  /dev/loop24      51M   51M     0 100% /snap/snap-store/547  /dev/loop25      66M   66M     0 100% /snap/gtk-common-themes/1519  /dev/loop26      66M   66M     0 100% /snap/gtk-common-themes/1515  /dev/loop27     640K  640K     0 100% /snap/gnome-logs/106  /dev/loop28     223M  223M     0 100% /snap/pinta-james-carroll/8  /dev/loop29      27M   27M     0 100% /snap/heroku/4068  /dev/loop30     308M  308M     0 100% /snap/telegram-desktop/3119  /dev/loop31      27M   27M     0 100% /snap/heroku/4076  /dev/loop32     2.5M  2.5M     0 100% /snap/gnome-system-monitor/163  tmpfs           1.6G   88K  1.6G   1% /run/user/1000  

Full output of sudo fdisk -l:

Disk /dev/loop0: 1.2 MiB, 1253376 bytes, 2448 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop1: 4 KiB, 4096 bytes, 8 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop2: 208.43 MiB, 218542080 bytes, 426840 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop3: 208.43 MiB, 218546176 bytes, 426848 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop4: 99.39 MiB, 104210432 bytes, 203536 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop5: 99.35 MiB, 104169472 bytes, 203456 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop6: 55.45 MiB, 58134528 bytes, 113544 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop7: 241.37 MiB, 253087744 bytes, 494312 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/nvme0n1: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors  Disk model: WDC PC SN730 SDBQNTY-1T00-1001            Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: gpt  Disk identifier: 09126438-D691-4D3B-BDF1-AC5099BB812D    Device              Start        End    Sectors   Size Type  /dev/nvme0n1p1       2048     534527     532480   260M EFI System  /dev/nvme0n1p2     534528     567295      32768    16M Microsoft reserved  /dev/nvme0n1p3     567296 1486360575 1485793280 708.5G Microsoft basic data  /dev/nvme0n1p4 1998360576 2000408575    2048000  1000M Windows recovery environment  /dev/nvme0n1p5 1486360576 1496125439    9764864   4.7G Linux swap  /dev/nvme0n1p6 1496125440 1672187903  176062464    84G Linux filesystem  /dev/nvme0n1p7 1672187904 1998360575  326172672 155.5G Linux filesystem    Partition table entries are not in disk order.      Disk /dev/loop8: 61.79 MiB, 64770048 bytes, 126504 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop9: 61.75 MiB, 64729088 bytes, 126424 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop10: 218.102 MiB, 229629952 bytes, 448496 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop11: 219 MiB, 229638144 bytes, 448512 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop12: 2.5 MiB, 2605056 bytes, 5088 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop13: 704 KiB, 720896 bytes, 1408 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop14: 548 KiB, 561152 bytes, 1096 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop15: 32.31 MiB, 33869824 bytes, 66152 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop16: 242.35 MiB, 254115840 bytes, 496320 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop17: 276 KiB, 282624 bytes, 552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop18: 2.24 MiB, 2342912 bytes, 4576 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop19: 55.45 MiB, 58130432 bytes, 113536 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop20: 2.49 MiB, 2600960 bytes, 5080 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop21: 240 KiB, 245760 bytes, 480 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop22: 32.32 MiB, 33878016 bytes, 66168 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop23: 307.46 MiB, 322387968 bytes, 629664 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop24: 50.98 MiB, 53432320 bytes, 104360 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop25: 65.22 MiB, 68378624 bytes, 133552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop26: 65.1 MiB, 68259840 bytes, 133320 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop27: 548 KiB, 561152 bytes, 1096 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop28: 222.2 MiB, 232800256 bytes, 454688 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop29: 26.24 MiB, 27504640 bytes, 53720 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop30: 307.48 MiB, 322404352 bytes, 629696 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop31: 26.24 MiB, 27512832 bytes, 53736 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/loop32: 2.51 MiB, 2621440 bytes, 5120 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  

Can I Install Termux on Linux?

Posted: 27 Sep 2021 08:20 AM PDT

We can install a Linux sub-system like CentOS or Ubuntu on Termux, but is it possible to have a Termux-like sub-system on Linux?

In Termux the installations of some packages are much easier with pkg install. And Termux provides many resources that cannot be obtained directly using one line of code on pure Linux.

I came up with this idea when I was learning Termux on my phone and found the limited screen and soft keyboard really troublesome.

(don't tell me that I need an Android emulator or virtual machine)

Grep Extract whole word without quotes

Posted: 27 Sep 2021 09:53 AM PDT

I have a file with lot of entries in it. I want to extract the ID of certain component. The prefix of that ID is abcd.inst Means there is only one word which is like

abcd.inst.sdt.gh-wer-1.anrg6ljrgo5rdtyc25lgtr2wf7iuhu2f5scwehpjjzerzpnphn3tzy4w2wjq

Whenever I do

cat abcd.txt | grep "abcd.inst"  

I'm getting output as

"id": "abcd.inst.sdt.gh-wer-1.anrg6ljrgo5rdtyc25lgtr2wf7iuhu2f5scwehpjjzerzpnphn3tzy4w2wjq"  

Is it anyway possible to get the Output as

abcd.inst.sdt.gh-wer-1.anrg6ljrgo5rdtyc25lgtr2wf7iuhu2f5scwehpjjzerzpnphn3tzy4w2wjq  

I tired using

grep -oh abcd.inst abcd.txt  

But the output was

abcd.inst  

I cannot untar a zip file keep getting error

Posted: 27 Sep 2021 10:22 AM PDT

From the link below I try to follow the steps and I got the curl portion to work but when I type

tar zxf admit.tar.gz  

I get

tar: Unrecognized archive format  tar: Error exit delayed from previous errors.  

I have no idea what to do I double click to unzip but then I have a new file come out as admit.tar.gz.cpgz I am not sure what to do? I am trying to follow the steps provided on website but it does not work.

http://admit.astro.umd.edu/installguide.html

How to list sub directories of a directory using ls?

Posted: 27 Sep 2021 10:09 AM PDT

I need to list the sub directories of a certain path. The separation should be with spaces and not new lines.

I also do not want the absolute path to the sub directories, just their names.

# correct  dir1 dir2 dir3    # incorrect: separation with new lines  dir1  dir2  dir3    # incorrect: absolute paths  /home/x/y/dir1 /home/x/y/dir2 /home/x/y/dir3  

I've seen a lot of other posts like this SO post, but they do not accomplish my request.

I've tried ls -d ~/y but it lists absolute paths and separates with new lines. I guess I could use sed to remove the irrelevant part of the path, and then remove all the new lines. But I couldn't get it to work, and it seems like there should be a better solution

/etc/sudoers - clarification about "all" vs "all:all" for groups

Posted: 27 Sep 2021 08:14 AM PDT

About configuration(s) for the /etc/sudoers file with visudo I have read the following tutorials (among others):

A very important part is the following structure:

  • user hostname=(runas-user:runas-group) command

I understand the following about users:

root ALL=(ALL:ALL) ALL  hope ALL=(ALL:ALL) ALL  

What is not clear for me is about the %groups. In the /etc/sudoers file are shown the %admin and %sudo groups as follow:

# Members of the admin group may gain root privileges  %admin ALL=(ALL) ALL  # Allow members of group sudo to execute any command  %sudo ALL=(ALL:ALL) ALL  

About (ALL) vs (ALL:ALL)

  1. When the former would be mandatory over the latter and viceversa?
  2. What type of commands should work with the former and latter respectively

So, it is not clear for me (even with the available comments for each one), therefore if I want create and a new group (i,e: developers) I don't know if should be declared (ALL) or (ALL:ALL).

slow access/reads of linux md raid1 array

Posted: 27 Sep 2021 09:17 AM PDT

I have a Linux md-raid raid1 array (ext4 fs), with 2 3TB disks. The array has been showing significant slowness in access and read times over the last few months. Doing an ls on a directory w/ less than 20 records can sometimes take 2-3 minutes to return.

It seems to spend a lot of time with a state of "checking," but even when the state is "clean," access and read times are very slow. I don't find any errors being reported in the system logs. The only thing of note is that the FS has been close to full for a while now. The output of mdadm -D /dev/md127 shows:

/dev/md127:       Version : 1.2       Creation Time : Thu Jun 20 11:34:21 2019          Raid Level : raid1          Array Size : 2930132992 (2794.39 GiB 3000.46 GB)       Used Dev Size : 2930132992 (2794.39 GiB 3000.46 GB)        Raid Devices : 2       Total Devices : 2         Persistence : Superblock is persistent         Intent Bitmap : Internal           Update Time : Sun Sep 26 13:58:50 2021               State : clean      Active Devices : 2     Working Devices : 2      Failed Devices : 0       Spare Devices : 0    Consistency Policy : bitmap                  Name : giles:meta  (local to host giles)                UUID : 638efea5:1e7b07d2:78fec1dc:d919dccf              Events : 8359        Number   Major   Minor   RaidDevice State         0       8        1        0      active sync   /dev/sda1         1       8       17        1      active sync   /dev/sdb1  

Any thoughts on what might be causing this or suggestions on debugging it? I'm in the process of copying the data to a new set of larger drives and it has only copied 301GB in over 48 hours.

Assign groups based on a list of paired values between all individual group entries

Posted: 27 Sep 2021 09:46 AM PDT

I have a tab-separated file pairs.tsv with two columns that display paired entries. Based on the two values in the two columns, I want to create a third column that assigns groups to the entries.

In some cases however more than two entries belong to the same group. The script should accordingly start at line 1 and assign group01 to the first pair and then check through the remaining lines if either of the two values from column 1 or 2 appear and if true, also assign group01 to this line.

This step should be repeated until all entries in the file affiliated to group01 by iteratively detecting pairs are assigned to group01.

Then the script should proceed with the next line and if no group was assigned yet, assign it to group02 and then again check through the remaining file, if the entry of column 1 or 2 in line 2 appears in any of the lines below and if yes assign also group02 to the line. And so on.

pairs.tsv:

a   b  c   d  e   f  e   g  h   i  h   j  k   l  f   g  m   n  i   j  

The output file should look like this:

a   b   group01  c   d   group02  e   f   group03  e   g   group03  h   i   group04  h   j   group04  k   l   group05  f   g   group03  m   n   group06  i   j   group04  

purpose of dashes in `wget -qO- https://get.speedify.com | bash -`

Posted: 27 Sep 2021 08:24 AM PDT

In this command:

wget -qO- https://get.speedify.com | bash -  

Source: https://support.speedify.com/article/562-install-speedify-linux

...the first -q is the option for "quiet" mode. What is the O- (notice that is the letter "O", NOT a zero) part though? Why the letter O? Why the trailing -? Finally, after the bash command there is also a trailing -. Why?

Update: now that I know that is the letter O, NOT a zero, I see this from the man wget manual pages:

  -O file    --output-document=file        The documents will not be written to the appropriate        files, but all will be concatenated together and written        to file.  If - is used as file, documents will be        printed to standard output, disabling link conversion.  

So, -qO is the same as -q -O, and -O sets the output file, and -O- apparently says to print the document to standard output. I wonder why they didn't do -O=- or -O - though...?

Not a duplicate:

This question answers the smallest, least-relevant, and least-significant part of my question: Do command line options take an equals sign between option name and value?. It does not answer my question.

How do I permanently set an environment variable for a specific Flatpak application?

Posted: 27 Sep 2021 08:34 AM PDT

I would like to set an environment variable so that it is set when I launch a specific Flatpak application, and only set for this application. How do I go about doing this in a permanent manner?

Trying to understand the difference between "modernNeo ALL=(ALL:ALL) ALL" and "modernNeo ALL=(ALL) ALL" in the sudoers file

Posted: 27 Sep 2021 08:25 AM PDT

In the sudoers file, you can have either of the following lines

modernNeo ALL=(ALL:ALL) ALL  modernNeo ALL=(ALL) ALL  

I looked at the following answers on here to understand this

Question 1

If I understand correctly from those above answers, (ALL:ALL) means that you can run the command as any user and any group and that (ALL) means that you can run the command as any user but your group remains the same [it remains your own group] regardless of the user you become when you use sudo with ALL for the third entry?

Question 2

But with (ALL:ALL)

  • If you can run it as any group, how does sudo decide what group you run the command as if you don't specify it on the commandline using -g?
  • does it first try to run it as your own group and then go through a list of all the groups on your machine before finding the group that allows you to run the command?
  • Where does it get the list of groups from and what is the order of the groups on that list?
  • Or does it just revert to using root for user and/or group when your preference for what user and/or group you want to become isn't specified? If that is the case, why do (ALL:ALL) when you can do (root:root) ?

Question 3

Furthermore, in this Ubuntu Forums post, with regards to the following lines

%admin ALL=(ALL) ALL    %sudo   ALL=(ALL:ALL) ALL    

They say that

Users in the admin group may become root. Users in the sudo group can only use the sudo command.
For instance, they could not sudo su
(ALL:ALL) refers to (user:group) that sudo will use. It can be specified with -u and -g when you run sudo. If you don't specify anything it will run as root:root, which is the default. That's how most end up using it anyway.

That confuses me; they are stating that if you can take on any group when running a command, then you are unable to become root?

Best way to use and install Linux (Ubuntu) using two hard drives

Posted: 27 Sep 2021 08:07 AM PDT

I'm currently looking to switch from Windows 10 to Ubuntu 18.04 LTS (not dual-booting, Ubuntu only).

On Windows I've used my 128GB SSD for OS-files almost exclusively, while all other stuff goes to my 2TB SSHD.

How do I effectively use both my hard-drives on Linux? Can I, like on Windows, have the Linux OS-files set-up on my SSD for a fast boot and all other files on my SSHD?

I've read that my "swap partition" should be on my SSHD since it's so large in size. How much size should I give it when I have 16GB DDR3 ram?

I'm open to suggestions, I just want my new install to go smoothly and not waste an entire hard drive.

Thanks.

How to add virtual IP to network interface in CentOS?

Posted: 27 Sep 2021 08:25 AM PDT

My CentOS VPS got many IP addresses that I'd like to add to the eth0 network interface.

Currently eth0 only got 1 IPv4 address and its other ones doesn't show up.

My searching gives me terms like IP Alias but that doesn't seem to apply to CentOS. The CentOS Wiki doesn't really show how it's done.

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

Now you can edit the new file ifcfg-eth0:0 and specify the network settings of the virtual interface.

How do I manually add IPv4 IP addresses to a physical network interface in CentOS 7?

Git clone from Bitbucket

Posted: 27 Sep 2021 10:03 AM PDT

I am trying to git clone a repo off of bitbucket. I use git clone {https} temp. This gives me an error of refs not found. The https address is the one I get off of bitbucket, but the one they provide uses hg instead of git. Why is this happening?

Laptop boots directly to Ubuntu, can't access BIOS or Boot menu anymore

Posted: 27 Sep 2021 08:35 AM PDT

I'm running Laptop with single OS: UbuntuMATE 15.04 Beta1 64bit on Toshiba laptop Core i3. After burning "Elementary OS" on a live USB drive using UNetbootin, what happened is:

-After reboot, laptop directly shows UbuntuMATE boot screen, doesn't show Toshiba logo at the begginning as usual. So no access to BIOS or boot menu anymore. So it boots directly to UbuntuMATE and it runs normally.

  • Installed Boot-Repair and ran (Recommended Repair); it gets aborted showing me this message: "Please use this software in a live-session (live-CD or live-USB). This will enable this feature"... which I can't boot from a live CD or USB as I lost access to boot menu.

  • Boot info summary gave me this link http://paste.ubuntu.com/10664795/ which I can ask for help providing information in it.

  • I looked around into several posts but couldn't find what matches my case.

What exactly am I supposed to do? I'm a little new to Linux (3 months) and I'm still learning, so I do not know much.

Install virtual machine as non-root?

Posted: 27 Sep 2021 10:05 AM PDT

Is it possible to install any virtual machine software as non-root user and run it ?

Which VM's are possible to be installed with out need of root access ?

If it is not possible what would be the most light weight virtual machine to use for a few VM's running windows xp sp3 ?

No comments:

Post a Comment