ubuntu - tips & tricks

As a freelance software developer I am constantly flipping between multiple operating systems and often get terminal commands confused. Probably one of the most common commands is pbcopy.

pbcopy on a mac enables you to copy the standard input from terminal window to your clipboard enabling you to paste it to other applications.

You can replicate pbcopy on ubuntu by utilising a similar tool called xclip which does exactly the same.  However its syntax is a little too verbose and I prefer to use OS X pbcopy command.

Fortunately due to the fact that OS X and Linux *nix based we can make use of the The alias Command to replicate the pbcopy functionality in ubuntu.

how to configure pbcopy on ubuntu

If you haven’t previously installed xclip simply run the following command in your terminal window:

Edit your BASH settings file using your favourite text editor.  I’ll be using nano, but feel free to use Gedit or Vim etc.

Then create an alias for pbcopy and pbpaste:

Close and save the file then just refresh your bash to import your new settings

Script for pbcopy on ubuntu

I have created a quick script to help automate the configuration of pbcopy on ubuntu.

Please bear in mind, that due to the fact the script will be installing new software it will require elevated permissions to run. Typically I execute the script

For further information on How to execute a BASH script

how to use pbcopy on ubuntu

After you have finished the configuration steps above you can simply use pbcopy on your ubuntu machine in much the same way you’ll utilize it on the mac.

This will copy your ssh public key and you can test if this works by pasting it into a Gedit text file.
This functionality also comes in very handy in situations when you need to copy the contents of your php info. For instance, when you need to configure xdebug to enable debugging for PHP.

You could use xclip to copy the contents

Or if you have taken the time to configure the short cut above you can make the command a lot easier to remember by removing some of the verbosity.


This is an example of how flexible, adaptable and customizable the Linux Operating system is. Simply utilising the The alias Command you’re easily able to replicate functionality found on the MacOSX directly on your Linux system.

This provides you with the capability to customise your system to how you prefer to work with it. Taking time to learn and understand the Aliases in Linux will help you to tailor your system and decrease the amount of typing you need to do.

Gary Woodfine

Freelance Full Stack Developer at threenine.co.uk
Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.

Affiliate Disclaimer

Disclosure: Please note that some of the links included in the blog posts are affiliate links, which means I will earn a commission if you decide to make a purchase.

I only include affiliate links to products, services and companies that I have personal experience and have actually used. I only recommend them because they are helpful and useful, not because of the small commissions I make if you decide to buy something.

Please do not spend any money on these products unless you feel they are relevant, suitable and will help you achieve your goals.

Buying anyone of these products and the commisions earned will not make me an overnite multi millionaire, but they will help to cover the hosting costs and compensate for the countless hours and effort I put in to create meaningful and valuable free content I provide to help others succeed.

You've also undoubtedly noticed that I also use various advertising networks - unless of of course you're using an Ad blocker, this is also an attempt to reduce my monthly deficit I experience in providing free relevant, valuable and on occassion insightful content for the benefit of others.

I only really make some money if people click on the ads, unless of course you consider 1c per 1000 impressions real money!

Bear in mind just how many impressions I need to make before I can cover my £20 hosting costs a month!

If you are using an adblocker and guilt stricken you can of course donate using any of the buttons below, but I won't be holding my breath.

Buy me a coffeeBuy me a coffee