lftp usage on Linux

This post introduces lftp usage on Linux.

(Thanks Scott for sharing this nice tool.)

lftp is a command-line program client for several file transfer protocols. lftp is designed for Unix and Unix-like operating systems.

1: Installation on Ubuntu:

$ sudo apt-get update
$ sudo apt-get install lftp

2: Some commonly used commands with lftp:

ls  — list direcotries and files on remote ftp server

cd — change directory on remote ftp server

lpwd — list local machine current directory

lcd — change local directory

mput *.csv  — mput for multiple files, put for a single specific file.

This will take from the current local directory  and put into the current remote directory on  remote ftp server.

copy directory and its contents to and from ftp server (from and to local machine):

mirror -c -R  path/to/localdirectory/   

This will copy local directory to (the current directory) on the  remove ftp server  , c means continue)

       mirror -c  path/to/remote/directory

This will copy the remote directory  to (the current local directory  , c means continue)

(for more commands, check the lftp man page provided in the references below.)

3: Using Box under Linux (using lftp)

The lftp command is a powerful file transfer client that can be used with Box.

Box supports the secure FTPS protocol and you can use this with lftp for secure file transfer and mirroring.

The lftp command is smart enough to auto-negotiate to use FTPS but this example forces the issue to make absolutely sure unencrypted FTP is never attempted.

Here is an example of how to connect using FTPS.

$ lftp
lftp :~> set ftps:initial-prot ""
lftp :~> set ftp:ssl-force true
lftp :~> set ftp:ssl-protect-data true
lftp :~> open ftps://ftp.box.com:990
lftp ftp.box.com:~> user yourusername@psu.edu
lftp yourusername@psu.edu@ftp.box.com:~> ls


when finish use exit to exit from lftp.

4: Copy a remote folder via FTP on the Linux command line using lftp (PDF)



lftp Man page (PDF)

Using Box under Linux (PDF)

For more commonly used Linux commands, check my other posts at here  and here .


Screenshot shortcuts on Linux (Ubuntu, CentOS, RedHat)

This post  provides shortcuts for taking screenshots on Linux (including Ubuntu, CentOS, and RegHat).

The command is the same for Ubuntu, CentOS, RedHat. (Check HERE for screenshot shortcuts on Mac.)

  •  Using Gnome Screenshot

    • Press PrtScn to take a fullscreen screenshot to a PNG file (normally the screenshot file is saved in the Pictures folder.)
    • Press Alt+PrtScn to take a screenshot of an active window. This shortcut will create a screenshot of your active window as a PNG file. The file will be saved in your Pictures folder.
    • Press Shift+PrtScn to capture a customized screen area. You’ll be able to click and drag a selection box to determine what is captured in the screenshot. A PNG file with the image you captured will be saved in your Pictures folder.
    • Press Shift+CTRL +PrtScn to copy what you customized area capture  to clipboard.
    • More advanced functions:

The Gnome Screenshot utility allows you to perform some additional screenshot functions, such as adding a delay, and add tooltip.

Open the Screenshot utility. You can find the Screenshot utility in the Accessories folder of your Applications menu.

      • Select your screenshot type. You can choose from any of the options outlined above.
        • (Ubuntu)

        • (RedHat)

      • Add a delay. If your screenshot is time-dependent, you can use the Screenshot utility to add a delay before the screenshot is captured. This will allow you to make sure the right content is on the screen.
        • (Ubuntu)

        • (RedHat)

      • Select your effects. You can choose to include your mouse pointer in the screenshot, as well as whether or not you want to add a border to the screenshot.






  •  Using GIMP

GIMP (GNU Image Manipulation Program) is a freely distributed software for manipulating images. We can easily optimize the image, convert their type using GIMP. It provides the power and flexibility to designers to transform images into truly unique creations. GIMP is the cross platforms application and available for Linux, Windows, MAC OS, and FreeBSD etc.

Install GIMP

You can get it for free using your Software Center. Open the Software Center, search for “gimp”, and then install the “GIMP Image Editor”.

