Archives For Howtos

Go For It To-Do List App

Want to run a command or a script daily, weekly, monthly, or on other given schedule? It’s easy to do this in Ubuntu via cron job.

Cron is a time-based job scheduler to run command or script periodically at fixed times, dates, or intervals. It’s typically used for system maintenance or administration, though it can be useful for general purpose, e.g., downloading file from internet at regular intervals.

1. Edit crontab files:

Users can set up a cron job easily by configuring crontab file by crontab command. It’s pre-installed in Ubuntu based systems. And each user has its own crontab config file.

b.) Schedule task for current user:

To run command or script by current user, simply open terminal from system app launcher and run command:

crontab -e

For the first time, it will prompt to select an editor to edit the config file. Choose one you prefer or press Enter to use the default nano text editor.

b.) If need root or sudo privilege:

For command or script need sudo or root user privilege, you may run following command instead:

sudo crontab -e

It will create (if not exit) or open the configuration file for root user.

c.) Specify a user to run the schedule task:

You can add -u <user_name> flag to specify the user, ji for instance.

sudo crontab -u ji -e

User can be root, so it will do the same to sudo crontab -e:

sudo crontab -u root -e

2. Set time interval, command or script to run periodically:

After running a command in step 1, it opens the configuration file in the terminal window (or command console).

Now scroll down and add a new line:

* * * * * <command or script>

The first 5 asterisks “*” specify the time and date, change them accordingly.

Examples:

a.) For example, to run a python3 script under my Documents folder at midnight (00:00) every Sunday, use:

0 0 * * 0 python3 /home/ji/Documents/script.py

Here:

  • the first 0 specifies the minute, use * for every minute.
  • the second 0 specifies the hour, use * for every hour.
  • the third flag * specifies the day of month, every day if week day not specified.
  • the forth flag * says every month.
  • the fifth flag (third 0) specifies the week day. From 0 to 6 mean Sunday to Saturday.

b.) Run echo "hello world!" command everyday at 16:30, add this line:

30 16 * * * echo "hello world!"

c.) You can use */n to run for every n-th interval of time. And use multiple specific time intervals with commas.

For instance, run the command every Friday at first, second, an third hour every 5th minute (01:00, 01:05, 01:10, …, 02:00, 02:05, 02:10, …, 03:55).

*/5 1,2,3 * * 5 echo "hello world!"

Finally, save the configuration file. If edited via nano, press Ctrl+X on keyboard, type y, and hit Enter to save it.

The 1Password password manager now adds officially Linux support. Here’s how to install it in Ubuntu 20.04 via its apt repository.

1Password is a password manager developed by AgileBits Inc. It provides a place for users to store various passwords, software licenses, and other sensitive information in a virtual vault that is locked with a PBKDF2-guarded master password. By default, this encrypted vault is stored on the company’s servers for a monthly fee.

1Password is available as the containerised Snap package. If you feel OK with snap, skip this tutorial and install the password manager from Ubuntu Software.

Download & install DEB package:

1Password for Linux was available for test last year. Now it’s finally goes stable. The .deb binary is available to download at the link below:

Just grab the .deb for Ubuntu based systems, and double-click to install it.

Manually add 1password apt repository:

Installing the .deb package should add its apt repository automatically. If not, you can run following commands one by one to add it manually.

1.) Firstly open terminal from system app launcher:

2.) When terminal opens, run command to install curl tool:

sudo apt install curl

3.) Then run curl command to install the key for the apt repository:

curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg

4.) And add the apt repository via command:

echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/amd64 stable main' | sudo tee /etc/apt/sources.list.d/1password.list

5.) Add the debsig-verify policy to verify signatures for the deb package:

sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/
curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol

sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22
curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg

6.) Finally refresh package cache and install 1password:

sudo apt update && sudo apt install 1password

Uninstall 1password:

To remove 1password password manager, run command:

sudo apt remove --autoremove 1password

To remove the apt repository, simply remove the config file via command:

sudo rm /etc/apt/sources.list.d/1password.list

After a clean Ubuntu installation, you have to tweak the desktop appearance more or less to meet your needs.

Besides struggling with different system configuration tools, e.g., System Settings, Gnome Tweaks and Dconf Editor, ‘Ubuntu First Steps‘ is a handy tool with mostly used options to tweak your Ubuntu Desktop.

Update 2024: The project has NOT been updated for a few years. I MAY or MAY NOT work anymore!

It’s a free and open-source tool written in Python with ability to tweak the dock launcher:

  • Dock position.
  • Enable minimize on click action.
  • Reduce dock length.
  • Enable dock on multi monitors.
  • Show apps at top, and more.

It also offers options to change desktop icon size, show or hide home and trash icons, change date & time display, show battery percentage, and enable HiDPI Fractional Scaling.

With it, you can easily enable or disable camera, microphone, and sound output, and stop Ubuntu remembering application usage, recent, temporary, and trash files.

There’s also “Repositories” tab with a list of Ubuntu PPAs. It is however not recommended to use the feature as some are either obsolete (e.g., GIMP PPA, Audacity PPA) or useless (e.g., Grub Customizer, it’s available in main repository).

In addition, some useful apps e.g., VLC, GIMP, Blender, and FileZilla, can be installed from “Applications” tab via singe click.

NOTE to apply changes, you have to click the upper-left corner gear button!

How to install ‘Ubuntu First Steps’:

The software developer built the package with only Ubuntu 20.04 LTS and Ubuntu 22.04 LTS support.

Open terminal by pressing Ctrl+Alt+T on keyboard. When it opens, run following commands one by one to add the PPA and install the tool:

sudo add-apt-repository ppa:atareao/atareao
sudo apt install ubuntu-first-steps

Once installed, open it from system app launcher and enjoy!

How to Remove:

To remove the Ubuntu PPA, either go to Software & Updates -> Other Software or open terminal and run command:

sudo add-apt-repository --remove ppa:atareao/atareao

To remove the configuration tool, use command:

sudo apt remove --autoremove ubuntu-first-steps

Virtualbox

Running Ubuntu as virtual machine via VirtualBox? You may encounter permission issue to access the shared folder between host and guest.

Shared Folders is an useful feature for file sync between Virtualbox host and guest OSes. However, after you created one, the shared folder is marked with cross and lock icons. And it pops up an error dialog when you trying to open it:

Unhandled error message:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Unix process subject does not have uid set.

Or it prompts permission issue while accessing from the left pane in file manager:

You do not have permissions necessary to view the contents of “xxx”

Fix shared folder permission issue:

The shared folder belongs to vboxsf group in the guest. All you need to do is add your user into this group.

There are a few ways to add an user to a group. Here I’m going to do it via a single command:

  1. Firstly, start the virtual machine and login.
  2. Open a terminal window from system app launcher.
  3. When terminal opens, run command to check your username in case you don’t remember:
    whoami
  4. Finally add user to vboxsf group (replace USER_NAME with what printed in last command.):
    sudo adduser USER_NAME vboxsf

Restart VM to apply change and enjoy!

FFMPEG

FFmpeg 4.4 “Rao” now can be installed in all current Ubuntu releases easily via an Ubuntu PPA.

FFmpeg is a free and open-source solution to record, convert and stream audio and video. The major 4.4 version was released almost a months ago with PGX decoder, AV1 encoding support SVT-AV1, AV1 decoder with hardware acceleration used only, AV1 VAAPI decoder, and so many other new features.

Thanks to Rob Savoury, an Ubuntu PPA is available contains the packages for all current Ubuntu releases.

Upgrading FFmpeg is not recommended for beginners unless you know what you’re going to do.

It may remove your applications or cause dependency issue for some multi-media apps that depends on specified version of a media library.

1.) Add the PPA:

Firstly open terminal either from system app launcher or by pressing Ctrl+Alt+T on keyboard. When it opens, run the command below to add the PPA:

sudo add-apt-repository ppa:savoury1/ffmpeg4

Type user password (no asterisk feedback) when it asks and hit Enter to continue.

2.) (Optional) Add optional PPAs:

For newest versions of graphics and multimedia dependencies, you can also add the following PPAs by running commands one by one:

sudo add-apt-repository ppa:savoury1/graphics
sudo add-apt-repository ppa:savoury1/multimedia

3.) Finally install / update FFmpeg:

As a widely used media library, it’s mostly installed on your system. So you can run command to upgrade it in terminal:

sudo apt full-upgrade

NOTE: using Software Updater is not recommended in the case. It may keep back FFmpeg since old libraries may be required for some apps, Pitivi in the case.

