Tag Archives: linux

After recently installing Ubuntu 14.04 inside VirtualBox and installing the guest editions, I was stuck with a very small screen resolution. Apparently this is a bug with VirtualBox and until a fix is applied to the VirtualBox guest additions package, the following command should be used to fix this issue:

Tonight I needed to check the runtime dependencies of a native unix executable. Luckily this can be achieved with a single command using the ldd utility (linux) or otool (MacOSX) to print a list of shared object dependencies as follows;

Preface

Entering long winded commands with many parameters, paths and redirection in the shell/terminal can be time consuming, repetitive and prone to human error. Luckily on both Windows and on Linux you can provide simple abbreviations for long commands.

Windows

On Windows the DOSKEY command (provided by default with the operating system) is pretty versatile and can be used to easily configure macros and command abbreviations. DOSKEY is actually resident during all Windows command line sessions and is the underlying system responsible for maintaining the command history (which can be navigate with the updown/pgup/pgdown keys). Below I have listed some example usages of DOSKEY;

# Note: The $G character is a special doskey escape character for the
# redirect character '>' which allows it to be specified as part of
# the command without redirecting the doskey command itself.
doskey /history # Show history of all previously run commands
doskey /reinstall # Clear command history
doskey here=explorer . # Add 'here' macro to open an explorer window at the current location
doskey desktop=cd "%USERPROFILE%\Desktop" # Add 'desktop' macro which takes you to the current user's desktop
doskey mp3list=dir %CD%\*.mp3 /S /O:N $G mp3list.txt # Add 'mp3list' macro to recursively and alphabetically list all .mp3
# files below the current directory, inside mp3list.txt

Note: Any macros configured using doskey are only active for the active command line session. To create macros which persist between sessions consider placing all macro creation commands in a batch script, you then have two options:

Use an alternative command line environment such as Console2 which can be configured to automatically run your batch script on start-up.

Linux/OSX

On Unix-esque systems it’s pretty much the same kind of setup using the alias command. Some example usages are listed below;

# Note: All alias entries are wrapped in single quotes so there is no requirement for special alias
# escape characters for piping / redirecting streams
alias here='nautilus ${PWD}' # Add 'here' macro to open a nautilus window at the current location
type here # Prints the expanded version of the 'here' macro
unalias here # Unregister the 'here' alias
alias blog='firefox https://tomtech999.wordpress.com' # Add a 'blog' alias to open your blog in firefox
alias dumpenv='export -p | grep "/" > env.txt' # Dump all bash environment variables containing a path to 'paths.txt'

Note: As with DOSKEY on Windows, any macros configured using ‘alias’ are only active for the active bash shell session. The easiest way to make aliases persist between bash sessions is to add all of your alias commands to the bashrc shell configuration file located in your home directory (~/.bashrc ). This script is executed whenever you open a bash shell and can be used to automatically register aliases for all bash sessions.

This is a really useful technique I recently discovered which allows you to bind a port on your local machine to the local port on a remote machine. Why would you want to do this?

Well in my case I was working on a remote web server via ssh, setting up some web aplications on various different ports. The hosting company had yet to open these ports to the outside world. However, this technique allowed me to bind the local ports on the remote machine (running the web applications) to my local machine. This allowed me to test and configure each application as if it was installed on my local machine, simply by accessing localhost:xx in my browser. The port numbers don’t even have to match! I ended up binding remote port 8080 to port 80 on my local machine.

This can be achieved by issuing the following command on the local machine…

After updating to Ubuntu 10.04 LTS everything seemed to have gone smoothly but for some reason the window buttons have shifted to the left for this release! The following tutorial shows how to put them back to the right and only takes around 30 seconds to apply.

Post navigation

I have recently graduated with a 1st class degree in MComp Games Software Development at Sheffield Hallam University, focusing primarily on application development in C++, with experience in graphics programming, scripting languages, DVCS/VCS and web technologyRead More