Español English

Tuesday, 10 November 2015

Tmux, basic command and usage



Tmux, basic commands and usage

How to install tmux in Archlinux/Manjaro

To install tmux in Archlinux/Manjaro you only need to type in the terminal:
yaourt -S tmux

How to start using tmux

Opening a tmux session

Tmux works with sessions, if you know screen you are familiar with this kind o sessions. How to create a session:
tmux new -s main
What does this command? It creates a session (-s) with a label called main. Label are useful if you have several sessions running.

Detaching from a tmux session

Detaching from a session means that tmux will keep running this session (as well as the programs running on it), but you will not see it. Really useful to keep it running in a server with something you do not want to loose even if the connection fails. To detach from a session simply type control + b and afterwards d

Attach to a tmux session

Attaching to a session means that we will join again to a session we detached before. To do that you simply type:
tmux attach -t main
What does this command? It attaches to (-t) to a session with label main.

Demo of creating, detaching and attaching to a session


Inside tmux, basic steps

Split window horizontal

To split horizontally the window we only need to press: control + b and

Split window vertical

To split vertically the window we only need to press: control + b and %

Moving between windows

To move between windows we only need to press: control + b and an arrow key one time.

Resizing windows

To resize a window we only need to press: control + b and arrow key several times.

Demo of splitting, moving and resizing windows


Create a new tab in the session

To create a new tab and move to it we only need to press: control + b and c. Check in the bottom of the terminal that you can see how many tabs do you have and what do they have focused.

Go to next tab

To go to the next tab we only need to press: control + b and n

Go to previous tab

To go to the previous tab we only need to press: control + b and p

Demo of creating and swapping tabs


Well, that was the basics. You can do plenty more in tmux, but for that you will have to use change the config file. As always, if people wants to know more about it and how to configure it, please leave a comment.

Saturday, 17 October 2015

How to install Xmonad in Arch Linux/Manjaro (2/2)

Now it is time to talk about my personal configuration in Xmonad. I will show pieces of the configuration file and I will explain what they mean (no worries, we will not go into Haskell details) and I will show some pictures if needed.
   
myTerminal      = "xterm"

myWorkspaces  = ["1:Main","2:Xat","3:Web","4:Music","5:Video","6", "7", "8", "9"]  

myModMask       = mod4Mask
  
In this code above we can see that xterm will be my terminal, my 9 workspaces (note that the names are strings, then you can change them as you wish) and the modMask button (using the windows button, mod4Mask, to use Xmonad actions).

myLayout = onWorkspace "2:Xat" pidginLayout $ onWorkspace "5:Video" nobordersLayout $ tiled1 ||| Mirror tiled1 ||| nobordersLayout  
 where  
  tiled1 = spacing 5 $ Tall nmaster1 delta ratio  
  --tiled2 = spacing 5 $ Tall nmaster2 delta ratio  
  nmaster1 = 1  
  nmaster2 = 2  
  ratio = 2/3  
  delta = 3/100  
  nobordersLayout = smartBorders $ Full  
  gridLayout = spacing 8 $ Grid       
  --gimpLayout = withIM (0.20) (Role "gimp-toolbox") $ reflectHoriz $ withIM (0.20) (Role "gimp-dock") Full  
  pidginLayout = withIM (18/100) (Role "buddy_list") gridLayout

In this part of the configuration file I am specifying what the behaviours of the different workspaces are. We can see that workspace 2:Xat will be using pidginLayout and workspace 5:Video will be using nobordersLayout. All the other workspaces will have three layouts (you can change them as you wish).

After that, we can see for tiled1 the ratio of the amount of screen we want to use between the master window and the stack. Moreover, we can see how the pidginLayout and nobordersLayout are specified. Please, see below a screenshot for the pidginLayout.

Pidgin running with special layout in workspace 2:Xat

myManageHook = composeAll       
     [ className =? "File Operation Progress"   --> doFloat  
     , resource =? "desktop_window" --> doIgnore  
     , className =? "xfce4-notifyd" --> doIgnore  
     , className =? "Pidgin" --> doShift "2:Xat"  
     , title =? "New Tab - Google Chrome" --> doShift "3:Web"
     , className =? "Firefox" --> doShift "3:Web"
     , className =? "Clementine" --> doShift "4:Music"  
     , className =? "Vlc" --> doShift "5:Video"  
     ]  