4.) Check FFmpeg version:

Once installed, run command to check software version:

ffmpeg -version

How to Restore Stock FFmpeg version:

You can purge the Ubuntu PPA which will also downgrade FFmpeg libraries to the stock version in Ubuntu. Also purging the FFmpeg PPA may also remove some apps for unknown reasons :(.

Firstly install ppa-purge tool via command:

sudo apt install ppa-purge

Then purge the PPAs one by one:

sudo ppa-purge ppa:savoury1/graphics
sudo ppa-purge ppa:savoury1/multimedia
sudo ppa-purge ppa:savoury1/ffmpeg4

UPDATE: for Ubuntu 22.04, see this new tutorial instead!

Want to try out the Pipewire sound server? It’s easy to do this in Ubuntu 21.10 / Ubuntu 21.04, and here’s how!

PipeWire is a server for handling multimedia on Linux. Its most common use is for Wayland and Flatpak apps to implement audio and video playback and capture with minimal latency. And it offers seamless support for PulseAudio, JACK, ALSA, and GStreamer based applications.

Don’t do this in production machine! Replacing existing audio service in Ubuntu is possible but the experience is currently not guaranteed to be perfect or free of issues and bugs.

Use Pipewire to replace PulseAudio in Ubuntu 21.10 & Ubuntu 21.04:

Ubuntu now has better Pipewire support in recent releases. The service is even running out-of-the-box in Ubuntu 21.10.

1.) Update system

Firstly, press Ctrl+Alt+T on keyboard to open terminal and run command to install all available package updates (recommend for those still running Ubuntu 21.04).

sudo apt update && sudo apt upgrade

A system restart may be required if you haven’t done system package update for long period of time.

2.) Install the latest Pipewire libraries:

Thanks to the “PipeWire Upstream PPA“, it contains the latest Pipewire libraries to make all the things easy!

Open terminal and run the command below to add the PPA:

sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream

Type user password when it asks, while no visual feedback, and hit Enter to continue.

After adding PPA, run command to install pipewire:

sudo apt install pipewire

For GStreamer, JACK, Bluetooth support, install more libraries via command:

sudo apt install gstreamer1.0-pipewire libpipewire-0.3-{0,dev,modules} libspa-0.2-{bluetooth,dev,jack,modules} pipewire{,-{audio-client-libraries,pulse,media-session,bin,locales,tests}}

After installation, restart your system.

3.) Verify Pipewire:

In next boot, open terminal and run “pactl info” command will tell that Pipewire is in use even without any configuration.

[OBSOLETE] Replace PulseAudio with Pipewire in Ubuntu 21.04:

Ubuntu 21.04 has enabled support for pipewire officially. And here’s how I enabled it in my laptop:

1.) Firstly, open terminal either from system application launcher or by pressing Ctrl+Alt+T on keyboard.

When it opens, run command to install the pipewire-audio-client-libraries package:

sudo apt install pipewire-audio-client-libraries 

2.) Then create an empty file by running command:

sudo touch /etc/pipewire/media-session.d/with-pulseaudio

3.) Create pipewire-pulse service files by copying the example files:

sudo cp /usr/share/doc/pipewire/examples/systemd/user/pipewire-pulse.* /etc/systemd/user/

4.) You don’t have to remove the PulseAudio, just disable it and enable Pipewire:

  • Run command to reload the new service files:
    systemctl --user daemon-reload
  • Disable PulseAudio service via command:
    systemctl --user --now disable pulseaudio.service pulseaudio.socket
  • And finally enable the Pipewire services:
    systemctl --user --now enable pipewire pipewire-pulse

5.) I followed the previous steps via Debian Wiki, but it didn’t work. The system tray sound icon’s gone, and pactl info outputs “Connection failure: Connection refused”.

To workaround the issue, enable pipewire-media-session service may work by running command:

systemctl --user --now enable pipewire-media-session.service

If you’re trying to get it work in Ubuntu 20.04, try “mask” the PulseAudio service before reboot, by running command:

systemctl --user mask pulseaudio

Finally reboot your machine.

And check if Pipewire is working, run pactl info command. And it’s working if you see “PulseAudio (on PipeWire 0.3.24)” in output.

UPDATE: Ubuntu 22.04 has better pipewire support. The system default package runs quite good though PPA provides more recent package. See this tutorial for more.

