Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, 12 July 2021

Find executables installed via apt

Problem:

I want to list all executables installed via apt (or apt-get). I know the name of the package installed and I am already comfortable with using shell commands.

Solution:

To list all executables installed for a package, in your shell use the following command while replacing "packagename" with the actual package name:
  dpkg -L packagename | xargs file | grep executable
  

Example:

For example, if I want to list all executables installed in the package "nullmailer":
  dpkg -L nullmailer | xargs file | grep executable
  

Other reminders:

To list all files installed for a package, in your shell and replacing "packagename" with your package name, use:
  dpkg -L packagename
  

To list all executables for a package (named "packagename") installed in the "opt" folder, use:

  dpkg -L packagename | xargs file | grep ^/opt | grep executable
  

References:

Wednesday, 24 January 2018

Seamonkey XPCOMGlueLoad error

Problem:

I updated Seamonkey on Linux Mint and it now won't launch. I am running a 64-bit version of Linux Mint.

In terminal, I tried to run Seamonkey but got an error similar to:

$ /path/to/seamonkey/seamonkey

XPCOMGlueLoad error for file /path/to/seamonkey/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.

When checking, I do have GTK 3:

$ locate libgtk-3.so.0

/usr/lib/x86_64-linux-gnu/libgtk-3.so.0
/usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9

Solution:

It may be that you're attempting to run a 32-bit version of Seamonkey on 64-bit Linux Mint. The default Seamonkey download from Mozilla as of Jan 2018 is the 32-bit version.

You can find the 64-bit version in their releases page: http://archive.mozilla.org/pub/seamonkey/releases/

For example, for 2.49.1:

Notes:

This solution worked for Seamonkey 2.49.1 running on 64-bit Linux Mint 18.1 Serena as of Jan 2018. Your mileage may vary with other versions and configurations.

Also for the system tested, the auto-update is not an issue because this browser will only be used on a local network. (You'll see the note from Mozilla when you launch the browser... at least for version 2.49.1). Keep this in mind if your situation is different and you need a browser that reliably auto-updates.

References:

http://archive.mozilla.org/pub/seamonkey/releases/ http://forums.mozillazine.org/viewtopic.php?f=40&t=3005417

Tuesday, 5 February 2013

Selectively and recursively copy all files of a single file type in OS X and Linux

Problem:

In OS X or Linux, how do I selectively copy only one type of file to a folder? For instance, how can I recursively copy all .mp3 files from a folder with many sub-folders into a single folder?

Solution:

Note: this solution assumes you have basic knowledge of using the Terminal and know how to avoid destructive commands.

To recursively check the paths of all files for instance all .mp3 in a folder and all its sub-folders, type the following into the Terminal (replacing the path and file extension to fit your need):

find /path/to/files/to/search -iname '*.mp3'

If everything looks alright, to copy the files use the following command (replacing the paths and the extension to fit your need - also note that this is a single line/command, but it's long so it may wrap to more than one line in your browser):

find /path/to/files/to/search -iname '*.mp3' -exec cp {} /path/to/destination/ ./mp3 \;

Important: make sure that the / is at the end of the destination path! (It will all be copied as a single file otherwise as it'll think that your destination is a file name and not a folder.)

Friday, 14 September 2012

Count the number of lines in a file using terminal

Problem:

I would like to count the number of lines in a file.

Solution:

An easy way to count the number of lines in a file in Linux or OS X is to use the 'wc' command in terminal. For instance:

cat myfile.txt | wc -l 

Reference:

The 'wc' command can also do a bunch of other useful things. You can find out more by googling, looking at the command's man page, or clicking the following reference: http://linux.about.com/library/cmd/blcmdl1_wc.htm

Replace spaces with newlines using terminal

problem:

Using Linux or OS X, I would like to replace spaces with newline characters in a file and output the result to a new file.

For instance, if my file's contents look like the following:
Monday Tuesday Wednesday Thursday Friday

The output should look like:
Monday
Tuesday
Wednesday
Thursday
Friday

solution:

In the terminal, a simple solution would be to use the 'tr' command, for instance:
cat infile.txt | xargs | tr -s ' ' '\n' > outfile.txt

reference:

http://www.linfo.org/tr.html

Sunday, 13 May 2012

Copy files in order using Linux or OS X

Problem:

How do I copy files in sorted order using the Linux or OS X Terminal?

Solution:

In the terminal, you can use a combination of the "find", "sort", "xargs", and "cp" commands to copy files in sorted order.

For instance, first switch to the directory that has the files you would like to copy:

cd /path/to/media/directory

Then copy the files in sorted order:

find . -print0 | sort -z | xargs -0 cp --parents
  --target-directory=/path/to/destination -v

Note that the above command is a single line, (but it appears split into two in order to fit into this page.)

In the cp command, the -v flag will help you see if files are being copied in the desired order. This can be omitted if you do not wish to monitor the files being copied. To customize the order of your sort, simply customize the flags used with the 'sort' command (see the manual pages for 'sort' using the command 'man sort', if you're unsure of how to do this).

Why copying files in sorted order can be useful:

Some MP3 players, digital media players, and other devices play back media in the order that files were copied to it. With some file managers, files can be copied out of order, in reverse-sorted order, or in other ways that copy files out of the order that is desired (such as copying multiple files in parallel). There are also other situations where copying files in a particular sorted order would be useful. For instance, copying files in some required order to a custom-built robot's flash memory, etc.

Other thoughts:

Although the command 'cp -R' can also recursively copy things in order, the method mentioned above in this post should give a bit more flexibility customizing the sorted order of the copied files.