Home directory renewing.

Every now and then something goes wrong in the home directory. I was having the problem that something or possibly of number of things causing:

  • Longish load times of gedit and Firefox and possibly a couple others.
  • A hang of one X.org session (and lose of tracker data).

How I fixed these problems previously

About every six months, I find myself cleaning out my home directory. This has always been because of bugs. Usually what happens is developers add new features, they cause incompatibilties with old configurations or how files get accessed… its necessary to do about this often.

Cleaning the home directory is a long and laborious process of going through all the files. A bit more throughly, the last couple times I would rename my home directory (mv /home/user /home/user-old) and mv the files I trusted over. I would keep the old directory around a bit if I needed to grab an old configuration.

The forest through the trees method

These days I just create a new user :).

useradd -g users -G \
  adm,audio,games,optical,power,scanner,storage,video,wheel alias
  install -d --owner=alias --group=users /home/alias
passwd alias    

To be able to transfer the files over, I use my backup utility and backup all home files and dependable configurations:

rback --repo linxhome --include "/home/oldname/.config/fontconfig/fonts.conf /home/oldname/.config/geany/geany.conf /home/oldname/.config/gtk-3.0/gtk.css ..."

And restore them:

rsync -axS .../backup-folder/home/oldname/* /home/alias/

Fix permissions:

find /home/alias/ -user oldname -exec chown alias {} \;

Vim: Customize Installed Colorschemes

Disclaimer: This is a guide of how to override an already installed colorscheme’s highlighting. Though I’m not an expert on creating Vim colorschemes, I do know a few things. These are a few tips that can help.

Reasoning

If wanting to try an alteration to a Vim colorscheme it’s usually nice to work with the author of that colorscheme to improve it. But if wanting to try it first and road test it, this is a good way to do it. First:

Get the plugin

For this to work a plugin is needed. Arch Linux users can install it from the Arch User Repository: vim-plugin-aftercolors. This plugin enables the vim/after/colors directory where edits can be put that override an installed colorscheme values. The directory to do this in is located at ~/.vim/after/colors by default; create it if it doesn’t exist.

Editing

Overrides for the colorscheme resemble that which are in the colorscheme file itself. It is usually useful to read the actual colorscheme file to get ideas of what to do: authors sometimes leave notes and one can see all the settings. To try a new setting, put it in a file here that matches the colorscheme name (e.g. ~/.vim/after/colors/desert.vim). To learn more about how to set and test them in an easier manner, read the next section. When an edit is saved here, the colorscheme can be reloaded (if say in another terminal) by doing:

    :colorscheme desert

Screenshot from 2014-10-13 13:26:19

On-the-fly testing

Screenshot from 2014-10-13 18:36:22

To try new settings immediately, Vim has got built-in, on-the-fly, colorscheme alteration support (using the highlight command). List all the colorscheme settings with:

    :highlight

Screenshot from 2014-10-13 18:46:22

Or to see a specific setting (tip: have wildmenu enabled to see tab-completions):

    :highlight CursorLine

Screenshot from 2014-10-13 18:50:39

To temporarily change a setting, enter the value:

    :highlight Cursorline ctermbg=4

To know what color to use, the terminal color number will need to be obtained. Here’s a couple links with script and desciptions: link1, link2; alternately, my own script is available (it prints to terminal the color and number, though is meagerly tested): termcolor.

Partition base number order restoration (sda2 > sda1)

I decided to remove Windows. It was at the beginning of my hard drive, so I deleted the first partition, then I extended the second partition down to the beginning of the hard drive. I assumed that doing this operation (the second partition becomming the first, and it being moved the beginning of the drive) that it would inherit the base partition number (i.e. the kernel device name of sda1). However I’ve learned that disk utilites are generally uninterested in doing this, and instead preserve partition numbers. I believe the likely reason for this is because the designers know that some configurations define partitions (fstab and bootloader configs, for example) and are thence hesitant to alter a bootable configuration. I, however, like order. And thankfully, the order can be re-based.

The easy way

First thing to do is add a partition, afterward the partition table can be re-based.

Adding a partition

Disk utilities generally follow the pattern that when they create a partition they begin with the first available number; hence, a new partition should be named sda1. Here’s what my partitions looked like originally:

01-sda2-&-sda3

Since it’s quicker to create a partition at the end of the drive… add a partition to the end… and get sda1:

02-sda_2-3-1

Fixing the partition order

The only disk utilites I know that have this available operation are fdisk and gdisk. They have an option to re-order partition numbers (i.e. the first partition is one…). Boot from a install CD or rescue disk and run fdisk:

# fdisk /dev/sda
...
Command (m for help): p  # prints partition table
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1       625133568 625141759      8192     4M 83 Linux
/dev/sda2  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda3       608364544 625133567  16769024     8G 82 Linux swap / Solaris

Partition table entries are not in disk order.

Notice that sda1 Starts and Ends after the other partitions. From here enter the expert menu:

Command (m for help): x

And fix the partition order:

Expert command (m for help): f
Done.

Expert command (m for help): r
Command (m for help): p
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda2       608364544 625133567  16769024     8G 82 Linux swap / Solaris
/dev/sda3       625133568 625141759      8192     4M 83 Linux

The easy but hold-on-tight way

I’ve heard of someone doing this but haven’t tried it myself. What is done is that the partition table values is written down, the partition table wiped, then the partition table values are re-entered. Since you’re creating a new partition table from scratch the correct partition order will be created. This actually is perfectly safe to do.. if the values are gotten right. The partition table is written on the first sectors of the disk so the partition contents are perfectly safe. I’ve known this to be done before; however, I have not tried it so please use at your own risk. To learn more about this read: Fix MSDOS partition manually.

Configurations with partition definitions

Afterward, be sure to adjust the partition definitions in any configurations that have them. Also some bootloaders may store this value in the header region of the drive requiring a re-install of the bootloader.

Resources

rback – a generic, local, rsync-based, backup and restore script

rback

rback is a generic backup and restore script. rback wraps common functions of rsync to aggregate backup necessities. rback defines:

  1. The copy options.
  2. The source and destination directories.
  3. The files, folders… to include or exclude.

rback is repository-based to allow for multiple backup types (like full system backups, configurations…). It is only for local backups (i.e. the same computer that it resides on). Additionally, rback includes a diff method for working with text files.

Usage

rback - a generic, local, rsync-based, backup and restore script
  -r, --repo    - repository select                     : -R repository new
  -i, --include - include list add files, folders...    : -I include list edit
  -e, --exclude - exclude list add files, folders...    : -E exclude list edit
  -x, --xecute  - execute a: restore, backup, or diff
  = overrides  =
  -c, --confdir - configuration dir. from livecd, e.g.  : -C configuration edit
  -s, --srcdir  - source directory,  alternate specify
  -d, --dstdir  - destination dir.,  alternate specify
  -j, --justdo  - no confirm

For more information, RTFW (read the fun manual). :)

gurl – a curl general download wrapper

Because I don’t need another download program (and sometimes I find it not installed) I built this:


#!/usr/bin/bash
# A curl general download wrapper
# -l : redirect automatically
# -O : output filename is remote name
# -# : progress bar
# -w : (--write-out) print filename
# -A : user agent
#    : resume difficult (wget -c, better): http://tinyurl.com/7umwyl3

for u in "$@"do
  curl -l -O -# -w "%{filename_effective}\n" -A "Mozilla/4.0" "$u"
done

And it looks like this:

# gurl http://.../archlinux-2014.09.03-dual.iso
###############################                                           43.4%

WTFM (Write the Fine Manual) with Pod2man text-converter

Todd Partridge (Gently):

Post before was a jetsam, added a bit and touched-up.

Originally posted on Linux Tidbits:

Note: This is a guide from a lightly-proficient manual writer that’s targeted for beginning users: it’s formatting method is easy and conversion method is basic. This method may also be helpful for those that use github because it has rendering support for this method. For a more traditional approach, nixCraft has an article for that.

Because it was the authors first effort to write a man page, talk was that it was good to use Pod2Man. Pod2man is an application that converts text using Plain Old Document (POD) formatting to traditional manual (man) pages. POD markup is easy to do and pod2man is conveniently pre-installed on most Linux distributions (as it is part of the Perl package).

An example

To get a good idea of what to do, here is a basic example demonstrating the formatting (of a fictitious program dr-smile):

 dr-smile - output platitudes to…

View original 467 more words

Gentoo Linux Tidbits

Todd Partridge (Gently):

Updated bash script and generally

Originally posted on Linux Tidbits:

I’ve been using Gentoo for about two years now and I took notes on managing my box. These are those notes. If you’re interested in installing Gentoo take a look at Gentoo Quick Install.

Update: bash script

This section is an addition. I’ve since created a bash script that does many of the functions and make reading the rest less necessary. The script is self-explanatory: link.

About Portage

Gentoo Linux uses a package management system called Portage. Portage offers one of the most extensible and customizable package systems available in Linux.

System Update

Update all packages on the computer. This process involves: syncing Portage, creating a text file to review updates, updating the system, merging new configuration files, remove orphaned dependencies.

Sync the portage tree

emerge --sync # or
eix-sync      # preferrable for faster searches (eix search)

Examine update before install

emerge --pretend --verbose --update --newuse --deep @world…

View original 806 more words

Follow

Get every new post delivered to your Inbox.

Join 52 other followers