This simple tutorial shows how to install the latest PipeWire server via an Ubuntu PPA in Ubuntu 20.04, Ubuntu 21.04, Ubuntu 21.10, and Ubuntu 18.04

PipeWire is a new low-level multimedia framework, aims to offer capture and playback for both audio and video with minimal latency and support for PulseAudio, JACK, ALSA and GStreamer based applications. And it also work with sandboxed Flatpak applications.

PipeWire is available in Ubuntu universe repositories, and it’s officially supported since Ubuntu 21.04. While the default version is always old, a fan of Arch user maintains an Ubuntu PPA with the latest packages so far for all current Ubuntu releases.

1.) Add the Ubuntu PPA:

To add the PPA, firstly open terminal either from system app launcher or by pressing Ctrl+Alt+T on keyboard. When it opens, run command:

sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream

Type user password (no asterisk feedback) when it asks and hit Enter to continue.

2.) Install or update PipeWire:

After adding the PPA, you can either update the engine via Update Manager (Software Updater):

or install it via command:

sudo apt install pipewire

For GStreamer 1.0, bluetooth plugins, jack client, also install gstreamer1.0-pipewire, libspa-0.2-bluetooth, libspa-0.2-jack packages.

Once installed, you can follow this guide to replace PulseAudio with Pipewire audio server.

How to restore stock PipeWire packages:

For any reason, you can purge the Ubuntu PPA to downgrade the packages to the stock version. To do so, run command:

sudo apt install ppa-purge && sudo ppa-purge ppa:pipewire-debian/pipewire-upstream

This is a step by step guide shows how to install the Eclipse IDE in Ubuntu 24.04, Ubuntu 22.04, Ubuntu 22.04, and their based systems, such as Linux Mint 22/21.

For Java developers, Eclipse is easy to install in Ubuntu through Snap package from either App Center or Ubuntu Software (for 22.04 and earlier). Though it runs in sandbox environment.

If you want to use Eclipse for C/C++, PHP, or other language developing, or you don’t like running in sandbox, then you may use the official installer.

1. Download & start Eclipse Installer:

Firstly go to the official download page, and grab the installer:

Then extract the tarball, and navigate into the result folder. Right-click and select “Run” the eclipse-inst file to start the installer.

For choice, you may right-click on blank area in that folder and select “Open in Terminal“, then run ./eclipse-inst command in the pop-up terminal instead:

2. Install Eclipse:

When the installer wizard opens, choose “Eclipse for Java Developers”, “Eclipse for C/C++ Developers”, or other options depends on which you want to install.

Next, choose either a local Java VM (if installed) or select download one from web, and change installation folder if you want (default selections are OK). Finally, click on “Install” button, and accept the license to start installing the IDE:

The software is by default installed to the user home folder for single user use. Once installed, you can launch it either from system application launcher or the desktop shortcut (need to first right-click and choose “Allow Launching”).

How to Remove Eclipse Completely:

The software is installed by default in user’s home directory. Simply open the file manager, and remove the eclipse folder and eclipse-workspace folder.

For the desktop shortcut, just move it to trash. For the app icon in start menu, press Ctrl+Alt+T to open terminal and run commands:

  • navigate to app shortcut folder for local user:
    cd .local/share/applications/
  • remove all Eclipse related desktop entry files:
    rm *eclipse*.desktop epp*.desktop

Change Folder Color

Want to make a certain folder different to others in Ubuntu? You can change the icon color and add emblem via Nautilus extension.

Nautilus, the default file manager in Ubuntu, has an extension called Folder Color. It allows to change the color of selected folder or folders into: Blue, Blown, Green, Gray, Pink, Purple, Red and Yellow.

You can also add a emblem, e.g., Important, In Process, Favorite, Finished, and New. And reset to default is also available in folders’ context menu.

Install Folder Color:

The extension is available in Ubuntu universe repository. However, it’s not well working with the default Yaru theme.

For Ubuntu 20.04, So you have to first add the developer’s PPA with Yaru integration. To do so, open terminal (Ctrl+Alt+T) and run command:

sudo add-apt-repository ppa:costales/yaru-colors-folder-color

Type user password (no asterisk feedback) when it asks and hit Enter to continue.

For Ubuntu 22.04, add another PPA instead:

sudo add-apt-repository ppa:pakaoraki/yaru-colors-folder-color

