Freelance projects

Wednesday, July 25, 2012

Starting, Detaching, Reattaching, and Stopping Screen

Starting, Detaching, Reattaching, and Stopping Screen

To begin a screen session, simply run screen from a terminal. It will be easier to reattach to a session later if you name the session when starting. Use the -S parameter to do so:
screen -S name
where name is an identifier for the session that you make up.
Commands to screen, covered more in depth in the next session, start with Ctrl+a. To detach from a screen session, use Ctrl+a then Ctrl+d. Reattach by running:
screen -r name
Occasionally screen needs to force a detach before it can successfully reattach. This is done with:
screen -d -r name
The list of currently active sessions is given by:
screen -list
If you use screen regularly, you may want to put that command in your .bash_profile so that when you log in the active screens are shown. To quit a screen session, simply exit from all active windows. When there are no windows left, you will be dropped back to your standard shell session.

Useful screen commands

All commands in screen, for the most part, begin with Ctrl+a. To see the built in help, first press Ctrl+a then ‘?’. That is, type a question mark with shift+/. Listed in the help screen are several Ctrl+a commands. I have some of the more common ones below.
Command         Description
-------         -----------
Ctrl+a, ?       Show built in help
Ctrl+a, c       Create a new screen
Ctrl+a, Ctrl+a  Cycle through screens (just hold Ctrl down, type aa)
Ctrl+a, n       Cycle through screens (Next screen)
Ctrl+a, Ctrl+n  Another cycle through screens
Ctrl+a, S       Split the screen (note the capital S)
Ctrl+a, X       Close the split screen you are currently in (note capital X)
Ctrl+a, tab     Switch between split screens
Ctrl+a, d       Detach from screen session
Ctrl+a, [       Start copy (see below)
Ctrl+a, ]       Paste (see below)
Split screen is a little tricky. To get a split console, begin a screen session. Use the Ctrl+a, S command to create the split. Then Ctrl+a, tab to switch to the newly created split. Create a new session with Ctrl+a, c. When finished, exit from the split session shell and use Ctrl+a, X to close the split.

Linux useful server command

Command to get the running services on port in linux 

netstat -lnp | grep :80 

Start and stop the server on Linux

Start, stop, or restart Flash Media Server using fmsmgr

  1. Log in as a root user.
  2. Change to the directory where the server is installed.
  3. Open a shell window and type one of the following:
    • ./fmsmgr server start
    • ./fmsmgr server stop
    • ./fmsmgr server restart

 

If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
 /etc/init.d/mysqld restart