Tom Studer's Home Page
[ start | index | login ]
start > Unix Stuff

Unix Stuff

Created by tom. Last edited by tom, 4 years and 173 days ago. 被访问了 554 次。 #14
[比较] [历史] [编辑] [rdf]
标签
附件

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

tail -f filename

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.

#PixelsScreen Size (mm)Screen Size (mm) RoundedResulting DPI
10.2540#DIV/0!
20.508151
30.762176
41.0161102
51.271127
61.524276
71.778289
82.0322102
92.2862114
102.54385
112.794393
123.0483102
133.3023110
143.556489
153.81495
164.0644102
174.3184108
184.572591
194.826597
205.085102
215.3345107
225.588693
235.842697
246.0966102
256.356106
266.604794
276.858798
287.1127102
297.3667105
307.62895
317.874898
328.1288102
338.3828105
348.636996
358.89999
369.1449102
379.3989104

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:

xdpyinfo -display :99

no comments | post comment
mouse_cartoon



< February 2012 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
26272829

snipsnap-help | More Help

Powered by SnipSnap 1.0b2-uttoxeter

Describe here what your SnipSnap is about!

Configure this box!

  1. Login in
  2. Click here: snipsnap-portlet-2
  3. Edit this box
snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt