Monday, May 14, 2012

Mounting a USB device

ASSUME:
Command line knowledge
How to get to be a root user

Despite all the promises, Linux often chokes when it comes to mounting a USB device such as a camera, phone, etc, it often chokes and its frustrating not knowing a way to get it to work.  Here it goes:

FIRST:
You need to be a root user to get this to work.  Often times that just means SUDO but you can also use SU as well.  If you type SUDO, type your username

(e.g. SUDO foo)...or whatever your name is.

Type in your normal password and you're a root user.  SU works the same way but you don't need to type a username...just SU (super user in other words) and you need to know the ROOT password to do it.  Most distros are going the SUDO route so chances are try that.

SECOND:
lsusb  (list USB devices...linux people hate to type)

This will just ensure you have a USB device in there. Look for the term 'usb in the list.

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 004 Device 002: ID 045e:00dd Microsoft Corp. Comfort Curve Keyboard 2000 V1.0
Bus 004 Device 003: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 001 Device 006: ID 22b8:70c6 Motorola PCS

In this example, you'll see the USB-2.04-Port HUB.  Ya, that looks about right and this tells us that USB is working. 

You could also type:

lsusb | grep USB

This would filter out the list to only show anything with USB in the name.  Don't ya love greg!

THIRD
Now that we KNOW we have a USB device, let's see what the drive is that mounts it.  Fortunately, we have a miracle command called DMESG.  This lists all the messages recently printed.  Naturally we want the find any USB devices. 


