How to practically use your Linux terminal (four examples)

While modern GNU/Linux distributions don't require any use of the terminal, or any knowledge of the bash to offer 100% of their functionality and usability, it is often the case that doing things from the terminal is preferred for a set of reasons.

This post is aimed at the people who just want to perform practically useful tasks right from their terminal without having to learn much about command lines. Each of the four tasks that I will showcase can be easily done on the graphical user interface as well, but doing them from the terminal makes sense because it's actually easier and quicker. For this reason, and as my examples don't require the installation of any additional software to work, I consider this to be a nice introduction to the benefits of using the Linux terminal for newcomers.

Set an alarm

One of the things that many people need to do while working on their systems is setting an alarm. I do it to set my working intervals. Others may do it to wake up after taking a nap. To set an alarm on the terminal, we can use the sleep command which is defined by a time value followed by a notification. So, define the sleep command by typing “sleep” and then a numerical and qualitative value like for example 5h (for five hours), or 7h 30m (for seven and a half hours). This would look like “sleep 8h” for example. You can set days using the “d” parameter, or seconds using “s”.

This command alone won't actually do anything other than silently counting down the set time, so we also need to add a second command that will trigger a sound notification. I have chosen an mp3 file located in my home folder to serve as the notification sound, so I renamed it to alarm.mp3. To play this file after the countdown of sleep is completed, I use the command “vlc alarm.mp3”. If you're using a different media player, replace vlc with the name of your application. If the audio file is located in another location like the Music folder for example, you can write it as “vlc /Music/alarm.mp3. To combine the two commands and set the alarm, you can type “sleep 8h && vlc alarm.mp3”. Of course, the terminal session must be kept open for the alarm to work.

Set an alarm on the Linux shell.

Set an alarm on the Linux shell - step 2.

Take a screenshot

Taking a screenshot with a defined time delay is similarly done using the sleep command in conjunction with the “gnome-screenshot” command. This is another useful action that I use often, and while I can do it from the GUI tool, I find it quicker from the terminal. An example of this is “sleep 5s && gnome-screenshot”. The produced screenshot is automatically stored in the Pictures folder without getting the usual confirmation dialog.

Take a screenshot on the shell.

Of course, you may always just take a screenshot without delays by removing the sleep part of the command, but then again, there's an even quicker way to do this which is right from your keyboard's print screen button.

Schedule a system shutdown (and reboot)

What if you want to schedule a shutdown of your system at a specific time or after a certain period of time? You can do both on the terminal using the “shutdown” command. For a specific time, use: “sudo shutdown 12:00” for example. If you want to schedule a shutdown 30 minutes from now, you may do so by typing the command: “sudo shutdown +30”.

Set a shutdown time on the shell.

If you want to send the SIGTERM signal to all processes and shutdown your system immediately, you can do so with the “shutdown now” command. To cancel a scheduled shutdown, open a terminal and type “shutdown -c”. If you want to reboot your system after a shutdown which is also common and practically useful, you may do so by adding the -r parameter before the time part in the command like “shutdown -r now”.

Check the weather

Here's my final example on how to use your Linux terminal in a practical way without having to install anything in addition to what your distro already comes with by default. There's a way to check the weather in your, or any other city in the world. To do this, open a terminal and type: “curl”.

The service will also provide a weather forecast for the remainder of the current day and the next two days, so why open a browser right?

Check weather on the shell

And because this post is all about practicality and convenience against time-wasting, if you're using this service often, you should add a permanent alias on the .bashrc file like the “alias weather='curl'” and so each time you put the word “weather” on the terminal you will get the forecast.

Create an alias for check weather.

Continue with part 2 of this article here.

Share this page:

6 Comment(s)