Tips and tricks cjc73

From CAC Documentation wiki
Jump to navigation Jump to search

Prevent accidental writes to mount point folders

Suppose you have a folder at /mnt/mountpoint that you would like to use as a mount point for a volume. Because the mount point is a valid path to a location on the boot volume, it is possible to write data to the mount point even when the volume is not mounted. Data written to the mount point will not be on the external volume --- it will be on the boot volume. It can a source of confusion, especially because copying data into the mount point and then later properly mounting a volume will hide any data on the boot drive that is in the mountpoint directory.

To avoid this, make the mountpoint directory unwritable so attempting to write data to the mountpoint when the volume is not mounted will generate an error.

  1. sudo chattr +i/mnt/mountpoint

Set up configure screen with .screenrc

Using a program like screen to keep your session active makes your computation robust to network interruption and disconnections. This means you can keep a process running on an instance even if your local machine is turned off or not connected to the internet.

Screen also has a number of optional features that make working from a remote terminal more pleasant. One feature is the "hard status" bar across the bottom the screen, which is roughly analogous to a tab bar. It will show the open screen windows as numbered "tabs" and the currently open window will be highlighted. A window can be renamed by entering the command sequence ctrl-a, shift-a. The new name will show in the tab bar.

You can enable the hard status bar (and extended scroll back history) by using nano to create a file in your home directory called .screenrc.

nano ~/.screenrc

Copy and paste the following into the nano editor:

#termcapinfo xterm* ti@:te@
autodetach on # Autodetach session on hangup instead of terminating screen completely
startup_message off # Turn off the splash screen
defscrollback 30000 # Use a 30000-line scrollback buffer
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "

Use ctrl-X to stop editing and follow the prompts to save the file. The next time you launch screen, it will show the status bar along the bottom.