Useful Tools when working with Ubuntu Linux

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

If you use Ubuntu Linux for your daily work or more frequently, it is likely that you will find the following commands/instructions very useful.

Navigating to directories

To move to a directory within a directory, type: cd directory (type in the command line)

To move up to the directory containing the one you are in, type: cd ..

To move up two levels, type: cd ../..

You can move as many levels as you like. To move up three levels, type: cd ../../..

To move to a directory in the one up from where you are, type: cd ../directory

To move to the root directory, type: cd /

To move to a directory within the root directory, type: cd /directory

To navigate to the home directory, type: cd ~

To navigate to a directory within the home directory, type: cd ~/directory


Delete directories or files

To delete empty directory, type: rmdir directory

Delete all subdirectories and files inside documents directory, type: $ rm -rf documents/

Where,

-r : Attempt to remove the file hierarchy rooted in each file argument i.e. recursively removes subdirectories and files from the specified directory

-f : Attempt to remove the files without prompting for confirmation, regardless of the file's permissions


In this example, remove data, foo and bar if bar were empty, foo only contained bar and data only contained foo directories:

cd /home/directory
rmdir -p data/foo/bar

Where,

-p - Each directory argument is treated as a pathname of which all components will be removed, if they are empty, starting with the last most component.


Uninstalling software in ubuntu - delete / remove binary packages


Using GUI (Graphical User Interface) Package Management Tool

Click on System > Administration > Synaptic Package Manager and then mark for removal

or to start GUI tool from command line, press Ctrl+Alt+T to evoke terminal and enter: $ synaptic

Here you will start GUI package management tool without Administrative provilleges

To start GUI with administrative privilleges, enter: $ sudo synaptic

Command Line Package Management Tool

apt-get is the command-line tool for handling packages. It is used for adding, removing or updating packages.


To uninstall / delete / remove package, use the following syntax: sudo apt-get remove package-name

For example, to remove package called ffmpeg, enter: $ sudo apt-get remove ffmpeg

To remove package called linpack along with all configuration files, enter: $ sudo apt-get --purge remove linpack

To list all installed package, enter:
dpkg --list
dpkg --list | less
dpkg --list | grep -i 'http'


Concatenating pdf files under ubuntu - Ghostscript

1. Merge two pdf files, file1.pdf and file2.pdf: pdftk file1.pdf file2.pdf cat output mergedfile.pdf

or

2. you can merge files in alphabetical order: pdftk *.pdf cat output merged.pdf

Originally Posted here: http://www.newlinuxuser.com/merge-multi ... -one-file/



This process requires installation of two packages: Ghostscript and pdftk. These packages are available in the repositories of almost all linux-based distributions.

To install them using apt tool, use the following commands:

$ sudo apt-get install gs
$ sudo apt-get install pdftk


To merge two pdf files using gs, open a terminal and copy and paste the following command:

Code: Select all

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged.pdf -dBATCH file1.pdf file2.pdf
Try:

Code: Select all

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf file1.pdf file2.pdf
Change the names of file.pdf and file2.pdf to the PDF files that you would like to merge, and change the name of merged.pdf to the name you would like to name your concatenated pdf file. If you haven’t changed directories, the merged output document will be created in the default directory, your home directory.

Using this command, you can merge more than two documents. To merge three or more PDF files, continue to append the file names to the above command, separated by a space.

You can however merge several .eps files into one pdf:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=single_file.pdf *.eps

Note:

At the first instance I failed to merge two pdf files using the command “pdftk file1.pdf file2.pdf cat output mergedfile.pdf”, the reason is that pdftk could not accommodate the nonstandard pdf files that were somewhat manipulated using xournal. Finally, I found the most powerful command which could take into account the nonstandard docs or ignoring some errors by simply scripting the piece of code: gs -dNOPAUSE -sDEVICE=pdfwrite-sOUTPUTFILE=merged.pdf -dBATCH file1.pdf file2.pdf

where file1.pdf and file2.pdf are input files and merged.pdf is the output

Splitting Large PDF file into many files

Execute the command:

1. pdftk largepdfile.pdf burst

or

2.

Code: Select all

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf output.pdf
Note:

Ghostscript is a package which is available by default in Ubuntu that enables you to view or print PostScript and PDF files to other formats, to convert those files to other formats or to combine PDF files. Files don't even need to be PDF files, they can even be PostScript or EPS files, or any mixture of the three.

Here is a brief explanation of the command:

gs starts the Ghostscript program.

-dBATCH once Ghostscript processes the PDF files, it should exit.
If you don't include this option, Ghostscript will keep running.

