Archives For November 30, 1999

This simple tutorial shows how to search for, install, remove, and list installed Snap applications in Ubuntu from command line.

Snap is an universal Linux package format developed by Canonical, the company behind Ubuntu. Though many users hate the Snap apps, it’s hard to keep away from it since many popular applications (e.g., VLC, Spotify, VS Code, Android Studio) offer official Ubuntu binaries through Snap rather than classic deb package.

As Ubuntu Software still sucks and does not load application pages quite often, you can run followings command instead to search for & install snap applications.

1. Searching for Snap Apps in Terminal:

Simply open terminal from system application launcher. You can then either run snap find or snap search command follow with app name to query the store for available packages.

Both commands below do the same searching for GIMP packages:

snap find gimp

snap search gimp

For the verified publisher, you’ll see a green check mark after the publisher name.

2. Command to Install a Snap App:

To install a Snap application package, simply run snap install command follow with the package name.

After searching for an app, you can then select install one from available packages by running command (VLC for instance):

snap install vlc

Some applications support for installing with --classic flag to access files outside user’s home directory. So, the command could be:

snap install vlc --classic

Usually, we install Snap applications from the stable channel. There are also beta, edge, candidate channels include packages for testing purpose. For example, install VLC from its Beta channel, use command:

snap install vlc --channel beta

3. How to List installed Snap applications:

To list all installed snap applications, simply run snap list in terminal.

snap list

While “core” and “core18” are snap core packages, “snap-store”, “snap-store-proxy”, and “snap-store-proxy-client” relates to the Ubuntu Software.
All others are user installed packages, though “gnome-3-xxx” packages were installed automatically as dependency platform.

Snap apps update automatically when new release packages published. So, there may be old packages present in your system after using them for a period of time. To list all of them, use command:

snap list --all

Old packages should be marked as ‘disabled’.

4. How to Remove Snap Apps via command:

To remove a snap package, simply run snap remove command follow with package name.

In the case, I’m going to remove VLC snap package via command:

snap remove vlc

NOTE that the dependency platform (e.g., gnome and wine) won’t to be removed while removing the snap that requires it.

The previous remove command will leave a snapshot of app data on your system. Use --purge flag will clear all the app data:

snap remove --purge vlc

By running snap list --all command in terminal, you may see some old versions of app packages left in system marked as “disabled”. To remove one of the disabled package, there’s a ‘revision‘ flag can do the job. For example, remove chromium marked as rev 2254:

snap remove chromium --revision=2254

Thanks to @Fernando, the command below will free up disk space by removing all the old disabled snap packages:

snap list --all | awk '/disabled/{system("sudo snap remove " $1 " --revision=" $3)}'

Summary:

In brief you can run snap find APP_NAME or snap search APP_NAME to search for available packages. Use snap install PACKAGE_NAME or snap remove PACKAGE_NAME to install or remove an application. And run snap list to list all installed snap applications.

Familiar with Linux commands? You may already know many tips and tricks that will save you a lot of time.

Here are some that I have been using for a long period of time, including Tab auto-completion, when you type something in Linux terminal and hit Tab, it auto-completes the command or file path, or outputs all possible options.

And Ctrl+Shift+V will do paste text to terminal instead of Ctrl+V. Without copying to the clipboard, you can simply select / highlight the text and use mouse middle-click to paste into terminal.

Today I found a new terminal tips that I didn’t know before. Thanks to the reddit, I’m going to share it with you by following steps.

1. Drag and drop file or folder to paste the path into terminal.

Just drag and drop a file or folder into terminal, and you’ll see the full path pasted with single quotes. It’s useful if there’s special character in file path or you just don’t want to type …

2. Drag and drop a selection of text into terminal.

You can also drag and drop a selection of text into terminal, so you don’t need to do copy and paste with context menu clicks or keyboard shortcuts.

This is a step by step beginner guide shows how to check local network IP and public IP in both IP4 and IPv6 via either graphical interface or Linux commands in Ubuntu 20.04.

1. Find IP address via System Settings:

