Friday, September 18, 2020
Setting a SSH server in a workstation
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
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
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
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
sudo apt autoremove
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
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.
----///
Creating Bootable USB Stick On Linux Using Command Line
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
# 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
ffmpeg -i input.mp4 -ss 00:20:01 -async 1 -c copy output.mp4
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
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
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 code can be downloaded from here.
Or copied from here:
<iframe height="480px" src="https://docs.google.com/viewer?srcid=0B6bwihHnzzPHbHdsQUpFYVQ3Mm8&pid=explorer&efh=false&a=v&chrome=false&embedded=true" width="720px"></iframe>
Saturday, October 01, 2016
Mounting the Android Phone in Ubuntu 16.04
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.
-----///
Wednesday, June 29, 2016
Updating the Youtube-DL (Now YT-DLP)
sudo pip install youtube-dl
If you want to upgrade youtube-dl
sudo pip install --upgrade youtube-dl
or, if necessary
The following method of installation is even older and deprecated, it's here just as a reference:
sudo apt-get install python-setuptools
sudo easy_install pip
Friday, February 12, 2016
Segmentation fault (core dumped)
sudo vim /etc/security/limits.conf
and add a line like:
username soft core 50000
The previous line is for a core dumped file up to 50000 KB for that user. The user would have to relogin for the changes to take effect. A "small" core dump file is around 10 MB.
-----///
Thursday, October 08, 2015
"ffmpeg" instead of "avconv" in youtube-dl
WARNING: Your copy of avconv is outdated and unable to properly mux separate video and audio files, youtube-dl will download single file media. Update avconv to version 10-0 or newer to fix this.
Use instead:
youtube-dl --prefer-ffmpeg https://www.youtube.com/watch?v=9SgpcpZU-tw
.
Sunday, September 27, 2015
Embedding Subtitles in a Video File
First install the GPAC
sudo apt-get install gpac
Then you can use the following command
MP4Box -add inputfile.srt target.mp4
More about this command in this link.
Another Option to do so:
apt-get install mkvtoolnix
mkvmerge -o output.mkv video.mp4 subtitles.srt
or
mkvmerge -o output.mp4 video.mp4 subtitles.srt
In the case you need subtitle conversion:
ffmpeg -i file.srt file.vtt
or
ffmpeg -i file.vtt file.srt
More info in the ffmpeg manual ("man ffmpeg").
How to download only subtitles of videos using youtube-dl
Options:
--write-sub Write subtitle file
--write-auto-sub Write automatic subtitle file (YouTube only)
--all-subs Download all the available subtitles of the video
--list-subs List all available subtitles for the video
--sub-format FORMAT Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"
--sub-lang LANGS Languages of the subtitles to download (optional) separated by commas, use IETF language tags like 'en,pt'
So for example, to list all subs for a video:
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
To download all subs, but not the video:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
The other way, this really works but makes the file bigger:
mencoder movie.avi -sub movie.srt -o movie.hardsubs.avi -oac copy -ovc lavc -lavcopts vbitrate=1200
Source: Ubuntu Forums.
-----------///
Thursday, October 24, 2013
Converting Still Images to Video from the Command Line
The Packages
You'll need:
ImageMagick
ffmpeg
Resizing Images from the Command Line
ImageMagick includes "mogrify" which is a fine tool for easily changing image size and resolution. Great for converting images for uploading to the web, or preparing large images for video. For example, the following code re-sizes all *.JPG images to a maximum width of 800 pixels and a maximum height of 600 pixels. This will over-write the originals, so take copies of your snaps first!
mogrify -resize 800x600 *.JPG
Morphing Images Together
This step is only needed if you want to create a smooth transition between the images.
Another fine part of ImageMagick is the ability to morph images together. In the following example we take all *.JPG files and create 10 images for each "gap" between the images. The resulting set of images are saved as XXXXX.morph.jpg, where X is the next number in the series.
convert *.JPG -delay 10 -morph 10 %05d.morph.jpg
Creating a Video from Images
ffmpeg can be used to stitch several images together into a video. There are many options, but the following example should be enough to get started. It takes all images that have filenames of XXXXX.morph.jpg, where X is numerical, and creates a video called "output.mp4". The qscale option specifies the picture quality (1 is the highest, and 32 is the lowest), and the "-r" option is used to specify the number of frames per second.
ffmpeg -r 25 -qscale 2 -i %05d.morph.jpg output.mp4
Putting It All Together
Here's a simple example of how to create a video from the command line, using the resizing and morphing techniques we have gone through above. The example first creates a "temp" directory to work in, so we don't risk destroying the original images. Note: the morphing stage may take a while, so be patient!
mkdir temp
cp *.JPG temp/.
mogrify -resize 800x800 temp/*.JPG
convert temp/*.JPG -delay 10 -morph 10 temp/%05d.jpg
ffmpeg -r 25 -qscale 2 -i temp/%05d.jpg output.mp4
# rm -R temp
The Code Used
# Create a directory and copy the original images there for manipulation:
mkdir temp
cp *.JPG temp/.
# Resize the images:
mogrify -resize 200x200 temp/*.JPG
# Create the morph images
convert temp/*.JPG -delay 10 -morph 5 temp/%05d.jpg
# Stitch them together into a video
ffmpeg -r 50 -qscale 2 -i temp/%05d.jpg output.mp4
---------------------------///
In order to make a video out of still images, like in a Power Point or Libre Office Impress, I created one image from every slide starting from a blanc one, naming them form 000.rdp.jpg to 025.rdp.jpg, then I used the command:
avconv -r .1 -qscale 2 -i %03d.rdp.jpg output.mp4
The "-r .1" gave 10 seconds lapse for every slide.
----------
Source: It For Everyone.
Creating an ISO image
sudo dd if=/dev/cdrom of=cd.iso
Create a dvd image
sudo dd if=/dev/dvd of=dvd.iso
Create a scsi cdrom image
For a SCSI CDROM image, your device is probably called /dev/scd0
sudo dd if=/dev/scd0 of=cd.iso
Create an ISO image from files in a directory
To create an ISO image from files within a directory is just as simple. State an output directory and name of the ISO to create, along with a source directory. For example:
mkisofs -o /home/linuxlookup/example.iso /source/directory/
Another way to make any Linux directory into an ISO file:
mkisofs -V LABEL -r DIRECTORY | gzip > cdrom.iso.gz
Using GENISOIMAGE to Create ISO-9660 CD-ROM filesystem
sudo apt-get install genisoimage
To create a vanilla ISO9660 filesystem image of directory:
genisoimage -o cd.iso cd_dir
In the next command the -r and -J ensures long file names work for Unix (using Rock Ridge) and Windows (using Joliet extensions).
genisoimage -r -J -o cd_image.iso /directory
Mounting an image
mkdir -p /mnt/isoimage
mount -o loop -t iso9660 cd.iso /mnt/isoimage
Unmounting
umount -lf /mnt/isoimage
Wednesday, December 26, 2012
How to Put a Password on a PDF File on Linux
Then type this command into the terminal:
pdftk original.pdf output new.pdf user_pw PROMPT
Replace "Original.pdf" with the original name and change "new.pdf" to a name of your choice. Enter a password when prompted. You will now have a password protected PDF.
Saturday, November 17, 2012
How to play movies with subtitles in mplayer
$ mplayer name_of_movie.avi -vobsub name_of_subtitle
As you can note, the name of the subtitle is written without any extension which usually are '.idx', '.ifo' or '.sub'.
The next command will do exactly the same than the first:
$ mplayer name_of_movie.avi -vobsub name_of_subtitle -vobsubid 0
If there is a second language available in the captions then you do:
$ mplayer name_of_movie.avi -vobsub name_of_subtitle -vobsubid 1
The name of the subtitles has to be exactly the same than the name of the movie.
Monday, August 08, 2011
Procedure to mount ISO images under Linux
1) You must login as a root user, if not root user then switch to root user using following command:
$ su -
2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk
3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk
4) Change directory to list files stored inside an ISO image:
# cd /mnt/disk
# ls -l
Setting date and time on Linux/Unix
where:
mm = month
dd = day of month
hh = hour
mi = minute
Example for today date:
sudo date 08081530
Another way, set new data to 8 August 2011 15:30:00, type the following command as root user:
# date -s "8 AUG 2011 15:30:00"
OR
# date --set="8 AUG 2011 15:30:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20110808"
Linux Set Time
To set time use the following syntax:
# date +%T -s "15:30:00"
Tuesday, May 24, 2011
Ubuntu Tip: Howto reduce PDF file size from command line
If you want to reduce PDF file size using command line you can use ghostscript.Ghostscript is used for PostScript/PDF preview and printing. Usually as a back-end to a program such as ghostview, it can display PostScript and PDF documents in an X11 environment.
Furthermore, it can render PostScript and PDF files as graphics to be printed on non-PostScript printers. Supported printers include common dot-matrix, inkjet and laser models.
Package gsfonts contains a set of standard fonts for Ghostscript.
Use the following command syntax to reduce your pdf files
Replace your file names output.pdf, input.pdf files with your file names.
This is only example you can check man gs command for more options.
For greater file size reduction, change /ebook for /screen but the resolution might not be good enough.
If you want to install ghostscript use the following command
------------
Note: You can achieve great reduction in file size using the commands pdftops and then ps2pdf.
Also you can use pdf2ps and then ps2pdf.




