Pages

Sunday, January 8, 2023

Miscellaneous Linux Shell Commands

  • Extract Postgres table list and re-execute sql command on all tables:

 

psql -U odoo13 odoo13 -h localhost -tqc '\dt' | awk -F "|" '{print $2}' | sed -r 's/[ ]*$//g'|xargs -i echo "select '{}', count(*) from {};"| psql -U odoo13 -h localhost
 

psql : Extract table names or a db

awk : Filtering result and extract (and print) table name

sed : Eliminate trailing space from table name

xargs and echo : generate desired sql [ Note {} ]

 

  • Using shell for:

for table in `mysql table_name -Nse 'show tables;'`; do mysql table_name -e 'drop table '$table ; done


  • Let's Encrypt certbot command to register domain and extend subdomain:

sudo certbot --nginx -d domain.com

sudo certbot --nginx -d domain.com,subdomain.domain.com --expand

 
  •  DNS lookup for TXT and MX 

`dig -t txt ilyn.global +short`

`dig ilyn.global txt +short`

 

`dig -t mx ilyn.global +short`

`dig ilyn.global mx +short`

Removing "+short" will give full result


  • Telnet a mail server and check if email user exists

 

Shell command: telnet gmail-smtp-in.l.google.com 25

Here 25 is the email server port

Email server commands after telnet is successful
 

helo <something>
mail from:<email@address>
rcpt to:<email@address> 

 The response will reveal if the user exists

No comments :

Post a Comment