Mounting a directory in a directory

You can mount a directory inside another directory. It is a functional analogue of having it hard linked, which is normally available only for files.

You can do it either by running a command:

  • mount --bind source_dir destination_dir

or, if you want it to be permanent, adding a line to your /etc/fstab:

  • source_dir   destination_dir   none   defaults,bind   0   0

Fix charset in Midnight Commander

If you see strange characters in mc, with all the line art ruined, run the following command in the terminal, before starting mc:

  • export LANG=en_US.ISO-8859-1

Canon LiDE20 not working

So you have a new computer with those blue USB3 ports and are using probably Linux Mint 17.3 Mate, Ubuntu 14.04 or similar OS.

The Canon LiDE20 scanner which used to work with your older computer, refuses to scan now.

If you enter “scanimage -L”, you get output shown here below, followed by a long wait:

  • device `plustek:libusb:002:003′ is a Canon CanoScan N670U/N676U/LiDE20 flatbed scanner

The problem is related to the fact that your system has USB3 ports.

One way to solve the problem is to go to BIOS setup of your computer and look for USB ports related options.

With my ASUS motherboard I fixed it like this:

  1. F2 or Del at boot for BIOS setup
  2. Advanced Mode (F7)
  3. Advanced:
  4. USB Configuration:
  5. Intel xHCI Mode -> change from Smart Auto to Disabled

		

Screen tearing in Linux Mint

Pronounced screen tearing with Linux Mint 17.3 Mate (inherited from Ubuntu 14.04).

Solution is extremely easy.

Create the following file:

  • /etc/X11/xorg.conf.d/20-intel.conf

And enter the following content:

Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "TearFree"    "true"
EndSection

Get the first n characters of a string

How to get few characters from beginning of a string in bash?

In this example the first 21 characters of all files in the directory are echoed on the screen:

  • for i in *; do echo ${i:0:21}; done

Get sha1sum checksum only

The sha1sum utility returns not only SHA-1 checksum, but also the name of the file it was called for. There is no option to disable this.

To discard the file name and keep only the checksum for file /etc/fstab:

  • sha1sum /etc/fstab | sed 's/ .*//'

Replace soft link with the original file

So you have a directory which contains soft aka symbolic links or symlinks. You want them gone, replaced with the actual files they are pointing to.

This one-liner will do the job:

  • for i in $(find . -maxdepth 1 -type l); do cp --remove-destination $(readlink $i) $i; done

Follow

Get every new post delivered to your Inbox.