dmesg (let it scroll past you.  We want the end of the list...NOT...anything else.


[ 2432.904237] sr 8:0:0:2: Attached scsi generic sg6 type 5
[ 2432.914538] sd 8:0:0:1: [sde] Attached SCSI removable disk
[ 2432.918523] sd 8:0:0:0: [sdd] Attached SCSI removable disk
[ 2435.563830] sd 8:0:0:1: [sde] 15572992 512-byte logical blocks: (7.97 GB/7.42 GiB)
[ 2435.565942] sd 8:0:0:1: [sde] No Caching mode page present
[ 2435.565950] sd 8:0:0:1: [sde] Assuming drive cache: write through
[ 2435.570814] sd 8:0:0:1: [sde] No Caching mode page present
[ 2435.570820] sd 8:0:0:1: [sde] Assuming drive cache: write through
[ 2435.573677]  sde: sde1
[ 2441.705601] sd 8:0:0:0: [sdd] 9050112 512-byte logical blocks: (4.63 GB/4.31 GiB)
[ 2441.707717] sd 8:0:0:0: [sdd] No Caching mode page present
[ 2441.707720] sd 8:0:0:0: [sdd] Assuming drive cache: write through
[ 2441.712716] sd 8:0:0:0: [sdd] No Caching mode page present
[ 2441.712718] sd 8:0:0:0: [sdd] Assuming drive cache: write throug




NOTICE: the 'removable disk.  Ya, that's what we want.  In this example we have sdd and sde telling us that there are two drives associated with the device.  We'll mount both.

Now, on some distro's they create a /media directory and you mount things there.  The default is always /mnt but honestly you can mount it anywhere.  I tend to use /mnt but its up to you.

mkdir /mnt/FRED
mkdir /mnt/FRED2

mount /dev/sdc /mnt/FRED
mount /dev/sde /mnt/FRED2

HU???

Well, easy.  mount is the command that tells us to mount the device.  It takes two parameters.  The first is the source and the second is where you want to mount it.

/dev/sdc comes from dmesg and /mnt/FRED is the directory (folder) I created to mount the device.  Ya, Fred isn't too original but you can come up with something more original.

That's it.  You should now see the data in /mnt/FRED and /mnt/FRED2

I tend to just cd into that directory (I'm not covering cd here) but you can use a file manager such as nautilus if you want.


Sunday, May 13, 2012

Kernel Parameters

ASSUME:
This is advanced so no beginners for this one.
How to edit grub to modify the kernel parameters
Know what a kernel parameter is:


Editing the kernel is one thing but modifying boot options is another.  In this entry, we're going to modify some kernel parameters that are really useful -- especially when headaches arrive. 
In Grub1, or Grub2 you are allowed to edit the Kernel parameters by simply modifying the line that launches the kernel.



(Yes I know it wraps to the next line...sorry
kernel        /vmlinuz-3.2.0-23-generic-pae root=UUID=65c84575-96be-4380-b4d8-1b1d6292816d ro

This is a typical line for a kernel in the grub menu.

kernel - saying we have a kernel
where to find the kernel - /vmlinuz-3.2.0-23-generic-pae root=UUID=65c84575-96be-4380-b4d8-1b1d6292816d

ro - make it read only...handy

Anyway, here are some items you can place to the right of that line to make it more functional.

quiet - 
I don't like this but its typically found to display displaying the bootup process.

splash -
 throw up a splash screen which I don't like either.

text - 
VERY handy.  Boot to text mode to avoid autoloading the graphic screen (GNU, XFCE, etc.)

nomodeset
Some distros (Ubuntu in particular) make the text screen a huge tiny size.  If you just want 80 * 25 for the size, make this option available.
NOTE: For Ubuntu, if you do that, you'll get one UGLY font.  Do this>

dpkg-reconfigure console-setup

check VGS not FIXED and you'll get a nice clean font.

noacpi, pci=noacpi
These are two separate options but essentially work on the same idea.  If you are having hang problems with an operating system, try this option(s).  It disables polling of the PCI bus for interrupts.  It can stabilize a system.  Treat this as a diagnostic.  If it works after this, chances are your BIOS is a problem.  Upgrade the bios.

That's it.

Wednesday, May 9, 2012

Smurf bug in Adobe

If you:

(a) Have the latest Adobe Flash player plugin
(b) Have the proprietary NVidia driver

You will see blue people due to a hue problem with the flash player. 


In short, try this:

sudo add-apt-repository ppa:tikhonov/misc
sudo apt-get update
sudo apt-get install libvdpau1
 
 
The patch is located here:
 
http://lists.freedesktop.org/archives/vdpau/2012-May/000022.html
 
This is a patch that works around the adobe flash problem. What is the problem????
 
Read this link in its entirety.
 
http://askubuntu.com/questions/117127/flash-video-appears-blue

Sorry this is so short but there are only so many hours in a day.

 
Try another link:
http://www.nvnews.net/vbulletin/showthread.php?t=177380

Monday, May 7, 2012

Install Grub2 from a LiveCD

KNOW:
Command line basics
chroot
grub

You would think that installing Grub...or GRUB2 from a LiveCD will be an easy task -- think again.  There is a lot to know so let's get to it.

1) Boot to a liveCD.  Most graphic LiveCD's take 20 years to bootup -- Ubuntu being a great one for that but you can get text only LiveCD's so look for em.

2) Run terminal.  You need to get to a terminal to make this work.

3) We're now going to make the installed version of linux work instead of the LiveCD. This is tricky so let's get to it.

(a) you MUST know the partitian for your boot (/boot) and your mnt (/) locations.
In this example, we're going to use /sdb6 for our root (/) and /sdb1 for our boot.  Most installations don't separate the two but I'm giving you the extreme example.

sudo /mnt/sdb6 /mnt

Here we mount the entire partitian to the /mnt directory.

sudo /mnt/sdb1 /mnt/boot

(IF your boot partitian is different, otherwise leave alone)

Now we're going to point three directories (/proc /dev /sys) to our new mount point.

mount -t proc none /mnt/proc
mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev  (the devices)
cp -L /etc/resolv.conf /mnt/etc/resolv.conf

The purpose of this is to simply avoid host name errors

chroot /mnt/ /bin/bash  (most critical)
env-update 
source /etc/profile 
export PS1="(chroot) $PS1"

NOTE:
cp /proc/mounts /etc/mtab

(use this if you plan to reinstall grub)

sudo grub-install /dev/sdb1

That should shove it on the boot of the drive.

 

Monday, March 19, 2012

Bad video display in XFCE fix from command line

BUG:

XFCE is kind of dumb. It doesn't back out of bad display setting such as 1280*1024 which, for whatever reason, you're card or monitor can't handle. Instead it leaves that whole crappy display up there for you to suffer with.  Here's how to fix it.

