Jul 9, 2016

Chrome Browser Freezing Up Your Linux Box? Here's A Workaround:

Being an absolutely avid GNU/Linux user, I am always very much enjoying my technological freedom!

In fact, switching to GNU/Linux is among the better choices I've ever made, career-wise and from the standpoint of weilding the cutting edge when it comes to Technology! Get Yours!

That said, I use two web browsers on my Linux machines: Google's Chrome and Mozilla's Firefox.

The thing with using Chrome on GNU/Linux, and it's good and a bad thing - is that the Adobe(tm) Flash plugin is integrated into the Chrome. So until all Flash content gives way to HTML5 content on the web, Chrome gives me the most functionality for the current Internet.

Google's Chrome is an awesome an powerful browser that's based on the Open Source Chromium project. This is an awesome project that helps to provide the most access to the web, from all sorts of devices and operating systems - it's cross-platform-compatible.

Google Chrome is awesome, but one thing I've noticed, is that since Chrome will launch extra processes as necessary to handle additional tabs in the browser, the browser can end up having a very large memory footprint on the machine. On several of my Linux boxes, this memory consumption by Chrome, seems to have caused an issue where the machine will actually lockup from being out of memory.

When the going gets tough, Linux is infinitely configurable! The user is in charge! So after looking around for a way to manage the issue where Chrome is eating up all of my system's memory and locking up the box, I found a blogpost entitled 'Automatically kill process using too much memory on Linux' by Jon Jensen on blog.endpoint.com - accessed 7/9/2016, that seems to have helped me solve my issue.

Mr. Jensen's blog post mentions a Perl script that is setup in a crontab to run every minute and kill off any process that uses too much memory. The script provides pretty much what I need to control my Chrome from running away with the memory on my system and locking up the machine.

After doing some testing, what I realized with the Chrome memory usage problem, is that due to the fact that many chrome processes are launched with the browser, we can't just watch for one process to eat up a large amount of memory and act accordingly. Instead, we need to look at the overall total usage of the several Chrome processes that will run to support multiple tabs in Chrome.

For instance, in a test, I have 7 tabs open in Chrome, and currently there are 10 chrome processes showing on my Linux machine:


Another thing I noticed is that with those 10 chrome processes, they are using over 2GB of the 8GB of RAM I have on my machine currently.

So here's the script I created to kill off some chrome processes when the overall memory usage from them is too large. This script is based on the example script from Mr. Jensen's blog post above. Note: The script example below will kill off chrome processes when total usage of system RAM by chrome is over 7.5GB, because I have 8GB of RAM installed. If your system has a different amount of RAM, adjust the value for $numMaxByteUsage accordingly. For example, if you have 2GB of RAM installed, I'd suggest setting something like this - $numMaxByteUsage = 1_610_612_736 in the script below.



Note: You then can setup a crontab to run the script every minute. In this case, if you're browsing along and chrome starts eating up all your memory, the crontab+script will kill off any chrome processes after reaching the threshold noted in the script. See '$intRamUsed' setting, which is shown as byte-size.

To run the script, you may have to install the supporting Perl package to inspect system processes first (e.g., if you get error 'Can't locate Proc/ProcessTable.pm in @INC (you may need to install the Proc::ProcessTable module'):

Also, you'll want to add the script to run in a crontab every minute. Here's the example crontab entry for root(sudo crontab -e) in my case (sudo crontab -l):


To test, I opened up about 60 tabs in Chrome(see 1st pic below). I then ran the script above to output the total memory used by chrome. As you can see, the usage reached about 7.5GB of RAM, then the script executed a command to kill some chrome processes. This caused a few tabs to go "snap", but the rest of the browser tabs continued working(see 2nd pic below).

Lotsa tabs to use all my RAM!
Totalrss gets to around 7.5GB, then chrome processes start getting killed

Mar 14, 2016

How To: Ubuntu 16.04 GNU / Linux - Netgear Wireless AC Adapter AC600 ( AC6100 ) Dual Band

Another GNU/Linux adventure. This time with Ubuntu GNU/Linux 16.04, kernel - uname -r - 4.4.0-12-generic.

So I went shopping at my local Walmart (TM), and picked up this Netgear (TM) Wireless AC Adapter AC600 (A6100) Dual Band USB wireless adapter and brought it home to install in my GNU/Linux rig.

Plug it in and nothing... No wireless connection detected!

Why does this still happen! The year is 2016, why do we still have to manually setup wireless adapters for GNU/Linux? Oh well, good honest CLI training for the users to understand their new system I guess.

So, as it turns out, the driver for this nice little USB wireless adapter is not automagically installed with Ubuntu 16.04 GNU/Linux. The purpose of this post is to help you get this adapter working.

First, follow the instructions below to ensure your new netgear wireless adapter matches the hardware in this post.

When you run this command in the terminal(ctrl+alt+t):
$ lsusb|grep -i wireless

You should see something like this:


If your hardware matches the above (RTL8811AU) , see the instructions below for manually building, installing, loading the wireless driver module.

Ah, where to to get the driver! No worries, Michal Ulianko - @Grawp, on github.com has us covered! Thanks for your contributions to Open Source Michal!

To get this Netgear AC600 adapter working, you're going to have to roll up your sleeves and follow these detailed instructions:

Preparation for building from source, run these in the terminal:
Note, you will have to have your computer connected to the Internet to run the commands below, say via the Ethernet, or another connection.

1.) $ sudo apt-get install linux-headers-generic build-essential git -y 


Note: for the above command, you will have to enter your password, then hit enter key (notice - it will not show your typing).

2.) ~$ mkdir wireless_driver && cd wireless_driver

3.) ~/wireless_driver$ git clone https://github.com/Grawp/rtl8812au_rtl8821au.git

4.) ~/wireless_driver$ cd rtl8812au_rtl8821au

5.) ~/wireless_driver/rtl8812au_rtl8821au$ make
Note: the process from #5 above may run for a time, have several lines of output, and should end with something like 'make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-12-generic'... no errors.

6.) ~/wireless_driver/rtl8812au_rtl8821au$ sudo make install

7.) ~/wireless_driver/rtl8812au_rtl8821au$ sudo modprobe 8812au


Voila! Driver loaded, now use the Network manager applet to select and connect to your network (see pic below):


















Great speed from this adapter - 434 Mb/s !



Hope this helps you get connected!

Cheers!


Shannon VanWagner
03/14/2016

Jan 9, 2016

How to fix slow video in Supertux 0.3.4 (FOSS game)

Supertux2, is a fantastic free open source ( FOSS / GPL ) 2d side-scroller game, similar to the Super Mario Bros variety. My children have been playing this awesome game for years.

This awesome game is available in most GNU/Linux distros via their software package-management systems. It's also available for other OSes.

In the case of the Debian-based GNU/Linux, the packages are available for the previous version of Supertux (sudo apt-get install supertux-stable), and Supertux2 (sudo apt-get install supertux).

To learn more about Supertux, checkout the project page for Supertux is supertuxproject.org Thanks to all the great efforts from the Supertux team for this awesome game!

Supertux2 is the newest of the Supertux games and is fabulous. However, the Supertux2 game appears to have a bug where the "auto" selection of video rendering can result in very slow behavior from the game.

You can check the video setting for Supertux2 from the terminal(CTRL+ALT+t) with something like this:
$ grep 'video \"' .supertux2/config
 (video "auto")

Note: The 'video "auto" setting appears to be the default setting installing Supertux2. And after some testing, this setting is what causes the game to be very slow in some cases.

To fix, try setting the video mode to "sdl" in the .supertux2/config file.

Here's how:
1.) Make a backup of your configuration:
$ cp .supertux2/config .supertux2/config.bak

2.) Update your Supertux2 video setting in the config file to use "sdl" instead of "auto" or "opengl".

$ sed -i 's/video\ "auto"/video\ "sdl"/g;s/video\ "opengl"/video\ "sdl"/g' .supertux2/config

3.) Check to ensure the change:

$ grep 'video \"' .supertux2/config
 (video "sdl")

4.) That's it! Launch the game and it should work as good as the original Supertux.



Shannon VanWagner
2015-01-09

Sep 16, 2015

Hulu.com - No Video Love For Linux Users(even paying ones); Modern Technology Fail!



(UPDATE 2-13-2016) - Hulu now working on Google Chrome browser again! Hulu folks - for us Linux users, please test before breaking Hulu on Linux in the future. Thanks for looking out.

Self-driving cars, the international space station, major stock markets, bullet trains, top supercomputers, billions of smart phones, animated movies, science, education, entire citties, and even the very Internet that we rely on for information and connectivity everyday. These are just a few of the amazing things that are brought to us thanks to the power of the GNU/Linux operating system!!

So why is it that hulu.com wouldn't test to ensure us GNU/Linux desktop users weren't blocked by their latest DRM/video-rendering update? C'mon hulu.com, I'm a paying customer - and hulu.com used to work just fine for me on my Ubuntu GNU/Linux systems.

Now when I try to view hulu.com, I'm presented with this problem and can't watch the videos at all:




To hulu.com's credit, it's not all their fault.. Adobe's flash sucks (especially in terms of Linux support), and Hollywood's endless push for Digital Rights Management technology makes it a miracle that any video content can be viewed online at all. That said, this is unacceptable for paying customers hulu!

There's an answer to this problem.. Netflix.com has already found it. Use open standards and HTML5 to deliver your content instead! Drop those arcane technologies that bind themselves to old technologies and lock-in systems.

So this is a callout to hulu.com - Please fix your site to work with Linux again. Thanks.

Update 10/16/2015: Thanks to the luanchpad.net PPA from  
Michael Blennerhassett, you can install the hal package then use Mozilla Firefox to view hulu.com. To enable the hal package, run these commands, then open hulu.com in Firefox to watch:
sudo add-apt-repository ppa:mjblenner/ppa-hal
sudo apt-get update && sudo apt-get install hal

Related linuxforums.com link


9/16/2015


Aug 10, 2014

How To Set Default Grub / kernel / boot option on Ubuntu GNU/Linux 14.04

Looking around on Google (or whatever one's favorite search engine); one can usually find everything they need in terms of tips for making GNU/Linux work optimally.

But sometimes, you just want to do one specific thing, and although the required documentation is available, it may be questionable because you can't figure out if the fix exactly matches what you need for your system.

Finding the fix online, along with too much information about how to implement it, is what happened in recent situation I encountered. A friend brought me his Gateway Laptop. The laptop was failing to boot (kernel panic) after some recent updates that were run. So I referred to my technical library, Google, and although I was able to find an answer, it wasn't immediately clear to how to implement the fix to my friend's specific situation. So for that reason, and for the reason of being able to quickly get of this jam in the future, I decided I would write up the specific steps that helped my friend out of his jam.

The problem: a kernel bug in the newest kernel that was running on his machine was causing kernel panic on startup.
The workaround: We needed to boot to a previous kernel version until a fix was released for the newer kernel. Furthermore, we didn't want to let the system accidentally boot into the newer kernel because it wasted time for us to exit the broken system and  have to go back through the steps to get to the older kernel for the workaround.

While I'm at it, I want to mention that (another thing) that's great about GNU/Linux is that you can choose to boot with a variety of different versions of the Linux kernel if you wish. This open capability enables you to easily transcend any kernel bugs that may affect your particular hardware, by being able to boot to whatever you want, and get back up and running! This type of openness with the system is the reason why I've switched to GNU/Linux and have been using it on all my computers for many years now.

So back to my friend's situation: He's running Ubuntu GNU/Linux 'Trusty Tahr' 14.04 and when he ran a recent update, it installed the newest available kernel. Let's just say it was kernel 3.13.0-32-generic, for the purposes of my examples below. With this newly updated kernel booting as default, my friend's machine would fail early in the boot process with a 'kernel panic'.

Since the machine was working perfectly before this latest update, we tried booting into an earlier version kernel. To do this, we would tap CTRL then SHIFT(but not together) repeatedly just as Linux is loading up, this would get us to the grub menu where we could select a particular kernel to boot with. The grub menu, if triggered, appears just after the machine shows the screen for the brand of the computer and the POST (Power On Self Test).

Let's walk through the steps to get to the menu for kernel selection on Ubuntu 14.04 so you can see how we began working around this issue.

1.) POST screen. This appears when you very first turn on your computer. Note: The image you see will vary depending on your specific computer maker.. It also may go by so fast that you don't even see it, so be ready to use the keyboard. Just at the end of this type of screen, start tapping back and forth between CTRL or the left SHIFT key to get the menu in #2 below.



2.) The GRUB menu with 'Ubuntu' as the default selection. We could press "e" at this prompt, and edit the Linux startup commands in grub, but unless we've memorized the specific text of the boot option we need, that idea may be difficult to implement on the fly. Instead, at this point we'll hit the down arrow on the keyboard to select "Advanced options for Ubuntu" (see next image):