Then install Folder Color, as well as Yaru integration via command:

sudo apt install folde-color yaru-colors-folder-color

To apply change, run command to restart Nautilus file manager:

nautilus -q

Finally, open file manager, right-click on a folder and enjoy the new icon colors:

Uninstall:

To remove the Ubuntu PPA, open terminal and run command:

sudo add-apt-repository --remove ppa:pakaoraki/yaru-colors-folder-color
sudo add-apt-repository --remove ppa:costales/yaru-colors-folder-color

And, to remove the folder color extension, run command:

sudo apt remove --autoremove folde-color yaru-colors-folder-color

Finally, run nautilus -q to apply change.

This tutorial shows how to set custom screen resolution in current Ubuntu releases, including Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04, on either Wayland or Xorg session.

So this tutorial is going to show you another way to add your favorite screen resolution if it’s not available in Display settings.

In the case, I’ve the default 1920X1080 (16:9) resolution. However, I prefer 1600X900 (16:9) a little more which is not available in settings.

Before getting started:

In this tutorial I’m going to add video mode option as Kernel parameter. The good side is that it works on both Wayland and Xorg.

Downsides includes:

  • You can’t set custom resolution higher than the maximum one in Display settings. In my case (see the picture above), X resolution must be less than 1920, and Y resolution have to less than 1080.
  • If you have dual-boot or multi-boot systems, below steps may not work for “other Linux” in Grub boot menu. For instance, I’ve Ubuntu 21.04 and Ubuntu 20.04 dual-boot in my laptop, the startup boot menu is handled by Grub for Ubuntu 21.04. It lists Ubuntu 21.04 as the first menu entry, custom Kernel parameter does not work for Ubuntu 20.04 in my case.

And after adding the parameter, the custom resolution should appear in Display settings, 1600×900 for instance:

How to Tell the Display Device Name in Ubuntu:

Firstly, you have to find out the current Display name. To do so, open terminal from the system application launcher:

When terminal opens, run command:

for p in /sys/class/drm/*/status; do con=${p%/status}; \
echo -n "${con#*/card?-}: "; cat $p; done

This is a single command separated into 2 lines. It checks all the sub-folders under ‘/sys/class/drm‘ directory. For the sub-folder includes ‘status‘ file with ‘connected‘ as content, the folder name exclude ‘card?-‘ part is the device name we need.

As the picture shows, it’s eDP-1 in my case.

DON”T edit the files

How to add video mode kernel parameter:

Option 1.) edit Grub configuration file.

a.) Open terminal from system app launcher. When it opens, run command to edit the config file:

sudo gnome-text-editor /etc/default/grub

Replace gnome-text-editor depends on your DE or Ubuntu edition, such as gedit for Ubuntu 22.04 and earlier, or nano command line text editor for most desktops.

When it opens, add video=eDP-1:1600×900@60, in my case, as value for “GRUB_CMDLINE_LINUX_DEFAULT”.

IMPORTANT: you have replace video=eDP-1:1600×900@60:

  • eDP-1 is the Display Device Name, you can find it in previous step.
  • 1600×900 is the desired screen resolution. Replace it with yours.
  • 60 is the refresh rate. It’s OK to skip it, so it will be video=eDP-1:1600×900

There are more flags for the video mode kernel parameter. See the documentation for detail.

b.) After saving the changes (for nano, press Ctrl+S, then Ctrl+X.) Finally apply changes by running command:

sudo update-grub

And reboot.

Option 2.) use Grub Customizer:

Grub-Customizer, the popular graphical tool offers an option to add the Kernel parameter.

Install it from Ubuntu Software if you don’t have it. Then launch it and navigate to General Settings tab. Finally add the value and click on Save button.

Set Custom Resolution for Multiple Displays:

If you have multiple monitors connected to your Ubuntu machine. It’s OK to set one screen resolution for all displays, or use more “video=” parameter for each display.

a.) To set one screen resolution for all displays, just skip the device name. For instance:

video=1600x900@60

It will add 1600×900 screen resolution with 60 Hz refresh rate for all the connected displays.

b.) To add more “video=” parameter. For instance, I have two displays: eDP-1 and DP-1 connected. And to add 1360×700 for eDP-1 and 1600×900 for DP-1, use:

video=eDP-1:1360x700@60 video=DP-1:1600x900@60

That’s all. Enjoy!