Thursday, August 26, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Installing man pages for section 9 (kernel routines)

Posted: 26 Aug 2021 10:52 AM PDT

I am trying to make possible reading manuals for kernel-mode functions, such as printk with man 9 printk. The section 9 is for kernel functions: from man man section descriptions:

9 - Kernel routines [Non standard]

Running make mandocs at /usr/src/linux/ throws this:

make: *** No rule to make target 'mandocs'.  Stop.  

(I think mandocs is obsolote or was removed). I cannot find man9 packages on my Gentoo GNU/Linux system. Also, I tried to install those manpages on Debian virtual machine, but it fails too.

How can I install/make/download those non-standard manpages for kernel functions to be able to run man printk to get docs without having to search documentation online or browsing header files?

I know that similar questions was already asked, but they are deprecated (no make mandocs now).

How to get disk space low alert?

Posted: 26 Aug 2021 10:35 AM PDT

Our webserver hosted in pair.com uses now over 100% of allowed disk space which is 20GB.

I try to create cron script which emails to 2 email addresses when used disk space is 95% full.

I have this script but i can't figure out whats wrong:

#!/bin/bash/disk-usage-alert.sh    for a in "$(du -s /usr/home/ourshortnameinpair)"  do  spc=$(echo $a|cut -d" " -f1)  if [ $spc -gt 1000 ]  then  echo "alert on $1, the space is $spc"|mail ouremailaddresshere -s "Alert space"  fi  done  

In my.pair.com ACC i have created cron job with correct path: $HOME/disk-usage-alert.sh and did sudo chmod u+x disk-usage-alert.sh and uploaded script to right folder /usr/home/ourshortnameinpair

https://www.pair.com/support/kb/configuring-cron/#a-note-on-cron-job-commands  

File operation difference and calculation - looping

Posted: 26 Aug 2021 10:35 AM PDT

i have 2 files. I need to find difference in percentage between these files value ( e.g 1st value of both files e.g aaa 200,20 and 100,00) then second bbb with bbb so on in unix shell script in HPUX. I have written below code. Its working for 1 value for(aaa) however I need to add a loop for it so it can work for multiple values likes bbb (500,20 and 300,60) and ccc, and so on.could you please help on looping in script on the same.

1.txt

aaa:200,20               bbb:500,20              ccc:600,40              

2.txt

aaa:100,00  bbb:300,60  ccc:400,50  

i have written below code.

M1=`cat 1.txt| sed -n 1p 1.txt|cut -d ":" -f2|sed 's/,//g`  M2=`cat 2.txt| sed -n 1p 2.txt|cut -d ":" -f2|sed 's/,//g`    if [ $M1 -gt $M2 ]  then  perc=$(expr $M1 - $M2)  echo $perc  erc1=$(expr $perc \* 100)  echo $erc1  exp2=$(expr $erc1 / $M2)  echo $exp2  echo "Diffence in Percentage is:$exp2"    else    perc=$(expr $M2 - $M1)  erc1=$(expr $perc \* 100)  exp2=$(expr $erc1 / $M1)  echo "Differnce in Percentage is:$exp2"  fi    if [ $exp2 -gt 20 ]     //20 is threshold  then  echo "Difference between trend is more then 20%: It is $exp2"  fi  

Use ls to list backup files only

Posted: 26 Aug 2021 10:50 AM PDT

I have a large number of "backup" files of the form '#e.xvg.i#', where i ranges from 1 to 60. A file e.xvg also exists in the same directory. For example:

e.xvg  '#e.xvg.1#'  '#e.xvg.2#'  ...  

On bash, how do I use ls to list ONLY the backup files?

ls '#e*#' returns "No such file or directory", while ls #e*# appears to list ALL files in the directory.

Backup of VM using "virsh snapshot-create-as" works once. Fails second time

Posted: 26 Aug 2021 09:44 AM PDT

I'm running Ubuntu 20.04 with QEMU 4.2.1 and am trying to setup backups using these instructions: https://libvirt.org/kbase/live_full_disk_backup.html (older libvirt instructions, as Ubuntu 20 has older libvirt).

The backup method works once, but fails when run a second time. This may be related to the instructions using a VM that has the VM disk as a .raw file, but I'm using a .qcow2. At this point have several VMs, so I'd rather not convert to .raw.

When I run:

$ virsh snapshot-create-as --domain vm1 overlay1 \      --diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \      --disk-only  virsh blockcommit vm1 vda --active --verbose --pivot   

Everything works, no errors. If I don't remove the "overlay1.qcow2" file and run the command again, I get this error:

error: unsupported configuration: external snapshot file for disk vda already exists and is not a block device: /var/lib/libvirt/images/overlay1.qcow2   

If I remove the file before running it again (as suggested by the instructions):

error: operation failed: domain moment overlay1 already exists   

Did some digging and ran the snapshot-list:

$ virsh snapshot-list --tree vm1  overlay1   

Tried removing the snapshot:

virsh snapshot-delete vm1 overlay1  error: Failed to delete snapshot overlay1  error: unsupported configuration: deletion of 1 external disk snapshots not supported yet  

Not sure where to go from here.
Do I have to use .raw images? . . If so, why?

Thanks.

How to obtain system and user information from a mounted VMDK file?

Posted: 26 Aug 2021 10:25 AM PDT

Looking for some help with obtaining (grabbing) data from a VMDK file that is mounted under (Ubuntu 20.04) Linux. The challenge is to mount the VMDK file and use CLI to obtain information on the VMDK installed Linux system instead of spinning it up in a VM or using Forensics tools on it.

There are things I was able to obtain such as os-release, timezone, hostname, and filesystem type.

I achieved it using the following commands:

  • cat /mnt/vmdisk/etc/os-release,
  • cat /mnt/vmdisk/etc/hostname,
  • cat /mnt/vmdisk/etc/timezone,
  • df -Th

While df -Th shows all drives, I could pinpoint /dev/loop5 which has /mnt/vmdisk under it to be ext4 filesytem. Which would make sense as the VMDK is for Ubuntu 14.04.6 LTS image.

Here is where I'm unsure where to look and what to run. I need to collect the following data as well.

  1. How do I obtain "last" system IP?
  2. Whose account is UID XXXX?
  3. On X date what IP did UID XXXX authenticate from?
  4. Last command used by user?

For #2 I think I could just use cat /mnt/vmdisk/etc/passwd or grep 'xxxx' /mnt/vmdisk/etc/passwd. However I'm not 100% certain fetching UID out of /etc/passwd would be the right place.

Suggestions on how to collect this data would be beyond helpful.

Thank you.

how to compare the lsblk disk size values to disk size values from df -h

Posted: 26 Aug 2021 10:39 AM PDT

I want to compare the size of the disk between the size from df -h to lsblk Because we performed resize2fs , and after resize2fs I want to check the size from df -h against the size from lablk

So we have the following from lsblk

lsblk  NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT  sdb                  8:16   0    4G  0 disk /data1  sdc                  8:32   0    4G  0 disk /data2  sdd                  8:48   0    4G  0 disk /data3  

from df -h

df -h  Filesystem                  Size  Used Avail Use% Mounted on  /dev/sdb                    3.9G   22M  3.8G   1% /data1  /dev/sdc                    3.9G   18M  3.8G   1% /data2  /dev/sdd                    3.9G   18M  3.8G   1% /data3  

So I did the following in my bash script

[[ ` lsblk | grep "^sdb" | awk '{print $4}'  ` == ` df -h | awk -v disk_var="sdb" '$1 ~ disk_var' | awk '{print $2}'  ` ]] && echo "val are equal " || echo "val are not equal "  

So I get from above value are not equal , in spite the values should be the same

Any suggestion how to use "df -h" in order to get readable size values that we can compare as the values from lsblk?

we are working on rhel 7.6 server

Are DRM/TTM Linux kernel module needed for a virtual machine with no graphical interface?

Posted: 26 Aug 2021 09:00 AM PDT

In a VMware virtual machine, I have a Debian 11 with no graphical interface (but with an SSH server). I try to blacklist some unneeded kernel modules, like everything related to Bluetooth, HDMI, serial mouse and so.

But for [DRM/TTM][1], I'm not sure of me: at first glance, I would say there is no need for a module managing the 3D of my graphical card. So I would blacklist the following in /etc/modprobe.d/my-blacklist.conf:

blacklist vmwgfx  blacklist drm_kms_helper  blacklist ttm  blacklist drm  

(before doing a update-initramfs -u do update the initramfs for next boot)

But I wonder if my Linux distribution is natively made to use the GPU to do some calculation, to help the CPU, and if disabling the DRM would break this? And does this has a sense for virtual environments, as the GPU of a VM is mainly managed by the CPU of the hypervisor?

[1]: https://www.kernel.org/doc/html/latest/gpu/drm-mm.html#:~:text=TTM%20was%20the%20first%20DRM,i.e.%20most%20discrete%20video%20cards).

Search for long string (>50 characters) and record match

Posted: 26 Aug 2021 10:29 AM PDT

I have a piece of code that looks for a string and then records if that matches. The code works fine when the string is not longer than 50 characters. However above this, say for a string of 100 or 150 characters it bases a match only on the first 50 characters in the string rather than the full 100/150 character string.

Is there a way to make sure it counts matches based on the full string length? Im using an awk program as currently a score is based on birthdate and being less than a column and then the long string matching.

want2=$( awk '{print $4}' temp10_0.txt | head -1 )  dob_want2=$(head -1 year.txt )  awk -v a="$want2" -v b="$dob_want2" '{ if ($1==a && $2<=b) print $0, "1";else print $0, "0"}' temp25_0.txt>  temp11_0.txt  
  • Input data in temp25_0.txt is as follows
    51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2016   51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2008    51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2013  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2000  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 1987  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 1965  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555150000555555515515551011155111555115155101155511 2000  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555000551511115555555155155511111551115551151551111555 2007  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111150500 2016  
  • want2 is
    51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511  
  • dob_want2 is
    2019  
  • Desired output is
    51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2016 1  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2008 1    51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2013 1  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 2000 1  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 1987 1  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111155511 1965 1  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555150000555555515515551011155111555115155101155511 2000 0  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555000551511115555555155155511111551115551151551111555 2007 0  51511151511115551515555551111111555115511511111511115151111555151555511115511551511555551555155555555151111555555515515551111155111555115155111150500 2016 0  

(I know it would be easier to read if the lines were shorter, but the line length seems to be the whole issue here.) Any advice would be much appreciated

Why all versions of Android until now contains almost no GNU softwares?

Posted: 26 Aug 2021 07:31 AM PDT

A GNU/Linux OS contain almost all GNU software (nano, tar, bash, make, etc.).

But how does Android? It even does not have a terminal by default for mobile. Google has replaced most of them by non-free softwares developed by Google.

Why Google did that?

Can't set up environment path variables in new Kali Linux 2021.2 installation [duplicate]

Posted: 26 Aug 2021 07:42 AM PDT

I want to add environment path variable for some stuff as I did in kali linux 2019, but it's not working. In kali 2019 i put this: PATH=$PATH:/home/kali/hacking/recon/ in ~/.bashrc and evertything was fine.

In 2021.2 I have tried to put this in: ~/.bashrc and ~/.profile.

export PATH="$PATH:/home/kali/hacking/recon/  PATH=$PATH:/home/kali/hacking/recon/    

and it's not working. echo $PATH does not show these paths. Any ideas?

Website served on port 80 unreachable from my phone in the local subnet

Posted: 26 Aug 2021 07:37 AM PDT

I'm building a website on my laptop. To see how it renders, I serve it locally on port 80 with lighttpd. I can then open it in my laptop's browser via any IP or URL referring to the laptop http://localhost or http://192.168.1.47 (IP on the local subnet) or http://coulomb (its hostname) . Fine.

