This is the command which can be used to show all the users with all the grants on mysql from command line.
select user,host,password from mysql.user order by user;
Useful command to add ssh key.
cat your_id_rsa.pub >> ~/.ssh/authorized_keys
SSH chain login.
ssh -A -t user@server1 ssh -A -t user@server2 ssh -A user@server3
Find in specific files and replace
grep -rl --include=*.xml oldname /var/www/html | xargs sed -i 's/oldname/newname/g'
Test CPU waiting time because of the IOPS
iostat -mx 1
Add ssh key to a remote server with a single command
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys && chmod 600 .ssh/authorized_keys && restorecon -R .ssh'
Login to a user which doesn’t have shell access (nologin)
su -s /bin/bash USER
Remove server from knows_hosts
ssh-keygen -f "~/.ssh/known_hosts" -R 192.168.0.xx
Working with git tags
Create a tag
git tag test_1000
Push tags to git
git push --tags
Delete a git tag
git tag -d test_1000 git push origin :refs/tags/test_1000 or git push origin ::refs/tags/test_1000
Generate hash passwords for puppet
openssl passwd -1
RDP from Linux to Windows with clipboard sync
rdesktop -u USERNAME -k en-us -p PASSWORD -a 16 -z -5 -P IP_ADDRESS -d DOMAINA.NAME -g 1366x1024 -5 -K -r clipboard:CLIPBOARD
Grep and sort logs
grep -rni "expression" access.log | grep -i login |cut -f 4 -d ' '|sort|uniq -c|sort -nr
Attach to docker container
docker attach --sig-proxy=false 0cd6bd960475
docker exec -it 0cd6bd960475 bash
Download with curl
curl -o /etc/yum.repos.d/rhel-pulp.repo https://repos.fedorapeople.org/repos/pulp/pulp/rhel-pulp.repo
Git remove deleted files
git ls-files --deleted -z | xargs -0 git rm
Kubernetes container with bash exec
kubectl exec -it `kubectl get pods --namespace NAMESPACE | grep -i POD | awk '{print $1}'` -c NGINX bash --namespace NAMESPACE
Netcat replacement
nmap -p 1-10 HOST
Create archives with tar password protected using gpg
Create
tar -czvpf - FOLDERS_FILES_TO_ARCHIVE | gpg --symmetric --cipher-algo aes256 -o ARCHIVE_NAME.gz.gpg
Extract
gpg -d ARCHIVE_NAME.gz.gpg | tar -xvzf -