3.) In this view, I've hit the down arrow on my keyboard to select "Advanced options for Ubuntu". I then hit ENTER to get all the options to boot to previous kernels that are still installed. Ubuntu keeps a number of previous kernels installed after updates, to help you if you ever have to fallback to an earlier version.


4.) Here's the menu with the Kernel selection menu. We want to boot to the 3.11 kernel because we tried and it's the one that boots without error for us. So we'll use the down arrow to move down to the 3.11 kernel (see next image).


5.) Here's the screen with the older kernel (kernel 3.11) selected, now we hit ENTER to boot the machine to that kernel, and when it boots, we give our colleagues a nice high-five because we were able to get the booting and running again! Go GNU/Linux! We've now learned about something that can be helpful to others that may encounter a similar situation.


So, in the case of my friend, once we booted to the previous kernel, his machine loaded up without issue.  So this is how we will work around the kernel issue. The next steps would be to file a bug (or add input to an existing bug) at launchpad.net to get the issue for the newer kernel fixed. The actual fixing of the new kernel will likely take time, but that's ok because we can use the workaround and still continue to enjoy our awesome Ubuntu GNU/Linux system!

But how do we make our machine boot to a specific kernel for future boots until the problem is fixed, so we don't have to worry about the system failing to boot? There are a few ways, but one way is to add the previous kernel as the default boot option via the /etc/default/grub file.

I'll explain how to do that below..

First of all, as seen in #2 above, Ubuntu 14.04, it's noteworthy to point out that Ubuntu now nestles the previous kernel boot options under a 'submenu' named "Advanced options for Ubuntu". In a separate, more advanced subject, another thing that's new is that it's no longer recommended to use the label of a grub.cfg menuentry to set it as default because it may cause a problem if it contains special characters in it. So instead, we should use the value for "$menuentry_id_option" that appears in the menuentry we want to select for the default boot option.

Sounds pretty confusing right? It's actually pretty straight forward, save for a few more steps needed to make the edit to the appropriate file to affect the changes. We simply have to build the GRUB_DEFAULT= value using the $menuentry_id_option for the submenu, then add ">" (no quotes), then add the $menuentry_id_option for the actual kernel boot selection we want to boot to behind it. For example:

GRUB_DEFAULT='gnulinux-advanced-7ec5403e-7a25-47a1-bf0c-1a7c955dc590>gnulinux-3.11.0-19-generic-advanced-7ec5403e-7a25-47a1-bf0c-1a7c955dc590'

1.) So first, let's get the $menuentry_id_option for the 'submenu' named "Advanced options for Ubuntu". Hit CTRL+ALT+t to open a terminal and run:

grep submenu /boot/grub/grub.cfg 

Example output (with the "id" text we need highlighted):


2.) Next, we get the $menuentry_id_option for the 3.11.0-19-generic kernel boot entry that we know will work with my friend's computer and we highlight the id for it. Hit CTRL+ALT+t to open a terminal and run:

grep gnulinux /boot/grub/grub.cfg 


Example output (with desired value highlighted):




2.) In the Terminals where you ran the commands for #1 and #2 above, use your mouse to select the text after "$menuentry_id_option" (everything inside and including '  '  ), then we'll use CTRL+SHIFT+c to copy them from the Terminal (one by one) and paste them into /etc/default/grub to build our default entry, in another step below. Example values to be copied:

'gnulinux-advanced-7ec5403e-7a25-47a1-bf0c-1a7c955dc590' 
'gnulinux-3.11.0-19-generic-recovery-7ec5403e-7a25-47a1-bf0c-1a7c955dc590'

3.) Now, with new Terminal, we'll backup, then edit /etc/default/grub file, and then use the values from the first two terminals above to make the default entry for boot.
Make a backup of the file, to our home directory:

sudo cp /etc/default/grub ~


Now edit the file:

sudo vi /etc/default/grub

4.) Edit the default entry in your /etc/default/grub file so your system will boot to the previous kernel by default. Use your arrow keys (or h j k l ) to move to the line with "GRUB_DEFAULT=0". Hit Y to copy, then P to paste the line again. Next, use the keyboard arrow keys, or h/j/k/l to position your cursor in front of the lower "GRUB_DEFAULT=0", then hit i for insert mode, then type # in front of the line to comment it out. Hit esc to get out of insert mode, then position your cursor over the 0 in the upper entry of GRUB_DEFAULT=0, then hit x to delete "0". Now, hit A to insert after the end of the line with "GRUB_DEFAULT=". Now, you'll copy the value from Terminal in  step #1. above(highlight text, then use CTRL+SHIFT+c), then switch back to the current Terminal and hit CTRL+SHIFT+V to paste it in, then type ">" (no quotes), then copy the 3.11 kernel text from Terminal in step #2 above and paste it in after the ">".  Then hit esc again, then type ZZ or :wq to save/quit. Example (also see image below):
GRUB_DEFAULT='gnulinux-advanced-7ec5403e-7a25-47a1-bf0c-1a7c955dc590>gnulinux-3.11.0-19-generic-advanced-7ec5403e-7a25-47a1-bf0c-1a7c955dc590'


5.) IMPORTANT: Now that we have the default kernel setting in place in the /etc/default/grub, we must update our grub configuration for the changes to take effect:

sudo update-grub

You'll see something like this:



6.) Reboot the computer, then verify the system has booted to the new default kernel by launching CTRL+ALT+T to open a Terminal, then run the command to check the loaded kernel:

uname -r

The output from the command should show something like:

3.11.0-19-generic

In closing: You'll want to keep an eye out for kernel updates as you update your system. The reason is that once the newer kernel comes out, like the one with the appropriate update to fix the original problem that's outlined in this post, you'll want to revert the changes outlined in the post to let your system to boot to the default kernel again. Basically you'll just go into /etc/default/grub, place a "#" in front of your custom kernel specified in #4 above.

GNU/Linux rockin!! Get your Freedom on!!

Shannon VanWagner
08/10/2014



Jan 23, 2014

How to Install Virtualbox 4.3 + Resizable Guest Video Resolution on Ubuntu 13.10 GNU/Linux

While I really like the FOSS KVM (Kernel-based Virtual Machine), KVM can be just a bit daunting for the more GUI-oriented types.

So, for the newly experienced, I usually recommend they try Oracle's Virtualbox virtual machine software from virtualbox.org.

The Ubuntu repositories have Virtualbox available, but it is the older version. This post provides instructions for installing the newer Virtualbox 4.3 in your Ubuntu 13.10 GNU/Linux box. Also, I've outlined the steps needed to install the packages inside the guest Ubuntu 13.10 virtual machine and make the video resolution re-sizable with the window. These steps also enable the Ubuntu guest to have larger screen resolution or even fullscreen resolution.

For the purpose of this writeup, I use Ubuntu 13.10 GNU/Linux as both the HOST operating system, and the Virtualbox GUEST operating system. This posting assumes that you know how to install and configure Ubuntu GNU/Linux as the guest OS.

These first set of steps are used to setup your Host Ubuntu 13.10 with the newer version of Virtualbox, version 4.3. Open the terminal from the Ubuntu menu, or hit CTRL+ALT+T, then run these commands to install the virtualbox repository for Ubuntu 13.10 Saucy Salamander, and then install Virtualbox 4.3:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian saucy contrib" >> /etc/apt/sources.list.d/virtualbox.list'

sudo apt-get update && sudo apt-get install dkms virtualbox-4.3

If the above commands were successful, you should now be able to find Virtualbox in your Ubuntu menu. Launch it, then install Ubuntu GNU/Linux 13.10 into a virtual machine. Once you have logged in and completely updated the software packages for your Guest Ubuntu GNU/Linux machine, take a baseline snapshot of the Guest Ubuntu OS.

The next set of steps are run inside the Guest Ubuntu OS to add mouse pointer integration. These steps also allow larger, re-sizable, and fullscreen video resolution of the Ubuntu guest. Run these commands in the Terminal(**or in alternate run-level) inside the Ubuntu guest OS to install the baseline software building components:

sudo apt-get install build-essential linux-headers-$( uname -r ) dkms

I suggest taking a VM snapshot here, just in case things go wrong during the next steps. Next, add the Virtualbox repository and install the Virtualbox guest additions iso.

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian saucy contrib" >> /etc/apt/sources.list.d/virtualbox.list'

sudo apt-get update && sudo apt-get install virtualbox-guest-additions-iso

I suggest taking a VM snapshot at this point. Also, reboot the Ubuntu guest OS so the driver modules can load. After you've rebooted the Guest OS, re-open the Terminal and run the command below to install the final packages needed for resizing the Ubuntu Guest video resolution.

sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

Next, reboot the Ubuntu guest OS to allow the newly installed modules to load.

Voila, mouse integration should work, and you should be able to re-size your Guest OS VM window and the video resolution should change size dynamically.

**As an extra tip, if you ever need to enter alternate run-levels (alternate TTYs) in your Guest VM OS: simply replace
CTRL+ALT+F1|F2|F3|F4|F7
with
(host-key,e.g.,Right-Control-Key)+F1|F2|F3|F4|F7

As another extra tip, if your Ubuntu Guest seems to be rather slow because of Unity, maybe you can try the gnome-session-fallback interface instead. Get to it by clicking the Ubuntu symbol near your username on login. Here's how to install it:

sudo apt-get install gnome-session-fallback




Cheers!
Shannon VanWagner


01-23-2014


Oct 12, 2013

Ubuntu 13.10 - Enable "Control+Alt+Backspace to terminate the X server"

Having loaded up Ubuntu GNU/Linux 13.10 on my computer which previously ran the 13.04 version, I have to say that I am quite impressed with the speed improvements and polish this new version brings to this already awesome operating system!! Way to go Canonical and Ubuntu developers!!

One of the things I really love about GNU/Linux is the power I have to customize things in the system to my liking. Rather than force changes down your throat like the other operating systems out there, GNU/Linux gives you the power to choose!! You have the power!!

Usually, after installing the base system, I come back and tweak things a bit to my liking. After all, per the license - I already own this copy of Ubuntu GNU/Linux that's installed on my computer, so I might as well customize it to my liking as much or as little as I like!! This is what Freedom in computing is all about!!

Of course, the developers behind Ubuntu, have made it so I don't need to customize anything at all if I don't want to, and it's still a very easy to use this awesome Ubuntu GNU/Linux anyway!! But when I do want to customize,  I can do this as little or as much "tweaking" as my geek appetite calls for.

Something I always customize in my Ubuntu GNU/Linux, is having Control+Alt+Backspace "kill the session".  This makes it easy to jump out of my logged in session if I've launched something that failed or otherwise screwed things up so I can't operate in the current session.

In Ubuntu 13.04, the aforementioned option was a few short steps to being enabled. It was done by clicking the gear menu by the clock, then System>Preferences>Keyboard, then on the Layouts tab, then clicking Layout options, then under "Key sequence to kill the X server", putting a check by "Ctrl+Alt+Backspace".

In Ubuntu 13.10, it seems the option has been moved around again, because they've polished up the menus a bit more. But, unlike some other systems out there that don't let you easily change things around, in this Ubuntu GNU/Linux - we can still change this setting(and much more) rather easily. So here's how I enabled "Use Control+Alt+Backspace to terminate the X server?":

1.) Hit Control+Alt+t to launch the terminal

2.) Type or paste in the command below into the terminal, hit enter, then authenticate with your user password necessary (below is a one liner):

sudo dpkg-reconfigure keyboard-configuration

3.) Hit enter 5 times, or as necessary, to accept the already-set values for the keyboard settings and arrive at the screen to change the behavior for "Control+Alt+Backspace" (see picture above).

4.) At the screen that says, "Use Control+Alt+Backspace to terminate the X server?", hit the left arrow key to select yes, then hit Enter to save the setting and complete the kbd configuration.

Voila! At this point, if you hit Control+Alt+Backspace, you will be exited from your current session! Just make sure you save any open work before testing this out, as it will not save anything automatically.


User Customizations - Another reason to love GNU/Linux!! Get Yours!!

Cheers!
Shannon VanWagner


10-12-2013


Feb 2, 2013

How to install xrdp on Ubuntu 12.04 Precise Pangolin

I absolutely love a system that can stay connected! With Ubuntu GNU/Linux, there are many ways to get connected remotely to your computer and get your Linux on!

For instance, here is a list of several ways you can stay connected:
Desktop Sharing (built-in VNC, see help)

FreeNX (requires install)
NX Free (requires install)
ssh -X (requires install and local xserver)


The default "Desktop Sharing" functionality in Ubuntu 12.04 is good for some things, but since it's based on VNC, and doesn't have any additional layer for security, it's not a necessarily secure method for connecting to remote machines. Also, people trying to connect from their windows systems will have to obtain/install a vnc client to use for connection. This can be a problem in some environments.

This is where xrdp comes in. xrdp.org is free open source software that can be easily installed in Ubuntu 12.04 GNU/Linux machine via the package management system. Since it uses the RDP protocol, xrdp is a relatively secure method of connection. Other benefits are that your windows users can easily connect with their built-in remote desktop client mstsc.exe and your Linux users with rdesktop.
 
