How to kill a frozen screen in Ubuntu 16.04

I am using Ubuntu now full-time, after formatting my machine and getting rid of windows or dual boot. While using it suddenly my Google Chrome screen was frozen and none of the controls were working. I tried killing it from task bar by right clicking on the icon -> Quit but it was not working at all.

So i decided to google it for solutions, Like how to kill a program(forcefully) and i came up with an interesting utility which is already there in Ubuntu/Linux machines Xkill.

What is Xkill?

Xkill is a utility for forcing the X server to close connections to clients. This program is very dangerous, but is useful for aborting programs that have displayed undesired windows on a user’s screen. If no resource identifier is given with -id, xkill will display a special cursor as a prompt for the user to select a window to be killed. If a pointer button is pressed over a non-root window, the server will close its connection to the client that created the window.

Command:

➜ ~ xkill
Select the window whose client you wish to kill with button 1....
xkill: killing creator of resource 0x4200001

When you enter xkill command on terminal without any parameter it will ask you to choose the window/client to kill, so simply switch tab, go to the client that you want to close and click on the client. It will forcefully close the client.

Happy sharing! Loving Ubuntu(Linux)! Command rocks! 🙂

Beanstalk helpful commands

I really had to scratch my head when i forgot the commands, so did happened with me today with beanstalk, I had to check that whether or not my jobs are getting queued in beanstalk queue, are they getting delayed?

Some of the commands that i used are:

  • Connect to beanstalk
telnet localhost 11300
  • Get the statistics of jobs and more details
stats

Output:

current-jobs-urgent: 15
current-jobs-ready: 22
current-jobs-reserved: 0
current-jobs-delayed: 25
current-jobs-buried: 0
cmd-put: 3620
cmd-peek: 0
cmd-peek-ready: 2
cmd-peek-delayed: 0
cmd-peek-buried: 0
cmd-reserve: 0
cmd-reserve-with-timeout: 82380
cmd-delete: 3573
cmd-release: 0
cmd-use: 643
cmd-watch: 12
cmd-ignore: 12
cmd-bury: 0
cmd-kick: 0
cmd-touch: 0
cmd-stats: 6
cmd-stats-job: 0
cmd-stats-tube: 0
cmd-list-tubes: 2
cmd-list-tube-used: 0
cmd-list-tubes-watched: 0
cmd-pause-tube: 0
job-timeouts: 0
total-jobs: 3620
max-job-size: 31457280
current-tubes: 8
current-connections: 8
current-producers: 5
current-workers: 4
current-waiting: 4
total-connections: 578
pid: 1286
version: 1.10
rusage-utime: 19.475000
rusage-stime: 22.225000
uptime: 421199
binlog-oldest-index: 45
binlog-current-index: 45
binlog-records-migrated: 0
binlog-records-written: 7193
binlog-max-size: 10485760
id: fb9d5d1abfc5af25
hostname: vagrant-0-6-0
  • To list all avaliable tubes
list-tubes

Output:

- default
- bd36a09e-f26b-4355-a4a0-584cae4c7a0e-elastic
- bd36a09e-f26b-4355-a4a0-584cae4c7a0e-chat
  • To get stat of specific tubes
stats-tube <your-tube-name>

Output:

---
name: default
current-jobs-urgent: 0
current-jobs-ready: 0
current-jobs-reserved: 0
current-jobs-delayed: 0
current-jobs-buried: 0
total-jobs: 2983
current-using: 1
current-watching: 1
current-waiting: 1
cmd-delete: 2983
cmd-pause-tube: 0
pause: 0
pause-time-left: 0
  • Getting into a tube
use <your-tube-name>
  • Return the delayed job with the shortest delay left
peek-delayed
  • To delete a job
delete <job-id>

 

Reference: Full document on protocol

 

 

 

 

 

How to Import/Export databases in MySQL from command-line

Recently i worked with MySQL import/export databases and i have found some useful commands below:

Export:

  • All databases into sql file using mysqldump tool
mysqldump -u [username] -p --all-databases &gt; /home/username/filename.sql

In case you want to compress at the same time, run below command

mysqldump -u [username] -p --all-databases | gzip &gt; /home/username/filename.sql.gz
  • Single database into sql file using mysqldump tool
mysqldump -u [username] -p [dbname] &gt; /home/username/filename.sql

In case you want to compress at the same time, run below command

mysqldump -u [username] -p [dbname] | gzip &gt; /home/username/filename.sql.gz
  • Single database table into sql file using mysqldump tool
mysqldump -u [username] -p [dbname] [table_name] &gt; /home/username/filename.sql

In case you want to compress at the same time, run below command

mysqldump -u [username] -p [dbname] [table_name] | gzip &gt; /home/username/filename.sql.gz

Import:

  • Database from sql dump
 mysql -u [username] -p [dbname] &lt; /home/username/filename.sql 

or

 mysql&gt; source /home/username/all_databases_export.sql 
  • Single database from the dump(if it contains multiple databases):
 mysql -u [username] -p --one-database [dbname] &lt; /home/username/all_databases_export.sql 

NOTE :

  • While importing some large database i experience below error something as
 ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes 

In this case i just increase the value of –max_allowed_packet(Default=16M) as below command

 mysql -u [username] -p --max_allowed_packet=256M [dbname] &lt; /home/username/filename.sql 
  • Better using absolute paths.