# screen.txt # Huan Chen, 2/3/2017 # updated 3/11/2017, add an example of taxi project Linux screen utility can be used for pair programming and more. ---------------------------------- Example: use screen to proceed "human VS human" mode in the chess project User 1 logins to the linux server, then: $ screen # start a screen session User 2 logins to the same account using another terminal or computer, do: $ screen -x # join a screen session Now the two users type in their own terminals and can see each other's moves immediately ---------------------------------- Example: use screen to run taxi project's server and client programs in two different windows # After entering a screen session, go to the directory containing "server" ./server 2001 # run the server program with port 2001 Hit Control-a S # split the screen (ctrl-a Q: unsplit screen) Control-a # move to the new split Control-a c # create a new window within the split # change directory to path of "client" ./client laguna 2001 # run the test client with port 2001 # check the output result of both splits ---------------------------------- Other helpful screen commands $ screen -ls # list all screen sessions $ screen -d # detach a screen session $ screen -r # reattach a screen session ---------------------------------- Window session management (performed within the screen): Hit Control-a ? # display help of screen's usage Control-a c # create a window session Control-a n # go to next window Control-a p # go to previous window Control-a [0-9] # go to window x (0~9) Control-a k # kill a window session Control-a " # show a list of windows created Control-a w # show current window's name Control-a \ # quit screen Control-a d # detach current screen session Control-a x # lock your screen with password (linux account password) $ exit # terminate a screen session ---------------------------------- A screen session can be protected with a password (when the other user joins the session using "screen -x", then the password is needed). To accomplish it, you need to edit ~/.screenrc # start a screen session $ screen # after entering the screen session (":" means command line mode) Type ctrl + a then type ":passwd" # after inputing the password Type ctrl + a + [ to copy the hash value of the password (or use "mkpasswd" utility to generate the hash of password) # add the following line (containing the generated hash value) to ~/.srceenrc: # xxxxxxx is a one-way hash value of the real screen utility password password xxxxxxx $ exit # exit screen and start a new screen session # join this session from another terminal to verify the prompt of the password ---------------------------------- A good programmer does not initiate a screen session inside a screen session!