Busser Tech Notes

A guide for various things computerish… where not otherwise specified, a lot of what is noted below is debian-based.

Bash command-line usage

  • apt-cache
    • sudo apt-cache showpkg gnumed-client shows the versions, the depends
    • sudo apt-cache showpkg gnumed-server shows the versions, the depends
    • sudo apt-cache policy python-psycopg2 shows what is installed, available, pinning values
  • apt-file
    • useful when searching for the package-of-origin of an as-yet uninstalled file (but whose usual destination you know)
    • not part of a base install; need to first do sudo apt-get install apt-file
    • example usage $ apt-file search /usr/bin/pdflatex yields
      texlive-latex-base: /usr/bin/pdflatex
  • apt-get
    • sudo apt-get update should be run regularly to keep your system informed about possible package updates
    • sudo apt-get -t testing install gnumed-client installs, on Debian, the GNUmed client
    • apt-get upgrade appears to require root access, making the easiest way to upgrade as follows:
      • sudo -i then, in the resulting root shell, $ apt-get update && apt-get upgrade
  • available commands
    • `tab` twice or `esc` 4 times at the beginning of a line (but lists >2,000 items… better to first input a character)
  • basename
    • basename `pwd` returns just the short name
  • dpkg
    • helpful among other things to identify a file's package-of-origin e.g. $ dpkg -S /usr/bin/pdflatex yields
      texlive-latex-base: /usr/bin/pdflatex
  • env
    • (Mac) display environmental variables
  • find
    • this command, unlike locate, does not depend on a maintained database
    • you tell find a least three things: where to start searching, what kind of a search to make, and what to look for:
      $ find / -name “somename” searches for a file by name (the -name option) named somename in / and all of its subdirectories (which is everything, as "/" denotes the root level).
    • you use * as a wild card within the quotes:
      $ find / -name “some*”
    • you use a tilde (~) when you want the search to start from and within the logged-in user's "home" directory:
      $ find ~ -name “somename”
    • you use a dot when want to start find in the directory you’re in and search it and its sub- directories:
      find . -name “filename”
    • # Use -name to find all files or directories which match the pattern "*.rhtml"
      • find ./ -name "*.rhtml"
      • find ./ -name "file name*"
    • # Print out a list of all the files whose names do not end in .c.
      • find / \! -name "*.c" -print
    • # Find files and directories that are at least seven levels deep in the working directory /usr/src.
      • find /usr/src -name CVS -prune -o -depth +6 -print
    • in the methods above, substitute -iname for case-insensitive searches of filenames
    • # Combine with -exec grep to find all rhtml files whose file contents match "Continuous Thinking" and -i for case insensitivity
      • find ./ -name "*.rhtml" -exec grep -Hn "Continuous Thinking" {} \;
      • find ./ -name "*.rhtml" -exec grep -iHn "Continuous Thinking" {} \;
  • grep
    • for newbies
    • concise
    • in Bash guide for beginners
    • remember options
      • --color will set out the found text
      • -l to list the filenames (not the matched content)
      • fgrep for literal (non-interpreted) searches
      • egrep to search 2 different words egrep -w 'word1|word2' /path/to/file
  • head
    • head -15 /usr/sbin/gm-bootstrap_server
  • locate
    • fast file finder, but depends on its database being maintained
    • typical usage: locate fileName
    • update its database with sudo /usr/libexec/locate.updatedb
      • if you get a getcwd error you might need to first cd /
      • to check its size, do (on FreeBSD?) ls -l /var/db/locate.database
  • operating system information
    • $ uname -a yields: Linux debian 2.6.26-2-686 #1 SMP Sun Jun 21 04:57:38 UTC 2009 i686 GNU/Linux
    • $ cat /etc/debian_version yields: 5.0.2
    • $ cat /etc/apt/sources.list shows one's sources
    • $ cat /etc/apt/preferences (provided the file has been created) shows any preferences including pinning as provided here
    • packages… show what's installed (using a post-install apt-show-versions)
      • $ sudo apt-show-versions | grep psyco (here the | grep was an optional filter among results, for "psyco...")
    • $ top shows running processes and, if a process has hung up the system, the kill command can release it
    • $ users tells you who else is logged in, before you might sudo shutdown
  • regex (expressions, not a command)
  • remove files
    • all from current directory (best to preserve the interactive "-i" until sure what one is doing):
      $ rm -i ./*
    • all from current directory and all directories below (i.e. "recursively"): caution
      $ rm -ir ./*
    • all from current directory except (e.g.) of type .ogg
      $ find . ! -name "*.ogg" -exec rm -f {} \;
    • all from a specified directory, recursively, based on matching a file name:
      • e.g. if your music folder is /home/dygear/music and you want to remove any file in it that contains .ini then you'd run
        $ rm -r /home/dygear/music/*.ini
  • sudo tips
    • Ubuntu ships with the root user locked and inaccessible to su (references: 1, 2) but can be unlocked using any of $ sudo bash or $ sudo -s or $ sudo passwd
    • for persistent access to root functionality, use $ sudo -i or, for a root file browser, $ gksudo nautilus
  • terminals in Ubuntu

Bash how to

Bash profiles

Bash prompts

Date-Time troubleshooting

  • Debian when run inside a VM may lose synchronization to servers (for example the enclosing host OS may go to sleep) so, as sudo
    • run ntpq -p to confirm that NTP is still working (Connection refused suggests is needs restarting)
    • run as root or sudo /etc/init.d/ntp restart to restart the ntp service; wait a few minutes, then re-issue ntpq -p
    • guide here
  • various issues with date-time formatting and localization; the devel archive has lots on this

Debian installation

  • DebianGuideLong
  • downloading via broswer – I personally could not figure out where the Gnome web browser paced its downloads, thus instead used wget from the command line
  • if running under a vm
    • it may sleep or be suspended confusing ntp service which may need restarting per above

Gnome Failsafe / Desktop repair

  • sudo dpkg-reconfigure -phigh xserver-xorg will try to update the /etc/X11/xorg.conf
  • sudo dpkg-reconfigure xserver-xorg should get your default driver back
  • to reinstall a driver outside Gnome:
    • obtain a terminal: CTRL ALT F1
    • sudo stop gdm to exit the active xserver
    • run a driver install if needed e.g. sudo sh ./NVIDA.run (having renamed the driver download to make it simple) and follow the e.g. Nvidia install instructions
    • when finished: sudo start gdm
  • if your gnome is borked, delete your whole .gnome2 dir and any other dotdir that might be related to gnome. Then log off and back on, gnome should just recreate them off the system defaults

GNUmed troubleshooting

  • local temp files plus installed client log in /home/jbusser/.gnumed/tmp
  • path
    • echo $PATH
    • export PATH equalsSign any_desired_colon_delimited_paths_as_string:$PATH

Howto (re)compile a package

Mac overview




Shell command: executables

  • "sh" is the name of the executable of a shell program
  • doing "sh some-program.sh" is pretty much like "python gnumed.py" except that the interpreter is the shell rather than Python
  • running an executable program
    • doesn't actually need the "sh" in front of it. Rather, sh is assumed by default
    • we must give an explicit path (commonly the current directory ./) without which the shell would trawl the executable directories for it (/bin/, /usr/bin/ etc).

SQL (general)


Sudo trick

  • when you forget (omit) to prepend sudo in a command line, just input sudo !! and this will reissue the last command


tar and Untar (punpack) files on a Mac


  • localhost's IP address is localhost's IP address
  • the first octet specifies the IP "Class", where values 0-127 denote "Class A" … 192-223 "Class C" ; each class has a different default subnet mask whose final subnet octet is normally 0 but can for example be 192 if an administrator needed to divide a range of available machine ip addresses among up to 4 physical networks; final (host) octet cannot assign 0 or 255 to an individual host
  • Understanding TCP/IP basics


  • clean up list of filenames from ls using Find/Replace [ ] grep [\t]+ \r


  • uscan is a Debian tool which inspects a so called watch file for new upstream versions. It run by our debian-med maintainer against this wiki page for a string matching http://www.gnumed.de/downloads/client/[\d\.]+/GNUmed-client\.([\d\.]+)\.tgz

wget (Mac)

Topic revision: 13 May 2013, JamesBusser
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
Powered by Olark