Linux Mint Tips

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
Caltrop
Level 2
Level 2
Posts: 79
Joined: Mon Aug 07, 2017 12:00 pm

Linux Mint Tips

Post by Caltrop » Fri Jul 27, 2018 7:54 am

My Adventures In Linux Land
A former Windows user.

Code: Select all

grub problems after installing Linux to external drive
--------------------------------------------------------------------------------
Linux now thinks your external drive is the primary booter.

Unmount & unplug the external drive.

Open a terminal and...
sudo grub-install sda6
   (or whatever partition you use)
sudo grub-mkconfig
sudo update-grub2

Now everything is back to normal, hopefully.

You can also plug the drive back in and run the grub commands.
The external drive becomes part of the boot system but not the primary.

I still have not figured out how to get just the external drive to boot.
You know, on another computer, all by itself.

This all came about trying to make a rescue system.
Best just to use the Live CD you originally installed from.

Sometimes after doing a LOT of file maintenance things get a little buggered.
Then your system will not boot right.
Best to put that Live CD in and run:
   fsck /dev/sda6
   (or whatever partition you use)
   this fixes all the messed up links & files
   the autofix option usually will not work, fsck will tell you
   just answer all the fsck questions to fix things

Code: Select all

make booting more interesting
--------------------------------------------------------------------------------
be verrwy careful...
mess up grub and you will have to install Linux again
or use that Live CD to edit things right

edit as superuser
   /etc/default/grub
add
   GRUB_BACKGROUND=your_picture_here.png
      make sure it is your screen size or the same ratio
         it will not fit like the desktop does
      no spaces in the name just to be safe
      a PNG or JPG work fine
sudo update-grub2
   now when you boot you will have glorius color instead of b&w

Code: Select all

caja crashing when opening a directory?
--------------------------------------------------------------------------------
this is for those migrating from Windows

WMF's!

It is the thumbnail view of a WMF that crashes the caja file browser.

Move all those pesky WMF's to their own directory.
Turn off image preview in caja.
Use an image viewer to find the BAD WMF & isolate it in its' own directory.

WMF's do not work well in Linux anyway.
I also find that my old CDR (Corel Draw) files do not import well to inkscape.

Code: Select all

make auto-fortunes format correctly
--------------------------------------------------------------------------------
Desktop Settings: mintdesktop -> terminal -> Show fortune cookies

add the -n option
that way auto-fortunes format correctly

you will have to edit this file with root privlages

/usr/bin/mint-fortune
...
    esac
    /usr/games/fortune | $command -f $cow -n
}
...

Code: Select all

remove all empty directories
--------------------------------------------------------------------------------
'rmdir', unless forced to, will not delete non-empty directories

WARNING! this might make some things fail
but I live dangerously

OH MY!
Where did my directory in the home dirctory go...?
Duh, I just deleted it...

the script: ~/bin/rm-empty -or- ~/.local/bin/rm-empty

#!/bin/bash
find ~ -type d ! -path '~.*' -empty -exec rmdir -v {} \;

Code: Select all

DOS XCOPY /S /E Clone
--------------------------------------------------------------------------------
another tip for those who used to be Windows

I also use rsync for backups to an external drive
BAH! on all those backup utilities
   rsync makes a clone of your directories
   you can access them just like your home directory

note: there are two ways of getting rsync imitate DOS XCOPY
rsync -avmn --delete --progress --include='*/' --include=$file_nam --exclude='*' $file_pth $2
rsync -avmn --delete --progress --include=$file_nam --filter='hide,! */' $file_pth $2

the script: ~/bin/xcopy -or- ~/.local/bin/xcopy

#!/bin/bash
if [ "$#" = 2 ]
then
   file_nam=$(basename "$1")
   file_pth=$(dirname "$1")"/"
   rsync -avm --progress --include='*/' --include=$file_nam --exclude='*' $file_pth $2
else
   echo -e "\nusage: move /src/pattern /dst/"
fi

Code: Select all

safely remove external drive from the terminal
--------------------------------------------------------------------------------
this finds the mount point, unmounts, & powers off the device
I use this a LOT!

usage: x-drv [drive label]

the script: ~/bin/x-drv -or- ~/.local/bin/x-drv

#!/bin/bash
if [ "$#" = 0 ]
then
   echo -e "\nusage: x-drv drive_name\n"
else
   dev_pth=/media/`whoami`/$1
   if [ -d "$dev_pth" ]
   then
      tgt_dev=`findmnt -n -r -o SOURCE "$dev_pth"`
      echo -e "\nejecting: $dev_pth - $tgt_dev"
      umount "$tgt_dev"
      udisksctl power-off -b "$tgt_dev"
      echo -e ">>> safe to remove <<<\n"
   else
      echo -e "$dev_pth - not mounted\n"
   fi
fi

Code: Select all

list home directories & sizes
--------------------------------------------------------------------------------
does not list hidden stuff
a 4.0K directory is empty

the script: ~/bin/lshmdir -or- ~/.local/bin/lshmdir

#!/bin/bash
echo > temp.txt
find ~ -maxdepth 1 -type d ! -name '.*' -exec du -hs {} \; >> temp.txt
sort -k2 temp.txt
rm temp.txt

Caltrop
Level 2
Level 2
Posts: 79
Joined: Mon Aug 07, 2017 12:00 pm

Linux Mint Tips - Another Tip

Post by Caltrop » Thu Aug 09, 2018 4:05 pm

This one is good for DOSBox.

Code: Select all

permanently mount drives
--------------------------------------------------------------------------------
automounting is fine most of the time but...

open Drive Manager, select drive, turn off automount, select name

instead of the drive being mounted '/media/[user]/[drive]'
it is now '/mnt/[drive]'

do this for
   Windows
      now it is mounted without accessing it
      system monitor now shows the drive without having to access or mount it
   CDRom
      permanently mounted
      can be accessed by DOSBox without mounting each CD
      you can now mount it in DOSBox [autoexec]

Post Reply

Return to “Tutorials”