Detachable terminal sessions

You can use ''screen'' or ''dtach'' to make sure that if your connection is dropped from a linux server, that your session is preserved and you can link back to it. This is especially useful for keeping processes running and being able to come back and check on them later.

Detachable sessions with SCREEN

Screen is very powerful, it's like a text-terminal window manager. You can create a session with multiple terminal windows all detachable and reattachable in one screen session.

Steps:

  1. Make sure you have ''screen'' installed on the target server. From a session on that server, run sudo yum install screen
  2. Start a ''screen'' session by entering >screen -S ''mysession'' at the prompt (replacing ''mysession'' with a name you'll remember when you re-attach)
  3. screen is mostly run with ctl-a <something> key combos, for example, ''ctl-a h'' will bring up a help screen, and ctl-a ctl-c creates a new shell.
  4. To re-attach a session, log back in to the machine, and then you can re-attach with screen -r ''mysession''

Detachable sessions with dtach

Another, less powerful but lower-overhead tool to use that lets you detach like in screen but doesn't do the other screen stuff is dtach. It is not as powerful as screen, but has the advantage that you can see with the ps command what is running what socket.

Steps:

  1. Make sure you have dtach installed on the target server. From a session on that server, run sudo yum install dtach
  2. dtach uses named sockets, so you will be creating a socket in /usr/tmp, and running a bash session (type dtach --help or check the ''man'' page for details):
  3. in the bash session, run whatever program you want
  4. Detach your session with ctl-\ key if you want
  5. Re-attach later (even after logging off) with dtach -a /temp/checkbotrun

How to Set Up a User-level Perl Library

If you can't figure out how to get elevated perms to install Perl modules and apps for everyone to use, you can set them to your local user account. Below where it says ".profile" you may need to change depending on your linux/unix environment to .bash_profile. This example also grabs and sets upcpanm on the first line, which you can skip if you already have it:
  curl http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib
  eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
  echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
  echo 'export MANPATH=$HOME/perl5/man:$MANPATH' >> ~/.profile

You will now have a local perl library, ~/perl5 where all subsequent perl module installs you do from the command line will go.

How to add a user to a linux server

To add a new user:

ex: sudo useradd <username> --groups webpub -p <password>

(the '''-e''' expires the account, if you have to put in an expire date, use YYYY-MM-DD format for expire date. You can expire the account *after* you create it, with usermod: ex: usermod <username> -e )

The password has certain rules (can't be a dictionary word or close), and this is not enforced with useradd and if it *is* too simple, the user won't be able to log in even after you create the account. So '''make it complicated OR you can set the password manually to make sure it passes after you create it as above''':

ex: sudo passwd <username>

 New password: 
 BAD PASSWORD: it is too short
 BAD PASSWORD: is too simple
 Retype new password: 
 etc

Also, if you want to add them to the sudoers group, an admin has to use sudo visudo to edit the sudo file in vi, add the new user like the other people in the list:

 ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
 #includedir /etc/sudoers.d
 trusteduser         ALL=(ALL)       ALL
 ...
 <username>          ALL=(ALL)       ALL

How to preview your Markdown document

.md files in git are written in Markdown. Even if you find a tutorial and figure it out, you may not be using a tool with preview to write or edit your markdown document.

Original Daring Fireball markdown site

How to pretty-print JSON at the command line