A Quick and Easy Guide to Tmux

Total Page:16

File Type:pdf, Size:1020Kb

A Quick and Easy Guide to Tmux 7/24/2018 A Quick and Easy Guide to tmux Ham Vocke writing stu about software (/) Home (/) Blog (/blog) About Me (/about) Talks (/talks) (https://github.com/hamvocke) (https://twitter.com/hamvocke) (http://www.hamvocke.com/feed.xml) A Quick and Easy Guide to tmux 16 Aug 2015 terminal 13 minutes read I love working with the command line. Seriously, I think there’s hardly any more productive and more versatile tool for a software developer than the terminal. Maybe it’s the hacker/wizard/neckbeard kind of feeling I get when using a terminal, I don’t know. At work we do lots of pair programming. Everyone’s got their own laptop and can set it up the way they like. And since I love working with the command line I’ve spent quite some time doing (only sane! I swear!) modications to my terminal environment that make working with the command line more pleasant and streamlined. This is why my pair usually will be greeted by something like this: https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 1/21 7/24/2018 A Quick and Easy Guide to tmux If they’ve worked with me before they know what they are up to. But every once in a while there will be a new team member who doesn’t know my environment. Usually this is the point where they will ask something like “WTF am I looking at?” and it’s my time to shine! Because what they’re looking at is nothing less than the best thing since sliced bread. It’s tmux (https://tmux.github.io/), a so-called terminal multiplexer. Simply speaking, tmux acts as a window manager within your terminal1 and allows you to create multiple windows and panes within a single terminal window. https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 2/21 7/24/2018 A Quick and Easy Guide to tmux I’ll proceed to give them a two minute tour about what you can do with tmux. After that they’re either hooked and want to try it themselves or they tell me to go away with my ancient neckbeard tools and just use iTerm2. In the former case I’ll usually end up helping them installing tmux on their machine and will give them a 10 minute guide to learn the most important basics. This post will give you the same two minute introduction about tmux and its possibilities, followed by the typical 10 minute hands-on guide to set up and get to know tmux yourself. If you’ve got 10 minutes to spare and nally want to be more procient with tmux: read on! What’s tmux? tmux’s authors describe it as a terminal multiplexer. Behind this fancy term hides a simple concept: Within one terminal window you can open multiple windows and split-views (called “panes” in tmux lingo). Each pane will contain its own, independently running terminal instance. This allows you to have multiple terminal commands and applications running visually next to each other without the need to open multiple terminal emulator windows. On top of that tmux keeps these windows and panes in a session. You can exit a session at any point. This is called “detaching”. tmux will keep this session alive until you kill the tmux server (e.g. when you reboot)2. This is incredibly useful because at any later point in time you can pick that session up exactly from where you left it by simply “attaching” to that session. If you’ve ever worked with remote servers or a Raspberry Pi over ssh you can guess where this will be useful: When you lose your ssh connection the tmux session will simply be detached but will keep running on the server in the background including all the processes that run within your session. To continue your session simply ssh to the server again and attach to the running session. But tmux is not only helpful when working on a remote machine. Not only for its window management features but also for the session handling. Personally I nd myself detaching from sessions when I’m switching context. I’ll just start a new session for my new task and attach to the old session whenever I want to continue with my old task. https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 3/21 7/24/2018 A Quick and Easy Guide to tmux You see that tmux basically oers two big features: Window management in your terminal and session management. If you are familiar with GNU Screen (https://www.gnu.org/software/screen) this is nothing new. Think of tmux as an easier-to-use and a little more powerful alternative to Screen (obviously I’m being opinionated here). Enough with the talking already. Let’s get our hands ready in the hands-on guide! Getting Started This hands-on guide will get you up and running with tmux pretty quickly. It will only cover the basic features which should be more than enough to get started and be productive with tmux. Simply open your terminal and follow the instructions. Installation Fortunately installing tmux is pretty straightforward on most distributions a simple sudo apt-get install tmux (Ubuntu and derivatives) or brew install tmux (Mac) should be sucient. Starting Your First Session For your rst session simply start tmux with a new session: tmux This will create a new tmux session with a nice all-green status bar at the bottom: https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 4/21 7/24/2018 A Quick and Easy Guide to tmux The status bar is an important part of tmux. Apart from the currently opened windows (on the left) it also shows some system information like date and time (on the right). The status bar can also be customized and I’ve seen some really fancy stu around (upcoming calendar events, battery status, to name a few) but this is something we’ll leave for later. Splitting Panes Now that we’ve created our rst session we can get a feeling for panes. When you create a new session, tmux will by default start with one window and a single panel inside. We want a nice split-screen, so let’s split this bad boy. All commands in tmux are triggered by a prex key followed by a command key (quite similar to emacs). By default, tmux uses C-b as prex key. This notation might read a little weird if you’re not used to it. In this emacs notation C- means “press and hold the Ctrl key”3. Thus C-b simply means press the Ctrl and b keys at the same time. The shortcut to split panes into a left and a right pane is C-b % . Remembering what I’ve just told you about tmux’s sequence of prex and command key this means to split your single pane into a left and a right pane you press Ctrl and b at the same time, release both, and then type the % key. Voilà! You’ve just invoked your rst tmux command and split your pane in two. https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 5/21 7/24/2018 A Quick and Easy Guide to tmux Where there’s a split into left and right, there’s also a split into top and bottom pane. To split a pane into top and bottom panes use the C-b " shortcut. Navigating Panes Right now we’re trapped in the newly created pane. But we really really want to go back to the left one. Easy peasy: Switching to a dierent pane uses the C-b <arrow key> shortcut, where <arrow key> is the arrow key pointing to the pane you want to switch to. In our case we want to switch to the panel on the left so it’s C-b left for us. Just once more, so that we fully understand this: This means you press Ctrl and b (your prex) followed by the left arrow key to get to the pane on the left. You can now go ahead and split each of your new panels even further. Feel free to experiment and split your panes like a maniac to get a feeling for it. Closing Panes Closing a pane is as simple as closing a regular terminal session. Either type exit or hit Ctrl-d and it’s gone. Creating Windows Windows in tmux can be compared to creating new virtual desktops; if you’ve ever worked with one of the major Linux deskop environments (KDE, Gnome) you’ll hopefully nd this analogy helpful. https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/ 6/21 7/24/2018 A Quick and Easy Guide to tmux Creating new windows is as easy as typing C-b c (one last time: that’s Ctrl and b at once, then c ). The new window will then be presented to you in tmux’s status bar. You can now divide the pane in your new window as you like. Or don’t. That’s up to you. To switch to the previous window (according to the order in your status bar) use C-b p , to switch to the next window use C-b n . If you’ve created many windows you might nd it useful to go to a window directly by typing its number (the status bar will tell you which window has which number), just use C-b <number> where <number> is the number in front of the window’s name in your status bar.
Recommended publications
  • Freenas® 11.0 User Guide
    FreeNAS® 11.0 User Guide June 2017 Edition FreeNAS® IS © 2011-2017 iXsystems FreeNAS® AND THE FreeNAS® LOGO ARE REGISTERED TRADEMARKS OF iXsystems FreeBSD® IS A REGISTERED TRADEMARK OF THE FreeBSD Foundation WRITTEN BY USERS OF THE FreeNAS® network-attached STORAGE OPERATING system. VERSION 11.0 CopYRIGHT © 2011-2017 iXsystems (https://www.ixsystems.com/) CONTENTS WELCOME....................................................1 TYPOGRAPHIC Conventions...........................................2 1 INTRODUCTION 3 1.1 NeW FeaturES IN 11.0..........................................3 1.2 HarDWARE Recommendations.....................................4 1.2.1 RAM...............................................5 1.2.2 The OperATING System DeVICE.................................5 1.2.3 StorAGE Disks AND ContrOLLERS.................................6 1.2.4 Network INTERFACES.......................................7 1.3 Getting Started WITH ZFS........................................8 2 INSTALLING AND UpgrADING 9 2.1 Getting FreeNAS® ............................................9 2.2 PrEPARING THE Media.......................................... 10 2.2.1 On FreeBSD OR Linux...................................... 10 2.2.2 On WindoWS.......................................... 11 2.2.3 On OS X............................................. 11 2.3 Performing THE INSTALLATION....................................... 12 2.4 INSTALLATION TROUBLESHOOTING...................................... 18 2.5 UpgrADING................................................ 19 2.5.1 Caveats:............................................
    [Show full text]
  • Linux on the Road
    Linux on the Road Linux with Laptops, Notebooks, PDAs, Mobile Phones and Other Portable Devices Werner Heuser <wehe[AT]tuxmobil.org> Linux Mobile Edition Edition Version 3.22 TuxMobil Berlin Copyright © 2000-2011 Werner Heuser 2011-12-12 Revision History Revision 3.22 2011-12-12 Revised by: wh The address of the opensuse-mobile mailing list has been added, a section power management for graphics cards has been added, a short description of Intel's LinuxPowerTop project has been added, all references to Suspend2 have been changed to TuxOnIce, links to OpenSync and Funambol syncronization packages have been added, some notes about SSDs have been added, many URLs have been checked and some minor improvements have been made. Revision 3.21 2005-11-14 Revised by: wh Some more typos have been fixed. Revision 3.20 2005-11-14 Revised by: wh Some typos have been fixed. Revision 3.19 2005-11-14 Revised by: wh A link to keytouch has been added, minor changes have been made. Revision 3.18 2005-10-10 Revised by: wh Some URLs have been updated, spelling has been corrected, minor changes have been made. Revision 3.17.1 2005-09-28 Revised by: sh A technical and a language review have been performed by Sebastian Henschel. Numerous bugs have been fixed and many URLs have been updated. Revision 3.17 2005-08-28 Revised by: wh Some more tools added to external monitor/projector section, link to Zaurus Development with Damn Small Linux added to cross-compile section, some additions about acoustic management for hard disks added, references to X.org added to X11 sections, link to laptop-mode-tools added, some URLs updated, spelling cleaned, minor changes.
    [Show full text]
  • Linux Hacking Case Studies Part 4: Sudo Horror Stories
    Linux Hacking Case Studies Part 4: Sudo Horror Stories written by Scott Sutherland | March 26, 2020 This blog will cover different ways to approach SSH password guessing and attacking sudo applications to gain a root shell on a Linux system. This case study commonly makes appearances in CTFs, but the general approach for attacking weak passwords and sudo applications can be applied to many real world environments. This should be a fun walk through for people new to penetration testing. This is the fourth of a five part blog series highlighting entry points and local privilege escalation paths commonly found on Linux systems during network penetration tests. Below are links to the first three blogs in the series: Linux Hacking Case Study Part 1: Rsync Linux Hacking Case Study Part 2: NFS Linux Hacking Case Study Part 3: phpMyAdmin Below is an overview of what will be covered in this blog: Finding SSH Servers Dictionary Attacks against SSH Servers Viewing Sudoers Execution Options Exploiting Sudo sh Exploiting Sudo VI Exploiting Sudo Python Exploiting Sudo Nmap Finding SSH Servers Before we can start password guessing or attacking sudo applications, we need to find some SSH servers to go after. Luckily Nmap and similar port scanning tools make that pretty easy because most vendors still run SSH on the default port of 22. Below is a sample Nmap command and screenshot to get you started. nmap -sS -sV -p22 192.168.1.0/24 -oA sshscan Once you’ve run the port scan you can quickly parse the results to make a file containing a list of SSH servers to target.
    [Show full text]
  • Cygwin User's Guide
    Cygwin User’s Guide Cygwin User’s Guide ii Copyright © Cygwin authors Permission is granted to make and distribute verbatim copies of this documentation provided the copyright notice and this per- mission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this documentation under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this documentation into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. Cygwin User’s Guide iii Contents 1 Cygwin Overview 1 1.1 What is it? . .1 1.2 Quick Start Guide for those more experienced with Windows . .1 1.3 Quick Start Guide for those more experienced with UNIX . .1 1.4 Are the Cygwin tools free software? . .2 1.5 A brief history of the Cygwin project . .2 1.6 Highlights of Cygwin Functionality . .3 1.6.1 Introduction . .3 1.6.2 Permissions and Security . .3 1.6.3 File Access . .3 1.6.4 Text Mode vs. Binary Mode . .4 1.6.5 ANSI C Library . .4 1.6.6 Process Creation . .5 1.6.6.1 Problems with process creation . .5 1.6.7 Signals . .6 1.6.8 Sockets . .6 1.6.9 Select . .7 1.7 What’s new and what changed in Cygwin . .7 1.7.1 What’s new and what changed in 3.2 .
    [Show full text]
  • The Elinks Manual the Elinks Manual Table of Contents Preface
    The ELinks Manual The ELinks Manual Table of Contents Preface.......................................................................................................................................................ix 1. Getting ELinks up and running...........................................................................................................1 1.1. Building and Installing ELinks...................................................................................................1 1.2. Requirements..............................................................................................................................1 1.3. Recommended Libraries and Programs......................................................................................1 1.4. Further reading............................................................................................................................2 1.5. Tips to obtain a very small static elinks binary...........................................................................2 1.6. ECMAScript support?!...............................................................................................................4 1.6.1. Ok, so how to get the ECMAScript support working?...................................................4 1.6.2. The ECMAScript support is buggy! Shall I blame Mozilla people?..............................6 1.6.3. Now, I would still like NJS or a new JS engine from scratch. .....................................6 1.7. Feature configuration file (features.conf).............................................................................7
    [Show full text]
  • Getty Scholars' Workspace™ INSTALLATION INSTRUCTIONS
    Getty Scholars’ Workspace™ INSTALLATION INSTRUCTIONS This document outlines methods to run the application locally on your personal computer or to do a full installation on a web server. Test Drive with Docker Getty Scholars' Workspace is a multi-tenant web application, so it is intended to be run on a web server. However, if you'd like to run it on your personal computer just to give it a test drive, you can use Docker to create a virtual server environment and run the Workspace locally. Follow the steps below to give it a spin. Scroll further for real deployment instructions. 1. Install Docker on your machine. Follow instructions on the Docker website: https://www.docker.com/ 2. If you are using Docker Machine (Mac or Windows), be sure to start it by using the Docker Quickstart Terminal. Docker is configured to use the default machine with IP 192.168.99.100. 3. At the command line, pull the Getty Scholars' Workspace image. $ docker pull thegetty/scholarsworkspace 4. Run the container. $ docker run -d -p 8080:80 --name=wkspc thegetty/scholarsworkspace supervisord -n 5. Point your browser to `<ip address>:8080/GettyScholarsWorkspace`. Use the IP address noted in Step 2. 6. The Drupal administrator login is `scholar` and the password is `workspace`. Be sure to change these in the Drupal admin interface. 7. To shut it down, stop the container: $ docker stop wkspc Web Server Installation These installation instructions assume you are installing Getty Scholars' Workspace on a server (virtual or physical) with a clean new instance of Ubuntu 14.04 as the operating system.
    [Show full text]
  • Tao-Of-Tmux Documentation 发布 V1.0.2
    tao-of-tmux Documentation 发布 v1.0.2 Tony Narlock 2020 年 04 月 18 日 Contents 1 前言 3 1.1 关于本书 ............................................... 3 1.2 代码等风格说明 ........................................... 4 1.3 本书主要内容 ............................................. 4 1.4 打赏 .................................................. 5 1.5 书籍形式(Formats) ........................................ 5 1.6 勘误说明(Errata){#errata} ................................... 5 1.7 感谢 .................................................. 6 1.8 本书跟新和 tmux 的变动 ...................................... 6 2 tmux 初识 {#thinking-tmux} 7 2.1 terminal 的窗口管理器 ....................................... 8 2.2 多任务处理 .............................................. 9 2.3 在后台运行程序 ........................................... 10 2.4 Powerful combos ........................................... 11 2.5 小节 .................................................. 12 3 Terminal 基础知识(fundamentals){#terminal-fundamentals} 13 3.1 POSIX 标准 ............................................. 13 3.2 Terminal interface .......................................... 14 3.3 Terminal emulators ......................................... 15 3.4 Shell languages {#shell-languages} ................................ 15 3.5 Shell interpreters (Shells) {#shells} ................................ 15 3.6 小节 .................................................. 16 4 开始使用(Practical usage){#practical-usage} 17 4.1 前缀组合快捷键(prefix key ){#prefix-key} ........................... 17 4.2 Session persistence and the server model ............................. 19
    [Show full text]
  • BSD UNIX Toolbox 1000+ Commands for Freebsd, Openbsd
    76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page iii BSD UNIX® TOOLBOX 1000+ Commands for FreeBSD®, OpenBSD, and NetBSD®Power Users Christopher Negus François Caen 76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page ii 76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page i BSD UNIX® TOOLBOX 76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page ii 76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page iii BSD UNIX® TOOLBOX 1000+ Commands for FreeBSD®, OpenBSD, and NetBSD®Power Users Christopher Negus François Caen 76034ffirs.qxd:Toolbox 4/2/08 12:50 PM Page iv BSD UNIX® Toolbox: 1000+ Commands for FreeBSD®, OpenBSD, and NetBSD® Power Users Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-37603-4 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data is available from the publisher. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permis- sion should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions.
    [Show full text]
  • Mac Os Serial Terminal App
    Mac Os Serial Terminal App Panting and acetous Alaa often scag some monoplegia largo or interdict legitimately. Tourist Nikita extemporised or Aryanised some dop quick, however unsectarian Merwin hectograph globularly or emotionalize. Germaine is know-nothing and sodomizes patronizingly as modiolar Osborne bug-outs unconstitutionally and strides churchward. Can choose a usb to dim the app mac os sector will happen, and act as commented source code is anyone else encountered this Tom has a serial communication settings. Advanced Serial Console on Mac and Linux Welcome to. Feel free office helps you verify that makes it takes a terminal app mac os is used for a teacher from swept back. Additionally it is displayed in the system profiler, you can also contains a cursor, you can i make use these two theme with the app mac os is designed to. Internet of Things Intel Developer Zone. Is based on the latest and fully updated RPiOS Buster w Desktop OS. Solved FAS2650 serial port MAC client NetApp Community. Mac Check Ports In four Terminal. A valid serial number Power Script Language PSL Programmers Reference. CoolTerm for Mac Free Download Review Latest Version. Serial Port Drivers and Firmware Upgrade EV West. Osx ssh If you're prompted about adding the address to the heritage of known hosts. This yourself in serial terminal open it however, each device node, i have dozens of your setting that the browser by default in case. 9 Alternatives for the Apple's Mac Terminal App The Mac. So that Terminal icon appears in the Dock under the recent apps do the.
    [Show full text]
  • Secure Automation: Achieving Least Privilege with SSH, Sudo and Setuid Robert A
    Secure Automation: Achieving Least Privilege with SSH, Sudo and Setuid Robert A. Napier – Cisco Systems ABSTRACT Automation tools commonly require some level of escalated privilege in order to perform their functions, often including escalated privileges on remote machines. To achieve this, developers may choose to provide their tools with wide-ranging privileges on many machines rather than providing just the privileges required. For example, tools may be made setuid root, granting them full root privileges for their entire run. Administrators may also be tempted to create unrestricted, null-password, root-access SSH keys for their tools, creating trust relationships that can be abused by attackers. Most of all, with the complexity of today’s environments, it becomes harder for administrators to understand the far-reaching security implications of the privileges they grant their tools. In this paper we will discuss the principle of least privilege and its importance to the overall security of an environment. We will cover simple attacks against SSH, sudo and setuid and how to reduce the need for root-setuid using other techniques such as non-root setuid, setgid scripts and directories, sudo and sticky bits. We will demonstrate how to properly limit sudo access both for administrators and tools. Finally we will introduce several SSH techniques to greatly limit the risk of abuse including non-root keys, command keys and other key restrictions. Introduction to files writable only by a particular group. For exam- ple, in FreeBSD programs that read system memory Since its introduction in 1995 by Tatu Ylonen, are setgid to a special kmem group.
    [Show full text]
  • Page 1 of 3 Sudo (Super User Do) Is a Very Useful
    Sudo Sudo (Super User Do) is a very useful program that allows a system administrator to give certain users the ability to run some (or all) commands as root 1. Download the source code: The source of sudo is available from http://www.courtesan.com/sudo/. At the time of writing, the latest version is V1.6.3 and the source code is provided as a compressed tar archive in the file sudo- 1.6.3.tar.gz . Download this file to a temporary directory, such as /tmp. 2. Prepare the source code for compilation: Log in as root, make a directory at a convenient point in the file system to hold the source code and copy the source into this directory. For example: # mkdir -p /opt/source/sudo # cd /opt/source/sudo # cp /tmp/sudo-1.6.3.tar.gz . Unzip and untar the source and then change to the directory created by tar: # gunzip sudo # tar xvf sudo # cd sudo-1.6.3 At this point, you may like to have a look at the README, INSTALL and FAQ files. 3. Compile the source code and install sudo: Configure the compilation process for your system: # ./configure Compile the source code: # make And install the compiled code: # make install This install the sudo program into /usr/local/bin, the visudo script (see later) into /usr/local/sbin and the manual page into subdirectories of /usr/local/man. 4. Modify the search path: If you haven't already done so for other software, you now need to modify the search paths so that the system can find the sudo program and its manual pages.
    [Show full text]
  • Delightful Command-Line Experiences
    Background Command-line basics How to have a good time Additional resources and TUI-related topics Delightful Command-Line Experiences Patrick Callahan 2017-09-14 Patrick Callahan Delightful Command-Line Experiences Background Command-line basics How to have a good time Additional resources and TUI-related topics Outline 1 Background About this talk Why use a command-line or textual user interface? 2 Command-line basics What (together) comprise a complete command-line environment? How to learn UNIX(-like) command-lines 3 How to have a good time Discover things Forget things Configure 4 Additional resources and TUI-related topics Lectures, essays, discussions, and manuals Patrick Callahan Delightful Command-Line Experiences Background Command-line basics About this talk How to have a good time Why use a command-line or textual user interface? Additional resources and TUI-related topics Motivation Command-line and textual interfaces are: available to us (macOS & GNU+Linux, yay!) required of us by some of our tools widely varied highly customizable often terrible but they don’t have to be! So why not have an experience that’s actually pleasant? Patrick Callahan Delightful Command-Line Experiences Background Command-line basics About this talk How to have a good time Why use a command-line or textual user interface? Additional resources and TUI-related topics Purpose My hope is that this talk will encourage you to get comfy with a CLI environment that suits you provoke you to teach or correct me help me get better at doing this Patrick Callahan
    [Show full text]