In this post I'm going to outline how to quickly install the xrdp packages and connect with mstsc.exe(windows) or rdesktop(GNU/Linux.

1.)  Enable the community repository in Ubuntu - click to open the "Ubuntu Software Center". Then, on the top menu(top of screen), click Edit > Software Sources > put a checkmark by "Community-maintained free and open-source software (universe)", then click Close.

2.) Update your sources and install xrdp using apt-get. Open the terminal with ctrl+alt+t, then type or paste these commands, hit enter, authenticate, then confirm to install the xrdp packages.

  sudo apt-get update && sudo apt-get install xrdp

Note: Depending on how quickly your machine can update the sources, the sudo apt-get update command may fail after closing the Ubuntu Software Manager because there may be a process running that is updating the sources already in the background. If this happens, wait longer, then try the command again.

3.) Add this special .xsession file entry into the /home/(username) directory you intend to login with (e.g., /home/shannon/.xsession) to improve performance by converting your session to ubuntu-2d:

  echo "gnome-session --session=ubuntu-2d" > /home/YOURUSER/.xsession

4.) Reload the configuration into the xrdp server process:

  sudo /etc/init.d/xrdp restart

That's it. Now you can connect to your xrdp host with ease from GNU/Linux using:

 rdesktop ip-or-host-of-your-xrdp-server


Or from windows, with:

  windows-key+R, mstsc.exe /v:ip-or-host-of-your-xrdp-server


Tip: If you find that you're having problems changing network settings via your xrdp session, it's because of the protection configured to secure the machine to console users only via policy-kit.

See this article for more information and a workaround:
http://ubuntuforums.org/showpost.php?s=d9ba0898e67cf91204ecc75f693ed4ed&p=10095159&postcount=3

Spoiler: Basically you're modifying all "no" values in the allow_inactive attributes to "yes" in
/usr/share/polkit-1/actions/org.freedesktop.network-manager-settings.system.policy


Cheers!
Shannon VanWagner

02-03-2013


Aug 3, 2012

Enable CentOS 5.8 GNU / Linux Authentication on Windows Domain

In case you should ever be finding yourself having to configure your CentOS 5.8 GNU/Linux machines to allow active directoy windows users to login to them, this post will help.

While there are a few ways to set this up, i.e., likewise-open (see beyondtrust.com), centrify (centrify.com), the built-in System, Authentication graphical controls in CentOS, etc., the method in this post focuses on touching just a few config files to enable active directory  authentication. K.I.S.S. is the way I like to roll.

Using the authentication methods below assume that you have already enabled services for Unix on your active directory server and that the users that would be logging in to CentOS have their Unix tab (on ad user and computers) populated with values.

The Authentication methods outlined here use LDAP and Kerberos. LDAP brings the UID/GID information (from the Unix tab in ad) for the user, and Kerberos provides for username/password authentication piece.

With the default install of CentOS 5.8, it's amazingly simple to setup authentication to your active directory for Unix-enabled ad users.

Here are the steps for enabling your CentOS 5.8 GNU/Linux computer to authenticate with active directory:

1.) Create a special user in active directory (e.g., ad-guest-01). Once you've created the user, add it to the group "Domain Guests", make it the Primary group, and remove all other group memberships (e.g., Domain Users should be removed).

2.) Make changes to the following configuration files on the CentOS 5.8 GNU/Linux machine as shown below:

##############################################################
#/etc/ldap.conf for connecting with Win-Server w/SFU Enabled #
##############################################################
base dc=yourcompany,dc=com
uri ldap://yourADserver.yourcompany.com ldap://yourADserver.yourcompany.com/
binddn ad-guest-01@yourcompany.COM
bindpw 
bind_policy soft
scope sub
pam_min_uid 1000
bind_timelimit 5 
timelimit 5
idle_timeout 3600
ssl no
referrals no
nss_base_group dc=yourcompany,dc=com?sub?&(objectCategory=group)(gidnumber=*)
nss_map_objectclass posixAccount user
nss_map_objectclass shadowAccount user
nss_map_objectclass posixGroup group
nss_map_attribute gecos cn
nss_map_attribute homeDirectory unixHomeDirectory
nss_map_attribute uniqueMember member
nss_initgroups_ignoreusers root,ldap


##############################################################
#/etc/krb5.conf for connecting with Win-Server w/SFU Enabled #
##############################################################
#  Tip: You can use predefined DNS names for your kerberos,
#+ ldap (ad) servers to make future ad dc hostname changes
#+ less painful.

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = YOURCOMPANY.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 forwardable = yes

[realms]
 YOURCOMPANY.COM = {
  kdc = yourADserver.yourcompany.com:88
  kdc = yourADserver
  admin_server = yourADserver.yourcompany.com:749
 }

[domain_realm]
 yourcompany.com = YOURCOMPANY.COM
 .yourcompany.com = YOURCOMPANY.COM

[appdefaults]
 pam = {
   debug = false
   ticket_lifetime = 36000
   renew_lifetime = 36000
   forwardable = true
   krb4_convert = false
 }


######################################################
#/etc/nsswitch.com for Win-Server w/SFU Enabled  Auth#
######################################################

passwd:     files ldap
shadow:     files ldap
group:      files ldap

#hosts:     db files nisplus nis dns
hosts:      files dns

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files     

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   files ldap

publickey:  nisplus

automount:  files ldap
aliases:    files nisplus


##############################################################
#/etc/pam.d/system-auth-ac for Win-Server w/SFU Enabled  Auth#
##############################################################
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        sufficient    pam_krb5.so use_first_pass
auth        sufficient    pam_ldap.so use_first_pass
auth        required      pam_deny.so

account     required      pam_unix.so broken_shadow
#The line below allows local user login
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     [default=bad success=ok user_unknown=ignore] pam_ldap.so
account     [default=bad success=ok user_unknown=ignore] pam_krb5.so
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok
password    sufficient    pam_krb5.so use_authtok
password    sufficient    pam_ldap.so use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
#The line below triggers creation of home-dir upon user first login
session     optional      pam_mkhomedir.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
session     optional      pam_krb5.so
session     optional      pam_ldap.so


If you want your windows users to be able to run sudo, run visudo as root, then add:

%Domain\ Users ALL=(ALL) ALL


Note: The above setting is just an example of how to add FULL CONTROL for the ad-based "Domain Users" to the sudoers file. Changes to the sudoers file can be more finely tuned to only allow certain programs. If user restriction is a concern for your situation, I suggest you research "sudoers" and find the more granular settings that are appropriate for your needs.