-dNOPAUSE forces Ghostscript to process each page without pausing for user interaction.

-q stops Ghostscript from displaying messages while it works.

-sDEVICE=pdfwrite
tells Ghostscript to use its built-in PDF writer to process the files.

-sOutputFile=merged.pdf
tells Ghostscript to save the combined PDF file with the specified name.


Compress pdf files


Type:

Code: Select all

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf


into the Terminal window, replacing "input.pdf" with the name of your PDF file and "setting" with the desired quality level, and then press "Enter."

Quality level settings are "/screen," the lowest resolution and lowest file size, but fine for viewing on a screen;

"/ebook," a mid-point in resolution and file size;

"/printer" and "/prepress," high-quality settings used for printing PDFs.


Converting between formats

To convert between formats, install ImageMagick

convert Desktop.png to Desktop.jpg

You can also specify a compression level for JPEG images. The number must be between 1 and 100. ImageMagick uses the quality level of the input image, if possible. If not, ImageMagick uses the default, 92.

convert Desktop.png -quality 95 Desktop.jpg

Resizing Images

The convert command can also be quickly used to resize an image. The following command asks ImageMagick to resize an image to 198 pixels in width and 155 pixels in height:

convert image.png -resize 198x155 newimage.png

ImageMagick tries to preserve the aspect ratio if you use this command. It will change the image to fit within a 198x155 area, but the image may not be exactly 198x155.

To force the image to become a specific size – even if it messes up the aspect ratio – add an exclamation point to the dimensions:

convert image.png -resize 198x155! newimage.png

You can also specify a specific width or height and ImageMagick will resize the image to that width or height while preserving the aspect ratio. The following command will resize an image to a width of 198:

convert image.png -resize 198 image.png

The following command will resize an image to a height of 155:

convert example.png -resize x155 image.png

Rotation

ImageMagick can be used to quickly rotate an image.

The following command takes an image named Desktop.jpg, rotates it by 90 degrees and saves the rotated image as NewDesktop.jpg:

convert Desktop.jpg -rotate 90 NewDesktop-rotated.jpg

Applying Effects

ImageMagick can apply a variety of effects to an image. For example, the following command applies the “charcoal” effect to an image:

convert image.jpg -charcoal 2 image-charcoal.jpg

The following command applies the “Implode” effect with a strength of 2:

convert image.jpg -implode 2 image-imploded.jpg

More: http://www.howtogeek.com/109369/how-to- ... -terminal/


Other Useful Ubuntu Stuffs

Burning Ubuntu ISO: https://help.ubuntu.com/community/Burni ... o#InUbuntu

Fuse ISO: https://help.ubuntu.com/community/FuseIso

Check MD5SUM and PGP: https://help.ubuntu.com/community/HowToMD5SUM

and

Compare with Ubuntu Hashes: https://help.ubuntu.com/community/UbuntuHashes

Install from USB Stick: https://help.ubuntu.com/community/Insta ... omUSBStick

Run LiveCD by adding Persistent image: https://help.ubuntu.com/community/LiveCD/Persistence

Ubuntu Upgrades: https://help.ubuntu.com/community/Upgrades

and

General Upgrade information: https://help.ubuntu.com/community/UpgradeNotes

Ubuntu Releases: http://releases.ubuntu.com/

Install Skype in Ubuntu 12.04 LTS:

To install Skype, firstly, add the Canonical Partner Repository:

sudo apt-add-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"

and then execute:

sudo apt-get update && sudo apt-get install skype


Install youtube-dl: http://www.tecmint.com/install-youtube- ... load-tool/

Install AIMS Desktop: https://launchpad.net/~aims/+archive/ub ... ms-desktop

Install Radio-Tray - a lightweight dedicated internet radio player for Ubuntu by executing the following:

sudo add-apt-repository ppa:eugenesan/ppa
sudo apt-get update
sudo apt-get install radiotray
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

We spotted a bug/error that is seemingly related to these security updates when trying to convert a document from one format to another using

convert doc.format1 doc.format2

we get convert: not authorized `doc.format2' @ error/constitute.c/WriteImage/1028

If you encountered the same problem, you can solve it by following the few steps below:

1. Open the Terminal and then run

$sudo gedit /etc/ImageMagick-6/policy.xml

Enter your sudo password.

2. Change the first line below into the second by substituting "none" with "read|write":

  1. <policy domain="coder" rights="none" pattern="PDF" />
  2. <policy domain="coder" rights="read|write" pattern="PDF" />


Finally make changes by saving the file.
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#3

0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux and Unix Based Operating Systems”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests