Posts

Showing posts with the label terminal

Make function keys work on putty's ssh session

Image
When you ssh to a Linux machine using putty and running tmux or byobu, by default, you can not use function keys to switch between sessions (F3, F4) or create a new session (F2). By setting putty as below, you will "fix" that: 1. Go to Putty settings, Terminal section, Keyboard, The Function keys and keypad, select Xterm R6 2. Apply and close.

Executing shellscript with administrator (sudo) privileges (GUI) in Mac OSX using AppleScript

You created an executable shellscript that requires sudo or admin privileges in Mac OSX to do something like install printers, change DNS server... It's not difficult, you just need to open the terminal, grant the script file the executable permission, then run it. But the thing is the terminal interface may scare the shit out of a normal user. What can you do about that? OK, AppleScript is your savior. Write a wrapper script using AppleScript to call your genius shell. With the AppleScript you can popup a beautiful window (GUI) asking for administrator password. Here is an example: myshellscript.sh: #! /usr/bin/bash sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 Basically, my example do the following: 1. Upload your shellscript somewhere public that allow you to download the script using curl. For example: http://mywebsite.com/myscript.sh 2. Using AppleScript to grant executable privileges to the shellscript with " with administrator privileges ": d...

MySQL - Using mysqladmin to do some jobs outside the mysql terminal

You can do some mysql jobs outside the mysql terminal using mysqladmin util: For example: 1. Drop a table: $ mysqladmin -u myuser -p'myuser_password' -f drop mytable The ' -f ' parameter is to proceed the command without prompting (y/N). 2. Create a new table: $ mysqladmin -u myuser -p'myuser_password' create my_newtable For more use cases,  read this article: http://www.tecmint.com/mysqladmin-commands-for-database-administration-in-linux/