john.ldif
dn: uid=john,ou=user,dc=example,dc=com
changetype: modify
add: objectclass
objectclass: ldapPublicKey
-
add: sshPublicKey
sshPublicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQOZcZYLg83R1owBWQbW2ieEp8cwNbAkju1ETm7M/NG2Bfgr2XwoZVo22Drsx3QgZzp0w5m/TbkOVrQM7gRngacl0lh0J/r0hsuPxi/pW36Zt2GG8nvAN9WfllMsPqp/XeaKo1OqMN98MQdqYH2HdeWV7aqnbo5jXcWL0zqUrEum1sAZbrDrwdDxfxrK4TDLW14GdSkesZht9r963eplxTMSTFLJP5HDsqWbaH3+8RdCiUA8tVHmqDZD8wYkmAYAzksPmAskewVo08TG9j0/Id6Oa+6C3rVJDBbgHOwQUkmvO90v4HkkSheMbymtcgsU6mOyEs3z3f7k6KMO8yEm4p
Then run:
ldapmodify -D "cn=manager,dc=example,dc=com" -W -f john.ldif
Enter LDAP Password:
modifying entry "uid=john,ou=user,dc=example,dc=com"
ldapsearch -W -D 'cn=manager,dc=example,dc=com' -H ldaps://ldap.example.com
I want to rename this:
mt-worker-1 mt-worker-2 mt-worker-3
To
mt-worker-01 mt-worker-02 mt-worker-03
rename -v mt-worker- mt-worker-0 mt-worker-?
Sort by 4th column
sort -t, -k4 -n memory.csv
su - apache -s /bin/bash
php script.php
setfacl -Rd -m u:<user>:rwX <dir>
redis-cli SMEMBERS resque:queues
redis-cli LLEN resque:queue:<queue_name>
cd /home/gitlab-runner/builds
find . -maxdepth 5 -type d -name mcb -ls
date --date @1496183649
ngrep -d any port 8125 <filter to grep for>
netstat -s --udp
SELECT pg_terminate_backend(<pid>);
find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
Refrence: https://stackoverflow.com/a/9387415/3238982
sed -i 's/DAEMON=\"\/usr\/bin\/php/DAEMON=\"$DOCKER_CMD_HEADER \/usr\/bin\/php/g' $(grep -l "DAEMON=\"/usr/bin/php" */rc.main)
sed -i 's/\/usr\/bin\/php ..\/..\//\/usr\/bin\/php /g' $(grep -l "/usr/bin/php ../../" */rc.main)
sed -i '8iif [ "$TARGET" = "trap" ]; then\n TARGET=_trap\nfi\n' my-*/rc.main
sed -i 's/apache /root docker run .../g' crontab
four five six
one
seve eight nine
one two three
one
ten eleven twelve
one
sed -e '/two/s/one/replaced/g' /tmp/file
Ref: https://www.golinuxhub.com/2017/09/sed-perform-search-and-replace-only-on.html
strace -s2000 -f -e '!lstat,munmap,mmap,fstat,clock_gettime,gettimeofday,ioctl,stat' -ttt -p 71503
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com
Zenoss —————————–
zenmodeler run -d <server_hostname> -v10
zendmd
>>> z = [x for x in devices.getSubDevices() if x.id == '<server_name>']
>>> d.getRRDValue("memCached_memCached")
To run sysdig on rancheros, you need kernel-header to be installed
sudo ros service enable kernel-headers
sudo ros service up -d kernel-headers
docker run -it --rm --name=sysdig --privileged=true \
--volume=/var/run/docker.sock:/host/var/run/docker.sock \
--volume=/dev:/host/dev \
--volume=/proc:/host/proc:ro \
--volume=/boot:/host/boot:ro \
--volume=/lib/modules:/host/lib/modules:ro \
--volume=/usr:/host/usr:ro \
sysdig/sysdig
Click on Filter section on top of the csysdig output and added your event type filters like below,
bellow example elemenates gettimeofday
, epoll_wait
and switch
event types.
(evt.type!=switch) and proc.pid=22973 and evt.type != gettimeofday and evt.type != epoll_wait and evt.type != switch
Full list of filters that can apply https://github.com/draios/sysdig/wiki/Sysdig-User-Guide#filtering
cli53 list | grep Name | awk '{print $2}
cli53 list | grep 'Name:' | awk -F\" '{print$2}' | xargs -n1 bin/cli53 export -f | tee fulldump
unbound-control flush_zone example.org.
mysqldump -t -u root -p mydb account --where="accountid=8242250"
delete n1 FROM blocklist n1, blocklist n2 WHERE n1.listid > n2.listid AND n1.MSISDN = n2.MSISDN AND n1.CreateDate > "2016-11-23 00:00:00";
while `sleep 2`; do mysql -e "show slave status;" | grep "Duplicate entry" && mysql -e "stop slave; SET GLOBAL sql_slave_skip_counter = 1; start slave;" ; done
pt-table-checksum --replicate=percona.checksums --tables <TABLE> --no-check-replication-filters --no-check-binlog-format --recursion-method=dsn=D=percona,t=dsns h=localhost,u=<USER>,p=<PASSWORD>
pt-table-sync --print --databases <DB> --tables <TABLE> --check-child-tables --replicate=percona.checksums --sync-to-master h=localhost,u=<USER>,p=<PASSWORD> > /tmp/<DB>-<TABLE>.sql
awk '{if ($11 >= 500) print }' /var/log/haproxy.log | grep -P ":07:(2|3)\d:(\d+).(\d+)" | awk '{ if ($NF >= "HTTP/1.0") print $(NF-1);else print $NF}' | awk -F"?" '{print $1}' | sort | uniq -c
tail -f /var/log/haproxy.log | awk -F '[/ ]' '{if ($17>=3000) print}'
tail -f /var/log/haproxy.log | awk -F '[/ ]' '{if ($16>=3000) print}'
awk '{print $(NF-1)}'
salt-run fileserver.update
salt-run git_pillar.update
salt '*' saltutil.refresh_pillar
<Location /uploads>
Order Deny,Allow
Deny from all
Allow from localhost
Allow from x.x.x.x
Allow from y.y.y.y
Allow from z.z.z.z
</Location>
List of Operating systems and architecture in https://golang.org/doc/install/source#environment
env GOOS=linux GOARCH=amd64 go get -v github.com/rubenv/sql-migrate/...
import "errors"
func failFunc() error {
return errors.New("Error message")
}
Ref: https://stackoverflow.com/a/36311290
Ref: https://godoc.org/github.com/avast/retry-go
personal_id_rds
~/.ssh/config
and add the following
Host github.personal
HostName github.personal
User git
IdentityFile ~/.ssh/personal_id_rsa
.git/config
[remote "origin"]
url = git@github.personal:mhdali/mhdali.github.io.git
NOTE: we changed the hostname from github.com
to github.personal
.
git remote add upstream git@github.com:...
git grep foobar -- './*' ':!*.java'
Ref: https://stackoverflow.com/a/30084612
:%s/old/new/gc
if you have resource with full name as this: module.tst_cluster.module.foo.tfe_variable.role_arn
tf taint -module=tst_cluster.foo tfe_variable.key_secret
resource "aws_instance" "foo" {
...
count = "${length(var.variable_type_list) > 0 ? 0 : 1}"
}
aws kms decrypt --ciphertext-blob fileb://<(echo '<ENCRYPTED_BLOB>' | base64 -D) --output text
Results will be something like this key ARN
ecnrypted text
:
arn:aws:kms:<REGION>:<ACCOUNT_ID>:key/<KEY_ID> <ENCRYPTED_TEXT>
array=(aardvark baboon "clouded leopard" dolphin)
while (( ${#array[@]} ))
do
echo "Animal: ${array[0]}"
array=( "${array[@]:1}" )
done
OR
array=(aardvark baboon "clouded leopard" dolphin)
set -- "${array[@]}"
while (( $# ))
do
echo "Animal: $1"
shift
done
Ref: https://stackoverflow.com/questions/50846539/shift-in-bash-but-on-arrays-instead-of-arguments
if [ -z "${ARRAY:-}" ]; then
error "Array is empty"
fi
define default value in case you’re using -u
option
Ref: https://serverfault.com/a/700936
ARR=("foo" "foo" "bar")
echo "${ARR[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '
Ref: https://stackoverflow.com/a/13648438
ARR+=("foo")
ARR+=("bar")
Ref: https://stackoverflow.com/a/1951523
dirname "${BASH_SOURCE[0]}"
Ref: https://stackoverflow.com/a/246128
function foo {
echo "foo"
}
source ./second.sh
foo
Ref: https://stackoverflow.com/a/10823213
ls -tr | head -n -5
OR
ls -tr | head -$(($(ls | wc -l)-5))
Ref: https://stackoverflow.com/a/18127758
Ref: https://www.reddit.com/r/firefox/comments/80u9vj/is_there_a_way_to_force_firefox_to_save_password/duyes28?utm_source=share&utm_medium=web2x
You need to put env.
before the key name of the environment variable.
stage {
...
env.WORKSPACE_EXISTS = true
}
Ref: https://stackoverflow.com/questions/53541489/updating-environment-global-variable-in-jenkins-pipeline-from-the-stage-level
You can access jenkins page to list down the current version default environment variables.
https://<jenkins_url>/env-vars.html
Ref: https://www.theserverside.com/tutorial/Jenkins-environment-variables-list-for-shell-script-build-jobs
Use async
to timeout a long running steps in ansible
- name: Execute nodetool repair
command: /bin/nodetool repair -j 4
async: 3600
poll: 10
Ref: https://stackoverflow.com/questions/41455002/long-running-command-in-ansible-ending-in-failed-status-with-host-unreachable