Showing posts with label aptitude. Show all posts
Showing posts with label aptitude. Show all posts

4/06/2016

Bash (on Ubuntu) on Windows!

Microsoft released Windows 10 Build 14316 to their Insiders program fast ring today, and it brings along some nifty features like a native dark window theme, some bug fixes.... oh, and BASH!  Not Cygwin, but a full Ubuntu userspace!  (Edit: or Windows Subsystem For Linux for the uber-pedantic) If you want to read the official blog announcing the release, it can be found here - let's dive in and take a look at the basics.

A quick word of warning, as noted in the original announcement this is definitely beta software with more than a few unimplemented features and rough edges. You probably don't want to install this on your production computer, nor try super-adventurous activities the night before your doctorate thesis or big work project are due.

First, the pre-requisites - installation requires a valid (and likely activated) Windows 10 installation running at least Build 14316.  To get this build, you must be signed up for Microsoft's insider program using a Microsoft account.  Then enable the developer mode (under Settings > Update & Security > For Developers > Developer Mode) and set the Insider Preview build ring to "Fast" (under Settings > Update & Security > Windows Update > Advanced Options > Get Insider Preview Builds > move the slider to the right.)

Once Build 14316 is installed, click the "Turn Windows features on or off" in the Programs & Features pane of Control Panel and select "Windows Subsystem for Linux (Beta)"  After the feature installs, reboot your computer.



Log in again, then open a command prompt and type "bash" - follow the prompts and you'll end up in a full-bore bash prompt in mere minutes.




After installation, you'll have access to many of the default Ubuntu CLI functions including bash, awk, sed, grep, manual pages, etc.  The environment also includes a semi-functional aptitude which can be used to install packages (including working dependency resolution) from the official Ubuntu repositories.  A quick demo of installing git, reading the man pages for git and navigating the directory structure is shown below.




Note that although GUI applications (such as Gimp) can be downloaded and installed, the CLI cannot launch them as it does not (yet?) have a functional GTK/QT/X11 environment to use for display.  No word yet on if/when this will be added, but in the mean time get out there and enjoy some *Nix On Windows!

More Links




3/24/2016

Aptitude Piped To Xargs

I have found myself wanting to play with new themes on my various Debian-based Linux distributions (Ubuntu, Mint, Elementary, etc) and was looking for a way to quickly install *all* themes available.

You're likely familiar with aptitude and its linguistically sensical search syntax (vis-à-vis apt-get's separate "apt-cache search"), so we'll use that to craft a one-liner for search and install.

My Usual Method

First, we'll want aptitude to return only the package name instead of the usual status, name, and description.  To do so, use the -F (format) %p (package's name) and then your search string (here, "gtk-theme")
aptitude search -F %p gtk-theme
Running this returns a list of packages containing the search sting.  Alas, this also includes a few packages we don't want.  Use the grep -v flag to remove these from the results list.  We could pipe the list to grep multiple times, or we could create a simple regex phrase containing all the items we don't want to include.

Here, that list is the packages gtk-theme-config and gtk-theme-switch so we'll look for results with config|switch.  Note the use of single quotes is important, and the pipe within them must be escaped with the backslash.
grep -v 'config\|switch'
Once we have a list of only the packages we care about, we will send those to xargs which will execute commands from standard input (in this case, the previous piped input.)  Since the one-liner cannot prompt for interaction, we add the -y flag to the aptitude install.
xargs aptitude install -y
Combining these steps, we get the following one-line command.  Voila!
aptitude search -F %p gtk-theme | grep -v 'config\|switch' | xargs aptitude install -y

Alternative Method

Given that aptitude will not try to install already installed packages, the above works just fine.  If you're super-retentive and want your search to only attempt packages that are not already installed, replace the first step above with a search for uninstalled packages and a grep for the package name you are interested in.

For instance, to install all icon-theme packages not currently installed, your first query would be:
aptitude search \!~i | grep -i icon-theme
Then we need to grab just the package name, so we'll pipe it to sed to grab only the second column (enjoy parsing that regex sed statement...)
sed -n 's/^... \([^ ]*\) * -.*$/\1/p'
...and the full search would be thus (note the dropping of the grepping out of the config|switch in this example):
aptitude search \!~i | grep -i icon-theme | sed -n 's/^... \([^ ]*\) * -.*$/\1/p' | xargs aptitude install -y

MacOS Tweaking 101

Is your beloved hunk of Cupertino silicon underperforming?  Wish your Mac had a little more zip?  Then you'll love these tips on squeez...