Now I want to test its responsive design, so I try to open the laptop address in my phone's browser: http://192.168.1.47 or http://coulomb. Both devices (phone and laptop) are in the 192.168.1.* subnet of my Wifi DSL box. Strangely to me, the phone's browser (be it Firefox or Chrome) "rephrases" the IP into "localhost". The connexion then fails with a "site unreachable"-like error.

lighttpd is not the culprit. To check this I instead served the files of some directory of the laptop with sudo ruby -run -ehttpd . -p80, the behavior is the same.

There is something with the port. If I serve the website on port 3000 (as shown in lighttpd docs) or 8000 or 8080 it works: the phone's browser opens 192.168.1.47:3000 (or :8000 or :8080) and I see the website.

The phone seems not to be the culprit either: I can open the HTTP interface of the DSL box at 192.168.1.1, default port, without problem. (If asked to, I might try and use a computer client instead of the phone, but it's not easy for practical reasons.)

If you wonder why I insist on serving it on port 80: it is built with Wordpress, and doesn't work right on a custom port, the plain text is shown but no css or images are loaded. I don't want to workaround the problem by tweaking Wordpress to make it custom-port-compatible, because when the site is ready I'll mirror it to a public server.

My sed command is throwing error sed: -e expression #1, char 22: unknown option to `s'

Posted: 26 Aug 2021 10:47 AM PDT

I tried below command in my script and got error,

sed -i -e 's/\(dataTable\)/$replace \1/' file.txt  

Error Message,

sed: -e expression #1, char 22: unknown option to `s'  

Please help me in correcting the command to avoid error.

Thanks!

Equivalent of executing a file (with shebang line) by entering its path?

Posted: 26 Aug 2021 10:47 AM PDT

Say I have a file hello:

#!/bin/sh    echo "Hello World!"  

Provided the executable bit is set on that file, I can execute it by entering its path on the prompt:

$ ./hello  Hello World!  

Is there a more explicit equivalent to the above? Something akin to:

$ execute hello  

I know I can pass hello as an argument to /bin/sh, but I'm looking for a solution that automatically uses the interpreter specified in the shebang line

My use case for this is to execute script files that do not have the executable flag set. These files are stored in a git repository, so I would like to avoid setting their executable flag or having to copy them to another location first.

Unable to set PATH in linux kali

Posted: 26 Aug 2021 07:27 AM PDT

I've been trying to add a path but I'm unable to do so. I tried adding PATH="$PATH:/snap/bin" in ~/.bashrc and ~/.profile but it didn't work. But if I do source ~/.profile it works. Is there a way to make it work without running any commands? I am using version 2021.2

Thanks.

Edit: I've added `export PATH="$PATH:/snap/bin:" as well. Didn't work.

This is my .profile enter image description here

My shell is using zsh and not bash if that is relevant.

How can i increment a number in each line that has the same number

Posted: 26 Aug 2021 07:30 AM PDT

Example a file has

test test test test test  TEST: 15000  abcabc TEST: 15000 testtest test  TEST: 15000  test test  test 14000 test test test  TEST: 15000  TEST: 15000  

it Must become so no matter the text when it see 15000 just increment 1 on each lines

test test test test test  TEST: 15001  abcabc TEST: 15002 testtest test  TEST: 15003  test test  test 14000 test test test  TEST: 15004  TEST: 15005  

Can busybox unzip tool overwrite symlinks?

Posted: 26 Aug 2021 09:29 AM PDT

I'm using the Busybox 1.32.0 package tools in an embedded device. When I'm in Ubuntu based x64 platforms, the unzip tool packaged there can extract over a destination directory without prompting any errors if I'm trying to extract a symlink. However, in the case of Busybox, when I try to do this and there's already a symlink with the same link stored there I get this error:

unzip: '/usr/local/bin/sample.so.1' exists but is not a regular file  

Sure it's not a regular file, because it's actually a symlink. But what I want to do is either:

  • Continue with the unzip process omitting this files.
  • Replace this files with the symlink files stored in the zip.

Is there any way to achieve this?

Convert a date from DD-MM-YYYY to YYYY-MM-DD format in bash LINUX

Posted: 26 Aug 2021 08:32 AM PDT

Scenario:

I am fetching a date value from a file into a variable and it is in DD-MM-YYYY format by default. I have to substract this date from system date. Subtraction is giving incorrect result if I had both dates in DD-MM-YYYY format. So I read a bit on google and decided to format both dates as YYYY-MM-DD as this will give correct value after subtraction. I have System date formatted successfully in YYYY-MM-DD, but facing a hard time to convert the date obtained from the file to YYYY-MM-DD format.

Below solution works fine with single digit dates:

$ date -d $(sed "s/-/\//g" <<< '9-2-1832') +%Y-%m-%d  Output : 1832-09-02  

but when I try to convert date in double digits like below:

$ date -d $(sed "s/-/\//g" <<< '19-07-2021') +%Y-%m-%d  

I get output

Invalid date '19/07/2021'  

Where:

19 - is Date of a month  07 - is Month i.e. July in this case.  2021 - is Year  

Desired output as -> 2021-07-19

I am working on RH Linux with Date version as: date (GNU coreutils) 8.22

Please help to provide a solution for above problem.

Any way to keep Stunnel from blowing up my logfiles?

Posted: 26 Aug 2021 07:30 AM PDT

I have stunnel v5.44 (Ubuntu 18.04 v3:5.44-1ubuntu3) configured on a client to connect to a server in a screened subnet. The remote host has syslog configured to listen for logfiles over the stunnel connection. The client, of course, is configured to forward it's logs to the server over stunnel.

This setup has worked great for years, but sometime last year (or year before? gawd 2020...), during OS upgrades (Ubuntu 16.04 and 18.04), something changed where stunnel is now spamming the logfiles with hundreds of error messages per second whenever the remote syslog server is rebooted or unavailable.

...  Jan 20 04:20:31 nwhost stunnel[25787]: LOG5[2126349]: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket  Jan 20 04:20:31 nwhost stunnel[25787]: LOG5[2126350]: Service [syslog_tunnel] accepted connection from 127.0.0.1:52970  Jan 20 04:20:31 nwhost stunnel[25787]: LOG3[2126350]: s_connect: connect 172.22.15.23:51400: Connection refused (111)  Jan 20 04:20:31 nwhost stunnel[25787]: LOG3[2126350]: No more addresses to connect  Jan 20 04:20:31 nwhost stunnel[25787]: LOG5[2126350]: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket  Jan 20 04:20:31 nwhost stunnel[25787]: LOG5[2126351]: Service [syslog_tunnel] accepted connection from 127.0.0.1:52974  Jan 20 04:20:31 nwhost stunnel[25787]: LOG3[2126351]: s_connect: connect 172.22.15.23:51400: Connection refused (111)  Jan 20 04:20:31 nwhost stunnel[25787]: LOG3[2126351]: No more addresses to connect  ...  

In my clientside /etc/stunnel/remote_log.conf I have this, but the errors keep filling up the logs:

client   = yes  cert     = /etc/stunnel/shared/stunnel.pem  pid      = /var/run/stunnel4/syslog_stunnel.pid  syslog   = no  output   = /var/log/stunnel4/stunnel.log    [syslog_tunnel]  accept   = 127.0.0.1:5140  connect  = 172.22.15.23:51400  

I thought syslog = no would disable logging (man page) but it doesn't. Anyone know of a config that works or something to disable the spammy logging altogether?

How to write Docker logs to a file in real time (à la `tail -f`)

Posted: 26 Aug 2021 08:00 AM PDT

I docker that output logs stdout stderr, which can be viewed using:

docker logs -f $LOGS_CONTAINER_ID  

I also added 'sed', which puts the container id on each line:

docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /"  

If I run it, I get something like:

container112 error 10:20:10 problem  container112 info 10:20:09 not problem  container112 error 10:20:01 problem  

where "container112" is $LOGS_CONTAINER_ID.

SO FAR SO GOOD. Now I want to output the above command to a file (log.out), so I wrote the following command:

docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /" >> log.out  

What happens is that it writes the logs to log.out, but it doesn't get new logs (if I open a new session and run tail -f log.out, I don't get output). So I also tried:

tail -f $(docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /") >> log.out  

But it also didn't work. What is the problem?

Lubuntu - G_Is_Dbus_Connection

Posted: 26 Aug 2021 08:02 AM PDT

I have just installed Lubuntu on VM VirtrualBox.

When I run an app from terminal, eg. firefox, it works but terminal pops up some warnings.

maciex@maciex-pc:~$ firefox    (firefox:1152): Gtk-WARNING **: 16:15:43.300: Theme parsing error: <data>:1:34: Expected ')' in color definition    (firefox:1152): Gtk-WARNING **: 16:15:43.300: Theme parsing error: <data>:1:77: Expected ')' in color definition    (firefox:1152): GLib-GIO-CRITICAL **: 16:15:43.425: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed    (firefox:1152): GLib-GIO-CRITICAL **: 16:15:43.425: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed    (firefox:1152): GLib-GIO-CRITICAL **: 16:15:43.425: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed    (firefox:1152): GLib-GIO-CRITICAL **: 16:15:43.426: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed    (firefox:1152): GLib-GIO-CRITICAL **: 16:15:43.426: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed  

It's not about firefox, the same issue with other apps. But if I start the same app not from terminal and then open terminal and run the same app from terminal - I do not have any warnings.

maciex@maciex-pc:~$ ps -u maciex    PID TTY          TIME CMD    829 ?        00:00:00 systemd    840 ?        00:00:00 (sd-pam)    865 ?        00:00:00 gnome-keyring-d    868 ?        00:00:00 lxqt-session    886 ?        00:00:00 dbus-daemon    920 ?        00:00:00 ssh-agent    950 ?        00:00:00 openbox    953 ?        00:00:00 at-spi-bus-laun    960 ?        00:00:00 agent    964 ?        00:00:00 gvfsd    969 ?        00:00:00 pcmanfm-qt    970 ?        00:00:00 lxqt-globalkeys    971 ?        00:00:00 lxqt-notificati    972 ?        00:00:00 lxqt-panel    973 ?        00:00:00 lxqt-policykit-    974 ?        00:00:00 lxqt-runner    976 ?        00:00:00 gvfsd-fuse    979 ?        00:00:00 xscreensaver    990 ?        00:00:00 dbus-daemon    992 ?        00:00:00 applet.py   1001 ?        00:00:00 pulseaudio   1063 ?        00:00:00 gvfsd-trash   1069 ?        00:00:00 gvfs-udisks2-vo   1086 ?        00:00:00 gvfs-goa-volume   1092 ?        00:00:00 gvfs-gphoto2-vo   1101 ?        00:00:00 gvfs-mtp-volume   1105 ?        00:00:00 gvfs-afc-volume   1119 ?        00:00:00 lxqt-powermanag   1121 ?        00:00:00 qlipper   1123 ?        00:00:00 nm-tray   1131 ?        00:00:00 qterminal   1134 pts/0    00:00:00 bash   1142 pts/0    00:00:00 ps  

Could someone explain it? How to solve it?

Thanks

Allow a user group read,write execute access in Ubuntu 16.04 on a particular directory

Posted: 26 Aug 2021 09:07 AM PDT

I want to grant a group "usera" rwx permission to a directory. The directory is already owned by a user that belongs to this group "usera". The name of the username and group is same.

Current Permissions:

If I check the current permissions of that directory by running the following command:

ls -la  

Following is the output:

drwxrwsrwx 2 usera        usera        4096 Jan  9 09:30 .  

Desired Output:

drwxrwxrwx 2 usera        usera        4096 Jan  9 09:30 .  

Problem Statement:

The problem is that the above-mentioned usera doesn't have ssh access to the server. So, I have to login via another user with admin privileges. And I want to grant group "usera" rwx permissions on a particular directory /opt/test/abcd. But I am unable to figure out which command to run. I know we can grant permissions by using chmod command but how to apply it in this context

How to export CA certificate chain from PFX in PEM format without bag attributes

Posted: 26 Aug 2021 10:17 AM PDT

I have a PKCS12 file containing the full certificate chain and private key. I need to break it up into 3 files for an application. The 3 files I need are as follows (in PEM format):

  • an unecrypted key file
  • a client certificate file
  • a CA certificate file (root and all intermediate)

This is a common task I have to perform, so I'm looking for a way to do this without any manual editing of the output.

I tried the following:

openssl pkcs12 -in <filename.pfx> -nocerts -nodes -out <clientcert.key>  openssl pkcs12 -in <filename.pfx> -clcerts -nokeys -out <clientcert.cer>  openssl pkcs12 -in <filename.pfx> -cacerts -nokeys -chain -out <cacerts.cer>  

This works fine, however, the output contains bag attributes, which the application doesn't know how to handle.

After some searching I found a suggested solution of passing the results through x509 to strip the bag attributes.

openssl x509 -in <clientcert.cer> -out <clientcert.cer>  

This works, but I run into an issue on the cacert file. The output file only contains one of the 3 certs in the chain.

Is there a way to avoid including the bag attributes in the output of the pkcs12 command, or a way to have the x509 command output include all the certificates? Additionally, if running it through x509 is the simplest solution, is there a way to pipe the output from pkcs12 into x509 instead of writing out the file twice?

If, elif and else shell script Linux statements

Posted: 26 Aug 2021 07:50 AM PDT

#!/bin/bash    echo "Type in your username in lowercase letters"  read user  #sudo adduser $user    echo "Are you a student or teacher?"  read group    if (("$group"=="teacher"));  then          #sudo usermod -aG teachers          echo "teacher"    elif (("$group"=="student"));  then          #sudo usermod -aG students          echo "students"  else          echo "Sorry this group doesn't exist"  fi  

I'm trying to make a shell script that allows me to create a user and then automatically add it into a group that they want to be in. The input is either a student or a teacher although i want to include these statements above but i can't seem to make it work because it just goes to to the 'if' statement and ignores if i use the input student.


Could you please help me with this problem?


What terminal emulators support tmux control mode?

Posted: 26 Aug 2021 09:31 AM PDT

tmux has its control mode, activated with -CC, to allow the terminal emulator to control tmux. iTerm2 uses this to great effect for allowing tmux windows to appear as separate iTerm windows.

Are there other terminal emulators that support control mode? I am particularly interested in terminal emulators / SSH clients for Windows that might offer such functionality, but Linux/Unix ones are interesting as well.

Equivalent of update-grub for RHEL/Fedora/CentOS systems?

Posted: 26 Aug 2021 07:30 AM PDT

In Ubuntu (and I guess in Debian too) there is a system script named update-grub which automatically executes grub-mkconfig -o with the correct path for the grub configuration file.

Is there any similar command for Red Hat based distributions?

If not, how do the system knows where is the grub configuration file to update when a new kernel version is installed?

How to install drivers for intel GMA 3600 intergrated graphics system?

Posted: 26 Aug 2021 10:03 AM PDT

I am currently using crunchbang 11 32bit, on a laptop with Atom D2500/GMA3600. Does anyone know how to install a more modern driver - rather than the gma500? Is this even possible?

sshfs LocalForward without config file

Posted: 26 Aug 2021 09:40 AM PDT

I'm trying to add portforwarding to my sshfs-mount-scripts:

sshfs tim@devserver1:/ /home/tim/mnt/devserver1/   -o SSHOPT=LocalForward 127.0.0.5:3306 127.0.0.1:3306  

So far I've failed using the correct syntax. Using brackets or commas instead of spaces did not work.

How do I remove leading zeroes from output of 'date' or avoid octal interpretation of such decimal numbers?

Posted: 26 Aug 2021 08:01 AM PDT

I have this:

date +"%H hours and %M minutes"  

I use festival to say it up.. but it says like: "zero nine hours".. I want it to say "nine hours"!

but date always give me 09... so I wonder if bash can easly make that become just 9?

in the complex script I tried like

printf %d 09  

but it fails.. not octal :(

any idea?

No comments:

Post a Comment