Blog

Blog

Tmux vs Screen

Tmux vs Screen

The unix command screen and tmux have similar goal, but tmux is more complex than screen.

Quick Tips

In order to start using tmux without worrying about forgetting keys, remember follows one after another.

  • Help using key Ctrl+b ?
  • Detach using key Ctrl+b d
  • Resume using command tmux a
  • Create window using command Ctrl+b c
  • Navigate windows using key Ctrl+b w, then arrow keys
  • Rename window using key Ctrl+b ,
  • Status bar has window name and <id>
  • Switch window using key Ctrl+b <id>

Commands

screen tmux
Startup screen tmux
Starting Named Session screen -S session_name tmux new -s session_name
List running session screen -ls tmux ls
Reattach screen -r
Reattach by id screen -r <id> tmux attach-session -t <id>

Keys

screen tmux
Help Ctrl+a ? Ctrl+b ?
Create a new shell (without window) Ctrl+a c
Switch to next shell Ctrl+a space
Switch to previous shell Ctrl+a backspace
Create a new window (with shell) Ctrl+b c
List all shells Ctrl+a "
Choose window from a list Ctrl+b w
Switch to N'th shell Ctrl+a <n>
Switch to N'th window Ctrl+b <n>
Rename the current window Ctrl+a A Ctrl+b ,
Split current region horizontally into two regions Ctrl+a S Ctrl+b %
Split current region vertically into two regions Ctrl+a | Ctrl+b "
Switch the input focus to the next region Ctrl+a tab Ctrl+b o
Toggle between the current and previous windows Ctrl+a Ctrl+a Ctrl+b ;
Close all regions but the current one Ctrl+a Q
Close the current region Ctrl+a X Ctrl+b x
Detach from session Ctrl+a d Ctrl+b d
Sent Ctrl+a to region Ctrl+a a

Customize

screen

Customization can be done in /etc/screenrc and ~/.screenrc. Sample of contents is shown below.

# Turn off the welcome message
startup_message off

# Disable visual bell
vbell off

# Set scrollback buffer to 10000
defscrollback 10000

# Customize the status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'

tmux

Customization can be done in ~/.tmux.conf. Sample of contents is shown below.

# Improve colors
set -g default-terminal 'screen-256color'

# Set scrollback buffer to 10000
set -g history-limit 10000

# Customize the status line
set -g status-fg  green
set -g status-bg  black

References

How To Use Linux Screen
Getting started with Tmux
How to split the terminal into more than one "view"?

VirtualBox Command Line Interface

VirtualBox Command Line

List all VMs

vboxmanage list vms

List all running VMs

vboxmanage list runningvms

Show a VM info

vboxmanage showvminfo <name or UUID>.

Start a VM

vboxmanage startvm <name or UUID>.

Control a VM

vboxmanage controlvm <subcommand>

Subcommand: pause, resume, reset, poweroff, and savestate

Unregister a VM

vboxmanage unregister <name or UUID>

Remove a VM

vboxmanage unregister --delete <name or UUID>

Modify a VM

vboxmanage modifyvm <name or UUID> --name <new name>
vboxmanage modifyvm <name or UUID> --description <new description>.
vboxmanage modifyvm <name or UUID> --memory <RAM in MB>.
vboxmanage modifyvm <name or UUID> --cpus <number>.

Change VM state

vboxmanage controlvm <name or UUID> setlinkstate<num> [off|on]
vboxmanage modifyvm <name or UUID> --nicpromisc<num> allow-all
vboxmanage controlvm nic<num> <network type>

Note: The <num> is referring to eth<num> interface. The Network type can be hostonly, etc.

References

An Introduction to the VirtualBox CLI

Install VirtualBox on CentOS in Proxmox

Install VirtualBox on CentOS in Proxmox

Steps

  • Install development kernel
yum install patch gcc kernel-headers kernel-devel make perl wget elfutils-libelf-devel
  • Reboot

Troubleshooting

Error message

systemctl status vboxdrv

Log

more /var/log/vbox-setup.log

References

How to Install VirtualBox on CentOS 7

Install Vagrant on CentOS in Proxmox

Install Vagrant on CentOS

Steps

Check version

The latest version of Vagrant can be found in https://releases.hashicorp.com/vagrant.

Install

yum install https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.rpm

Verify

vargant --version

Init CentOS 7 with Vagrant

sudo mkdir ~/vagrant-centos-7
cd ~/vagrant-centos-7
vagrant box add centos/7

Create Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
end

Start Vagrant

vagrant up

SSH

vagrant ssh

Halt Vagrant

vagrant halt

Destroy Vagrant

vagrant destroy

Troubleshooting

If the following error appeared, change the CPU type of CentOS VM in Proxmox to host.

Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)

References

How to Install Vagrant on CentOS 7
centos/8 Vagrant box

Manage VMware Fusion via `vmrun`

Manage VMware Fusion via vmrun

Start VMware Fusion

$ open -a "VMware Fusion"

List running VM

vmrun list

Start a VM

vmrun start <vm_name>.vmx

Troubleshooting

Hanging at VM starting up

This could be caused by some warning message appears on the screen.

References

Examples of vmrun Commands
How to Open Applications Using Terminal on Mac

Convert VMware VM to Proxmox VM

Convert VMware VM to Proxmox VM

Create a new VM in Proxmox

Linux

  • Create new VM in Proxmox, and select correct BIOS.

Windows

  • Create new VM in Proxmox, and select OVMF (UEFI).

Remove newly created disk

  • Detach disk
  • Remove detached disk

Convert disk

Run following command to convert vmdk to qcow2

qm importdisk <VM_ID> <Virtual Disk>.vmdk <storage> --format qcow2

Here, VM_ID is a number. After completed a newly created disk appears in VM

Add disk

Ubuntu

Double click the newly created disk, then select VirtIO Block device.

Select Write Back as cache method

RHEL and Windows

Double click the newly created disk, then select SATA device.

Select Write Back as cache method

Start VM and remove VMware Tools

Ubuntu

apt remove --auto-remove open-vm-tools
apt remove --auto-remove xserver-xorg-video-vmware
apt purge open-vm-tools
apt purge open-vm-tools-desktop

RHEL

yum remove open-vm-tools open-vm-tools-desktop

Reboot the server

Enable VMmotion in VMware

Enable VMmotion in VMware

Two ESXi servers, for example esx01 and esx02.

CPU

The CPU of both esx01 and esx02 are same family.

Storage

Both esx01 and esx02 are having same shared storage.

Configure

Configure NFS or iSCSI in both ESXi servers.

Verify

Access storage, and check Hosts tab, both ESXi servers should be in the list.

Network

Add VMkernel Network Adapter with vMotion service, can be on an existing standard switch.

References

VMware Tutorial No.45 | VMware vMotion Step by Step |vMotion in VMware 6.7 |vSphere vMotion GOVMLAB