Bash keyboard shortcuts

I can’t remember them all except the ones I use on a daily basis.

Advertisements

What is exec?

As opposed to fork or other means that creates a new process, exec will replace the process that calls it.

Wikipedia:

In computing, exec is a functionality of an operating system that runs an executable file in the context of an already existing process, replacing the previous executable. This act is also referred to as an overlay. It is especially important in Unix-like systems, although exists elsewhere. As a new process is not created, the process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program.

exec is implemented in several programming languages. In Linux, we have an exec system call as well as a bash builtin.

type exec
exec is a shell builtin

Let’s do a simple example to understand what it means to replace the calling process. Continue reading

The allssh command in a Nutanix CVM

The allssh command in a Nutanix CVM is an alias to __allssh which is a bash function defined in /usr/local/nutanix/profile.d/bashrc.

$ which allssh
alias allssh='__allssh'
$ type __allssh
__allssh is a function
__allssh () 
{ 
    CMDS=$@;
    OPTS="-t -o LogLevel=ERROR -o StrictHostKeyChecking=no";
    echo "Executing $CMDS on the cluster";
    for i in `svmips`;
    do
        echo "================== "$i" =================";
        /usr/bin/ssh $OPTS $i "source /etc/profile;$@";
    done
}

Add second VMKernel interface to multiple ESXi hosts

I have to add a VMKernel interface for NAS traffic to a series of hosts that I just built. I am going to call the portgroup NAS as that is the purpose. The portgroup will be in vSwitch0 along with the MGMT network.

These are the commands I need

esxcli network vswitch standard portgroup add -p NAS -v vSwitch0
esxcfg-vmknic -a -i a.b.c.d -n 255.255.255.0 -p NAS
esxcli network ip interface  set -i vmk1 -m 9000    

But I need to run this through a series of hosts. I place the hostnames and IPs in a file in this format. Continue reading

Configure hostname for multiple ESXi hosts

I build a bunch of new ESXi hosts and this is how I configure hostname for each host.

First, I have the list of the hosts’ FQDN in a file

$ cat list
esxi01.example.com
esxi02.example.com
esxi03.example.com
esxi04.example.com
esxi05.example.com
esxi06.example.com

I use cat and awk to generate an ssh command for each host. This assumes you have ssh keys configured. Continue reading