banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Too Long, Didn't Read


by Peter Kelly (critter)

Learning to use a computer can be a difficult and frustrating experience. Modern point and click graphical interfaces have made things somewhat simpler than the original DOS or Unix text terminal interfaces. Surprisingly though, and to the horror of many Windows migrants, the text terminal is still used by many Linux users, and in some cases, it is the only way to resolve a problem.

Unfortunately learning to use the Linux 'command line' interface is hampered by the dated style and technical nature of the provided documentation which comes in the form of 'man pages' and the difficult to navigate but comprehensive info system. Most times you simply want a quick reminder of what to type and what options are available. What you get is often more confusing than enlightening. For example, The tar command is often used, sometimes in conjunction with a compression utility, to bundle several files together for purposes of backup or archiving. From the man page I get over a thousand lines of accurate, but confusing to most, instructions including paragraphs such as this:

DESCRIPTION
  GNU tar is an archiving program designed to store multiple files in a single file (an archive), and to manipulate such archives. The archive can be either a regular file or a device (e.g. a tape drive, hence the name of the program, which stands for tape archiver), which can be located either on the local or on a remote machine.

Yes, this describes what it does but do I really have to wade through reams of such text just to find out how to use one command? Not any more. There is now a real alternative in the form of a Linux community project called TLDR (an acronym meaning Too Long, Didn't Read - which is rather appropriate). Using this system we get:

$ tldr tar

tar

Archiving utility.
Often combined with a compression method, such as gzip or bzip.


- Create an archive from files:
tar cf target.tar file1 file2 file3
- Create a gzipped archive:
tar czf target.tar.gz file1 file2 file3
- Extract an archive in a target folder:
tar xf source.tar -C folder
- Extract a gzipped archive in the current directory:
tar xzf source.tar.gz
- Extract a bzipped archive in the current directory:
tar xjf source.tar.bz2
- Create a compressed archive, using archive suffix to determine the compression program:
tar caf target.tar.xz file1 file2 file3
- List the contents of a tar file:
tar tvf source.tar

That is the complete output from this command and is usually enough. There are currently over 500 tldr man pages and the project is currently still active.



Installation

The Distrowatch website recently carried an article describing tldr and has a link through which you can access the pages, but there are many other clients available to access this information. As this is most useful when in a bash terminal session, it makes sense to have a bash client which will display the information without leaving the terminal. Such a client has been produced by Ray Lee and is available on GitHub. Tldr is Linux distribution agnostic and setup is extremely simple. Open a terminal and type in the following lines.

mkdir -p ~/bin
curl -o ~/bin/tldr https://raw.githubusercontent.com/raylee/tldr/master/tldr
chmod +x ~/bin/tldr

The curl command does the downloading and is extremely quick. Now, in a plain text editor, add the following to your ~/.bashrc file. This may not be necessary depending on your setup but will not cause any problems.

export PATH=~/bin:$PATH

Restart the terminal and you should be good to go! Typing just tldr in the terminal gives this usage information

USAGE: tldr [options] <command>

[options]
    -l, --list: show all available pages
    -p, --platform: show page from specific platform rather than autodetecting
    -u, --update: update, force retrieving latest copies of locally cached files
    -h, -?, --help: this help overview

<command>
    Show examples for this command

The client caches a copy of all pages and the index locally under /home/{user}/.config/tldr. By default, the cached copies will expire in 14 days.

Note: {user} will be the name of the user where you created the bin directory above. If you want this to also be available when you are working as root (recommended) then you will have to install it again as root.

Now, when I can't remember the option for showing a long, sorted directory listing:

tldr ls
ls
List directory contents.
- List files one per line:

ls -1
- List all files, including hidden files:
ls -a
- Long format list (permissions, ownership, size and modification date) of all files:
ls -la
- Long format list with size displayed using human readable units (KB, MB, GB):
ls -lh
- Long format list sorted by size (descending):
ls -lS
- Long format list of all files, sorted by modification date (oldest first):
ls -ltr

And there it is, ls -lS.



Previous Page              Top              Next Page