Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

Friday, May 25, 2018

Creating image from a running instance

Sometimes we want to spawn off a few new instances, with the same spec and operating systems, but we do not want to go through the hassle of setting up each OS manually, and then update it one by one. In order to do that efficiently, openstack provides a very good way, which is to create an image from a running instance, and this image can be used to spawn off new instances afterwards.

Before we turn any instance to an image, we need to know its instance ID

$ openstack server list

We can then create an image from the above instance ID
$ openstack server image create --name centos7-updated-20180525 21e78f23-8b67-423a-9622-d46c8487f829

To make sure our image is created correctly, check using:
$ openstack image list

To create a new instance from the image, please refer here

Creating a new instance on openstack

In order to create new instance (it is called server in openstack command), you need to know beforehand a few information to feed to the create instance command. Refer below for those information:

check available flavor

$ openstack flavor list

check available images
$ openstack image list

check available network
$ openstack network list

check available security group
$ openstack security group list

check available keypair
$ openstack keypair list


Once you get all the above information, to create the new instance, just use below command, providing the above information as option to openstack server create command
$ openstack server create \
--image centos-7-20180520 \
--key-name my-keypair \
--flavor m1.medium \
--security-group defaults \
--network private-140 \
thenewinstancename


To check whether your new instance has been created and active:
$ openstack server list


Thursday, February 19, 2015

Starting with tmux - putting in initial settings

After a few years using GNU screen as my main terminal multiplexer, I have now changed it to tmux. The reasons behind that are:

  1. A lot more customizable
  2. The commands are also available in easy human understandable language, rather than just the shortcuts. For example: to kill a window, just "ctrl-b" and type "kill-window" or "killw", which is easier for new user like me to remember and use, rather than shortcuts like "ctrl-b &" which sometimes can be confusing.
  3. Easier horizontal and vertical splitting mechanism

To start with tmux, especially if you are coming from screen, it is very important to set th ekey binding right, since ctrl-b is not easily reachable with one hand compared to ctrl-1. Below are my initial .tmux.conf settings, to ease up my transition from GNU screen to tmux.

$ cat .tmux.conf
# unbind control-b, and replace it with control-a (GNU screen style)
set-option -g prefix C-a
           unbind-key C-b
           bind-key C-a send-prefix
# Use vi or emacs-style key bindings in copy and choice modes
set-window-option -g mode-keys vi       
# start windows numbering at 1
set -g base-index 1
# renumber windows when a window is closed                     
set -g renumber-windows on              

So there you go, some very simple settings to be appended to .tmux.conf, to ease up your learning in using tmux. Please refer to the comments, to actually know what the settings are for. You can always refer to tmux manual (man tmux) for more settings.

Hope this will be helpful :)

Friday, March 19, 2010

Running windows cmd from linux

To run windows cmd from linux box, there is one tool you could use, which is winexe. You can download the installer from here. There are 2 ways to install this tool:


1. Use the preinstalled version.
  • Download from here
  • Unpack the bz2 file: # bunzip2 winexe-static-081123.bz2
  • Change mod to allow execute: # chmod +x winexe-static-081123
  • Make soft link in your /usr/local/bin: # ln -s winexe-static-081123 /usr/local/bin/winexe

2. Compile from source
  • Install necessary packages (gcc, svn, *-devel....)
  • Get sources from here
  • Unpack the source file: # tar -xvjf winexe-source-081123.tar.bz2
  • Compile according to README file:
    • cd to unpacked tar.bz2 sources
    • ./autogen.sh
    • ./configure
    • make proto bin/winexe
  • Compiled file will be located in wmi/Samba/source/bin/winexe
  • Install winexe:
    install -s wmi/Samba/source/bin/winexe /usr/local/bin/winexe

To use it is very simple:

# winexe -U foo -W WORKGROUP -n FOO-PC //10.0.0.61 "cmd.exe"

where -U for username, -W for workgroup, -n for target machine netbios name, 10.0.0.61 is the ip address of the target machine and cmd.exe is to start windows command prompt.
Once connected, you will get command prompt like below:

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\WINDOWS\system32>

To quit, just type exit at the windows command prompt.

That's all :)