Thursday, November 30, 2023

Reducing a video's size with FFMPEG

 The following command uses the H.265 codec that compresses more for the same quality:

ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Other options for further compression are the following:

To scale to half size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" -c:v libx265 -crf 28 half_the_frame_size.mkv

One-third size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/6)*2:trunc(ih/6)*2" -c:v libx265 -crf 28 a_third_the_frame_size.mkv

One-quarter size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/8)*2:trunc(ih/8)*2" -c:v libx265 -crf 28 a_fourth_the_frame_size.mkv

One-fifth size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/10)*2:trunc(ih/10)*2" -c:v libx265 -crf 28 a_fifth_the_frame_size.mkv

In these examples, the size is divided by twice of the reduction value and multiplied by two to ensure the pixel size is a multiple of two, which is required for some codecs, including H265. Changing the resolution always requires re-encoding.



Saturday, March 25, 2023

Removing Hidden Chars from a File

Removing the garbage characters with the Linux/Unix 'tr' command:

To get the binary characters out of your files, there are several approaches, probably the easiest solution involves using the Linux/Unix 'tr' command. To remove non-printable binary characters (garbage) from a Linux/Unix text file do the following:


tr -cd '\11\12\40-\176' < input.c > output.c

----

Thursday, March 09, 2023

Using a Mplayer option to keep the pitch at higher speeds of video or audio.

If you like to listen to an audio or watch a video at higher speed, the sound could get distorted, i.e. with the wrong pitch ("chipmunk mode"). In mplayer when you change the speed using the keys "[" to decrease or "]" to increase; the tempo is not adjusted accordingly. In command line a solution is with the use of  "-af scaletempo" option, example: 

mplayer -af scaletempo videofile.mp4

The speed can be included as 

mplayer -af scaletempo -speed 2 videofile.mp4

or being changed later with  the keys "[" or "]". 

In the case of using a "Mplayer" GUI, like in the case of "SMPlayer", the "-af scaletempo" functionality is already integrated. 



Tuesday, February 28, 2023

MousePad Text Editor Bug

This issue is happening in Ubuntu 22.04 with the MousePad text editor version 0.5.8 

Files are automatically saved in a directory at: ~/.local/share/Mousepad

The files have no extension, they get the name "autosave-0", "autosave-1", "autosave-2", . . . , "autosave-n".

At some point, after a reboot, if you have not saved any of those files and you try to open the MousePad text editor, it won't come up unless you call it through the command line and you will get the following message:


(mousepad:21465): Mousepad-WARNING **: 19:56:09.717: Some 'autosave-*' files in directory '~/.local/share/Mousepad' do not correspond to any session backup anymore. They will not be deleted automatically: please do it manually to remove this warning.


You can go there and delete those files, or save them, or move them to another directory; they are plain text files, you can open those with VIM, NANO, or any other text editor. After those files are removed from that default directory the MousePad text file app will work fine and it will respond to the calls from the GUI.

----

Monday, February 13, 2023

Downloading subtitles from YouTube videos

 This works with youtube-dl and with yt-dlp

yt-dlp --write-auto-sub --sub-lang es --convert-subs=srt --skip-download URL

---

Thursday, September 15, 2022

Compiling the Linux Kernel 5.19.8 under Ubuntu 22.04

Compiling the Linux Kernel version 5.19.8 in Ubuntu 22.04

First we need to install the following:

sudo apt install git libncurses-dev gawk openssl libssl-dev dkms libudev-dev libpci-dev libiberty-dev autoconf llvm

sudo apt install libncurses5-dev libncursesw5-dev

sudo apt install pkg-config

sudo apt install bison

sudo apt install flex

sudo apt install libelf-dev

sudo apt install openssl

sudo apt-get install libssl-dev

sudo apt-get install liblz4-tool 

After downloading and decompressing the Kernel file, under a Terminal go to that directory and run the configuration script:

MyPC:~/Downloads/LinuxKernel/linux-5.19.8$ make menuconfig


We can check our hardware characteristics using the following commands:

lshw

lscpu

lsmod

lspci

lsusb

With that information we can set the configuration file properly.

The compilation process can be started with the command:

make -j 8

The number 8 means that 8 threads will be used for the compilation process. You can check with the command lscpu how many cores and threads your computer support. If you have 4 cores and every core can support 2 threads that makes a total of 8. Using all your threads will speed up the compilation process, in average using 8 threads the compilation would be over in about 30 minutes. If you use just one core or thread it would take over 2 hours to finish the compilation.

If you get the following error:

make[1]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.

make[1]: *** Waiting for unfinished jobs....

make: *** [Makefile:1847: certs] Error 2

make: *** Waiting for unfinished jobs....

You can fix it editing your ".config" file and changing the line:

CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"

to

CONFIG_SYSTEM_TRUSTED_KEYS=""

and run again the command for compilation.

Wednesday, March 09, 2022

Installing jGRASP in Linux

First download and unzip jGRASP for Linux (the bundled version).

Unzip it in a directory, in this case it was downloaded inside the directory "snap". Then create a link to it in /usr/bin/jgrasp as follows:

 sudo  ln  -s  /home/username/snap/jgrasp/bin/jgrasp  /usr/bin/jgrasp

You can call the program from command line or you can also create a desktop icon to call its execution.

Adding support for JavaFX:

First download the JavaFX and unzip it in a proper location, it could be also inside the "snap" directory. Then you need to go in jGRASP to "Settings ==> Compiler Settings ==> Workspace", a new window will be opened, and go to the "JavaFX" tab, there browse and input the JavaFX home path.


Note: the JavaFX has to be of the proper architecture, i.e. x64, or any other correctly corresponding to your machine, otherwise graphics won't work. 


After that, for testing purposes you can use the following code from Oracle.

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
 
public class HelloWorld extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
 
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
}

The outcome will be the following:


Every time the button is clicked you will get the string:

Hello World!

That string is in the terminal in pure text mode.





---

Thursday, February 24, 2022

Converting A4 PDF to Letter Size

 One solution that usually works is to use pdfjam from the texlive distribution

pdfinfo input.pdf 

pdfjam --outfile output.pdf --paper letter input.pdf 

pdfinfo output.pdf 

We can also do the opposite, from Letter size to A4 size.



----///

Wednesday, January 26, 2022

SOFT & HARD LINKS

Soft links

Commonly referred to as symbolic links, soft links link together non-regular and regular files. They can also span multiple filesystems. By definition, a soft link is not a standard file, but a special file that points to an existing file. Format: 

ln -s (file path [original] you want to point to) (the soft path pointing to the original)

Example:

ln -s  /home/simon/snap/jgrasp/bin/jgrasp   /usr/bin/jgrasp

Hard links

The concept of a hard link is the most basic. Every file on the Linux filesystem starts with a single hard link. The link is between the filename and the actual data stored on the filesystem. Creating an additional hard link to a file means a few different things. The syntax is:

ln (original file path) (new file path)

Example:

ln  TestFile  /tmp/link2TestF

First, you create a new filename pointing to the exact same data as the old filename. This means that the two filenames, though different, point to identical data. When changes are made to one filename, the other reflects those changes. The permissions, link count, ownership, timestamps, and file content are the exact same. If the original file is deleted, the data still exists under the secondary hard link. The data is only removed from your drive when all links to the data have been removed. If you find two files with identical properties but are unsure if they are hard-linked, use the "ls -i" command to view the inode number. Files that are hard-linked together share the same inode number. Example:

ls  -li  TestFile  /tmp/link2TestF

Conclusion

  • A hard link always points a filename to data on a storage device.
  • A soft link always points a filename to another filename, which then points to information on a storage device.



Reference: RedHat.

---


Sunday, December 26, 2021

CONCATENATION OF VIDEOS [CONCATENATE]

FFmpeg has three concatenation methods:


1. concat video filter

Use this method if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering.

Note that this method performs a re-encode of all inputs. If you want to avoid the re-encode, you could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding everything.

ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \

-filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] \

concat=n=3:v=1:a=1 [v] [a]" \

-map "[v]" -map "[a]" output.mkv


2. concat demuxer

Use this method when you want to avoid a re-encode and your format does not support file-level concatenation (most files used by general users do not support file-level concatenation).

