Archive for the 'features' Category

Simple tar and untar

It’s incredible the number of people who confuse tar, gzip not to mention the flags associated with these commands, note that the order is relevant.

Quick reminder:

  • tar is an archiver used to to combine multiple files into one
  • gzip is a compression tool used to reduce the size of a file

Now that you finally understand the difference, here’s how the basic operations work:

  • Create a tarball with the content of a directory:
    tar -cvf foo.tar foo/
  • Extract the content of a tarball:
    tar -xvf foo.tar
  • Compress a tarball with gzip, this will replace foo.tar with a compressed version foo.tar.gz:
    gzip foo.tar
  • Extract a gzipped tarball:
    tar -xvzf foo.tar.gz

Get current date / time

A very useful function of the unix shell is the date function. It allows you to get the current system time in any format you need. Some examples:

date : returns the current date / time
date -u : returns the current UTC date / time
date +"%s" : returns the current date / time in unix timestamp format (seconds since the epoch)

Find binary location

To find where a process is launched from, as well as it’s source code and manual if available, the useful whereis command comes in handy.
To find for example, where the bash binary is located, just run:
whereis bash
It will output something like:
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

This tells me the following about the bash process:
- The binary is located in /bin/bash
- The source code is located in /etc/bash.bashrc
- The manual (man bash) is located in /usr/share/man/man1/bash.1.gz

Detach a process from shell

If you want to detach a process from the shell it was ran from, that is leave the process running after the shell is closed, add & disown to the end of the command. A simple example:
kate readme.txt & disown

Window Print Screen

You can print screen from anywhere in Ubuntu by just hitting the Print Screen (PrtSc) key on your keyword. This will capture your whole screen and you will be prompted to where the screenshot should be saved.

Now the cool thing is if you want to capture only the current window, PrtSc + ALT will do the trick for you. Sweet!!

Windows Capture