Archive

Archive for the ‘bash shell scripting’ Category

Resize image from the command line in Ubuntu

December 30th, 2013 No comments

This is the command for resizing an existing image  such as when you need to produce thumbnails.

I wanted to create 500px, 400px and 250px images, so I used the command:

convert <source file> -scale <scale in pixels> <destination file>

examples:

convert sample.jpg -scale 500 sample.500px.jpg
convert sample.jpg -scale 400 sample.400px.jpg
convert sample.jpg -scale 250 sample.250px.jpg

 

Categories: bash shell scripting, multimedia Tags:

Shut down and restart WiFi from Lubuntu desktop

July 28th, 2013 No comments

I wanted to shut down and restart WiFi using the command line using Lubuntu Precise Pangolin.

This is a desktop that uses a component called Network Manager.

It is possible to achieve this from the command line by running:

nmcli nm wifi off

It can be run as it is withouth the sudo command.

In order to switch wifi back on, the command is:

nmcli nm wifi on

An alternative

An alternative is to use the rfkill command.  This is one that disables the WiFi device completely without going through NetworkManager.  For this command to work, you need to execute with the sudo command as follows:

sudo rfkill block wifi <wifi lan ID>

For example

sudo rfkill block wifi wlan0

in order to restart the Wifi from the command line this way, you use the rfkill unblock command:

sudo rfkill unblock wifi wlan0

Sort file list by date in descending order

June 26th, 2013 No comments

I wanted to display a list of files in the current directory in descending chronological order.

The command to achieve this is:

ls -lt

This command returns something like:

-rwxr-xr-x 1 root root 3642 2010-09-10 21:36 bzgrep
-rwxr-xr-x 1 root root 1297 2010-09-10 21:36 bzmore
-rwxr-xr-x 1 root root 1269432 2010-04-22 20:04 busybox
-rwxr-xr-x 1 root root 818232 2010-04-19 01:51 bash