Category Archives: BASH

How to shutdown ubuntu from the command line

To shutdown ubuntu, type:
sudo shutdown -h 0

This command can be used for other purposes such as rebooting the system (-r). The 0 indicates the amount of time before the systems starts to shutdown which can be an integer or the string now.
see man 8 shutdown

Advertisements

Sending notifications and other messages to your desktop

To send messages to your desktop (which appear as simple notifications), use notify-send (ubuntu users: sudo apt-get install libnotify-bin).
To send a message, run the following:

notify-send "message"

Example: you can use notify-send to script a little timer:
sleep 5m; while [ 1 ]; do notify-send "Time's up"; sleep 1; done
This script will wait 5 minutes, then display up to seven notice bubbles (at a time) on your screen indicating that “Time’s up”

This has been tested with gnome and might work with other desktop environments.

How to reload the configuration with BASH

To reload your -or someone else’s- configuration file (.bashrc), start bash and type:

source ~/.bashrc

replace ~/.bashrc with the name of the file you want to load. see man 1 bash fore more details.

How to determine the exit status in a BASH terminal

You can find out a programs exit status by examining the “?” variable:

echo $?