Tmux – An Introduction to a Hacker’s Swiss Army Knife

  • 544
  •  
  •  
  • 2
  •  
  •  
  •  
    546
    Shares

Tmux is a terminal multiplexer: which in lamen terms means it is able to create a number of terminals, inside a session, with the ability to install and attach multiple sessions to it. Sounds kind of overwhelming doesn’t it? Well it isn’t, let me show you.

What is Tmux?

Tmux, in the simplest of terms allows you to have multiple terminal sessions inside one terminal window, with the ability to divide your terminal screen into numerous ways. Something like this.

 

Tmux in action
Tmux in action

Like the look? Well so do I

Installation

Installing Tmux is fairly easy, you won’t need to compile anything manually, it’s a world recognized tool and I haven’t met one Sys Admin who doesn’t use it. It’s available on both APT (Debian), Brew (Mac) and RPM (Fedora) repositories.

Ubuntu – Debain

sudo apt install tmux

Mac

For this you have to have Homebrew preinstalled on your Mac.

brew install tmux

Fedora

I am pretty you get the gist at this point.

rpm install tmux

After the installation is finished, type the following on your Terminal.

tmux

You’ll see the same terminal but this time with a green bar
running down the bottom of your screen.

This is the bare minimum interface of Tmux, but still there are some things to be explained.The [0] down at the bottom left on the screen indicates the current Tmux session you’re on. If you have multiple sessions connected, you can traverse through them and the number will change, more on this later.

Now on to the meat and bones of Tmux. The first thing to note is the prefix key, by default it ctrl+b which changes the mode of Tmux from input mode to command mode. Those commands can be either Split the screen, send you into copy paste mode and much more.

Screen Split with Tmux

Go ahead try it, press the prefix key ctrl+b and and after that shift+”, this will split the screen horizontally. Similarly, using shift+% will split the screen vertically. After you do this, your screen will be oriented like this.

Tmux in splitscreen mode
Tmux in splitscreen mode

 

Navigating through Windows

Now navigating through these split screen windows can be a bit daunting, of course by simply clicking on a window wouldn’t work to do that, we’ll be going back to our prefix key. Press ctrl+b and then the arrow key in whichever direction you’d like to go in, this will change the current active window.

Starting New Windows

A small terminal window inside a parent is called a pane. On the bottom left of the screen there’s a 0: bash, which means that you’re on the first window, and the name of the window is Bash. Tmux names the windows automatically which can of course changed as well. To start a new window, press, ctrl+b and tell c to start a new window. Now you’ll see 0: bash* 1:bash. The start indicates the current active window.

Note - Navigating through windows is somewhat same as panes. You press the prefix key and the window number to change the current window you're on.

Scrolling in Tmux

Type the following command on your Tmux session

history

too much output? isn’t it. Try scrolling through the output. Can’t can you? The scroll just displays the last commands you used. You can try two options now.

  • Using less to control the buffer.
  • Using the Tmux default method.

Less Method

less is a utility built into Linux which reads the first few lines of any file or output from a command, display’s it on the terminal to read further along, you can scroll through the buffer using arrow keys or your mouse. So this command solves our reading problem.

history | less

here we get the output of history and PIPE it into less.

Tmux Method

This is the much more preferred method and can be useful in copy and pasting as well. To scroll through the buffer using Tmux simply press the prefix key ctrl+b and [. Now you can scroll through the buffer using your mouse or your arrow keys.

Copy and Pasting in Tmux

To copy and paste in Tmux first you must drop into the scroll mode using prefix key and [. After that go to the line you’d like to copy and press ctrl+space and use the arrow keys to navigate to the point where your desired selection ends. This process selects the statement. Now to copy it press alt+w. Once you’ve copied something you’d automatically thrown out of scroll mode. To paste the copied text use the prefix key and ]. This will paste the copied text.

Note- Whatever you copy is stored inside the Tmux clipboard which in turn means that you won't be able to copy and paste from Tmux session to your browser for example.

What Bunny Rating Does it Get

Tmux is one of the best tools for any professional and power user out there. The ability to add sessions and have them saved is a huge plus for anyone who deals with a lot of server management and has to hop from one machine to another over and over again. If you’re only interested in splitting screens to better analyze files, you can try GNU Screen. I don’t start my terminal without Tmux, it can be daunting at first but learning it would be biggest favor you’ll do to yourself. I give it a full 5 bunny rating.

Want to learn more about ethical hacking?

We have a  networking hacking course that is of a similar level to OSCP, get an exclusive 95% discount HERE

Do you know of another GitHub related hacking tool?

Get in touch with us via the contact form if you would like us to look at any other GitHub ethical hacking tools.

 

 

The following two tabs change content below.
Avatar

Unallocated Author

Please note that the article you are reading has an unallocated author as the original author is no longer employed at latesthackingnews.com, this has been put in place to adhere with general data protection regulations (GDPR). If you have any further queries, please contact: [email protected]
Avatar

Unallocated Author

Please note that the article you are reading has an unallocated author as the original author is no longer employed at latesthackingnews.com, this has been put in place to adhere with general data protection regulations (GDPR). If you have any further queries, please contact: [email protected]

Do NOT follow this link or you will be banned from the site!