$ cat mylist.txt

file '/path/to/file1'

file '/path/to/file2'

file '/path/to/file3'

$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4


3. concat protocol

Use this method with formats that support file-level concatenation (MPEG-1, MPEG-2 PS, DV). Do not use with MP4.

$ ffmpeg -i "concat:input1|input2" -codec copy output.mkv

This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method.

--

If in doubt about which method to use, try the concat demuxer.

---

Source: Stackoverflow.


Sunday, September 20, 2020

Commands useful along with Youtube-dl

The following is to download a only a particular part of a video from YouTube 

ffmpeg -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=cmne_rokrs4) -ss 00:10:10 -to 00:12:52 -c:v copy -c:a copy happy.mp4

Or you can download all the video first and then cut some parts following the instructions here.

If you want to concatenate MP4 videos (you can prepare an script):

echo file input1.mp4 >  mylist.txt

echo file input2.mp4 >>  mylist.txt

ffmpeg -f concat -i mylist.txt -c copy output.mp4

To list all subs for a video:

youtube-dl --list-subs URL

To download all subs, but not the video:

youtube-dl --all-subs --skip-download URL

Or you can only download one subtitle

youtube-dl --write-sub --sub-lang en --skip-download URL

Or  for downloading the automatically generated subtitles

youtube-dl --write-auto-sub --skip-download URL

If you want to convert the subtitles do:

ffmpeg -i input.vtt output.srt

The following is to convert videos to a higher speed. For instance, if you want to multiply by 1.15, the command is:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.87*PTS[v];[0:a]atempo=1.15[a]" -map "[v]" -map "[a]" output.mkv

#The "setpts" corresponds to the inversed speed (in this case 100/1.25 = 0.8)

#while the "atempo" corresponds to the desired direct speed of the video.

#Those values are proportionally inversed.

#For a 25% higher speed output video the values

#would be "setpts=0.8*PTS" and "atempo=1.25"

100/1.25 = 0.8

References:

Friday, September 18, 2020

Setting a SSH server in a workstation



sudo apt install openssh-server

systemctl status sshd

sudo systemctl restart ssh

sudo ufw allow ssh

Enable the SSH server to start automatically during the boot.

sudo systemctl enable ssh

Connect from a remote client to your SSH server. First, obtain an IP address of your SSH server. 

ip a

If connecting over the internet you need your external IP address:

echo $(wget -qO - https://api.ipify.org)

Check if IP being used to login via SSH is correct. Re-check IP of device being SSH'd into with:

hostname -I

For Dynamic DNS the freedns.afraid.org works fine with ddclient in Linux.

If you don't want to use the default port 22 for SSH, you need to edit the sshd config file in:

/etc/ssh/sshd_config 

and change the value of "Port 22" in it for another number. You should run SSH on an unprivileged port number, i.e. from 1024 to 65535. You can check what local ports are in use currently to avoid a conflict with:

netstat -taulpn 

and also avoid IANA registered service numbers, check with:

cat /etc/services

Once you have made the appropriate change open a firewall port to correspond with the new SSH port where "xxxx" represent the new number that you chose:

sudo ufw allow xxxx/tcp

Then

sudo systemctl restart ssh

For a SSH connection through a specific port, where "xxxx" is the number chosen, do:

ssh -p xxxx username@{hostname or IP}



----

Sunday, September 06, 2020

Dual Boot Linux and Windows 10

 If Windows was installed to run in UEFI, the Linux OS must also be installed using the UEFI mode. This means that most likely you need to disable in the BIOS the legacy mode and allow secure boot.

Is the "Install Ubuntu alongside Windows 10" option missing?

Please note that in the following circumstances the Ubuntu 20.04 installation option "Install Ubuntu alongside Windows 10" may be missing, if your Windows 10 installation: is not correctly shutdown or is hibernating, has corrupted partition which needs repair, partition has not enough free disk space left for resizing, uses Dynamic Disk or the file system contains uncontrollable file fragmentation.

Another case is if you try to install Linux using legacy boot for your installation media; the installation would be possible but the dual boot won't work. 

-----

References: LinuxConfig.org 


Thursday, August 13, 2020

dd is a great tool to fully wipe out your disk data to forensic levels How to wipe a hard drive clean in Linux

dd is a great tool to fully wipe out your disk data to forensic levels

# dd if=/dev/zero of=/dev/DISK/TO/WIPE bs=4096

# dd if=/dev/zero of=/dev/sda bs=4096

# dd if=/dev/zero of=/dev/sdX bs=512 

If you messed up your master boot record (MBR) you can wipe it using this command:

dd if=/dev/zero of=/dev/hdX bs=446 count=1 #replace X with the target drive letter.

If you are wiping your hard drive for security, you should populate it with random data rather than zeros (This is going to take even longer than the first example.) :

# dd if=/dev/urandom of=/dev/DISK/TO/WIPE bs=4096

# dd if=/dev/urandom of=/dev/sda bs=4096

# dd if=/dev/urandom of=/dev/sdX bs=512 

# dd if=/dev/urandom of=/dev/sdX bs=4096 status=progress

---



Wednesday, April 29, 2020

Set a default audio output device in Ubuntu 18.04


First: List the audio output devices using:

pactl list short sources  

Example of the output:

0 alsa_output.usb-Dell_Dell_AC511_USB_SoundBar-00.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_input.usb-Dell_Dell_AC511_USB_SoundBar-00.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 alsa_output.pci-0000_00_1b.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz IDLE
3 alsa_input.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
4 alsa_input.usb-046d_HD_Pro_Webcam_C920_627B04DF-02.analog-stereo module-alsa-card.c s16le 2ch 32000Hz SUSPENDED

Now, to make this work at every restart, follow this :

sudo -H gedit /etc/pulse/default.pa

Example of the edit:

### Make some devices default ###  sink(for output) / source(for input)
#set-default-sink output 
#set-default-source input
set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
#set-default-source input

----
Sources:
AskUbuntu
Rastating.

Tuesday, October 08, 2019

Compiling the Linux Kernel 5.3.5

In Ubuntu 18.04 we need to install some tools first:

sudo apt install build-essential libncurses5-dev gcc libssl-dev bc flex bison

Then we download and decompress the kernel source code:

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.3.5.tar.xz

tar xvf linux-5.3.5.tar.xz

After that from inside the decompressed directory we run and do the preferred configuration:

make menuconfig

Other options for the configuration would be "oldconfig" and "xconfig"; for this last one we need QT 4.8 or 5.x.

sudo apt install qt5-default

After saving the configuration we run "make" with the option "-j" with the number of processors to speed up the compilation process:

make -j 8
 or
make -j8

My machine has 2 sockets with 4 cores each (Xeon), cache L1d and L1i of 32K each, L2 of 256K and L3 of 10240K; and a total of 16 GB of RAM
Just running plain "make" it took above 2 hours and 10 mins to finish the compilation. When using the -j8 option it took about 32 minutes.

The uncompressed executable that I got is saved directly in the linux-5.3.5 directory with a size of over a 665 MB with the name of "vmlinux".
The compressed executable kernel image is in arch/x86/boot/ with the name of "bzImage" and a size close to 9 MB.

If wanting to get a compiled kernel in the form of a Debian package we need to copy the configuration file from our running boot directory and into the linux-5.3.5 directory.

cp  /boot/config-4.15.0-65-generic  .config

We need to install the "pkg-config" and the "kernel-package" packages:

sudo  apt  install  pkg-config  kernel-package

And then compile it with the deb-pkg command:

make -j8 deb-pkg

Or doing the following steps:

make-kpkg clean

fakeroot make-kpkg -j8 --initrd --append-to-version=-custom kernel_image kernel_headers

After --append-to-version= you can write any string that helps you identify the kernel, but it must begin with a minus (-) and must not contain whitespace.

And to install the kernel in this case would be:

sudo dpkg -i linux-*.deb



Checking the linux kernel source code for special functions, we use the "grep" command to search for specific text inside the kernel source files:

 grep -iRl "sem_init" .

From the list that we get we can check for that text term:

vim ipc/sem.c

Other examples:

grep -iRl "pthread_create" .
vim tools/usb/testusb.c

grep -iRl "pthread_mutex" .
vim tools/lib/lockdep/include/liblockdep/mutex.h

grep -iRl "= fork(" .
vim tools/lib/subcmd/run-command.c

grep -iRl " signal(" .
vim tools/lib/subcmd/sigchain.c




-------------///

Thursday, August 15, 2019

Reducing the size of a video

Calculate the bitrate you need by dividing 1 GB by the video length in seconds. So, for a video of length 16:40 (1000 seconds), use a bitrate of 1000000 bytes/sec:

ffmpeg -i input.mp4 -b 1000000 output.mp4

Additional options that might be worth considering is setting the Constant Rate Factor, which lowers the average bit rate, but retains better quality. Vary the CRF between around 18 and 24 — the lower, the higher the bitrate.

ffmpeg -i input.mp4 -vcodec libx265 -crf 20 output.mp4

Vary the codec as needed - libx264 may be available if libx265 is not, at the cost of a slightly larger resultant file size.

------------||
Other option is to use the program "Handbrake" for Linux.

Friday, July 19, 2019

How to Install Linux Kernel 4.4 in Ubuntu 18.04

The default kernel line for Ubuntu 18.04 LTS is 4.18
I have a Chromebook ASUS C300 and the sound card is  working fine with kernel 4.4 line but not with 4.18, the 4.4 line corresponds to the Ubuntu 16.04 LTS

So I downloaded from the Ubuntu kernels server
https://kernel.ubuntu.com/~kernel-ppa/mainline/
The latest update in the 4.4 line which at this moment is 4.4.185:

linux-headers-4.4.185-0404185_4.4.185-0404185.201907100448_all.deb
linux-headers-4.4.185-0404185-generic_4.4.185-0404185.201907100448_amd64.deb
linux-image-unsigned-4.4.185-0404185-generic_4.4.185-0404185.201907100448_amd64.deb
linux-modules-4.4.185-0404185-generic_4.4.185-0404185.201907100448_amd64.deb

Then it can be installed with the command:
sudo  dpkg  -i  *.deb

You can see a list of your installed kernels with the following command:
dpkg --list | grep linux-image

I'm keeping only the latest versions of the two official lines, we can remove any older version of the 4.4 or the 4.18 with the command:
sudo apt remove linux-image-4.x.x-xxxxxxx-lowlatency

then
sudo apt autoremove

Then we do:  sudo update-grub

We have to edit our grub file to set the default booting kernel
https://forums.gentoo.org/viewtopic-t-1060880-start-0.html

sudo vim /etc/default/grub

In Grub2 we have two different screens before the selection of the kernel, you can check them hitting the "esc" key before the booting. The numbers begin with 0 for the first selection, 1 for the second, and so on. In my case the grub configuration file has the following values for the default, where the number 1 corresponds to the selection in the first screen and the number 2 correspond to the selection for the second screen before the actual boot:

GRUB_DEFAULT="1>2"

Other necessary changes
GRUB_TIMEOUT=10
and comment out either: 
#GRUB_HIDDEN_TIMEOUT=0
or
#GRUB_TIMEOUT_STYLE=hidden

Save & exit.

Then we have to commit with: sudo update-grub

If for some reason we need a higher kernel version, another solution could be downloading the corresponding driver for our sound card and recompiling it for the new kernel.

UPDATE: Up to the kernel 4.4.220 the sound and mic work fine, I have tested kernels beyond that version and the sound is not working. 
I also tried all this in Ubuntu 20.04 but there were broken dependencies for the kernel 4.4.220

----///

Creating Bootable USB Stick On Linux Using Command Line

dd if=~/home/username/path/to/myfile.iso of=/dev/sdb

dd bs=4M if=/path/to/myfile.iso of=/dev/sdx status=progress oflag=sync


----///

Thursday, October 25, 2018

Auto Forwarding Mail From ALPINE To Any Other Email Address

We need just to create a file named ".forward" at your home directory (where your ".pinerc" file is). Here is a sample file:

# Exim filter - do not edit this line!
# only works for exim... others will treat it as a plain .forward file...

# if this filter generates an error, then deliver to original address
if error_message then finish endif

# If you want to forward your email to an offsite address, uncomment and modify
# the following line to use your own email address:
#deliver mymailaddress@gmail.com
deliver myEmailUname@myUni.edu

finish

# Extra Note from Slide
# You can keep the incoming mails as well as
# forward them to unsuspecting recipients. Typing
# "\yourid, other@address.com"
#


We can also create a signature file ".signature" that will be automatically included in all the outgoing mail.

These configurations should also work for MUTT.

----
References:
snmlab.cs.nchu.edu.tw
PPT-PDF presentation

Wednesday, November 01, 2017

Cutting Video with ffmpeg

The highlighted represent the starting point for the cut. In this case no ending point set, so by default the output will include all the remaining of the video.

ffmpeg -i input.mp4 -ss 00:20:01 -async 1 -c copy output.mp4 

If we want to cut the video before the end we cand do it in two ways:

ffmpeg -i input.mp4 -ss 00:20:03 -t 00:01:08 -async 1 -c copy output.mp4

The "-t" option specifies a duration, not an end time. The above command will encode 1 minute and 8 seconds of video starting from the time 00:20:01

ffmpeg -i input.mp4 -ss 00:20:03 -to 00:21:11 -async 1 -c copy output.mp4

If you are using a current version of ffmpeg you can also replace "-t" with "-to" in the above command to end at the specified time.

Note:
Use "-c copy" for making it instantly. In that case ffmpeg will not re-encode the video, just will cut to according size.


-----///

Saturday, November 26, 2016

Rotate a PDF under Linux with pdftk

sudo apt-get install pdftk

To rotate page 1 by 90 degrees clockwise:
pdftk in.pdf cat 1east output out.pdf 

To rotate all pages clockwise:
pdftk in.pdf cat 1-endeast output out.pdf 

From the "man" page
The page rotation setting can cause pdftk to rotate pages and documents. Each option sets the page rotation as follows (in degrees): north: 0, east: 90, south: 180, west: 270, left: -90, right: +90, down: +180. left, right, and down make relative adjustments to a page's rotation.

Adding a Swap Partition After System Installation

Updating partitions.
We need to edit /etc/fstab and add the new swap partition.

sudo nano /etc/fstab

We need to add a line that looks like

UUID=735b3be3-779c-4d21-a944-b033225f3ab4 none   swap    sw      0       0

The UUID can be got using the command

sudo blkid /dev/sdaX

---------///
We can format this partition with:

sudo mkswap /dev/sdX
replacing the X with your partition number. Mount this partition as swap with

sudo swapon -U UUID

If you want to use your swap for hibernating then you need to update the UUID in
/etc/initramfs-tools/conf.d/resume
with this content RESUME=UUID=xxx.
Don't forget to
sudo update-initramfs -u

-----///

Sunday, October 16, 2016

Embedding a PDF in Blogger

The following HTML code is to embed a PDF in Blogger (Blogspot). We only need to change the "srcid" value (the 0B6bwihHnzzPHbHdsQUpFYVQ3Mm8 part for the new corresponding PDF value)


The code can be downloaded from here.
Or copied from here:

<iframe height="480px" src="https://docs.google.com/viewer?srcid=0B6bwihHnzzPHbHdsQUpFYVQ3Mm8&amp;pid=explorer&amp;efh=false&amp;a=v&amp;chrome=false&amp;embedded=true" width="720px"></iframe>

Saturday, October 01, 2016

Mounting the Android Phone in Ubuntu 16.04

I was getting the following pop up message 'Unable to mount Android Device' every time that I plugged my Android smartphone in my Linux Ubuntu 16.04 machine.

I found the solution taking as a reference the following thread.

First I used the following command:

lsusb

That gives me:
Bus 001 Device 004: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)

Then I included this info:
# Samsung LTD Galaxy
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

in the following file:
sudo vim /lib/udev/rules.d/69-libmtp.rules

And the following line:
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666"

In the following file:

sudo vim /lib/udev/rules.d/61-persistent-storage-android.rules

And that's all. After a reboot my Linux PC can mount without problems my Android phone.

-----///