In this piece of configuration file we can see the hooks that we want to have in the system. I think they are quite straight forward, but I would like to mention that Firefox is moved always to workspace 3:Web or Vlc is moved to workspace 5:Video.

    ------------------ 
    -- Window Managing
    ------------------
    -- Move focus to the next window    
    , ((mod4Mask, xK_j), windows W.focusDown)
    -- Move focus to the previous window
    , ((mod4Mask, xK_k), windows W.focusUp)
    -- Move focus to the master window
    , ((mod4Mask, xK_m), windows W.focusMaster)
    -- Swap the focused window and the master window
    , ((mod4Mask, xK_Return), windows W.swapMaster)
    -- Swap the focused windows with the next window
    , ((mod4Mask .|. shiftMask, xK_j), windows W.swapDown)
    -- Swap the focused windows with the previos window
    , ((mod4Mask .|. shiftMask, xK_k), windows W.swapUp)
    -- Shrink the master area
    , ((mod4Mask, xK_h), sendMessage Shrink)
    -- Expand the master area
    , ((mod4Mask, xK_l), sendMessage Expand)

This is another important piece of the configuration file. This snippet shows how to interact with the windows you have in a workspace. Let's read a few lines to see how it works. The first one is how to focus on the next window, for that we have to use the combination Win+j or to move to the previous window we have to use the combination Win+k.

    -------
    -- Apps
    -------
    -- Google Chrome
    , ((mod4Mask, xK_g), spawn "google-chrome-stable")
    -- Pidgin
    , ((mod4Mask .|. shiftMask, xK_p), spawn "pidgin")
    -- VirtualBox
    , ((mod4Mask, xK_v), spawn "VirtualBox")
    -- Clementine
    , ((mod4Mask, xK_c), spawn "clementine")
    -- VLC
    , ((mod4Mask .|. shiftMask, xK_v ), spawn "vlc")
    -- Terminator
    , ((mod4Mask, xK_Return), spawn "terminator") -- spawn terminator terminal  
    -- Thunar
    , ((mod4Mask, xK_t), spawn "thunar")  
    -- Dmenu
    , ((mod4Mask, xK_p), spawn "dmenu_run")
    -- Kill the focused app
    , ((mod4Mask .|. shiftMask, xK_c), kill) -- kill the app

The last piece of configuration file shows how to launch applications using shortcuts. As you can see, they are as easy as the movements of the windows. To launch pidgin I will have to use Win+Shift+p or to kill the app which I am focused I will use Win+Shift+c.

Finally, to apply these changes you need to compile Xmonad and restart the session. To compile your changes you only have to write in the terminal:

xmonad --recompile


That's all for today. If anyone has questions or wants more information, please, feel free to write a comment.

Wednesday, 14 October 2015

Como instalar Xmonad en Arch Linux/Manjaro (1/2)

En éste post hablaré sobre como instalar Xmonad y usarlo con mis ficheros de configuración personales para hacerlo funcionar. Recuerda que los videos están hechos con asciinema. Eso significa que puedes copiar texto del video!!

Primer paso es añadir el repositorio archlinuxfr a el fichero /etc/pacman.conf e instalar yaourt.

Instala xmonad, xmobar, dmenu, zsh, git, feh entre otras cosas que son necesarias.

Clona el repositorio dot-files desde mi repositorio en GitHub y activa SLiM como login manager.

Una vez te autentiques en el sistema deberías ver algo parecido a esto:

Hay muchos ficheros de configuración que han sido usados para hacer funcionar esto. Además, sería muy costoso y extenso explicar cada uno de ellos, pero si la gente muestra interes, en alguno o en todos ellos, crearé otra entrada explicandolos.


En el siguiente post hablaré sobre my configuración de Xmonad y como usarlo. Si quieres ver un avance de lo que veremos en el proximo post puedes hechar un vistazo a el fichero ~/.xmonad/xmonad.hs

Para finalizar. Ultimamente he estado jugando un poco con DWM, otro tiling window manager, de suckless.org. Haré una entrada explicando como usarlo y porque creo que es muy interesante.

Monday, 12 October 2015

How to install Xmonad in Arch Linux/Manjaro (1/2)

In this post I will talk about how to install Xmonad and use my personal configuration files to make it run. Remember the videos are made with asciinema. That means you can copy from the video!!

First step is adding archlinuxfr repo to the /etc/pacman.conf file and installing yaourt.

Install xmonad, xmobar, dmenu, zsh, git, feh and all other needed stuff.

Gather dot-files from my repository in GitHub and enable SLiM as login manager.

Once you log into the system you should see something like:

There are plenty of configuration files put in place to make it run. Therefore, it will be so long to explain each of them, but if people are interested in some or all of them I will make another entry explaining them.

In the next post I will talk about the configuration I have in Xmonad and how to use it. If you want to see something in advance have a look to the file ~/.xmonad/xmonad.hs

Finally, recently I have been playing with DWM, another tiling window manager, from suckless.org. I will make another entry in the future explaining about it, because I think is really interesting.

Thursday, 27 August 2015

Installing Manjaro minimal

Manjaro has different flavours and each one has their own installer, but there is a minimal version of Manjaro. The minimal version only installs the required software to start the system. At the end we have something similar such after installing Arch Linux, but we all advantages of Manjaro.