You would think that modifying /etc/xorf.conf would be your go-to center for changing the display settings from the command line in XFCE.  NO!

Nope, there is a profile saved with each user -- which I suppose has its benefits.  Here is where you modify it...get ready for a long path.

vim ~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml

Set the proper resolution in displays.xml.

Whatever it is, a safe choice is 800*600.  Then you can take it from there. 

I am also told that:

xfconf-query works but I've never found it useful.

Monday, February 13, 2012

VIM - Search and Replace

Assume:
You know some VIM.

VIM has an amazing and daunting search and replace command but we're going to ignore most of it and show you the basic search and replace. 

The Search/Replace command is activated with the command mode (:).  Incidentally, the command mode actually triggers ex which is the command line editor in Unix/Linux.  Ex was the grandfather of Vim (or actually Vi).  Ex was the main reason why so many people wanted to burn their computer to the ground.  It's a line editor which means you only see one line at a time.  In the DOS world, it was Edlin (edit a line).  I actually used Edlin once...notice the Once!

 Anyway, to activate search/replace you actually do (substitute -- which is the actual name of the command). 

:s


That triggers the search replace command and does nothing since you've told it nothing.  The basic thing it does is:

:s/search text/replace text/

So
:s/fred/bob/

will search for fred on the current line and replace it with bob.  I know not very exciting.  VIM can get really complex when you start specifying line numbers in searches but what we really want to start of is a global search and replace with a prompt.  That's what every single editor does on the planet. Here's how.

:%s/search text/replace text/gc

%s says all lines.
/g means global and that means do every single replacement on all lines -- not just the first time we find it (ya like that's useful right?)
/c means prompt you for the replacement.


:%s/fred/bob/gc

Will replace every instance of fred with bob in the entire document with a prompt warning.  (say y or n and ignore the rest for now).  That's about as basic as it gets.

Now, I'm going to give you one more idea before we depart.  Ever had an instance where you want to do a global search and replace BUT on only certain conditions.  For example, I want to replace every instance of Fred with Bob but only if the last name is Sampson.  Hmmm...can't be done on any editor I know...but VIM is NOT just any editor is it?

:g/Sampson/s/Fred/Bob/gc
 
 
In other words, globally search for Sampson but then search next to Sampson for Fred 
and replace it with Bob. Pretty neat hu!
 
 
That's about it.  Hope you enjoyed!!! 

VIM - Command mode

Assume:
You know VIM basics.


Most people poking around in VIM don't realize that the command mode (typing a : or a colon) can really lead to some powerful features.  Now did you know there are several commands that are of great use to VIM available in the command mode.  Here are my favorites.

Directory Listing (:Ex)
That's right.  You can get a directory listing of the current directory or anywhere you want with Ex -- think Execute directory.  Once you execute that you can get a directory listing.  This goes great with the tab command.

:tabnew | :Ex

This will create a new tab (see my tab blog) and give you a directory listing.  Notice the '|' pipe command.  That allows you to string two commands together.

Shell (:sh)
Ever wanted to execute a command from the shell without leaving VIM.  No problem.  Execute this command (sh) and you can get to a shell.  NOTE, just don't load VIM while you're in the shell.  Type quit to get back to VIM. 

Execute a command (!)
Ever wanted to just execute a command instead of a shell.  Use bang (!)

:! ls

That of course is the famous list command.


Quit all :qa
You know about (q) and (wq) and perhaps q!) but did you know about (qa).  That means quit all and it dumps you back to the prompt exiting all files.  Please note that it will prompt for saving the file.

MISC (:q, :wq, :q!)
Just in case, we'll be complete.
q -> means quit
wq -> means write current file and quit
q! -> means don't save the file even if there are changes and quit

There you go.  Not too bad a lesson right and don't forget the tab commands.

Tab commands (:tabnew, :tabn, tabp, tabn (number)
Just as a review...
:tabnew - opens a new tab
:tabn - next tab
:tabp - prior tab
:tabr - rewind to first tab
:tabl - last tab
tabn (number) just to a tab in the list.


Goto line number (: #)
Ever wanted to jump to a line number.  No problem.  Just literally type the line number.
:50 - go to line 50
:20 - go to line 20

That's it for today.