Speaking of security, something else to consider is that if the user can become root with sudo -s on the machine, they will then be able to su and be seen as that user as far as the local machine is concerned. You can force them to authenticate (even as root) by commenting the line below in /etc/pam/su, but if they are root - they can still change it back:
vi /etc/pam.d/su
#auth sufficient pam_rootok.so

That's it. Reboot your CentOS, then you should be able to login as your windows user on the box. Feel free to leave a comment below with any suggestions or questions.


Cheers!
Shannon VanWagner

08-03-2012



Aug 1, 2012

How To Install Clearcase 7.1.1 on CentOS 5.8

First of all, if you're going to have to use source control, get something FOSS - like git, or subversion, or mercurial, etc. Here's a great list on wikipedia.org

Otherwise, if you're one those poor bastards that are tasked(like me) with installing the less-than-FOSS IBM Rational Clearcase (c) (version 7.1.1) on the CentOS 5.8 GNU/Linux machine, you've come to the right place for some notes on a real installation.

Basically, IBM Clearcase does not include support for CentOS. To make things worse - the IBM installer will actually fail the install for "unsupported operating system" when installing on the non-supported operating system. As to why the IBM installer doesn't have the option to "try anyway" is beyond me, but since it doesn't, we will have to resort to other means.

Luckily, it is rather easy to workaround the "unsupported operating system" problem. To install Clearcase 7.1.1.1 on CentOS 5.8, we simply have to trick it into thinking that our CentOS is actually Red Hat Enterprise Linux. In this post, I'm providing an overview for how the installation process worked for me.

Disclaimer: This is an experimental procedure only. By using these methods, you accept full responsibility for any subsequent damages that might happen to your system by using these instructions.

And now for the installation details:

First, on the computer you'll use for testing Clearcase, install CentOS 5.8 GNU/Linux (32-bit version in this example). There are no special requirements to this step, except that upon your first login, you should run all system/security updates. After running the updates, you should reboot to ensure you are booted to the latest installed kernel.

Related terminal command for system updates:
yum update && yum upgrade -y


And now, let's get the system ready for the install of Clearcase 7.1.1:
Note: These commands assume you are running the terminal as root, use this command to become root:
su - 


Next, check to see if you are running the PAE kernel so we can decide which dependency packages to install for the Clearcase MVFS module build. Run the command below and take note of the result:
uname -r

Example result for running the PAE kernel:
2.6.18-308.11.1.el5PAE

Now, let's install the dependencies needed to build the mvfs module for Clearcase:

If you are having the PAE kernel:
yum install compat-libstdc++-33 \ 
gcc glibc-devel glibc-headers kernel-headers \
kernel-devel kernel-PAE-devel -y


If you are NOT having the PAE kernel (command above would work fine too):
yum install compat-libstdc++-33 gcc glibc-devel \ 
glibc-headers kernel-headers kernel-devel -y


In this step, we'll set up the trickery that is needed to mask CentOS system to mask itself as Red Hat for the installation of Clearcase 7.1.1:

First, open the terminal, and make a backup of your redhat-release file:
cp /etc/redhat-release /etc/redhat-release.original


Then, edit /etc/redhat-release as follows:
vi /etc/redhat-release

Insert this text:
Red Hat Enterprise Linux ES release 5

Save the file and close it.

Now, let's Mount the VOB storage folder on your clearcase server using NFS so the MVFS will be able to mount the VOB folder. To do this, create a mount point (directory):
mkdir /home/clearcase


Then, modify /etc/fstab to mount the clearcase folder you just created:
vi /etc/fstab

Add a line to mount the server files:
ccaseserver(or IP):/home/ /home/clearcase nfs defaults 0 0

Then, re-process the entries from /etc/fstab with:
mount -s


Then, test to ensure you can see the files on the server with this command (should not produce an error):
ls /home/clearcase


Unzip and install the IBM installation agent (installer version 1.3.3 for this example), cd into the dir, then run the install script:

unzip -d extracted agent.installer.linux.gtk.x86_1.3.3.zip

cd extracted

./install


Then, use the graphical interface to install the IBM Installer (Note: You should restart the installer with the button provided at the last step of the process).

Now for the install of Clearcase 7.1.1.1. From the IBM Installation Manager, click File > Preferences > Add Repository, then Browse to "Disk 1" dir of your Clearcase 7.1.1 installation files and add the diskTag.inf as a repository. Click OK as necessary to get back to the IBM Installation Manager screen, then click the install button to install Clearcase.

As for the installation steps, I used the defaults pertaining to my environment, except I also added the "ClearCase Full Function Installation" package, and I tested to ensure the "kernel source" build directory was accessible on the MVFS Module page. To test this yourself, run ls of the directory in the terminal. The result should be an existing directory with a list of files:
ls /lib/modules/2.6.18-309.11.1.el5PAE/build

same as
ls /lib/modules/$(uname -r)/build
for me.
If you get an error at this step, check to ensure the dependency packages are installed (per the step above).

If for some reason the MVFS module doesn't get built by the installer, you may see a message like "... albd_server MVFS module could not be found ..." when restarting clearcase with this command:
/etc/init.d/clearcase restart


If you experience the above error, you can try building and installing the MVFS module by hand with these commands:
/etc/init.d/clearcase stop
cd /var/adm/rational/clearcase/mvfs/mvfs_src
make
make install


Finally, to test that the MVFS module is installed and running, perform these commands:
/etc/init.d/clearcase restart

/opt/rational/clearcase/bin/cleartool lsvob

The result should list out your VOB directories with a * (to show mounted) to the left. Example:
* /vob_storage/MyVob.vbs



So, that's it. Hopefully something here will help someone with their setup. If you have any questions or comments, please leave them below.


Cheers!
Shannon VanWagner

08-01-2012



Jul 17, 2012

Fun with Bash Double Brackets, Regular Expressions, Case Matching, and Digits

After some quick searching and not finding the answer, I decided to write this up for my own reference.

My original inquiry was how do I form a double-bracketed if branch statement, using "=~" to check a variable against a regular expression for upper OR lower case of a specific search string in bash. After some working it out, I think I got it. See below.

For instance, in the example script below, the user is asked to answer yes or no, the value entered is then checked to "loosely" match a predefined value. In this case, yes/y (with any combination of case) will match the Regular Expression.

This example points out how to formulate your bracketed regular expression to match any variations in case (or even a single character answer, e.g., y OR n). There are differences with the bracketed use of regular expressions compared to how grep uses them, I'm finding.

Like, notice in the experimental script below, how single quotes are not used in the bracketed expression, and the "|" for the OR situation is not escaped with \. Also, with the example that checks for exactly 6 characters, no "\" are used to escape the curly braces.