Manjaro minimal net install 64 bits

Manjaro minimal net install 32 bits

Right below you can watch a video where I show how you can install Manjaro minimal (for those ones who remember the old Arch Linux installer this will remind you to it)

NOTE: When it looks like I am doing nothing in the /etc/hostname file actually is installing the system, but it is not shown in the video.

I hope you liked it. In the next post I will explain how to install and configure Xmonad in Manjaro.

Instalación mínima de Manjaro

Manjaro tiene diferentes instaladores dependiendo de que entorno de escritorio vayas a instalar, pero también cuenta con un instalador mínimo. Éste instala sólo lo necesario y nos proporciona un entorno parecido al que tenemos después de instalar Arch Linux, pero con las ventajas de Manjaro.

Manjaro minimal net install 64 bits

Manjaro minimal net install 32 bits

A continuación podéis ver un video en el cual realizo una instalación de Manjaro (para los que llegasteis a conocer el antiguo instalador de Arch Linux os será familiar).

Nota: Cuando tengo el curso encima de /etc/hostname por unos 10 minutos es que el sistema se está instalando. No se porque no se ha grabado bien esa parte.

Espero que os haya gustado. En la siguiente entrada explicaré como instalar y configurar Xmonad en Manjaro.

Thursday, 6 June 2013

Diferentes tipos de redes para VirtualBox

La aplicación VirtualBox nos proporciona diferentes opciones para conectar las máquinas virtuales que hemos creado entre ellas o a diferentes redes. En esta entrada quiero mostraros las opciones que nos proporciona VirtualBox y que características y ventajas nos proporcionan.

Los tipos de conexión que hay disponibles en VirtualBox:
  • NAT (Network Address Translation).
  • Bridged.
  • Red interna.
  • Red sólo anfitrión.
Supongo que la mayoría estáis familiarizados con los dos primeros tipos de conexión, pero los otros dos os pueden resultar confusos. Por eso paso a explicar un poco que características tienen cada tipo y la forma de utilizarlas en el VirtualBox.

NAT:

El NAT (Network Address Translation) es un mecanismo utilizado por routers IP para intercambiar paquetes entre dos redes que asignan mutuamente direcciones incompatibles. En este caso el router es el sistema anfitrión que hace el trabajo de traducción entre las dos redes (la privada de las máquinas virtuales y a la que está conectado el sistema anfitrión). 

VBoxManage modifyvm "Nombre Máquina Virtual" --natpf1 "<Nombre de la regla>,tcp|udp,<IP destino>,<Puerto de escucha>,<IP máquina virtual>,<Puerto de la máquina virtual>"

por ejemplo, vamos a crear una regla que nos permita conectarnos por SSH a la máquina virtual ArchLinux, con cualquier IP y desde cualquier IP. Para ello vamos a dejar en blanco el apartado de las IP.

VBoxManage modifyvm "ArchLinux" --natpf1 "ConexionSSH,tcp,,2222,,22"

Bridged:

El Puente conecta segmentos de red formando una sola subred. Para nosotros tenemos dos segmentos de red, uno es el que forman las máquinas virtuales y el otro es la red a la que está conectado el sistema anfitrión. 


VBoxManage modifyvm "Nombre Máquina Virtual" --nic1 bridged --bridgeadapter1 <Adaptador de red adaptador>

Utilizamos la máquina virtual ArchLinux para que se conecte a una red puente.

VBoxManage modifyvm "ArchLinux" --nic1 bridged --bridgeadapter1 eth0

Red interna:

La red interna es similar a la puente en que la máquina virtual se puede comunicar directamente con “el mundo exterior”. Sin embargo, el “el mundo exterior” está limitado a las otras máquinas virtuales en el mismo anfitrión que estén conectadas a la misma red interna. 

Para utilizar este tipo de conexión debemos tener un servidor DHCP primero, para ello ejecutamos la siguiente orden:

VBoxManage dhcpserver add --netname intnet --ip 192.168.2.100 --netmask 255.255.255.0 --lowerip 192.168.2.101 --upperip 192.168.2.254 --enable

Ahora debemos decirle a la máquina virtual que utilize la red que acabamos de crear. Para ello empleamos esta orden:

VBoxManage modifyvm "ArchLinux" --nic1 intnet

Red sólo-afitrión:

La red sóloanfitrión es un híbrido entre la red puente y la res interna. Las máquinas virtuales puede
comunicarse entre si y además con el sistema anfitrión. 

Primero debemos activar un servidor DHCP, como en el caso anterior, y después cambiar el tipo de red en la máquina virtual como en la siguiente orden:

VBoxManage modifyvm "ArchLinux" --nic1 hostonly

Como siempre si alguien tiene alguna duda o quiere preguntar algo, que lo escriba en los comentarios y lo intentaré responder ;)