Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This
This chapter is from the book

Executing Multiple Commands

Often you may want to execute several commands together, either by running one after another or by passing output from one to another.

Running Sequentially

If you need to execute multiple commands in sequence but don’t need to pass output between them, there are two options based on whether or not you want the subsequent commands to run only if the previous commands succeed or not. If you want the commands to run one after the other regardless of whether or not preceding commands succeed, place a ; between the commands. For example, if you want to get information about your hardware, you could run lspci ; lsusb, which would output information on your PCI buses and USB devices in sequence.

However, if you need to conditionally run the commands based on whether the previous command has succeeded, insert && between commands. An example of this is building a program from source, which is traditionally done with ./configure, make, and make install. The commands make and make install require that the previous commands have completed successfully, so you would use ./configure && make && make install.

Using Byobu to Manage Your Terminal

One of the challenges of using the terminal is the difficulty of managing multiple screens. If you are in a desktop environment, you can launch another terminal window or use GNOME terminal’s tabs, but if you are on a server or another machine that doesn’t have a desktop environment installed, that doesn’t work.

Thankfully, such a tool to help you does exist: byobu. Japanese for screen, byobu is a set of default configurations for the GNU screen command. Essentially, screen is a window manager for the command line. To install byobu, type sudo apt-get install byobu.

After it is started, you will notice you are back at a terminal prompt, but with a few differences. At the bottom are two lines of information. From the left to the right, the bottom line shows you the version of Ubuntu you are currently running, number of packages to update (if there are none, this won’t appear), how long the system has been running, the system load, the CPU speed, the current memory usage, and the current date and time. The upper bar shows the list of open windows, the current logged in user, the system name, and the menu option (Figure 7-4).

Figure 7-4. Byobu in GNOME terminal

You can now use your terminal exactly as you normally would, just with a few added pieces of information. Advanced use of byobu (and screen) is a topic too large for this chapter, but following are a few commands to get you started:


Open new terminal window.


Move backward/forward through the list of windows.


Detach from current byobu session. To reattach, use byobu -x.


Scroll back through the output. Hit Esc to exit this mode and return to the command prompt.


Set the window title to a custom title.


Launch the menu.

Using Byobu by Default in GNOME Terminal

To have GNOME terminal launch byobu by default when it starts, you need to edit the preferences, which can be found at Edit > Profile Preferences under the Title and Command tab. Tick the box Run a Custom Command Instead of My Shell, and enter byobu in the line below. Now when you launch GNOME terminal, byobu will launch with it, and closing byobu will close GNOME terminal as well.

  • + Share This
  • 🔖 Save To Your Account