For the default Gnome desktop, you can check the wireless network IP address via:

  • Open Settings and navigate to Wi-Fi in left pane.
  • Click on the gear icon after the connected wifi network.
  • In the pop-up it shows the detailed information including your IP address.

To check the wired network IP address, do:

  • Open Settings and navigate to Network in left pane.
  • Click on the gear icon under connected wired network.
  • In the pop-up it shows the detailed information including your IP address.

2. Check Local IP address via ifconfig command:

While wired network name is usually eth0, eth1, eno1, wireless network name is usually wlan0, wlan1, wlo1, …

For other desktops or Ubuntu server without an UI, you can run ifconfig command to find your IP.

ifconfig

If the command does not exit, run command to install it: sudo apt install net-tools

3. Check Local IP address via ip command:

There’s another command looks more straightforward. Simply run:

ip address

4. Check Your Public IP address:

You can search your public ip via Google or other web search engine. If you don’t have a web browser or you’re on Ubuntu server, following commands will tell the public IP.

ifconfig will tell the public IP if you are not behind a router.

Or you can run command in console:

curl https://ipinfo.io/ip

internet speed test

Want to test your internet bandwidth without opening web browser? Well, here’s command line tool to do this using speedtest.net.

This may be help if you’re on Ubuntu Linux servers that doesn’t have a GUI. The tool is based on Python 2.4-3.3, so it works on all Canonical supported Ubuntu releases.

To install the tool, speedtest-cli:

1.) First install python-pip, a tool for installing and managing Python packages. To do so, run below command:

sudo apt-get install python-pip

2.) Install speedtest-cli via python-pip:

sudo pip install speedtest-cli

Once installed, you can use one command to test your internet bandwidth. The command is:

speedtest

You’ll see the similar output, which display you internet bandwidth as well as ISP & IP address.

Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from M-net Telekommunikations GmbH (88.217.180.40)…
Selecting best server based on ping…
Hosted by InterNetX GmbH (Munich) [2.23 km]: 18.756ms
Testing download speed………………………………….
Download: 7.81 Mbit/s
Testing upload speed…………………………………………..
Upload: 3.46 Mbit/s

One Command to Convert .NRG to .ISO in Ubuntu Linux

Last updated: September 4, 2013

NRG A .nrg file is a proprietary CD image file format used by Nero Burning ROM. In Ubuntu Linux, you can easily convert the .nrg to .iso file using the command line tool nrg2iso.

nrg2iso is available in Ubuntu universe repository. You can install it using Ubuntu Software Center. Or run below command if you’re on Ubuntu Server without GUI:

sudo apt-get update; sudo apt-get install nrg2iso

Once installed, you can convert .NGR file to .ISO via one command. For example:

nrg2iso image.nrg image.iso

That’s it. Enjoy!

If you’re dual booting Ubuntu with Windows 7 or other Operating Systems, you may wish to change boot order to set which OS starts by default. Well, In this tutorial I’ll show you how to do it in Ubuntu 13.10 Saucy and 13.04 Raring.

grub2 boot loader

There’s a GUI (graphical user interface) tool for editing Grub 2 boot loader, it called Grub-Customizer. You can install it in Ubuntu using the PPA repository. To do so, press Ctrl+Alt+T to open terminal, then run below commands one by one:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

sudo apt-get update

sudo apt-get install grub-customizer

With Grub-Customizer, highlight the OS entry and click up / down arrow button to change its order. Or set the default OS in General Settings tab.

change boot order via grub customizer

If you’re comfortable with running some terminal commands, it’s not difficult to change default OS without installing any third-party program.

1.) Press Ctrl+Alt+T to open terminal. Edit the “/etc/default/grub” via below command and change GRUB_DEFAULT=0 to GRUB_DEFAULT=saved. This will make it easy to change default OS later.

sudo gedit /etc/default/grub

2.) Update grub to apply changes to grub configuration:

sudo update-grub

3.) After that, you can run sudo grub-set-default with the number of menu entry to boot (the first entry is 0) at any time, which will set the entry as default OS permanently. Or run sudo grub-reboot only for next boot.

For example, below command will set Windows 7 as default OS (Windows 7 is 4 in picture at top) permanently.

sudo grub-set-default 4

This simple tutorial shows you how to repair your Windows 7 boot loader (MBR) from Ubuntu dual boot or Ubuntu Live CD / USB. This can be useful if you don’t have a Windows CD or DVD on hand.

To do so, first boot into your Ubuntu system. When you’re in Ubuntu, press Ctrl+Alt+T on your keyboard to open terminal and follow below steps:

1.) First run below command to check your disk:

sudo fdisk -l

The output tells you the disk information:

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x016c8108

Device Boot Start End Blocks Id System
/dev/sda1 * 63 39054014 19526976 7 HPFS/NTFS/exFAT

2.) Now run commnad to install syslinux, which is a suite of lightweight IBM PC MBR bootloaders for starting up computers with the Linux kernel.

sudo apt-get update; sudo apt-get install syslinux

install syslinux to fix mbr

3.) Once installed, you can fix your Windows bootloader by running below command in terminal:

sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda

Replace the startup disk name /dev/sda in the above command according to the output in step 1.

repair-mbr

Enjoy!

This simple and brief tutorial will show you how to backup live CD or DVD to iso image on Ubuntu Linux using dd command.

dd is a command on Unix and Unix-like operating systems whose primary purpose is to convert and copy a file. On Unix, device drivers for hardware (such as hard disks) and special device files (such as /dev/zero and /dev/random) appear in the file system just like normal files; dd can also read from (and in some cases write to) these files. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining fixed amount of random data.

To make iso image out of CD or DVD:

Insert your live CD or DVD into computer, then you can check the device name by running below command:

df -lh

You’ll get a similar output. The last line tells the device name /dev/sr0 and mount point /media/handbook/CD-Rom

Filesystem Size Used Avail Use% Mounted on
/dev/sda6 92G 47G 41G 54% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 870M 4.0K 870M 1% /dev
tmpfs 176M 980K 175M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 878M 3.5M 874M 1% /run/shm
none 100M 56K 100M 1% /run/user
/dev/sr0 807M 807M 0 100% /media/handbook/CD-Rom

Now, use below command to create iso from it:

dd if=/dev/sr0 of=~/backup.iso bs=1000000 count=512 &&sync

Here if reads from file /dev/sr0, of write to file backup.iso, ~/ means user home directory. The value of ‘bs’ means read and write up to 1000000 bytes at a time.

For more, run:

man dd

How to Flush DNS Cache on Ubuntu 13.04, 12.10

Last updated: July 18, 2013

This simple tutorial will show you how to flush or clear your system’s DNS records on Ubuntu 13.04 Raring and 12.10 Quantal.

Objectives:

  • Flush DNS records on Ubuntu 13.04 or Ubuntu 12.10
  • Enjoy!

To get started, press Ctrl+Alt+T to open a terminal window.

Open Terminal to run commands

Then run command to flush dns:

sudo /etc/init.d/dns-clean restart

You can also use this command:

sudo /etc/init.d/networking force-reload

In addition, to flush nscd dns cache:

sudo /etc/init.d/nscd restart

To flush dnsmasq dns cache:

sudo /etc/init.d/dnsmasq restart

download

This tutorial shows you how to mount / access VMware Virutal Machine File System (vmfs) on Ubuntu (non host).

VMFS is a clustered filesystem designed to store virtual machine disks for VMware ESX or ESXi Server hosts. There is a command line tool for Linux that allows to access VMFS filesystems from some other non ESX/ESXi host for e.g. maintenance tasks.

First install this tool by searching and installing the package from Ubuntu Software Center. Or run the command below:

sudo apt-get install vmfs-tools

Find you vmfs partition by running this command:

sudo fdisk -l

Then mount vmfs with this tool. For example, /dev/sdb3 is the vmfs that we want to mount. We’re going to mount it to /mnt directory. Run this command in terminal (Ctrl+Alt+T):

sudo vmfs-fuse /dev/sdb3 /mnt/

After that, browser with Nautilus file browser.

Enjoy!