Base64 Encoding a String
echo some-string | openssl enc -base64 -e
Use the -d option to decode.
FTP Login
If your shell login works but your FTP or secure FTP login doesn't, check your shell login script and make sure it doesn't generate any
console output.
Emacs Essentials
General: Command keys like C-x means
Ctrl-x. Mode (meta) keys
like M-x means Meta-x (use ESC, Alt or Windows key as meta key)
F10 - Navigate the menus in a text console (ncurses) emacs.
C-x C-c - Exit; allows you to save modified buffers.
vi Essentials
Use ESC to put vi in command mode, 'i' or 'a' to type text.
:q - Exit, no save (add ! to discard changes)
:x - Save and exit
i - insert text
a - append text
yy - copy current line
Nyy - copy N lines (including current one)
dd - delete current line
Ndd - delete N lines (including current one)
p - paste
/string - search for 'string' from cursor
/ - repeat search
Searching The File System
find . -name "filename.*" (searches for files)
find . -exec grep -H 'pattern' '{}' \; (searches for 'pattern')
Text Find/Replace in Multiple Files
find . -name Root -exec sed -i s/olduser/newuser/g '{}' \;
Replaces 'olduser' with 'newuser' in all files named Root under the current directory tree.
Viewing a growing log file
Running an X11 virtual frame buffer
Java applications running on servers sometimes require a running X11 environment and a display server they can contact in order to run or function properly. (As an alternative, setting the Java system property java.awt.headless=true usually eliminates this requirement. However, it didn't in my case.)
You can start a virtual X11 server with the following command:
Xvfb :any-free-display-number
Then do a
setenv DISPLAY :your-xvfb-display-number.0
And run your application.
In a Java application I was running using this approach, the fonts in image files generated by the application were scaled wrongly. The reason for this was a wrong DPI setting of my virtual frame buffer (Xvfb uses the default DPI setting initialized with Xserver on the system). This was 100 DPI in my case and I wasn't in a position to change that.
However, I was able to trick Xvfb into returning a DPI value other than 100 when queried by an application. This was possible because the dimension in pixels of the virtual frame buffer was irrelevant to my application (i.e. I could run Xvfb with any screen resolution). The follwing table shows a few possible screen resolutions and resulting DPI values.
| #Pixels | Screen Size (mm) | Screen Size (mm) Rounded | Resulting DPI |
|---|
| 1 | 0.254 | 0 | #DIV/0! |
| 2 | 0.508 | 1 | 51 |
| 3 | 0.762 | 1 | 76 |
| 4 | 1.016 | 1 | 102 |
| 5 | 1.27 | 1 | 127 |
| 6 | 1.524 | 2 | 76 |
| 7 | 1.778 | 2 | 89 |
| 8 | 2.032 | 2 | 102 |
| 9 | 2.286 | 2 | 114 |
| 10 | 2.54 | 3 | 85 |
| 11 | 2.794 | 3 | 93 |
| 12 | 3.048 | 3 | 102 |
| 13 | 3.302 | 3 | 110 |
| 14 | 3.556 | 4 | 89 |
| 15 | 3.81 | 4 | 95 |
| 16 | 4.064 | 4 | 102 |
| 17 | 4.318 | 4 | 108 |
| 18 | 4.572 | 5 | 91 |
| 19 | 4.826 | 5 | 97 |
| 20 | 5.08 | 5 | 102 |
| 21 | 5.334 | 5 | 107 |
| 22 | 5.588 | 6 | 93 |
| 23 | 5.842 | 6 | 97 |
| 24 | 6.096 | 6 | 102 |
| 25 | 6.35 | 6 | 106 |
| 26 | 6.604 | 7 | 94 |
| 27 | 6.858 | 7 | 98 |
| 28 | 7.112 | 7 | 102 |
| 29 | 7.366 | 7 | 105 |
| 30 | 7.62 | 8 | 95 |
| 31 | 7.874 | 8 | 98 |
| 32 | 8.128 | 8 | 102 |
| 33 | 8.382 | 8 | 105 |
| 34 | 8.636 | 9 | 96 |
| 35 | 8.89 | 9 | 99 |
| 36 | 9.144 | 9 | 102 |
| 37 | 9.398 | 9 | 104 |
As an example, this is what I had to do to have my Java application generate images for a target system with 76 DPIs (see line 3 in the table above, 3x3 in the command means the screen resolution):
Xvfb :99 -screen 0 3x3x24 &setenv DISPLAY :99.0<run my Java application>
By the way, you can query the properties of your display with the xdpyinfo command. For example: