bash – check if a string in a variable
if you use#! /bin/zsh $MYVAR=”Hello world” if [[ $MYVAR == *”hello”*]] thenecho “FOUND”fi If we don’t use #! /bin/zsh $MYVAR=”Hello world”if [[ $MYVAR == *”hello”*]]; thenecho “FOUND”fiRead More →
if you use#! /bin/zsh $MYVAR=”Hello world” if [[ $MYVAR == *”hello”*]] thenecho “FOUND”fi If we don’t use #! /bin/zsh $MYVAR=”Hello world”if [[ $MYVAR == *”hello”*]]; thenecho “FOUND”fiRead More →
When i try to remove a disk in Virtualbox with this command: # VBoxManage storageattach “myvm” –storagectl SATA –port 0 –device 0 –type hdd –medium none I got the following error VBoxManage: error: The machine is not mutable or running (state is Saved) VBoxManage: error: Details: code VBOX_E_INVALID_VM_STATE (0x80bb0002), component SessionMachine, interface IMachine, callee nsISupports VBoxManage: error: Context: “DetachDevice(Bstr(pszCtl).raw(), port, device)” at line 403 of file VBoxManageStorageController.cpp And the fix is: VBoxManage discardstate uuid VBoxManage discardstate 23036a87-de86-4bee-ad92-5eed022a13d9Read More →
Please check if your subdomain is a CNAME , the DNS rule does not allow CNAME record to have other record. The fix is to use A record for your sub domain – this could be hard if you are using some cloud service like aws.Read More →
rrdcached is a daemon that receives updates to existing RRD files, accumulates them and, if enough have been received or a defined time has passed, writes the updates to the RRD file. A flush command may be used to force writing of values to disk, so that graphing facilities and similar can work with up-to-date data. rrdcached uses the line protocol to communicate with client. When we start rrdcached , it will listen on port 42217 and create a socket file. We can telnet to port 42217 or use ncat to create a connection to socket file. telnet localhost 42217 or nc -U /var/run/rrdcached/rrdcached.sock AfterRead More →
You might receive the error Column count of mysql.user is wrong. Expected 42, found 44. The table is probably corrupted , this is probably because you import the whole database from mysql 5.6 to 5.7 . The table structure has changed , so you need to update it. You can use the command mysql_upgrade to do this work for you. After you import the data , run this file mysql_upgrade -uroot -p -h127.0.0.1 -P3306 this command will go all over your databases table and upgrade the database structure . mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK UpgradingRead More →
When we add new data: # vi /etc/apt/sources.list … deb http://deb.debian.org/debian stretch main contrib non-free deb-src http://deb.debian.org/debian stretch main contrib non-free we got some errors below: # apt-get update Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Fetched 172 kB in 2s (73.3 kB/s) Reading package lists… Done root@netsgn:~/soft# nano /etc/apt/sources.list root@netsgn:~/soft# apt-get update Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:4 https://packagecloud.io/grafana/stable/debian stretch InRelease [23.2 kB] Err:4 https://packagecloud.io/grafana/stable/debian stretch InRelease The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 37BBEE3F7AD95B3F Fix: #Read More →
I had a samsung J7, it’s in the drawer for many months. today i tried to charge it, there was no sign it’s charging. i changed many cables , i thought the battery is dead. Luckily i have its original charger adapter + cable , i connected it to the phone , the phone starts up . i don’t know if there is any difference between the original charger and other compatible charger. Hope it help you in some cases.Read More →
rrdtool dump filename.rrd rrdtool info filename.rrd rrdtool graph /dev/null -s 3600 DEF:ierr=filename.rrd:ds1:AVERAGE VDEF:ioct_a=ierr,AVERAGE PRINT:ierr:%lf this command will get the avg value of ds1 (ds1 is the dataset – you can see it in rrdtool info ) , assign it to variable ierr and print out #3600 => one hourRead More →
Create a service: sudo vi /etc/systemd/system/rc-local.service Add your code there: [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target Create and make sure /etc/rc.local is executable and add this code inside it: sudo chmod +x /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will “exit 0” on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0 Enable the service: sudoRead More →
When you setup a GRE tunnel through an existing ipsec – the keepalives should be turn off , if you turn on keepalives the tunnel will never be up int Tunnel100 no keepalives Read More →