Cheat Sheet: Screen

The screen command is a used to launch and arrange multiple terminal shells within a single shell.

It is mainly used for two purposes:

  1. It can be used to run long-running commands on remote servers.
  2. It can be used to organise multiple shells and allow you to navigate between them.

Commands

All screen commands need to be prefixed by an escape key, which is Ctrl-a by default.

CommandCategoryDescription
screenBasicStarts a new session
screen -S <session_name>BasicStarts a new session with session name
screen -lsBasicLists running screen sessions
screen -r <session_name>BasicAttach to a running session with name
screen -d <session_name>BasicDetach a running session with name
screen -r -d <session_name>BasicAttach to a screen that is already attached
Ctrl-a dExitingDetach
Ctrl-a D DExitingDetach and logout (fast way to exit screen)
Ctrl-a :ExitingQuit and exits all of the programs in screen
Ctrl-a escScrollingEnter scrolling mode
Ctrl-uScrollingScroll Up
Ctrl-dScrollingScroll Down
esc escScrollingExit scrolling mode
Ctrl-a cWindow ManagementCreate new window
Ctrl-a Ctrl-aWindow ManagementChange to last-visited active window
Ctrl-a <number>Window ManagementChange to window by number (only 0-9)
Ctrl-a ' <number_or_name>Window ManagementChange to window by number or name
Ctrl-a nWindow ManagementChange to next window in list
Ctrl-a pWindow ManagementChange to previous window in list
Ctrl-a "Window ManagementDisplays list of windows, allowing to select window to change into
Ctrl-a AWindow ManagementRename current window
Ctrl-a kWindow ManagementKill current window
Ctrl-a \Window ManagementKill all windows
Ctrl-a aMiscSend Ctrl-A to screen within screen, useful when working with screen within screen

Posted on September 06, 2021

Helpful Linux commands

So this is just going to be a bit of knowledge dump of things I’ve picked up lately / don’t want to forget.

Bang Cash !$

If you are intending on running a few commands with the last argument of the command being the same this can be really helpful. For example:

ping 127.0.0.1
netmap !$
traceroute !$

Alternatively you can also do !* to use all the arguments of the previous command.

sudo !!

This one is pretty simple sudo !! takes the last command and re-runs with sudo.

Screen

screen is a great feature that allows you to do any of the following; – Use multiple shells in a single SSH session. – Run a long running process without maintaining an active shell or worrying about network disruptions. – Disconnect and re-connect to a shell from multiple locations.

Using it is very simple, to start it you just use the command screen, from this point you are now inside of a window within screen.

Using screen requires remembering a few more commands (or noting them down in a blog post or something).

Start screen:

screen

To start a screen with a name, you can do the following screen -S 'name'

Create another window:

Ctrl-a c

Next window:

Ctrl-a n

Previous window:

Ctrl-a p

Detach window:

Ctrl-a d

This will detach your window and return you to your bash shell.

Re-attach screen:

screen -r If you have multiple screens, this will display a list of them and you will have to use the name of the screen as a third parameter to reattach to it.

Searching through previous commands

So as you may know you can use Control + R on Linux to search through previous commands you’ve entered in the terminal. You can with a few modifications of your ~/.profile or ~/.bash_profile improve what is stored in the ~/.bash_history file, making this feature even more useful for remembering previous commands.

Ignore certain commands:

HISTIGNORE="pwd:df:du:cd:ls"

Increase how many commands are stored:

HISTFILESIZE=10000 (the default on most systems is 500)

Don’t save duplicate commands:

HISTCONTROL=ignoredups


Posted on January 14, 2018

Earcandy in Ubuntu Jaunty

EarCandy is a volume manager for PulseAudio that fades applications in and out based on your current activity. Meaning it can do handy things like muting your music playing when you decide to turn on a youtube video. EarCandy can sniff out applications to tell what kind of application they are

Screenshots:

earcandy.png

earcandy2.png

How to install Earcandy on Ubuntu Jaunty

You can do this by using the following command:

sudo kate /etc/apt/sources.list

Then add the following to the end of the file:

deb http://ppa.launchpad.net/earcandy-devel/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/earcandy-devel/ppa/ubuntu jaunty main
``
Then you can install earcandy by using the following command!
```bash
sudo apt-get install earcandy

Posted on September 28, 2009

Google Chrome on Ubuntu

If your using Ubuntu you can now start using Chrome, or Chromium at least, which is based on it. Daily builds of Chromium can be got from here.

You’ll need to add the following repositories to get Chromium:

Note: Substitute interpid with jaunty or hardy as needed!

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main

Then you can then install it by opening a terminal and do the following command:

sudo apt-get install chromium-browser

Of course this is still in Pre-Alpha so make sure to keep another browser installed! ;)


Posted on September 22, 2009

The One-Page Linux Manual

This The One-Page Linux Manual has a summary of all useful commands in Linux. one-page.png


Posted on September 19, 2009