To use OR when you are doing a grep search use the \| characters to separate the items you are searching for.
cat text_to_search_in | grep 'first\|second\|third'
To use OR when you are doing a grep search use the \| characters to separate the items you are searching for.
cat text_to_search_in | grep 'first\|second\|third'
You want to update your dns resolution locally after some change in DNS.
You want to do this because your local dns cache still holds the old information about the domain. For example using your local dns and the google one returns two different results
host changed_domain.com returns the old ip host changed_domain.com 8.8.8.8 returns the new ip.
Check your systemd-resolved is active:
sudo systemctl is-active systemd-resolved active
Get some statistics:
sudo systemd-resolve --statistics Transactions Current Transactions: 0 Total Transactions: 38818 Cache Current Cache Size: 73 Cache Hits: 21120 Cache Misses: 19745 DNSSEC Verdicts Secure: 0 Insecure: 0 Bogus: 0 Indeterminate: 0
Flush the cache (make the Current Cache Size above 0)
sudo systemd-resolve --flush-caches
Check the cache again (should be 0 now):
sudo systemd-resolve --statistics ransactions Current Transactions: 0 Total Transactions: 38818 Cache Current Cache Size: 0 Cache Hits: 21120 Cache Misses: 19745 DNSSEC Verdicts Secure: 0 Insecure: 0 Bogus: 0 Indeterminate: 0
Information taken from https://www.techrepublic.com/article/how-to-flush-the-dns-cache-on-linux/
Using the asdf version manager to manage versions of various binaries like terraform, vault or packer is easily done by following the instructions below:
asdf plugin add terraform asdf install terraform latest asdf global terraform 0.14.9 asdf list terraform 0.14.9 terraform --version Terraform v0.14.9
Problem
You would like to rename multiple files, replacing some text with something else (like replacing Pixies_The with Pixies).
Solution
Install the rename utility
sudo apt install rename
and replace the text as follows
cd folder_to_rename_files rename 's/Pixies_The/Pixies/g' **
To get or set in environment variables the platform information of a system you can use the following:
export ARCH=$(case $(arch) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(arch) ;; esac) export OS=$(uname | awk '{print tolower($0)}')
Taken from the installation instructions of the Operator SKD here: https://master.sdk.operatorframework.io/docs/installation/
To stop having a service automatically start after bootup in a Linux system with systemctl use the following to stop and then disable the service:
sudo systemctl stop service_name sudo systemctl disable service_name
Trying to start the docker service after some upgrades fails with the following message:
Failed to start docker.service: Unit is masked.
It turns out that after upgrading or more specifically removing and then upgrading the docker installation in ubuntu (in this particular case in raspberry 4 with Ubuntu 20.04 installed), results in this error.
A search brings up the following:
https://forums.docker.com/t/failed-to-start-docker-service-unit-is-masked/67413
and from that the following bug post:
https://bugs.launchpad.net/ubuntu/+source/docker.io/+bug/1844894
So the solution is to run the following to be able to start the docker service (described in the first link above):
sudo systemctl unmask docker sudo systemctl start docker
To be able to get a more detailed information about your current linux distribution, including the code names use the following:
kosmas:$ cat /etc/os-release NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.5 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic
If you would like to be able to see the dmesg output with timestamps instead of time in seconds since booting up, use the -T like:
dmesg -T | less
There is a very nice example on the O’reilly ‘Linux Under The Hood’ training about using strace to compare performance of two commands that provide the same output but with different calls. The two different commands were: ls and echo *, that they both provide the listing of the current directory.
First using the strace with ls:
kosmas:$ strace -c ls abi-4.13.0-45-generic config-4.4.0-31-generic initrd.img-4.4.0-31-generic System.map-4.15.0-123-generic vmlinuz-4.15.0-123-generic abi-4.13.0-46-generic efi memtest86+.bin System.map-4.15.0-124-generic vmlinuz-4.15.0-124-generic abi-4.4.0-31-generic grub memtest86+.elf System.map-4.15.0-126-generic vmlinuz-4.15.0-126-generic config-4.13.0-45-generic initrd.img-4.13.0-45-generic memtest86+_multiboot.bin System.map-4.4.0-31-generic vmlinuz-4.4.0-31-generic config-4.13.0-46-generic initrd.img-4.13.0-46-generic retpoline-4.13.0-45-generic vmlinuz-4.13.0-45-generic vmlinuz-4.4.0-31-generic.efi.signed config-4.15.0-123-generic initrd.img-4.15.0-123-generic retpoline-4.13.0-46-generic vmlinuz-4.13.0-45-generic.efi.signed config-4.15.0-124-generic initrd.img-4.15.0-124-generic System.map-4.13.0-45-generic vmlinuz-4.13.0-46-generic config-4.15.0-126-generic initrd.img-4.15.0-126-generic System.map-4.13.0-46-generic vmlinuz-4.13.0-46-generic.efi.signed % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 15.81 0.000095 12 8 write 14.64 0.000088 7 12 mprotect 13.48 0.000081 5 17 mmap 9.98 0.000060 7 9 openat 7.82 0.000047 4 11 close 7.32 0.000044 22 2 getdents 6.82 0.000041 6 7 read 5.66 0.000034 3 10 fstat 4.99 0.000030 4 8 8 access 3.16 0.000019 10 2 2 statfs 2.00 0.000012 12 1 munmap 1.83 0.000011 4 3 brk 1.66 0.000010 5 2 ioctl 1.50 0.000009 5 2 rt_sigaction 0.67 0.000004 4 1 rt_sigprocmask 0.67 0.000004 4 1 arch_prctl 0.67 0.000004 4 1 set_tid_address 0.67 0.000004 4 1 set_robust_list 0.67 0.000004 4 1 prlimit64 0.00 0.000000 0 1 execve ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000601 100 10 total
And using the same with echo *
kosmas:$ strace -c echo * abi-4.13.0-45-generic abi-4.13.0-46-generic abi-4.4.0-31-generic config-4.13.0-45-generic config-4.13.0-46-generic config-4.15.0-123-generic config-4.15.0-124-generic config-4.15.0-126-generic config-4.4.0-31-generic efi grub initrd.img-4.13.0-45-generic initrd.img-4.13.0-46-generic initrd.img-4.15.0-123-generic initrd.img-4.15.0-124-generic initrd.img-4.15.0-126-generic initrd.img-4.4.0-31-generic memtest86+.bin memtest86+.elf memtest86+_multiboot.bin retpoline-4.13.0-45-generic retpoline-4.13.0-46-generic System.map-4.13.0-45-generic System.map-4.13.0-46-generic System.map-4.15.0-123-generic System.map-4.15.0-124-generic System.map-4.15.0-126-generic System.map-4.4.0-31-generic vmlinuz-4.13.0-45-generic vmlinuz-4.13.0-45-generic.efi.signed vmlinuz-4.13.0-46-generic vmlinuz-4.13.0-46-generic.efi.signed vmlinuz-4.15.0-123-generic vmlinuz-4.15.0-124-generic vmlinuz-4.15.0-126-generic vmlinuz-4.4.0-31-generic vmlinuz-4.4.0-31-generic.efi.signed % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 1 read 0.00 0.000000 0 1 write 0.00 0.000000 0 5 close 0.00 0.000000 0 4 fstat 0.00 0.000000 0 6 mmap 0.00 0.000000 0 4 mprotect 0.00 0.000000 0 1 munmap 0.00 0.000000 0 3 brk 0.00 0.000000 0 3 3 access 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 arch_prctl 0.00 0.000000 0 3 openat ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 33 3 total
So the difference in time is 0.00000 for the echo and 0.000601 for the ls.
Similarly the number of calls for the echo is 33, but ls is using 100.