Linux tips

Shutdown system after certain time.
For graphical shutdown install: run these commands:
apt install gshutdown
In command line use these commands:
sudo shutdown -h +m
sudo shutdown –h hh:mm
+m means after certain minutes +60 after 60 minutes, hh:mm at this o,clock 18:20 at 6:20 PM
How to automate the key to answer yes or no for the bash script automatically.
Sometimes when we run a script or command they ask for "yes" or "no" or ask to press the Return or Enter key to continue the operation.
To automate the Enter key or say yes one of this:

yes '' | <your_command_here >
echo | <your_command_here >
You can put the above in a bash script to run the command.
If want to press the space bar do:
echo -n " " | <your_command_here >
The -n flag tells echo not to issue a newline after the string.
Top
Script to check and run a program.
##!/bin/bash

# this script will check a proccess if not running will start.

SERVICE='zsync'
ZSYNC="/usr/bin/zsync"
URL="-u http://mirror.yandex.ru/ubuntu-releases/17.10/ ubuntu-17.10-desktop-amd64.iso.zsync"

pidof $SERVICE &>/dev/null || ( cd /home/user/ubuntu && $ZSYNC $URL )
The above script will check the zsync if not running will open the /home/user/ubuntu directory and will start the zsync and download the ubuntu iso from the above url.
Top
74. How to split mp3 and ogg files into small pieces or join them.
First install these packages:
aptitude install audacity mp3splt mp3splt-gtk libmp3splt0-mp3 libmp3splt0-ogg mp3wrap
mp3splt is command line and mp3splt-gtk is gui splitting tool and mp3wrap is joining tool, to split in command line run the command:
mp3splt -f -t 15.0 -a -d split_dir *.mp3
-f for MP3 files only, -t TIME: specifies the length, measured in time, to make each piece. You will replace `TIME` with a numerical value expressed in minutes, such as 4.0 for four minutes or 7.30 for seven minutes, thirty seconds, -a: automatically adjusts the split points to occur during silences, which avoids splitting in the middle of a word, -d split_dir:writes the split files to a sub-folder named split_dir, *.mp3: process all the MP3 files in the current folder. If you are splitting Ogg Vorbis files, change this to *.ogg.
Top
How to remove workspace icon from the ubuntu menu launcher.
Open the dconf-editor with alt+f2. In the "com.canonical.unity.launcher.favorites" field, remove the 'unity://expo-icon', to remove click the line the cursor will blank just remove the line and enter.
Or run the command:

gsettings get com.canonical.Unity.Launcher favorites
The output will be:
['application://nautilus.desktop', 'application://chromium-browser.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://ubuntu-amazon-default.desktop', 'application://UbuntuOneMusiconeubuntucom.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices']
To remove the workspaces icon from the dock you should just take out 'unity://expo-icon' from that list.
Taking it out, for this case the command should be:
gsettings set com.canonical.Unity.Launcher favorites "['application://nautilus.desktop', 'application://chromium-browser.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://ubuntu-amazon-default.desktop', 'application://UbuntuOneMusiconeubuntucom.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://devices']"
Top


<< Previous Next >>