#!/bin/bash

while [ 1 ]
do
    echo "Are you ready to get started? Enter: Yes|No"
    read result

    #Test the result for yes/no (or variation)
    if [[ "$result" =~ ^[Yy][Ee][Ss]$|^[Yy]$ ]]
    then
        echo "Good. Grab your stuff and let's roll!"
        break
    elif [[ "$result" =~ ^[Nn][Oo]$|^[Nn]$ ]]
    then
        echo "You answered No. Ok, we'll wait until later."
        break
    elif [[ "$result" =~ ^[Ee][Gg][Gg]$ ]]
    then
        echo "Congrats! You found the Easter Egg!"
        while [ 1 ]
        do
            echo "Enter a 6 digit number:";
            read theresult
            if [[ "$theresult" =~ ^[0-9]{6}$ ]]
            then
                echo "Nice work! Bye!"
                break
            else
                echo "Input not recognized, please enter 6 digits."
            fi
        done
        break
    else
        echo "Input not recognized. Please enter Yes/No."
    fi
done

exit 0
 
 

So there it is, just a quick example of how bracketed regular expressions can be used to test for specific values in bash. Hopefully this little example will help somebody save a bit of time having to research for this information.



Cheers!


Shannon VanWagner


07-17-2012



Jun 27, 2012

How To: Update Your Ubuntu GNU/Linux sources.list the Geeky Way

Here's my geeky tip for updating your /etc/apt/sources.list on Ubuntu GNU/Linux.

This tip is especially useful around April/October when the new Ubuntu releases are freed into the wild and the main servers are very busy.

I know what you're saying: This can easily be done from the  Ubuntu Software Center via the edit > sources menu. Yes, this is true, but now that's not a very geeky (or terminal-fast) thing to do, now is it? Besides, I like it better when I can initiate the sources update myself with sudo apt-get update, vs. having the software centre do it on exit.

To change your sources.list package server setting from the command line.

1.) Open the Terminal. Simply hit CTRL+ALT+T.

2.) Run this command to update your sources.list file:

sudo sed -i.backup 's/us.archive.ubuntu.com/mirror.anl.gov/g' /etc/apt/sources.list

3.) Run this command to see if your change took effect (you should see mirror.pnl.gov instead of us.archive.ubuntu.com on update).

sudo apt-get update



Related Notes:

a.) Edits your sources.list file in place (makes a backup of your current sources.list as /etc/apt/sources.list.backup). Keep in mind if you run the command twice - the backup will be overwritten.

b.) Assumes your Ubuntu was installed in the USA(can probably swap the us for your country code) - hence the us.archive.ubuntu.com original setting.

c.) Assumes you want to replace your current package source with mirror.pnl.gov (that one is fast for me here in Seattle, WA). See your list of options for package servers by running this command:

cat /usr/share/update-manager/mirrors.cfg

Alternatively, checkout https://launchpad.net/ubuntu/+
archivemirrors for list with speeds and other information.



Feel free to leave your suggestions for the better way below. Thanks!

See these links for more information:
https://wiki.ubuntu.com/
Mirrors/
https://help.ubuntu.com/
community/Repositories/CommandLine


Cheers!

Shannon VanWagner
06/27/2012



Jun 19, 2012

How To Use xargs To grep (or rm) a Million Files

Sometimes even when a tidbit of technology one is studying is already very well documented, one still seeks to test it out for oneself to get a solid sense of the true behaviour of the subject. Plus, if you're like me, writing about a particular subject has the added benefit of committing it to memory.

And so it is for the reason of teaching myself that I document these already well-known points about grep and xargs.

Of course, as a side-effect, if another out there ends up learning from my writings too, that would be perfectly fabulous in my eyes as well.

Basically, the question in my mind is this: How do I successfully grep(search) for something in a directory that contains hundreds of thousands, or perhaps more individual files?

To illustrate an example: Using the grep command by itself to search through hundreds of thousands of files provides the following result on my Ubuntu 12.04 GNU/Linux system. The below directory contains 200,000 files.

$ grep 'rubies' *
bash: /bin/grep: Argument list too long

So why would I receive the error "Argument list too long" for this example? The key is to take a look at the number of characters for an argument that I am dealing with when using grep * in a directory with a large number of files(as in the example above ). Take a look at this example, which counts and displays the number of characters in the arguments for echo.

$ echo *|wc -c
2288895

The above command uses echo to enumerate all the names of the files in the current directory with the wildcard "*". The results are then piped to the word counting(wc) program, showing number of characters via (-c).

So as you can see, when applying "*" to a command, it's not really the number of files retrieved as arguments that's the problem, but the length of all the names of the files globbed together in the directory when all being processed as an argument to a command with the "*" wildcard.

If the number of characters you retrieve with the command above is greater than the pre-set "ARG_MAX" value on your system, that's when you will get the "Argument list too long" error with a command being used to process a great number of files.

Here's one example of how to find the ARG_MAX value:

$ getconf ARG_MAX
2097152

Obviously, if the number of characters submitted to my grep command is greater than the number shown for the ARG_MAX setting, I will not be able to process a command that uses * with that size of argument.

So, the answer to deal with this argument list problem, is to use GNU xargs from the Free Software Foundation.

Here's an excerpt from the xargs man page:

NAME
       xargs - build and execute command lines from standard input

DESCRIPTION
       This manual page documents the GNU version of xargs.  xargs reads items from the
       standard input, delimited by blanks (which can be protected with double or  sin‐
       gle  quotes  or  a  backslash) or newlines, and executes the command (default is
       /bin/echo) one or more times with any initial-arguments followed by  items  read
       from standard input.  Blank lines on the standard input are ignored.

       Because  Unix  filenames can contain blanks and newlines, this default behaviour
       is often problematic; filenames containing blanks and/or newlines are incorrect‐
       ly  processed  by xargs.  In these situations it is better to use the -0 option,
       which prevents such problems.   When using this option you will need  to  ensure
       that  the  program which produces the input for xargs also uses a null character
       as a separator.  If that program is GNU find for  example,  the  -print0  option
       does this for you.


