moving files into different directories based on their names matching with another file Posted: 31 Mar 2021 11:12 AM PDT I have a folder with ~6000 files (some of the are .txt and some .pdf files) and I am trying to organize them in different folders. folder looks like this: cd ./res-defaults ML3020T1--ML3020N_chr6-209980-34769899-LOH_clusters.pdf ML3020T1--ML3020N_chrom_clust_freqs.txt ML3020T1--ML3020N_cluster_summary.txt ML3020T1--ML3020N_mol_time_estimate.pdf HTMCP-01-01-00451-01A-01D--HTMCP-01-01-00451-11B-01D_boots.txt .... I have then another file which is a metadata file head meta.data bam TRUE 81-52884 81-52884T tumour grch37 genome A01423 DL_M bam TRUE 06-30342 ML3020T1 tumour grch37 genome A43002 ML_K bam TRUE 10-24757 10-24757T tumour grch37 genome A61218 CL_GC bam TRUE HTMCP-01-01-00451 HTMCP-01-01-00451-01A-01D tumour grch37 genome A71785 DL_HTMCP .... The strings "before" the "--" in file names in the res-defaults folder matche with the column 4 in the metadata file. I want create folders according to the column 9 in the metadata and move files in the res-default to the directory that column 4 in meta data matche with characters before "--". I am expecting outputs like this cd ./ML_K ls ML3020T1--ML3020N_chr6-209980-34769899-LOH_clusters.pdf ML3020T1--ML3020N_chrom_clust_freqs.txt ML3020T1--ML3020N_cluster_summary.txt ML3020T1--ML3020N_mol_time_estimate.pdf and cd ./DL_HTMCP ls bam TRUE HTMCP-01-01-00451 HTMCP-01-01-00451-01A-01D tumour grch37 genome A71785 DL_HTMCP I honestly do not know how to do that with bash shell! |
How to change the extension of all files from a directory? Posted: 31 Mar 2021 11:36 AM PDT I am using Linux and I want to write a shell script that takes two directories and moves the second directory in the first one (so the second directory becomes a subdirectory of the first one) and all the files from the second directory become ".txt" extension. For exemple: dir2 contains: file1 file2 dir3 file3.jmp After running ./shell_scrip dir1 dir2 , I want dir1 to contain dir2 and dir2 would look like this: file1.txt file2.txt dir3 file3.txt I tried to change the extensions but I got this error: mv: cannot stat `file1`: No such file or directory using the following code: #!/bin/sh for file in $2/*; do f=$(basename "$file") mv "$f" "${f}.txt" done |
How to match a specific word or its parts in a case statement? Posted: 31 Mar 2021 11:16 AM PDT Suppose one has the following case: #!/bin/sh case $1 in e|ex|exa|exam|examp|exampl|example) echo "OK" ;; t|te|tes|test) echo "Also OK" ;; *) echo "Error!" ;; esac Is there a more elegant and at the same time a POSIX-compliant solution (i.e., no bash, zsh, etc.) to a situation like this? P.S. No need for exampleeee or Exam to work. |
Arch linux: neither ethernet or wireless adapter showing up, can't start the installation Posted: 31 Mar 2021 10:35 AM PDT So while installing arch linux snapshot 2021-03-01, I wasn't able to connect to the internet neither wirelessly or by cable. I tried ip link show , but it only showed the lo adapter. I then tried disabling the systemd-networkd-wait-online.service service, as it did work for some people that couldn't init their adapters in time, but again no luck. I am quite new to arch, It's just a pissing because I wasn't able to find anything answered yet like this. Thanks. |
How to block all users from creating directories with specific names? Posted: 31 Mar 2021 10:40 AM PDT I want to block all users from creating directories with specific names (root is not important for me). For example, I want to block all users from creating directories with xroot name. I think I must create/modify some files in /usr or /etc folder. |
Why "file xxx.src" leads to "cannot open `xxx.src' (No such file or directory)", but exit status is 0 (success)? Posted: 31 Mar 2021 11:06 AM PDT Why file xxx.src leads to cannot open `xxx.src' (No such file or directory) , but exit status is 0 (success)? $ file xxx.src ; echo $? xxx.src: cannot open `xxx.src' (No such file or directory) 0 Note: to compare with ls : $ ls xxx.src ; echo $? ls: cannot access 'xxx.src': No such file or directory 2 |
Grep a pattern in a line from log file and print next n lines until next patter Posted: 31 Mar 2021 10:30 AM PDT Suppose the file log.txt contains below content [12] 03/31/21 08:33:30.080851 T(12581) _DBG message x 1 [12] 03/31/21 08:33:30.080851 T(34897) _DBG message y 1 [12] 03/31/21 08:33:31.241167 T(12344) _DBG message z 1 [12] 03/31/21 08:33:31.457612 T(34897) _DBG message y 2 test message line 2 test message line 3 test message line 4 [12] 03/31/21 08:33:31.78912 T(12344) _DBG message z 2 [12] 03/31/21 08:33:32.56341 T(34897) _DBG message y 3 [12] 03/31/21 08:33:33.12789 T(12581) _DBG message x 2 test message for x [12] 03/31/21 08:33:33.78123 T(34897) _DBG message y 3 test message line 2 [12] 03/31/21 08:33:34.12342 T(12581) _DBG message x 3 [12] 03/31/21 08:33:34.56712 T(34897) _DBG message y 4 Desired output should be [12] 03/31/21 08:33:30.080851 T(34897) _DBG message y 1 [12] 03/31/21 08:33:31.457612 T(34897) _DBG message y 2 test message line 2 test message line 3 test message line 4 [12] 03/31/21 08:33:32.56341 T(34897) _DBG message y 3 [12] 03/31/21 08:33:33.78123 T(34897) _DBG message y 3 test message line 2 [12] 03/31/21 08:33:34.56712 T(34897) _DBG message y 4 Given a thread ID, it should print the line + next few lines belong to that msg. Note that in the desired output, all other thread messages are removed. I tried below sed command but it prints the next line also (which is different thread message) sed -n -e '/T(34897)/,/_DBG/ p' log.txt I tried other grep/awk/regex commands but couldn't get this done. Please help |
Detect changes in network status on SBC running Debian using inotify? Posted: 31 Mar 2021 11:14 AM PDT I have Debian 10 running on a small SBC (industrialized Raspberry Pi like form factor). I have some python programs running that make use of inotify capabilities. I want to detect when the network status changes so I can toggle a light. Should I look around for some files in something like /sys/class/net/eth1 and watch for a change with notify? and compute a status from whats in that directory somehow? Or is there a better way to do this that doesn't involve polling? I was trying to infer this from my mqtt client connection status, but that's not responsive enough and at times is ambiguous anyway. Is there perhaps some hook that systemd/networkd would provide to make this possible? |
Creating script to change between NVIDIA and Nouveau drivers without restarting. I managed to successfully unbind from NVIDIA's, but Posted: 31 Mar 2021 09:23 AM PDT I'm creating a script to change my GPU drivers to proprietary to open source and vice and versa. I originally intended to do this rebooting, which is a drag. Now i'm trying to do it without the need to restart. ATM I'm trying to switch from proprietary's to opensource: - At this point, I managed to unbind my GPU from proprietary's driver without freezing, but I end up at TTY with no driver bounded to my GPU. My script already probes Nouveau driver, but it seems to have no effect. When I try to modprobe nouveau again on TTY, I got this(go to the part the screen went black with some glitches). I have a full script to handle configuration files and etc, which works just fine if I restart. This is the release part, which releases the card from proprietary's drivers and try to bind it to Nouveau:
/usr/bin/systemctl stop sddm; sleep 1 killall -9 --user lucas while [[ -n "$(/usr/bin/pgrep plasmashell)" && "$(/usr/bin/pgrep kwin_x11)" && "$(/usr/bin/pgrep klauncher)" && "$(/usr/bin/pgrep Xorg)" && -n "$(/usr/bin/fuser -v /dev/dri/card0)" && -n "$(/usr/bin/fuser -v /dev/dri/card1)" ]]; do /usr/bin/killall -9 plasmashell; /usr/bin/killall -9 kwin_x11; /usr/bin/killall -9 Xorg; /usr/bin/killall -9 X; /usr/bin/killall -9 klauncher; /usr/bin/sleep 0.2 done echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind; echo '0000:01.00.0' /sys/bus/pci/drivers/nvidia/unbind; sleep 1; rmmod nvidia; sleep 1; echo '0000:01.00.0' /sys/bus/pci/drivers/nouveau/bind; sleep 1 systemctl restart sddm; Full dmesg log. Thoughts: Frambuffer on NVIDIA cards seems works differently from AMD's. I feel that it has something to do with it. Is it possible that frambuffer is holding something back? This is a wild guess.. |
Does the "reboot" command log me out of the shell or does it forcefully terminate it? Posted: 31 Mar 2021 09:11 AM PDT Under Linux, if I issue a reboot command from the shell, what is the sequence of events that lead to the shell (e.g. bash ) disconnecting? I think it's one of the following, but not sure which: - It log me out of the shell before it sends a reboot signal.
- It send the signal to reboot and the shell logs me out.
- It send the signal to reboot and the shell just terminates abruptly without going through a logout procedure.
|
linux how to log all ping responses Posted: 31 Mar 2021 11:36 AM PDT in linux (RHEL / CentOS 7 specifically) is there a way, such as in /var/log/audit/audit.log to log all responses to ping ? If somebody on the network pings my linux computer, is there a way to log that and at some later date know when that happened and from what IP address I was pinged from? |
Use GNU Parallel when file has a single (long) line Posted: 31 Mar 2021 09:10 AM PDT I have a file which is an HTML document, containing a <table> I want to extract data from and output into a csv. This file has 544609657 characters, is about 545 megabytes, all in a single line. I managed to extract the data into a csv by using sed and making many string replacements, but I wanted to speed things up by using GNU parallel. Is this possible, considering it's a single line file? My attempts below have not increased processing speed nor improved memory usage: parallel -a table.html --pipepart 'sed -e [...etc.]' > table.csv Or cat table.html | parallel --pipe 'sed -e [...etc.]' > table.csv I'm guessing the problem is because the file has a single line. If so, what strategies could I used to process the file more efficiently? |
bcmwl-kernel-source not working with kernel 5.11.0-7612-generic Posted: 31 Mar 2021 09:43 AM PDT I've spent the last hours trying to figure out how to get my wifi working. Today I updated from Pop_OS 20.04 to 20.10. Everything worked fine, but after an hour my 5GHz Wifi connection stated constantly dropping over and over again. So I restarted the network manager and the 5GHz network was gone. I then decided to just use the 2.4GHz one, which worked for a while until it started disconnecting too. After another hour I couldn't even use the internet anymore, as it constantly kept connecting and disconnecting (in a 5 second rythm). Then I finally started trying to fix the problem. At first I tried searching online which brought me to the idea to reinstall bcmwl-kernel-source, which then resulted in it not being able to reinstall anymore. Nothing network related with my network card works at the moment. This is the error I am getting: Reading package lists... Done Building dependency tree Reading state information... Done dkms is already the newest version (2.8.3-4ubuntu0.1). 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up bcmwl-kernel-source (6.30.223.271+bdcom-0ubuntu7) ... Removing old bcmwl-6.30.223.271+bdcom DKMS files... Deleting module version: 6.30.223.271+bdcom completely from the DKMS tree. Done. Loading new bcmwl-6.30.223.271+bdcom DKMS files... Building for 5.11.0-7612-generic Building for architecture x86_64 Building initial module for 5.11.0-7612-generic ERROR (dkms apport): kernel package linux-headers-5.11.0-7612-generic is not supported Error! Bad return status for module build on kernel: 5.11.0-7612-generic (x86_64) Consult /var/lib/dkms/bcmwl/6.30.223.271+bdcom/build/make.log for more information. dpkg: error processing package bcmwl-kernel-source (--configure): installed bcmwl-kernel-source package post-installation script subprocess returned error exit status 10 Errors were encountered while processing: bcmwl-kernel-source E: Sub-process /usr/bin/dpkg returned an error code (1) Same happens with all the broad broadcom-sta-dkms and all the other broadcom-sta-* packages too (I tried installing them from source and from deb). I always get this error in some form of telling me the 5.11 Kernel is not supported. I own/have this problem with a ASUS PCE-AC68 network card btw (here the Chip ID (I think?): 14e4:43a0). I don't know how to fix this problem without downgrading to Pop_OS 20.04 again. And it seems like just starting from scratch with a new install seems easier, I just really hope somebody can help me out here :/ |
Date and time zone offset not working correctly Posted: 31 Mar 2021 10:33 AM PDT I'm facing a strange behavior of date command when using time zone offset on Solaris. >echo $TZ MET >date Wed Mar 31 11:41:45 MEST 2021 >TZ=MET+24 date Tue Mar 30 09:42:06 MET 2021 >TZ=MEST+24 date Tue Mar 30 09:42:52 MEST 2021 Why date output is showing MEST when TZ is set to MET and how is TZ+24 is showing 26 hours offset instead of 24 in both timezones. |
Disk encryption without requiring a password at boot is possible? Posted: 31 Mar 2021 11:33 AM PDT Is it possible to encrypt the boot disk but not require users to input a password when the system boots? I have some headless boxes in remote locations for which I cannot guarantee they will be securely disposed off. I want to avoid somebody being able to take out the disk drive and hook it up to another device and look what is on it but at the same time the system must be able to (re)boot without user interaction. I have very little experience with encryption but I was thinking about something along the lines of storing the key in the UEFI but I am unable to find any information on whether such a thing is possible. I'm using Ubuntu 18.04 LTS, but I could upgrade if required. |
Need to merge lines for fixed width file based on length Posted: 31 Mar 2021 09:11 AM PDT Each line starts with FEPS. Merge the line which doesn't start with FEPS to previous line and then sort the file based on length i.e; keep the lines whose length is 23 chars Input: FEPS xxxx01 BUILDING 0 FEPS xxxx02 BUILDING FEPS xxxx03 BUILDING 0 FEPS xxxx04 BUILDING 0 Output: FEPS xxxx01 BUILDING 0 FEPS xxxx03 BUILDING 0 FEPS xxxx04 BUILDING 0 Used below script it worked: awk 'BEGIN /FEPS/ { if (NR>1) print "" printf "%s", $0 next } {printf ",%s", $0} END {print " "}' Output of the above script should be passed to below awk 'length ==23 {print $0}' |
Is tcpdump a client of rpcpad and implemented in pcap? Posted: 31 Mar 2021 09:01 AM PDT https://www.tcpdump.org/index.html#documentation has manpages for pcap, tcpdump, and rpcapd, but I don't find what relation is between the three. Is pcap a C library for implementing a client of rpcapd? Is tcpdump a client of rpcpad and therefore dependent on rpcpad? Is tcpdump implemented in pcap? |
I would like to get the names of entire headers present in another fasta file Posted: 31 Mar 2021 09:49 AM PDT I have a fasta file like that : >TRINITY_DN100_c0_g1_i1 len=242 path=[0:0-241] AGCAATTCAAACTGCTGCAATCTGGGCTCGTGAAAACGATATGGTATTACACTTACATCGTGCAAGACAAACAACAAGTGCGTTACGTCACGTTACGTTAATTCGTTCGTTCGTCTCTCTATTGCGTTGCGTTACGCTCTCGCCGCGGACCCAGCACCGCATACCCGCCCATACAAGTCATACAGTACACAACACAAAAACACAACCAACTATTTCCTTGGAAGAGAAAGCAAGCCCAAAAC >TRINITY_DN105_c0_g1_i1 len=260 path=[0:0-259] TGAAAATATTAATTCTCAACCTTTTATGCGTTGGAGAGAAAGATATTTATTTTCAATAGAGGGAGTTAATCGTGCAGCGGCAGCAAGTGGTGAAATTAAAGGACATTATTTAAATGTTACTGCAGGTACAATGGAAGACATGTACGAACGCGCCAAGATTGATGTGCCTGAGAACCACATGAATAACGAGGAGCAATACACACTTCACTACCAAGAGTACCTTGTGGGTAGCTCGGCTGGTGTGCCCAAGGATATGAAGG >TRINITY_DN103_c0_g1_i1 len=260 path=[0:0-259] GTTCTCTTCGGTGGCAGCCTTACGGCCGACCACCTGGTATTGTCGCATAATTCCCGCAGCAGTCATGATGTCTATTGTTTGTCGTGAAAAGAAATGAATTAAGAGAGTCATAGTTACTCCCGCCGTTTACCCGCGCTTGGTTGAATTCCTTCACTTTGACATTCAGAGCACTGGGCAGAAATCACATTGCGTCAACACCATCTCTGTTTCAACGAAATCAGCAGTATCTGTAGAAGTGTAGTTAAAACTAATATCTTTCC And I want to add the species names to the headers containing in an other fasta file using the beginning of the header and don't change the sequence of the first fasta. >TRINITY_DN100_c0_g1_i1 len=242 path=[0:0-241]@Guinardia_delicatula AGCAATCCAAACTGCTGCAATCTGGGCTCGTGAAAACGATATGGTATTACACTTACACCGTGC >TRINITY_DN100_c0_g1_i1 KR048205>TRINITY_DN105_c0_g1_i1 len=260 path=[0:0-259]AGCAATTCAAAGTGCTGCAATCTGGGCTCGTGAAAACGATATGTTATTACACTTACACCGTGCA >TRINITY_DN103_c0_g1_i1 len=260 path=[0:0-259]@Luticola_sparsipunctata AGCAATTCAAAGTGCTGCAATCTGGGCTCGTGAAAACGATATGATTTTACACTTACACCGTGCA I would like something like that : >TRINITY_DN100_c0_g1_i1 len=242 path=[0:0-241]@Guinardia_delicatula AGCAATTCAAACTGCTGCAATCTGGGCTCGTGAAAACGATATGGTATTACACTTACATCGTGCAAGACAAACAACAAGTGCGTTACGTCACGTTACGTTAATTCGTTCGTTCGTCTCTCTATTGCGTTGCGTTACGCTCTCGCCGCGGACCCAGCACCGCATACCCGCCCATACAAGTCATACAGTACACAACACAAAAACACAACCAACTATTTCCTTGGAAGAGAAAGCAAGCCCAAAAC >TRINITY_DN100_c0_g1_i1 KR048205>TRINITY_DN105_c0_g1_i1 len=260 path=[0:0-259] TGAAAATATTAATTCTCAACCTTTTATGCGTTGGAGAGAAAGATATTTATTTTCAATAGAGGGAGTTAATCGTGCAGCGGCAGCAAGTGGTGAAATTAAAGGACATTATTTAAATGTTACTGCAGGTACAATGGAAGACATGTACGAACGCGCCAAGATTGATGTGCCTGAGAACCACATGAATAACGAGGAGCAATACACACTTCACTACCAAGAGTACCTTGTGGGTAGCTCGGCTGGTGTGCCCAAGGATATGAAGG >TRINITY_DN103_c0_g1_i1 len=260 path=[0:0-259]@Luticola_sparsipunctata GTTCTCTTCGGTGGCAGCCTTACGGCCGACCACCTGGTATTGTCGCATAATTCCCGCAGCAGTCATGATGTCTATTGTTTGTCGTGAAAAGAAATGAATTAAGAGAGTCATAGTTACTCCCGCCGTTTACCCGCGCTTGGTTGAATTCCTTCACTTTGACATTCAGAGCACTGGGCAGAAATCACATTGCGTCAACACCATCTCTGTTTCAACGAAATCAGCAGTATCTGTAGAAGTGTAGTTAAAACTAATATCTTTCC Do you have an idea how I can do? |
Display git-diff between master and my last commit Posted: 31 Mar 2021 11:38 AM PDT I use git on a regular basis for collaboration with other people. When we work together on a shared repository, I'd like to be able to view the changes performed by others which happened between my last commit and the current master branch (or the current HEAD ). Until now I'm using the following workflow: git fetch # download everything git merge # since I'm a trusting person ;) git logadog # my git-alias for `git log --all --decorate --oneline --graph` # manually look into how many commits were performed since my last commit git diff HEAD~3 # if 3 commits were performed since then Alternatively, I could also use git diff c0ffee (if my last commit was c0ffee ). Although that works, I'd prefer something simpler, like git diff COMPARE_HEAD_WITH_THE_LAST_COMMIT_FROM_MY_USER , but I'm unsure how that would work. I'm also using the awesome vim -plugin fugitive by Tim Pope and if it would be possible to do this using the :Gdiffsplit HEAD~THE_STUFF_FROM_ABOVE -syntax that would be amazing. |
xkb Can't find file "myswap" for symbols include error in systemd python job Posted: 31 Mar 2021 10:33 AM PDT I'm using Ubuntu 20.10 and python 2.7. I've got a bash script which overwrites default keyboard bindings and it always works when I execute it from terminal, here's the script. #!/bin/bash xkbcomp -w0 -I$HOME/.xkb $HOME/.xkb/keymap/mykbd $DISPLAY I've also added it to my .bashrc file so that it executes always when I open a new terminal. The problem is that I have a standing desk and sometimes when I adjust the height the keyboard is disconnected and connected again and I have to open a new terminal again so that my custom keybindings are applied again. The best solution that I came up with is to create a systemd python job that will execute the bash script when my keyboard is plugged in. When I run the python script by itself it very rarely works, I can see in syslog that the python script calls the bash script when the keyboard is disconnected and connected again and the keybindings are overwritten but the new keybindings don't work. Here's the python script #!/usr/bin/python import functools import os.path import pyudev import subprocess def main(): BASE_PATH = os.path.abspath(os.path.dirname(__file__)) path = functools.partial(os.path.join, BASE_PATH) call = lambda x, *args: subprocess.call([path(x)] + list(args)) context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem='usb') monitor.start() for device in iter(monitor.poll, None): name = 'Freestyle_Edge_Keyboard' if device.get('ID_MODEL') == name: subprocess.call(['sh', '/home/user/scripts/loadKeyboardOverwrites.sh']) if __name__ == '__main__': main() When I start the systemd job I can see in syslog that the keys are overwritten but it doesn't work and the only thing in syslog that I find a bit suspicious is the message about xkb_variant & xkb_options requires a string value and error about myswap Mar 24 21:33:32 user callShOnKeyboardPlugin.py[1533582]: Error: Can't find file "myswap" for symbols include Mar 24 21:33:32 user callShOnKeyboardPlugin.py[1533582]: Exiting Mar 24 21:33:32 user callShOnKeyboardPlugin.py[1533582]: Abandoning symbols file "(null)" Mar 24 21:17:01 user /usr/libexec/gdm-x-session[28481]: (**) Option "xkb_model" "pc105" Mar 24 21:17:01 user /usr/libexec/gdm-x-session[28481]: (**) Option "xkb_layout" "sk" Mar 24 21:17:01 user /usr/libexec/gdm-x-session[28481]: (WW) Option "xkb_variant" requires a string value Mar 24 21:17:01 user /usr/libexec/gdm-x-session[28481]: (WW) Option "xkb_options" requires a string value The myswap file is located in ~/.xkb/symbols/myswap Here's the systemd job [Unit] Description=desc [Service] ExecStart=/home/user/scripts/callShOnKeyboardPlugin.py Restart=always Environment="PYTHONPATH=$PYTHONPATH:/home/user/.local/lib/python2.7/site-packages" [Install] WantedBy=multi-user.target Does anyone have any idea where the issue could be please? Or is there any other better way how to do this? Any help would be greatly appreciated. If there's something missing please let me know and I'll provide it. Update I handled it in a different way. I've set it up as a startup script and also I've added a bit of delay after when the keyboard was detected and that made it work consistently. |
How to print in only one column if condition with awk Posted: 31 Mar 2021 11:23 AM PDT I have a file bla.tsv (FS=\t ): id hub fil plop drift 3 187 0.91 bis XX 2 245 0.93 XX 4 250 0.70 bis XX 1 245 0.95 bis XX And I want to print in the column plop the folowing string : - If
hub<200 print intcv - If
hub>200 and fil<0.90 print int - If
hub>200 and fil>0.90 don't print In my example it would be : id hub fil plop drift 3 187 0.91 intcr XX 2 245 0.93 XX 4 250 0.70 int XX 1 245 0.95 bis XX I've write this but did not have a good result : awk -F"\t" -vOFS="\t" ' NR==1{print $0} ; (NR>1 && $2<200){$(NF-1)="intcv"; print $0,$(NF-1) }; (NR>1 && $2>200 && $3<0.90) {$(NF-1)="int"; print $0,$(NF-1) } ' bla.tsv > result.tsv Do you have an idea how to do that ? Thanks |
Repair corrupted file list in reprepro Posted: 31 Mar 2021 10:29 AM PDT Seeing this message when dput 'ing a package to my local reprepro instance: ... Exporting indices... Corrupted file list data for pool/main/q/qualys-cloud-agent/qualys-cloud-agent_2.6.0-88_all.deb Corrupted file list data for pool/main/q/qualys-cloud-agent/qualys-cloud-agent_2.6.0-88_all.deb Calculating packages to pull... Installing (and possibly deleting) packages... Exporting indices... Deleting files no longer referenced.. I am running version 5.3.0 of reprepro on Debian buster. How do I repair (or remove) the corrupted files? |
bind9 named-checkzone failing with SOA record not at top of zone Posted: 31 Mar 2021 10:03 AM PDT I set up bind9 perfectly a year ago but neglected to document exactly what I done, and now something has changed and I am struggling to fix it. The problem manifested itself first from the DHCP clients which are now unable to resolve the DHCP/NS host on the LAN. Checking my bind config with named-checkzone gives an error: adam@gondolin:~$ sudo named-checkzone 192.168.0 /var/cache/bind/db.192.168.0 /var/cache/bind/db.192.168.0:2: SOA record not at top of zone (0.168.192.in-addr.arpa.192.168.0) zone 192.168.0/IN: loading from master file /var/cache/bind/db.192.168.0 failed: not at top of zone zone 192.168.0/IN: not loaded due to errors. Of course named doesn't load the zones either. This is the zone file: adam@gondolin:~$ sudo cat /var/cache/bind/db.192.168.0 $TTL 86400 0.168.192.in-addr.arpa IN SOA localdomain. root.localdomain. ( 1123 ; serial 604800 ; refresh (1 week) 86400 ; retry (1 day) 2419200 ; expire (4 weeks) 86400 ; minimum (1 day) ) NS gondolin.localdomain. $ORIGIN 0.168.192.in-addr.arpa. adam@gondolin:~$ and my only other zone file gives the same result: adam@gondolin:~$ sudo cat /var/cache/bind/db.localdomain $TTL 86400 localdomain IN SOA localdomain. root.localdomain. ( 1650 ; serial 604800 ; refresh (1 week) 86400 ; retry (1 day) 2419200 ; expire (4 weeks) 86400 ; minimum (1 day) ) NS gondolin.localdomain. $ORIGIN localdomain. adam@gondolin:~$ This is the bind config: adam@gondolin:~$ cat /etc/bind/named.conf.options acl goodclients { localhost; localnets; }; options { listen-on { 192.168.0.3; 127.0.0.1; }; listen-on-v6 { fe80::2a37:37ff:fe03:4225/64; ::1; #any; }; directory "/var/cache/bind"; forwarders { 208.67.220.220; 208.67.222.222; }; allow-query { goodclients; }; allow-recursion { goodclients; }; allow-transfer { goodclients; }; dnssec-enable no; #dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 }; adam@gondolin:~$ and the zones: adam@gondolin:~$ cat /etc/bind/named.conf.local // // Do any local configuration here // // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc1918"; include "/etc/bind/rndc.key"; zone "localdomain" { type master; notify no; file "/var/cache/bind/db.localdomain"; allow-update { key "rndc-key"; }; }; zone "0.168.192.in-addr.arpa" { type master; notify no; file "/var/cache/bind/db.192.168.0"; allow-update { key "rndc-key"; }; }; adam@gondolin:~$ I'm not quite sure what other config is relevant here so I'm going to show everything I can think of. adam@gondolin:~$ cat /etc/hostname gondolin adam@gondolin:~$ cat /etc/hosts 127.0.0.1 localhost localhost.localdomain gondolin 127.0.1.1 gondolin 192.168.0.3 gondolin.localdomain gondolin # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters resolv.conf could be a worry: adam@gondolin:~$ cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run "systemd-resolve --status" to see details about the actual nameservers. nameserver 192.168.0.3 domain localdomain search localdomain adam@gondolin:~$ The systemd-resolve msg is irrelevant I assume, but doing a status shows this: adam@gondolin:~$ sudo systemd-resolve --status Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found. Running a simple look-up on the host: adam@gondolin:~$ dig gondolin ; <<>> DiG 9.11.3-1ubuntu1.9-Ubuntu <<>> gondolin ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 58942 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ; COOKIE: 083d35c6e1daa489584481225d74b44000978776cbc340e9 (good) ;; QUESTION SECTION: ;gondolin. IN A ;; AUTHORITY SECTION: . 3600 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2019090800 1800 900 604800 86400 ;; Query time: 7 msec ;; SERVER: 192.168.0.3#53(192.168.0.3) ;; WHEN: Sun Sep 08 08:56:48 BST 2019 ;; MSG SIZE rcvd: 140 adam@gondolin:~$ |
Not able to connect to openldap server in ldaps mode - CentOS Posted: 31 Mar 2021 11:04 AM PDT I have configured my openldap server in ldaps mode. But after configuring I am not able to connect it on 636 port where as I am able to connect on 389 port [root@testldap certs]# ldapsearch -x -LLL -h testldap.india.airwave.com -p 636 -D cn=Manager,dc=india,dc=airwave,dc=com -w whopee -b "ou=Users,dc=india,dc=airwave,dc=com" ldap_result: Can't contact LDAP server (-1) [root@testldap certs]# ldapsearch -x -LLL -h testldap.india.airwave.com -p 389 -D cn=Manager,dc=india,dc=airwave,dc=com -w whopee -b "ou=Users,dc=india,dc=airwave,dc=com" dn: ou=users,dc=india,dc=airwave,dc=com objectClass: organizationalUnit ou: users dn: cn=Sandeep Lade,ou=users,dc=india,dc=airwave,dc=com cn: Sandeep Lade sn: Lade objectClass: inetOrgPerson userPassword:: d2hvcGVl uid: vlade dn: cn=Engineering,ou=users,dc=india,dc=airwave,dc=com cn: Engineering objectClass: groupOfNames member: cn=Sandeep Lade,ou=users,dc=india,dc=airwave,dc=com Both 389 and 636 are listening [root@testldap certs]# netstat -an | grep 389 tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN tcp 0 0 :::389 :::* LISTEN unix 2 [ ] DGRAM 19389 [root@testldap certs]# netstat -an | grep 636 tcp 0 0 0.0.0.0:636 0.0.0.0:* LISTEN tcp 0 0 :::636 :::* LISTEN unix 3 [ ] STREAM CONNECTED 13636 [root@testldap certs]# Able to connect to 636 port using openssl connect [root@localhost sandeeplade]# openssl s_client -connect 10.22.156.157:636 -showcerts -CAfile cacert.pem CONNECTED(00000003) write:errno=104 --- no peer certificate available --- No client certificate CA names sent --- SSL handshake has read 0 bytes and written 307 bytes --- New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None Krb5 Principal: None PSK identity: None PSK identity hint: None Start Time: 1516769274 Timeout : 300 (sec) Verify return code: 0 (ok) --- [root@localhost sandeeplade]# ldap.conf file [root@testldap certs]# cat /etc/openldap/ldap.conf # # LDAP Defaults # # See ldap.conf(5) for details # This file should be world readable but not world writable. #BASE dc=example,dc=com #URI ldap://ldap.example.com ldap://ldap-master.example.com:666 #SIZELIMIT 12 #TIMELIMIT 15 #DEREF never PORT 636 #TLS_CACERTDIR /etc/openldap/certs TLS_CACERTDIR /etc/openldap/certs TLS_REQCERT allow ssl start_tls tls_checkpeer yes tls_cacertfile /etc/openldap/certs/cacert.pem [root@testldap certs]# slapd.conf file [root@testldap certs]# cat /etc/openldap/slapd.conf TLSCACertificateFile /etc/openldap/certs/cacert.pem TLSCertificateFile /etc/openldap/certs/server.crt TLSCertificateKeyFile /etc/openldap/certs/server.key # Use the following if client authentication is required #TLSVerifyClient demand # ... or not desired at all TLSVerifyClient never [root@testldap certs]# certificates are available in /etc/openldap/certs and they are generated using openssl [root@testldap certs]# cd /etc/openldap/certs/ [root@testldap certs]# ls -lrt total 96 -r--------. 1 root root 45 Jan 23 21:59 password -rw-r--r--. 1 root root 16384 Jan 23 21:59 secmod.db -rw-r--r--. 1 root root 65536 Jan 23 21:59 cert8.db -rw-r--r--. 1 root root 16384 Jan 23 21:59 key3.db -rw-------. 1 ldap ldap 1743 Jan 23 23:57 server.key.pass -rw-r--r--. 1 root root 1094 Jan 23 23:59 server.csr -rw-r--r--. 1 root root 4718 Jan 24 00:02 server.crt -rw-r--r--. 1 root root 1675 Jan 24 00:38 server.key -rw-r--r--. 1 root root 4537 Jan 24 05:18 cacert.pem [root@testldap certs]# ldaps enabled in /etc/sysconfig/ldap [root@testldap certs]# cat /etc/sysconfig/ldap # Options of slapd (see man slapd) #SLAPD_OPTIONS= # At least one of SLAPD_LDAP, SLAPD_LDAPI and SLAPD_LDAPS must be set to 'yes'! # # Run slapd with -h "... ldap:/// ..." # yes/no, default: yes SLAPD_LDAP=yes # Run slapd with -h "... ldapi:/// ..." # yes/no, default: yes SLAPD_LDAPI=yes # Run slapd with -h "... ldaps:/// ..." # yes/no, default: no SLAPD_LDAPS=yes # Run slapd with -h "... $SLAPD_URLS ..." # This option could be used instead of previous three ones, but: # - it doesn't overwrite settings of $SLAPD_LDAP, $SLAPD_LDAPS and $SLAPD_LDAPI options # - it isn't overwritten by settings of $SLAPD_LDAP, $SLAPD_LDAPS and $SLAPD_LDAPI options # example: SLAPD_URLS="ldapi:///var/lib/ldap_root/ldapi ldapi:/// ldaps:///" # default: empty #SLAPD_URLS="" # Maximum allowed time to wait for slapd shutdown on 'service ldap stop' (in seconds) #SLAPD_SHUTDOWN_TIMEOUT=3 # Parameters to ulimit, use to change system limits for slapd #SLAPD_ULIMIT_SETTINGS="" [root@testldap certs]# I am struggling to get the openldap worked from past two days. Any help is highly appreciated |
In NixOS, how to add a user to the sudoers file? Posted: 31 Mar 2021 10:59 AM PDT I installed and am trying to get started with NixOS, and am trying to add my user to the sudoers file. So that I'm not running all my commands as root I created a user following Chapter 7. User Management of the NixOS manual. That is, I ran # useradd -m matthew # su - matthew -c "true" # passwd matthew Enter new UNIX password: *** Retype new UNIX password: *** And also I added users.extraUsers.matthew = { isNormalUser = true; home = "/home/matthew"; extragroups = [ "wheel" "networkmanager" ]; } to /etc/nixos/configuration.nix . But still I am not able to run sudo as matthew . For example, when I try to open sudo's man page with sudo, I get the matthew is not in the sudoers file error. $ sudo man sudo [sudo] password for matthew: matthew is not in the sudoers file. This incident will be reported. Then I tried following advice on how to add a user to the sudoers file in other distributions, namely editing with $ visudo . But when I run that, nixos tells me not to edit that file. That is, running $ visudo opens /etc/sudoers.tmp with first line reading # Don't edit this file. Set the NixOS option 'security.sudo.configFile' instead. How do I set the NixOS option 'security.sudo.configFile'? |
What's the difference between `mkdir -p` and `install -d`? Posted: 31 Mar 2021 10:39 AM PDT What is the difference in what is being performed by mkdir -p and install -d , in terms of what changes the two commands are doing to the system? |
ssh 3des private key encrypt and decrypt Posted: 31 Mar 2021 09:01 AM PDT i have converted my ssh private key with 3des encryption openssl pkcs8 -topk8 -v2 des3 -in ~/.ssh/id_rsa.old -out ~/.ssh/id_rsa how do I remove encryption and get the old key? |
Resetting password of another Linux Posted: 31 Mar 2021 08:57 AM PDT I have an external hdd partitioned into two. One of the partitions has Linux (Ubuntu) installed on it (bootable). The thing is I have forgotten the password of it's user (single user). How can I reset the password of user by plugging the external hdd to another Linux machine and then editing some file, using some command through terminal, changing the bash(remember doing something similar long time ago), or something else? And I do not want to get into Grub etc. Booting through that drive is not an option (although it is but I am not willing to get into it and don't want to restart the running("another") Linux machine). |
How do I install htop inside mac os x? Posted: 31 Mar 2021 11:01 AM PDT How do I install htop for Mac OS X? (The easiest and laziest path) |
List files sorted numerically Posted: 31 Mar 2021 08:51 AM PDT I have a bunch of files from log1 to log164 . I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort log1.gz log10.gz log100.gz log101.gz log102.gz log103.gz log104.gz log105.gz log106.gz ...etc What I want is home:logs Home$ ls -1 | sort log1.gz log2.gz log3.gz log4.gz log5.gz log6.gz log7.gz ...{more here} log99.gz log100.gz log101.gz log102.gz ...etc Any suggestions in what I could use to do this? |
No comments:
Post a Comment