If your VPN client office using forticlient, you might want to run your VPN client with only command line, so you don’t have to see the small window just for connect your servers from home. With this bash script you can run your forclient VPN client only with CLI. GUI is for loosers.
Install expect first if you’re using ubuntu.
$ sudo apt-get install expect
Then copy this script below and save it. Inside the script there are some variables like username, password, host, port, that you need to fill.
# Forticlient SSL VPN Client launching script utilizing expect.
# VPN Credentials
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
if [ -z "$FORTICLIENT_PATH" ]; then
FORTICLIENT_PATH=`uname -r | grep -q 64 && echo $(locate forticlientsslvpn_cli | grep 64bit) || echo $(locate forticlientsslvpn_cli | grep 32bit)`
if [ ! -f $FORTICLIENT_PATH ]; then
echo "Tried to locate Forticlient SSL VPN Cli binary, but failed."
echo "Specify it at variable FORTCLIENT_PATH"
echo "Located Forticlient VPN Client at: $FORTICLIENT_PATH"
echo "Killing previous instances of Forticlient SSL VPN client..."
killall -9 $(basename $FORTICLIENT_PATH) 2> /dev/null
cat << EOF > /tmp/expect
set timeout -1
spawn $FORTICLIENT_PATH --server $VPN_HOST --vpnuser $VPN_USER --keepalive
expect "Password for VPN:"
send -- "$VPN_PASS"
send -- "\r"
expect "Would you like to connect to this server? (Y/N)"
send -- "Y"
send -- "\r"
expect "Clean up..."
chmod 500 /tmp/expect
/usr/bin/expect -f /tmp/expect
rm -f /tmp/expect
After you saved the script, let’s try to run it with sudo mode:
$ sudo vpn.sh &
These two commands will enable and disable your init script/service in system startup in Ubuntu 14.04:
Enable/add your service in startup
$ sudo update-rc.d docker defaults
Disable/remove service from startup
$ sudo update-rc.d -f docker remove
This is how to play your favorite music with command line, no UI bullshit
$ sudo apt-get install mpg321
$ cd ~/Music/
~/Music$ mpg321 Pink Floyd - Comfortably Numb.mp3
These command lines show you how to get your current public IP address just from terminal, just follow one of these way to get yours:
$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
Or, the shorter one:
$ curl ipinfo.io/ip
Sometimes it sucks when you listen to music on youtube with very limited sound level after your volume level has reached maximum and you’re using piece of shit earphone. Just go with this command to extend the limitation sound level, it works on ubuntu 14.04:
$ pactl -- set-sink-volume 0 150%
be careful with maximum sounds, can be dangerous for your ears.
To connect host with specific key
$ ssh user@host -i mykey.pem
Just a case if you want to know some application or service who is running under specific port :
$ netstat -tulpn | grep :80
Sometimes you need to run with sudo to see all services :
$ sudo netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1393/nginx.conf
It turns out that 1393 is the pid of service
docker to start a container from image
$ sudo docker run -itd --name jenkins --publish 8080:8080 --publish 50000:50000 jenkins
docker to get inside the container
$ sudo docker exec -it jenkins bash
Play video headlessly and only audio with command line :
$ mplayer -vo null myvideo.mp4
To describe specific AMI
$ aws ec2 describe-images --image-ids ami-5731123e
To describe instance
$ aws ec2 describe-instances --instance-ids i-1234567890abcdef0
To describe VPCs
$ aws ec2 describe-vpcs
To describe route tables
$ aws ec2 describe-route-tables