For installing GIMP from command line on Ubuntu, check my post HERE.

Click the “File” menu and select “Create” → “Screenshot”.

The screenshot creation tool will open. This tool is very similar to the Gnome Screenshot utility.


Select the type of screenshot you want to take.

You can choose to take three different types of screenshots: single window, full-screen, or custom selection. If you choose the single window option, you’ll be able to click the window that you want to take a screenshot of.



Add a delay.

You can add a delay before the screenshot is taken so that you can arrange everything exactly how you want it. If you have single window or custom screenshots selected, you’ll choose your screenshot target after the delay timer runs out.

Click “Snap” to take the screenshot.

Depending on your settings, the screenshot may be taken immediately. When you’re finished, the screenshot will open in the GIMP editing window.


Save the screenshot. If you don’t want to make any edits to the screenshot, you can save it to your hard drive. Click the “File” menu and select “Export”. Give the screenshot a name and choose where you would like to save it. Click the “Export” button once you are satisfied.




4 Ways to Take a Screenshot in Linux (with Pictures) – wikiHow (PDF)






Use latexdiff to compare different versions of LaTeX tex files to visually mark differences

This post introduces how to use latexdiff to compare two versions of latex *.tex files, in order to visually mark changes to tex files.

(One colleague asked me about the usage of latexdiff, so I think it is a good time to write it up into a blog post to share with those who need some help with this.)

latexdiff is a Perl script and requires an installation of Perl 5.8 or higher.

Use latexdiff to mark differences and create a new LaTeX document with markup differences between two latex files.

  • Linux (Ubuntu) users

latexdiff can be found in Ubuntu repository and detailed description of usage can be found here.

In your terminal, issue the commands below to install latexdiff.

sudo apt-get update
sudo apt-get install latexdiff
# open your terminal, and cd to the tex files you need to compare
# issue the following command
latexdiff original_version.tex revised_version.tex > diff.tex

Run the diff.tex file like you run a normal tex file, you will see beautifully marked differences in the pdf file.

  • Mac OS X users

latexdiff is a Perl script and requires an installation of Perl 5.8 or higher.
Mac OS X includes an installation of Perl and no additional setup is required. latexdiff can be found in any CTAN repository
(If you are using MacTex on your mac,  latexdiff is already installed in MacTex under /usr/texbin/latexdiff. No need to install it separately. To use latexdiff in commend line, see below)
After you setting perl and latexdiff, just open your terminal, and cd to the path where you put you two versions of latex tex files, and then issue the command. (If the two tex files are located in different location, you can just give the relative path to that location for each version of tex file.)


$ latexdiff original_version.tex revised_version.tex > diff.tex
will compare original_version.tex to revised_version.tex and create a new file diff.tex showing the differences.
Run the diff.tex file like you run a normal tex file, you will see beautifully marked differences in the pdf file.
  • Online latexdiff 

when you get the diff.tex on the online latexdiff, you can paste into a new tex file and then you can run it and you will see the pdf which shows the differences.
  • Multiple tex files for each version

If each version of your text files contains multiple (sub) tex files or if you want to use latexdiff with Git, check the Reference lists for potential solutions.


LATEXDIFF: SUPERB DIFF TOOL FOR LATEX (pdf) — talks about solutions to multiple files, but this can only deal with sub-files on the same level, not nested cases.

Two LaTeX gems: ShareLaTeX and latexdiff (pdf)

Using Latexdiff For Marking Changes To Tex Documents (pdf)

Multiple-file LaTeX diff (pdf— this one is very good. – use python code to merge multiple tex files to one big tex file for each version and then use latexdiff to make comparision.

Latexdiff with subfiles (pdf) — this one talks about solutions to multiple tex files.

Using latexdiff with git (pdf) – Git Latexdiff  — this is about using git together with latexdiff

Git and latexdiff: compare versions of LaTeX documents (pdf) — this is also about using git together with latexdiff