fdupes – Removing Duplicate Files (Linux)

The Problem

Thousands of duplicate files that you can’t possibly imagine going through and deleting on your own.

The Solution

The wonderful fdupes command.

How to Install

sudo apt-get install fdupes

The Process

I had just transfered about 2500 songs form external HD to my Linux machine. I had another external drive with about 3000 other songs (mostly duplicates). I copied both sets of files to my Linux machine assuming that I would be able to skip over the duplicates.

After they had completed transferring to my machine I realized they had all been duplicated!!!

I did some searching around and found out about my new best friend, fdupes.

How to Use

The following will give you a list of the possible options, and is very well written:

fdupes --help

You can do a recursive search without deletion by doing the following:

fdupes -R

I suggest doing this before you decided to “bite the bullet” and delete all your duplicates, because you just never know.

Once you feel comfortable with what it has determined to be a duplicate you can run the following command to take care of business:

fdupes -R -d -N ~/Some/Directory

  1. -R – Do a recursive search
  2. -d – Delete the files
  3. -N – Do not prompt for choices (if your impatient like me)

 

This won’t solve all of you problems, but it will certainly take care of a good chunk of it. For me it removed over 1500 duplicate files.

Enjoy!

Adding Git Branch To Bash Prompt (Debian)

The Problem

Not knowing what branch you are currently in when browsing a local git repository.

The Solution

Adding your git branch name to your Bash prompt (if it is a git repository), by editing your .bashrc file.

The Process

I was getting sick of being in the Bash terminal and not being able to see what git branch I was currently in. After browsing some forums, here is how you can add you current git branch to your Bash prompt.

Open up your .bashrc file, which is in you home directory. It is a hidden file, so you may need to show hidden files. I put it in my local .bashrc file so that it wont be overwritten on an upgrade.

You need to force bash to use a color prompt, by uncommenting the following line:

FORCE_COLOR

Then you will need to add the following code to your .bashrc file, you can replace any of the duplicate code that already there:

# Add git branch if its present to PS1
parse_git_branch() {
     git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/(\1)/’
}
if [ “$color_prompt” = yes ]; then
     PS1=’${debian_chroot:+($debian_chroot)}\[33[01;20m\]\u@\h\[33[00m\]:\[33[01;35m\]\w \[33[01;31m\]$(parse_git_branch)\[33[00m\]\$ ‘
else
     PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ‘
fi

Thats it!!!

Your prompt will now go from this:

NO_GIT_PROMPTpng

To this, when you in a git directory (notice the pl branch):

GIT_PROMPTpng

For more details, I found this info on the following site:

http://www.leaseweblabs.com/2013/08/git-tip-show-your-branch-name-on-the-linux-prompt/

Example Vim Settings File (.vimrc)

Vim

In short Vim is a text editor that can be both used on a UNIX command line or via it graphical user interface. It is a free and open source software written by Bram Moolenarr.

Why Use Vim?

I recently started using Vim because its something I have wanted to learn for a few years now. The reason why I finally decided to give it a shot is because its so easy to customize. You can customize nearly every aspect of the application that you want through the .vimrc file. Vim also has many open source plug-ins that are being actively developed, and are all available up on GitHub.com.

Pathogen

Pathogen makes it extremely easy to manage your plug-ins in Vim.

You can grab it from GitHub, instillation instruction are also on GitHub: https://github.com/tpope/vim-pathogen

you can see how to invoke Pathogen in the .vimrc example at the bottom of the post.

Plug-ins

Plug-ins can be easily installed using git, or simply extracting the plug-ins zip folder into Vim’s bundle folder.

For example, lets say you want to add SuperTab to Vim.

  1. First change to the bundle directory:
    1. cd ~/.vim/bundle
  2. Use git to clone the contents from GitHub in the bundle folder.
    1. git clone https://github.com/ervandew/supertab.git

Thats it! You now have a new plug-in.

This is my bundle directory:

example_bundles_folder

Favorite Plug-ins

  1. NerdTree
  2. SuperTab
  3. Syntastic
  4. SnipMate
  5. Surround

.vimrc Example!

The following is a .vimrc folder that i started working on the other day.

You can copy this into your .vimrc folder.

If you don’t have one yet, just make on in your home directory and copy the following:

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => Pathogen

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
execute pathogen#infect()   

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => VIM Color Scheme

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

set t_Co=256                      “Enable 256 Colors in terminal
let g:solarized_termcolors=256    “Enables 256 color package

syntax enable            “Enable Syntax Highlighting
set background=dark      “Enable Dark Color theme
colorscheme solarized    “Enable the Solarized color theme

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => VIM Global Settings

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

” Lines
        set number                        ” line numbers
        set linebreak

” Command Line
        set showmode
        set showcmd
        set cmdheight=1                    ” command line one line high
        set ruler                        ” show the line number on the bar

” Tabs
        set cindent
        set autoindent smartindent        ” auto/smart indent
        set smarttab                    ” tab and backspace are smart
        set tabstop=4                    ” 6 spaces
          set shiftwidth=4                ” Size of indent
        set softtabstop=4                ” Spaces and tabs uused to simulate tab stops at a width
        set smarttab                    ” tab and backspace are smart
        set expandtab                    ” expand Tabs to spaces

” History
        set scrolloff=5               ” keep at least 5 lines above/below
        set sidescrolloff=5           ” keep at least 5 lines left/right
        set history=200
        set undolevels=1000           ” 1000 undos
        set updatecount=100           ” switch every 100 chars

” File Types
        filetype on                   ” Enable filetype detection
        filetype indent on            ” Enable filetype-specific indenting
        filetype plugin on            ” Enable filetype-specific plugins

” Menu
        set wildmode=longest:full
        set wildmenu                  ” menu has tab completion

” Other
        “set nocompatible              ” vim, not vi
        set cmdheight=1               ” command line one line high
        set noerrorbells              ” No error bells please
        set autoread                  ” watch for file changes
        set lazyredraw                ” don’t redraw when don’t have to

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => VIM Search Settings

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
set incsearch                 ” incremental search
set ignorecase                ” search ignoring case
set hlsearch                  ” highlight the search
set showmatch                 ” show matching bracket

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => VIM Backup Settings

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
set backup
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => VIM Spelling Settings

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
if v:version >= 700
  ” Enable spell check for text files
  autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en
endif

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

”    => Key Bindings

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
” Allows for (shift + tab) to unindent
imap <S-Tab> <C-o><<

” Changes (shift + :) to ( ; ) to get to command line
nore ; :
nore , ;

 

Black (Blank) Screen After Closing Laptop Lid (Or Suspending/Hibernating Laptop)

The Problem

After closing (which suspends and locks your OS) your laptop lid in a Linux environment, your laptops screen turns black(blank) and will not turn back on until your system is restated.

The Issue

A bug in the kernels open source GPU drivers for AMD Radeon.

The Solution

Use proprietary drivers to solve the problem.

My Graphics Card

My graphics card is a terrible Radeon HD 7660G. You can see your graphics card by using the following command:

lspci -v

Which will give something similar to the following (with a bunch of other info):

graphics card

The Process

After a fresh install of Xubuntu on my laptop I noticed that when I closed my lid, and then opened my lid, the screen would remain black(blank) until I restarted my system again.

I attempted manually putting my laptop into a suspend or hibernate mode and was able to re-produce the problem.

I also tried putting my laptop into a locked screen instead of sleep or hibernate mode when the lid was closed. This did NOT reproduce the problem.

I started to notice that when my laptop was connected to an external monitor, that would start up just fine, but the laptops monitor would stay off.

I spent the better part of two hours looking through several help forums to find an answer to this issue with absolutely no luck whatsoever.

I then noticed that on startup, when both my laptop screen and second monitor worked, that the screen went through several disorienting stages of random pixel colors and screen stretches before my desktop environment was loaded, which lead me to believe that my GPU drivers could be the issue.

The Steps

  1. I went into my settings manager.

    • Went into “Additional Drivers” section.

      1. Selected the proprietary driver seen below.

      2. Let Linux install the driver.

add_driver

Thats it! After installing these drivers and rebooting I was able to suspend my computer and startup again with no issues. I also noticed a substantial increase in speed, and better aliasing around the corners of windows.

I was also given the software to manage my drivers and pick advanced settings for 3D rendering which is very useful.

Snipping Tool – Linux

The Problem

I wanted a snipping tool similar to the one found in windows, as I use it all the time.

The Solution

Shutter!!! Heres the website: http://shutter-project.org/

The Process

If you want to install shutter on your computer, just open up your terminal and enter the following command:

sudo apt-get install shutter

I find shutter to be much more usable and feature rich application than the Windows snipping tool.

 

XFCE Bind Windows Key (Super L) To Application Menu (Start Menu)

The Problem

I’ve decided to try XFCE desktop environment for Ubuntu, otherwise known as Xubuntu. I love the light weight environment, however, as a windows user i also like my application menu to pop up when using the “Windows Key”.

The Solution

Binding the Windows Key (Super L) to the application menu command.

The Process

Go to your application menu and type in:

“settings”

Click on Setting Manager, which should give you th following:

Settings Manager

Notice the highlighted keyboard settings option? Click that now.

Now select the Application Shortcuts Menu:

App Shortcuts Menu

Click the Add button and select the following Command:

command window

After hitting open, hit okay and record the shortcut keys you want to use, in my case I used the Windows Key (Super L).

record shortcut

Its that easy!!