Linux Terminal – Tmux

Tmux is a Linux terminal with more advance and helpful features. It allows you to split window, save the session, Multiple windows and many more. But as many features are there it feels hard to use for beginners. There is another replacement of tmux which is easy but it has only split option. I am talking about terminator it is another terminal for easy and simple use.

If you just want to split the terminal window then you can use terminator. You can install it with normal apt-get install terminator.

Let’s talk about tmux, Tmux is helpful for Pentester and Linux Administrator. You can install the tmux with

apt-get install tmux

One tmux is installed you can start it with tmux command in your current terminal then you will be inside the tmux environment. Let’s see some important shortcut keys you should know.

Prefix: This is the most important one tmux require you to use prefix key every time you want to do anything which is ctrl+b (you can change it).

Attach Detach

Tmux allows you to attach and detach what that means is when you start tmux with tmux command in your normal terminal and you want to go back to the normal terminal from tmux session you use detach. Simply type tmux detach in your tmux terminal.

But this won’t clear your tmux session when you want to go to the same tmux session type tmux attach in your normal terminal and you will be back In your tmux with same as before as your session is not closed.

Keys

As I said everything in tmux required you to type prefix key. If you are vim user you might know it works. when you want to do anything type your prefix key. Which is ctrl+b by default and then release both keys. now type keys based on what you want to do. For example, you want to create another tmux window inside this session. Type the prefix key the release it then presses c.

C is to create new window but after you type prefix key. Now you know how to use prefix key ( press prefix key then release and then type key for what you want). Let’s look at some common keys to do things with tmux.

Keys

Prefix key + “

Prefix key + %

Prefix key + arrow key

Prefix key + c

Prefix key + 0-9

Prefix key + z

OUTPUT

Split current window in horizontal.

To Split the current window in vertical.

move between split windows

Create new Tmux window

Navigate from one window to another

zoom in and zoom out.

These are some but regular use keys most of you will think it’s hard to remember but you just need to use them for some times to get familiar with it you can even change the keys according to you pus you can add some colour to your tmux.

Using tmux multiple Window and split windows

Tmux window and split methods have multiple options to like tmux doesn’t have scroll bar so you can’t scroll up and down and many other things.

Tmux Window Rename [ prefix key + , ]: When you create multiple window tmux give a random name or last command you used in that window as the window name so it’s important to give your window a name like what that window is doing to give a name use prefix key + ,

Copy Mode

Tmux Session saving

As tmux allows you to save you need to first create a session. You should not start tmux as tmux. to create a session so you can use it even after reboot use tmux new -s session-name from your normal terminal.

By default you can’t save this session for that you need an extra plugin called tmux-resurrect but for that, we need to install plugin manager with the following command

Now save that file and reboot the system then start tmux and type prefix key + I ( capital i). Now you can save the session with Prefix key + ctrl +s and restore it with prefix key + ctrl + r

You can edit the same tmux.conf file to change your keys and default setting, but for now, that’s it. I hope you find it useful. If you want me to write another blog for modification of tmux comment down below. #Don’t-spam