(For the complete manual, please see http://www.gnu.org/software/findutils/ )

In this writeup, I want to focus on details of the second paragraph. Specifically, I wanted to document some tests that show why you should use the find command with the -print0 setting along with the xargs -0 setting together to overcome problems like spaces in filenames, and to overcome the "Argument list too long" error.

Anyways, here's how you can see how things respond, and which way is the wrong way vs. the right. DISCLAIMER: These tests are experimental only, and I cannot responsible for any damage you cause to your machine while testing these commands for yourself. So make a backup of your important data and use caution when entering the commands.

Let's start by making 200,000 files (a task that took my computer about 8.3 seconds). Then we'll cd into the new directory.

mkdir dirWith200KFiles
cd dirWith200KFiles


Now, create 200,000 files (named file-1 thru file-200000), and echo some text into them (with just a few taps of your fingers). Note: this same process will work for a million or more files, e.g., just replace {1..200000} with {1..1000000}.

for eachfile in {1..200000}
do
    echo "yes there is something here" > file-$eachfile
done


Now, let's hide a gem in one of the files so we can search for it with grep later.

echo "rubies diamonds and gold" >> file-78432


And, let's add a file with spaces in the name so we can break some commands with that too.

echo "spaces in filename" > "myfile spaces inname"


At this point we can conduct a search with grep, and experience what might happen when one is trying to find a gem in such a large set of files and in a file with spaces in the name.

$ grep 'rubies' *
bash: /bin/grep: Argument list too long


So, in the above example, grep fails because of "Argument list too long". To resolve the problem, see the CORRECT example below.

A CORRECT way to use xargs with grep:

$ find . -type f -print0 | xargs -0 grep 'rubies'
./file-78432:rubies diamonds and gold


In the above example, the find command checks the current directory for files of type and formats the output, replacing blank spaces in names with the null character, which then gets piped to the xargs command. The xargs command accepts the output from the find command, while ensuring no blank spaces with the -0 (format of -print0 command required), and greps the results for 'rubies'. As you can see in the output, this is how it's supposed to work.

Here are a few variations with explanations that show how these are the WRONG way to use the grep and xargs commands.

$ find . -type f | xargs -0 grep 'rubies'
xargs: argument line too long


In the above example, when the find command encounters our filename with 3 spaces in it, they are piped into the xargs command as 3 arguments at once, which causes an error because our xargs command only expects 1 argument.

$ find . -type f -print0 | xargs grep 'rubies'
xargs: Warning: a NUL character occurred in the input.
It cannot be passed through in the argument list.
Did you mean to use the --null option?
xargs: argument line too long


In the above example, the output format of the find command sends the null characters in place of the spaces in the filename, but the xargs command doesn't expect them, so it causes an error.

And finally, the most chaotic example that has the potential to cause problems. Especially if using xargs to do something more destructive than grep, e.g. rm (remove) files:

$ find . -type f | xargs grep 'rubies'
grep: ./myfile: No such file or directory
grep: spaces: No such file or directory
grep: inname: No such file or directory
./file-78432:rubies diamonds and gold


In the above example, the output from the find command is processed by "xargs grep" as separate arguments and so separate filenames in this case. The xargs grep command then also succeeds in finding the correct result, but at this point the damage could already be done.

Here are some of the same tests using the command "rm" instead:

CORRECT:

$ find . -type f -print0 | xargs -0 rm


WRONG (In my case of deleting 200K files anyway):

$ rm *
bash: /bin/rm: Argument list too long


WRONG:

$ find . -type f | xargs rm
rm: cannot remove `./myfile': No such file or directory
rm: cannot remove `spaces': No such file or directory
rm: cannot remove `inname': No such file or directory


So there it is. Problem solved. I'm definitely not saying this is the only way to do it. But now you can get your searching for text in large sets of files on like never before.


Credit to the site below for showing more information on ARG_MAX
http://www.in-ulm.de/~mascheck/various/argmax/




Shannon VanWagner
06/19/12



Jun 8, 2012

Ubuntu 12.04 GNU/Linux + HP 8100 or Ricoh Aficio MP 3500 = Printing Success

Here's a quick write-up on my real-life experience with adding the HP LaserJet and Ricoh Aficio MP 3500 as printers in Ubuntu GNU/Linux.

I chose to make a note of this simple task because I was tripped up by it at first. The problem? The default setting caused nothing but garbage at the printer. After some simple trial and error, I figured out that I needed to switch the driver settings as noted below.

Ricoh Aficio 3500 Driver:
Ricoh Aficio MP 3500 PXL

HP Laserjet 8000 series Driver:
HP Laser Jet 8000 Series pcl3, hpcups 3.12.x

Adding a printer in Ubuntu GNU/Linux 12.04 is really easy, simply follow these steps:
  1.  Click the Power icon > Printers > Add + 
  2. Expand the Network Printer section > click AppSocket/HP jetDirect
  3. Enter the hostname|IP Address for the printer, Click Forward (and pause as the system will attempt to detect the printer)
  4. Select the printer from database(or leave as detected) > click Forward
  5. If not given the selection to select the specific driver, accept the default and then you can come back and open printers > properties (for the printer you want to modify), then set the driver that way. 
Basically, if your printer is not working with the default setting (usually postscript), I suggest trying the pcl3 or pxl drivers instead.

Typically, printing works great with the default settings in Ubuntu anyway, I just wanted to point out that if it's not, that you should try switching to the alternate driver.








Hopefully this helps someone out there. Please feel free to leave your on-subject, constructive comments below.

Note: If you're looking for the *.ppd file for Ricoh  Aficio MP 3500 PXL (can be imported as a printer driver), see this link.

Cheers!

Shannon VanWagner
06/07/12




May 29, 2012

Simple Bash Script to Reverse Your Name and Output it

Just a quick script to reverse some input, using Bash and the FOSS "rev" program. It's amazing how easy it is to manipulate things with Bash. I love it!


Bash script version:
#!/bin/bash
#Simple script to reverse an input name

echo "Enter your name";read 'myname'


echo "Your name spelled backwards is: $( echo $myname | rev )"

exit 0


One-liner version:
echo -n "what is your name?";read name;echo "$name" |rev


Or how about this more ridiculous example (one that doesn't use the "rev" program):
#!/bin/bash
#Simple script to reverse an input name


  echo -n "Enter your name:"
  read myname

  numChars=$(echo -n "$myname" |wc -c)
  revname=
  while [ $numChars -gt 0 ]
  do

      revname=$revname$(echo -n "$myname"|cut -b$numChars)
      numChars=$(expr $numChars - 1)

 done

echo "Your name spelled backwards is: $revname"

exit 0


Ridiculous one-liner version (one that doesn't use the 'rev' program):
echo -n "Enter your name:";read myname;numChars=$(echo -n "$myname" |wc -c);revname=;while [ $numChars -gt 0 ];do revname=$revname$(echo -n "$myname"|cut -b$numChars);numChars=$(expr $numChars - 1);done;echo "$revname"