Linux: Difference between revisions

From 太極
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__FORCETOC__
= man =
=== man ===
[https://www.maketecheasier.com/read-linux-man-page/ How to Easily Read a Linux Man Page]
[https://www.maketecheasier.com/read-linux-man-page/ How to Easily Read a Linux Man Page]
* Underlined or Italicized Text: It means you need to replace it with an appropriate argument.
* Underlined or Italicized Text: It means you need to replace it with an appropriate argument.
* Ellipses: It means that argument or expression is repeatable.
* Ellipses: It means that argument or expression is repeatable.


==== Navigation ====
== Navigation ==
[https://wiki.gentoo.org/wiki/Man_page/Navigate Gentoo] and [https://fossbytes.com/linux-lexicon-man-pages-navigation/ fossbytes]
[https://wiki.gentoo.org/wiki/Man_page/Navigate Gentoo] and [https://fossbytes.com/linux-lexicon-man-pages-navigation/ fossbytes]


Line 14: Line 13:
* q – Quit
* q – Quit


==== Search within a man page ====
== Search within a man page ==
Use / and type your search pattern.
Use / and type your search pattern.


Line 25: Line 24:
Regular expression is supported. For example to find all of the long arguments with: /(--)[a-Z]
Regular expression is supported. For example to find all of the long arguments with: /(--)[a-Z]


==== Colored man pages ====
== Colored man pages ==
<span style="color: red">This is a cool tip!</span>
<span style="color: red">This is a cool tip!</span>


Line 41: Line 40:
</pre>
</pre>


==== Navigate to another man page within a man page ====
== Navigate to another man page within a man page ==
See [https://stackoverflow.com/a/38604548 here].
See [https://stackoverflow.com/a/38604548 here].


Line 48: Line 47:
For example : !man cat
For example : !man cat


==== View a specific "Section" ====
== View a specific "Section" ==
* [https://unix.stackexchange.com/a/3587 What do the numbers in a man page mean?]
* [https://unix.stackexchange.com/a/3587 What do the numbers in a man page mean?]
* [https://superuser.com/questions/357048/how-do-you-switch-between-linux-manual-pages How do you switch between Linux manual pages?]
* [https://superuser.com/questions/357048/how-do-you-switch-between-linux-manual-pages How do you switch between Linux manual pages?]
Line 60: Line 59:
</syntaxhighlight>
</syntaxhighlight>


==== Read man pages in vi without using temporary files ====
== Read man pages in vi without using temporary files ==
[https://stackoverflow.com/a/16740302 What is a way to read man pages in vim without using temporary files]
[https://stackoverflow.com/a/16740302 What is a way to read man pages in vim without using temporary files]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 66: Line 65:
</syntaxhighlight>
</syntaxhighlight>


==== Search man page referenced by ====
== Search man page referenced by ==
'''man -f KEYWORD'''
'''man -f KEYWORD'''


This command is equivalent to '''whatis -r KEYWORD'''
This command is equivalent to '''whatis -r KEYWORD'''


==== Search from all man pages ====
== Search from all man pages ==
'''man -k KEYWORD''' will give you a list of all man pages which relate to 'KEYWORD'.
'''man -k KEYWORD''' will give you a list of all man pages which relate to 'KEYWORD'.


==== TLDR pages: alternative to Man ====
== TLDR pages: alternative to Man ==
[https://fossbytes.com/tldr-pages-linux-man-pages-alternative/ TLDR pages: Simplified Alternative To Linux Man Pages]. Note I got a syntax error when running ''tldr --update''.
[https://fossbytes.com/tldr-pages-linux-man-pages-alternative/ TLDR pages: Simplified Alternative To Linux Man Pages]. Note I got a syntax error when running ''tldr --update''.


=== Some books ===
= Some books =
* UNIX in a nutshell
* UNIX in a nutshell
* sed & awk
* sed & awk
Line 96: Line 95:
* [https://opensource.com/article/18/5/list-books-Linux-open-source 17 books for Linux and open source fans]
* [https://opensource.com/article/18/5/list-books-Linux-open-source 17 books for Linux and open source fans]


=== Beautiful desktop ===
= Beautiful desktop =
* http://lifehacker.com/the-aincrad-desktop-1732684767
* http://lifehacker.com/the-aincrad-desktop-1732684767
* http://lifehacker.com/the-distant-pyramid-desktop-1654404411
* http://lifehacker.com/the-distant-pyramid-desktop-1654404411
Line 102: Line 101:
* http://lifehacker.com/the-midsummer-nights-desktop-1704207155
* http://lifehacker.com/the-midsummer-nights-desktop-1704207155


==== .desktop file ====
== .desktop file ==
This is not related to ''beautiful desktop''. It is used to launch applications in Linux. Without the .desktop file, your application won’t show up in the Applications menu and you can’t launch it with third-party launchers such as Synapse and [https://www.maketecheasier.com/albert-launcher-linux/ Albert Launcher].
This is not related to ''beautiful desktop''. It is used to launch applications in Linux. Without the .desktop file, your application won’t show up in the Applications menu and you can’t launch it with third-party launchers such as Synapse and [https://www.maketecheasier.com/albert-launcher-linux/ Albert Launcher].


Line 112: Line 111:
* /usr/share/applications
* /usr/share/applications


==== List of installed desktop environment ====
== List of installed desktop environment ==
<pre>
<pre>
ls -l /usr/share/xsessions/
ls -l /usr/share/xsessions/
</pre>
</pre>


==== Themes ====
== Themes ==
[https://www.maketecheasier.com/best-linux-dark-themes/ 5 of the Best Linux Dark Themes that Are Easy on the Eyes]
[https://www.maketecheasier.com/best-linux-dark-themes/ 5 of the Best Linux Dark Themes that Are Easy on the Eyes]


=== Virtual consoles/virtual terminals ===
= Virtual consoles/virtual terminals =
Linux allows ''virtual consoles'' (aka ''virtual terminals'') to be opened while an ''X Window System'' is executing.
Linux allows ''virtual consoles'' (aka ''virtual terminals'') to be opened while an ''X Window System'' is executing.


Line 127: Line 126:
[https://opensource.com/article/16/11/managing-devices-linux Managing devices in Linux] -> Fun with device files.
[https://opensource.com/article/16/11/managing-devices-linux Managing devices in Linux] -> Fun with device files.


==== Change console fonts ====
== Change console fonts ==
https://www.linux.com/learn/intro-to-linux/2018/1/how-change-your-linux-console-fonts
https://www.linux.com/learn/intro-to-linux/2018/1/how-change-your-linux-console-fonts


=== Desktops/Workspaces ===
= Desktops/Workspaces =
'''Ctrl + Alt + ->''' or '''Ctrl + Alt + <-''' to switch workspaces.
'''Ctrl + Alt + ->''' or '''Ctrl + Alt + <-''' to switch workspaces.


Line 141: Line 140:
[https://www.lifewire.com/complete-list-of-linux-mint-4064592 Complete List of Linux Mint 18 Keyboard Shortcuts for Cinnamon] for more examples.
[https://www.lifewire.com/complete-list-of-linux-mint-4064592 Complete List of Linux Mint 18 Keyboard Shortcuts for Cinnamon] for more examples.


=== Virtual memory ===
= Virtual memory =


==== vmstat ====
== vmstat ==
* [http://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ '''vmstat''' – A Standard Nifty Tool to Report Virtual Memory Statistics]
* [http://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ '''vmstat''' – A Standard Nifty Tool to Report Virtual Memory Statistics]
* [https://www.howtogeek.com/424334/how-to-use-the-vmstat-command-on-linux/ How to Use the vmstat Command on Linux]
* [https://www.howtogeek.com/424334/how-to-use-the-vmstat-command-on-linux/ How to Use the vmstat Command on Linux]


==== hcache ====
== hcache ==
A tool fork from pcstat, with a feature that showing top X biggest cache files globally
A tool fork from pcstat, with a feature that showing top X biggest cache files globally
* https://github.com/silenceshell/hcache
* https://github.com/silenceshell/hcache
* http://www.datastart.cn/tech/2017/05/20/hcache.html
* http://www.datastart.cn/tech/2017/05/20/hcache.html


=== Memory ===
= Memory =
[https://www.makeuseof.com/tag/manage-linux-ram/ Is Linux Eating Your RAM? How to Manage Your Memory]
[https://www.makeuseof.com/tag/manage-linux-ram/ Is Linux Eating Your RAM? How to Manage Your Memory]


Line 172: Line 171:
</syntaxhighlight>
</syntaxhighlight>


==== Logging memory ====
== Logging memory ==
* [[#System_monitor_tools_.28GUI.29 | Linux system monitor tools]] where [http://sebastien.godard.pagesperso-orange.fr/documentation.html Sysstat] package can be used.
* [[#System_monitor_tools_.28GUI.29 | Linux system monitor tools]] where [http://sebastien.godard.pagesperso-orange.fr/documentation.html Sysstat] package can be used.
* [https://www.linux.com/learn/how-much-memory-installed-and-being-used-your-linux-systems How Much Memory Is Installed and Being Used on Your Linux Systems?]
* [https://www.linux.com/learn/how-much-memory-installed-and-being-used-your-linux-systems How Much Memory Is Installed and Being Used on Your Linux Systems?]
Line 183: Line 182:
** '''htop'''
** '''htop'''


==== ps_mem: Shows Per-Program Memory Usage On Linux ====
== ps_mem: Shows Per-Program Memory Usage On Linux ==
https://www.linuxuprising.com/2019/04/psmem-shows-per-program-memory-usage-on.html. In this case I have 6 tabs open in chrome and 12 tabs for firefox.
https://www.linuxuprising.com/2019/04/psmem-shows-per-program-memory-usage-on.html. In this case I have 6 tabs open in chrome and 12 tabs for firefox.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 197: Line 196:
</syntaxhighlight>
</syntaxhighlight>


==== Check RAM information ====
== Check RAM information ==
* [https://www.binarytides.com/linux-command-check-memory-usage 5 commands to check memory usage on Linux]
* [https://www.binarytides.com/linux-command-check-memory-usage 5 commands to check memory usage on Linux]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 203: Line 202:
</syntaxhighlight>
</syntaxhighlight>


==== Monitor Memory Utilization And Send an Email ====
== Monitor Memory Utilization And Send an Email ==
[https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-usage-and-send-email/ Bash Script to Monitor Memory Usage on Linux]
[https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-usage-and-send-email/ Bash Script to Monitor Memory Usage on Linux]


=== ps, pgrep and pidof: How much resource is used by a process ===
= ps, pgrep and pidof: How much resource is used by a process =
Find the process ID first by '''ps -ef | grep APPLICATIONAME''' where "-e" is to show the running processes and "-f" is for a full listing. Then
Find the process ID first by '''ps -ef | grep APPLICATIONAME''' where "-e" is to show the running processes and "-f" is for a full listing. Then
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 241: Line 240:
</syntaxhighlight>
</syntaxhighlight>


=== All You Need To Know About Processes in Linux ===
= All You Need To Know About Processes in Linux =
http://www.tecmint.com/linux-process-management/
http://www.tecmint.com/linux-process-management/


=== [https://www.ghacks.net/2017/11/04/5-things-to-do-after-a-fresh-install-of-gnulinux/ Things to do after a fresh install of GNU/Linux] ===
= [https://www.ghacks.net/2017/11/04/5-things-to-do-after-a-fresh-install-of-gnulinux/ Things to do after a fresh install of GNU/Linux] =


# Run upgrade such as '''apt-get update; apt-get upgrade'''. It helps to resolve the unmet dependencies issue too.
# Run upgrade such as '''apt-get update; apt-get upgrade'''. It helps to resolve the unmet dependencies issue too.
Line 253: Line 252:
# Install ClamAV / Clamtk antivirus
# Install ClamAV / Clamtk antivirus


=== Query whether the OS is 64-bit or 32-bit ===
= Query whether the OS is 64-bit or 32-bit =
<pre>
<pre>
SYSTEM_ARCH=getconf LONG_BIT
SYSTEM_ARCH=getconf LONG_BIT
Line 259: Line 258:
</pre>
</pre>


=== Switch user in command line ===
= Switch user in command line =
use <pre>su newusername</pre> to switch to another user.
use <pre>su newusername</pre> to switch to another user.


=== Command line improved ===
= Command line improved =
https://remysharp.com/2018/08/23/cli-improved
https://remysharp.com/2018/08/23/cli-improved


=== Directory permission / attribute ===
= Directory permission / attribute =
See http://unix.stackexchange.com/questions/21251/how-do-directory-permissions-in-linux-work
See http://unix.stackexchange.com/questions/21251/how-do-directory-permissions-in-linux-work


Line 276: Line 275:
When we create a new directory, the attribute is 775. Some pre-created directories (Desktop, Documents, Music, Pictures, Public) have an attribute 755.
When we create a new directory, the attribute is 775. Some pre-created directories (Desktop, Documents, Music, Pictures, Public) have an attribute 755.


=== Making a new temporary directory ===
= Making a new temporary directory =
https://www.howtoforge.com/linux-mktemp-command/  
https://www.howtoforge.com/linux-mktemp-command/  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 284: Line 283:
</syntaxhighlight>
</syntaxhighlight>


=== Special permissions ===
= Special permissions =
* [https://www.linux.com/learn/understanding-linux-file-permissions Understanding Linux File Permissions]
* [https://www.linux.com/learn/understanding-linux-file-permissions Understanding Linux File Permissions]
* [https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits How to use special permissions: the setuid, setgid and sticky bits]
* [https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits How to use special permissions: the setuid, setgid and sticky bits]
Line 290: Line 289:
'''s''' bit - setuid, getuid
'''s''' bit - setuid, getuid


=== Shell ===
= Shell =
==== Change to root shell ====
== Change to root shell ==
The following command will switch to an environment similar to what the user would expect had the user logged in directly.  
The following command will switch to an environment similar to what the user would expect had the user logged in directly.  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 312: Line 311:
When sudo is invoked, it asks for the password of the user who started it.
When sudo is invoked, it asks for the password of the user who started it.


==== Switch to another user and run a command ====
== Switch to another user and run a command ==
* [https://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/ Linux Run Command As Another User]
* [https://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/ Linux Run Command As Another User]
'''runuser -l''' command
'''runuser -l''' command
Line 338: Line 337:
</syntaxhighlight>
</syntaxhighlight>


==== What’s the Difference Between Bash, Zsh, and Other Linux Shells ====
== What’s the Difference Between Bash, Zsh, and Other Linux Shells ==
https://www.howtogeek.com/68563/htg-explains-what-are-the-differences-between-linux-shells/
https://www.howtogeek.com/68563/htg-explains-what-are-the-differences-between-linux-shells/


==== Bash shell programming ====
== Bash shell programming ==
http://bash.cyberciti.biz/guide/Main_Page
http://bash.cyberciti.biz/guide/Main_Page


==== [https://fishshell.com/ Fish shell] ====
== [https://fishshell.com/ Fish shell] ==
[https://www.ostechnix.com/oh-fish-make-shell-beautiful/ Oh My Fish! Make Your Shell Beautiful]
[https://www.ostechnix.com/oh-fish-make-shell-beautiful/ Oh My Fish! Make Your Shell Beautiful]


==== Tools To Record Your Terminal And Generate Animated Gif or SVG Images ====
== Tools To Record Your Terminal And Generate Animated Gif or SVG Images ==
* [https://www.2daygeek.com/terminalizer-a-tool-to-record-your-terminal-and-generate-animated-gif-images/ Terminalizer – A Tool To Record Your Terminal And Generate Animated Gif Images]
* [https://www.2daygeek.com/terminalizer-a-tool-to-record-your-terminal-and-generate-animated-gif-images/ Terminalizer – A Tool To Record Your Terminal And Generate Animated Gif Images]
* [https://www.2daygeek.com/termtosvg-record-your-terminal-sessions-as-svg-animations-in-linux/# Termtosvg – Record Your Terminal Sessions As SVG Animations In Linux]
* [https://www.2daygeek.com/termtosvg-record-your-terminal-sessions-as-svg-animations-in-linux/# Termtosvg – Record Your Terminal Sessions As SVG Animations In Linux]


=== Redirect standard error ===
= Redirect standard error =
http://bash.cyberciti.biz/guide/Standard_error. Use '''2>''' operator.
http://bash.cyberciti.biz/guide/Standard_error. Use '''2>''' operator.
<pre>
<pre>
Line 357: Line 356:
</pre>
</pre>


=== Quotes and asterisk ===
= Quotes and asterisk =
Combining these two will not work. For example
Combining these two will not work. For example
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 369: Line 368:
</syntaxhighlight>
</syntaxhighlight>


=== ls command ===
= ls command =
To use UID/GID instead of the user name and group name in '''ls -l''', use the '''-n''' option.
To use UID/GID instead of the user name and group name in '''ls -l''', use the '''-n''' option.
<pre>
<pre>
Line 383: Line 382:
</pre>
</pre>


==== Follow the symbolic link ====
== Follow the symbolic link ==
Use '''-H''' option
Use '''-H''' option
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 389: Line 388:
</syntaxhighlight>
</syntaxhighlight>


==== ls | more without lose color ====
== ls | more without lose color ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ ls --color=auto
$ ls --color=auto
Line 396: Line 395:
Most likely your ls is aliased to ls --color=auto. If you do ls --color (which is morally equivalent to ls --color=always), that will force it to turn on colors.
Most likely your ls is aliased to ls --color=auto. If you do ls --color (which is morally equivalent to ls --color=always), that will force it to turn on colors.


==== ls output with color background ====
== ls output with color background ==
[http://unix.stackexchange.com/questions/94498/what-causes-this-green-background-in-ls-output stackexchange] or [http://askubuntu.com/questions/17299/what-do-the-different-colors-mean-in-the-terminal askubuntu].
[http://unix.stackexchange.com/questions/94498/what-causes-this-green-background-in-ls-output stackexchange] or [http://askubuntu.com/questions/17299/what-do-the-different-colors-mean-in-the-terminal askubuntu].


In my case, after I apply '''chmod 755 -R XXXX''', the weird green background color goes away.
In my case, after I apply '''chmod 755 -R XXXX''', the weird green background color goes away.


==== ls on BSD/macOS ====
== ls on BSD/macOS ==
Use the '''-G''' option to get a color output
Use the '''-G''' option to get a color output
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 407: Line 406:
</syntaxhighlight>
</syntaxhighlight>


=== tree command ===
= tree command =
'''tree -d''': show directories only
'''tree -d''': show directories only


=== cp command ===
= cp command =
[https://www.howtoforge.com/linux-cp-command/ Linux cp command tutorial for beginners (8 examples)]
[https://www.howtoforge.com/linux-cp-command/ Linux cp command tutorial for beginners (8 examples)]


==== copy a directory ====
== copy a directory ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
cp -avr Dir1 Dir2
cp -avr Dir1 Dir2
Line 419: Line 418:
where -a will preserve the attributes of files/directories, -v means verbally and -r means copy the directory recursively.
where -a will preserve the attributes of files/directories, -v means verbally and -r means copy the directory recursively.


=== Copy a file with progress bar with '''pv''' (plus how to eject the USB drive) ===
= Copy a file with progress bar with '''pv''' (plus how to eject the USB drive) =
http://www.tecmint.com/monitor-copy-backup-tar-progress-in-linux-using-pv-command/
http://www.tecmint.com/monitor-copy-backup-tar-progress-in-linux-using-pv-command/


Line 437: Line 436:
My testing shows this procedure works (tested by running '''md5sum''' after eject/plug-in) when I need to copy a 9GB file.
My testing shows this procedure works (tested by running '''md5sum''' after eject/plug-in) when I need to copy a 9GB file.


==== Reliable way: Split the large file and copy smaller chunks ====
== Reliable way: Split the large file and copy smaller chunks ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
# Use 'sudo iotop -o' to monitor the I/O
# Use 'sudo iotop -o' to monitor the I/O
Line 454: Line 453:
Remember: Use a reliable USB drives.
Remember: Use a reliable USB drives.


==== The operation could not be completed because the volume is dirty ====
== The operation could not be completed because the volume is dirty ==
On a USB 2.0 drive, I can copy files to there but the drive cannot be rejected (Ubuntu has a pop-up showing it is still writing data to it).
On a USB 2.0 drive, I can copy files to there but the drive cannot be rejected (Ubuntu has a pop-up showing it is still writing data to it).


Line 486: Line 485:
</pre>
</pre>


=== Files ===
= Files =
==== List files by sorting according to the file size ====
== List files by sorting according to the file size ==
Use the '''-S''' option in ls.
Use the '''-S''' option in ls.


==== List files using wildcard without showing files under subdirectories ====
== List files using wildcard without showing files under subdirectories ==
Use the '''-d''' option in ls. For example, the following command will not showing files under R-3.4.4 and R-3.5.3
Use the '''-d''' option in ls. For example, the following command will not showing files under R-3.4.4 and R-3.5.3
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 500: Line 499:
</syntaxhighlight>
</syntaxhighlight>


==== Delete multiple files ====
== Delete multiple files ==
[http://www.howtogeek.com/276516/how-to-remove-multiple-subdirectories-with-one-linux-command/ How to Remove Multiple Subdirectories with One Linux Command]
[http://www.howtogeek.com/276516/how-to-remove-multiple-subdirectories-with-one-linux-command/ How to Remove Multiple Subdirectories with One Linux Command]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 506: Line 505:
</syntaxhighlight>
</syntaxhighlight>


==== Delete a certain type of files recursively under a directory ====
== Delete a certain type of files recursively under a directory ==
For example to delete *.o files under the current directory,
For example to delete *.o files under the current directory,
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 512: Line 511:
</syntaxhighlight>
</syntaxhighlight>


==== Create a new directory and cd to it ====
== Create a new directory and cd to it ==
[http://www.howtogeek.com/273304/how-to-make-a-new-directory-and-change-to-it-with-a-single-command-in-linux/ How to Make a New Directory and Change to It with a Single Command in Linux]
[http://www.howtogeek.com/273304/how-to-make-a-new-directory-and-change-to-it-with-a-single-command-in-linux/ How to Make a New Directory and Change to It with a Single Command in Linux]
<pre>
<pre>
Line 518: Line 517:
</pre>
</pre>


==== chown and chmod recursively (-R) ====
== chown and chmod recursively (-R) ==
Use '''-R''' (capital R).
Use '''-R''' (capital R).


==== Display files sorted by modified date in a directory recursively ====
== Display files sorted by modified date in a directory recursively ==
* [http://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s stackoverflow.com]  
* [http://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s stackoverflow.com]  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 532: Line 531:
Both of methods give the same output. Note the latest changed file is shown at the bottom of the output.
Both of methods give the same output. Note the latest changed file is shown at the bottom of the output.


==== Sort files by their size ====
== Sort files by their size ==
use the '-S' option.
use the '-S' option.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 538: Line 537:
</syntaxhighlight>
</syntaxhighlight>


=== alias ===
= alias =
https://www.cyberciti.biz/faq/how-to-turn-on-or-off-colors-in-bash/
https://www.cyberciti.biz/faq/how-to-turn-on-or-off-colors-in-bash/


Line 562: Line 561:
</pre>
</pre>


=== lolcat - bring color to text ===
= lolcat - bring color to text =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo apt-get install ruby
sudo apt-get install ruby
Line 582: Line 581:
</syntaxhighlight>
</syntaxhighlight>


=== File manager ===
= File manager =
==== Cloud commander ====
== Cloud commander ==
* https://cloudcmd.io/
* https://cloudcmd.io/
* https://www.ostechnix.com/cloud-commander-a-web-file-manager-with-console-and-editor/. You can upload files from the Cloud services like Google drive, Dropbox, Amazon cloud drive, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram and many.
* https://www.ostechnix.com/cloud-commander-a-web-file-manager-with-console-and-editor/. You can upload files from the Cloud services like Google drive, Dropbox, Amazon cloud drive, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram and many.


=== [http://meldmerge.org/ Meld] and [http://diffuse.sourceforge.net/about.html Diffuse] ===
= [http://meldmerge.org/ Meld] and [http://diffuse.sourceforge.net/about.html Diffuse] =


To make meld to be in the right click menu, follow  
To make meld to be in the right click menu, follow  
Line 597: Line 596:
The 'nautilus-compare' program does not work from my testing on Ubuntu 14.04.
The 'nautilus-compare' program does not work from my testing on Ubuntu 14.04.


==== Refresh does not work ====
== Refresh does not work ==
On Ubuntu 14, Meld version is 1.8.4. The current version is 1.16.2 (Jul 30 2016). The current version requires GTK+ 3.14 or higher.
On Ubuntu 14, Meld version is 1.8.4. The current version is 1.16.2 (Jul 30 2016). The current version requires GTK+ 3.14 or higher.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 606: Line 605:
* http://askubuntu.com/questions/638443/how-to-upgrade-gtk-3-10-to-gtk-3-14-on-ubuntu-14-04
* http://askubuntu.com/questions/638443/how-to-upgrade-gtk-3-10-to-gtk-3-14-on-ubuntu-14-04


==== Final though ====
== Final though ==
* I install kdiff3 (<2 MB to download) and the 'File' -> 'Reload' (F5) function there works though it shows an extra space on the place I modified.
* I install kdiff3 (<2 MB to download) and the 'File' -> 'Reload' (F5) function there works though it shows an extra space on the place I modified.
* [http://www.scootersoftware.com/download.php Beyond Compare] (commercial $60, trial version can be downloaded)  
* [http://www.scootersoftware.com/download.php Beyond Compare] (commercial $60, trial version can be downloaded)  
Line 615: Line 614:
</syntaxhighlight>
</syntaxhighlight>


=== diff ===
= diff =
==== Run diff with large files ====
== Run diff with large files ==
Meld freezes When I tested it with two large files (800k & 936k lines coming from human gtf files). Actually the whole linux system became unresponsive.
Meld freezes When I tested it with two large files (800k & 936k lines coming from human gtf files). Actually the whole linux system became unresponsive.


Actually Meld is sluggish when it is used in small files in Odroid XU4 running Ubuntu 16.04 MATE. I have used Meld 3.14.2 and the latest 3.16.2.
Actually Meld is sluggish when it is used in small files in Odroid XU4 running Ubuntu 16.04 MATE. I have used Meld 3.14.2 and the latest 3.16.2.


==== Directory ====
== Directory ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
diff -qr dir1 dir2
diff -qr dir1 dir2
Line 627: Line 626:
where '''-q''' means to report only when files differ and '''-r''' is to recursively compare any subdirectories found.
where '''-q''' means to report only when files differ and '''-r''' is to recursively compare any subdirectories found.


==== diff & colordiff-color in terminal ====
== diff & colordiff-color in terminal ==
PS. For a GUI version of diff, [http://meldmerge.org/ Meld] works fine.
PS. For a GUI version of diff, [http://meldmerge.org/ Meld] works fine.
Need to install first. apt-get install colordiff. http://www.cyberciti.biz/programming/color-terminal-highlighter-for-diff-files/
Need to install first. apt-get install colordiff. http://www.cyberciti.biz/programming/color-terminal-highlighter-for-diff-files/
Line 680: Line 679:
* cvsstuff=cyan
* cvsstuff=cyan


=== gnome-terminal ===
= gnome-terminal =


==== Remember the session ====
== Remember the session ==
* [http://manpages.ubuntu.com/manpages/xenial/man1/gnome-terminal.1.html gnome-terminal --help-all] '''--tab-with-profile'''
* [http://manpages.ubuntu.com/manpages/xenial/man1/gnome-terminal.1.html gnome-terminal --help-all] '''--tab-with-profile'''
** https://stackoverflow.com/questions/17422810/opening-terminal-with-multiple-tabs-using-shell-script
** https://stackoverflow.com/questions/17422810/opening-terminal-with-multiple-tabs-using-shell-script
Line 696: Line 695:
</pre>
</pre>


==== Fun: piano ====
== Fun: piano ==
[https://www.ostechnix.com/let-us-play-piano-terminal-using-pc-keyboard/ Let Us Play Piano In Terminal Using Our PC Keyboard]
[https://www.ostechnix.com/let-us-play-piano-terminal-using-pc-keyboard/ Let Us Play Piano In Terminal Using Our PC Keyboard]


=== Terminals in grids ===
= Terminals in grids =
==== [https://gnometerminator.blogspot.com/p/introduction.html Terminator] ====
== [https://gnometerminator.blogspot.com/p/introduction.html Terminator] ==
* [https://www.tecmint.com/linux-terminal-emulators/ 20 Useful Terminal Emulators for Linux]
* [https://www.tecmint.com/linux-terminal-emulators/ 20 Useful Terminal Emulators for Linux]
* https://wiki.archlinux.org/index.php/Terminator (include some keyboard shortcuts)
* https://wiki.archlinux.org/index.php/Terminator (include some keyboard shortcuts)
Line 713: Line 712:
* You can take a screenshot to record the directories for all split screens.
* You can take a screenshot to record the directories for all split screens.


==== GNU screen ====
== GNU screen ==
* https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
* https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
* http://unix.stackexchange.com/questions/7453/how-to-split-the-terminal-into-more-than-one-view
* http://unix.stackexchange.com/questions/7453/how-to-split-the-terminal-into-more-than-one-view
Line 732: Line 731:
** Note: After splitting, you need to go into the new region and start a new session via Ctrl + a then c before you can use that area.
** Note: After splitting, you need to go into the new region and start a new session via Ctrl + a then c before you can use that area.


==== tmux* ====
== tmux* ==
* https://github.com/tmux/tmux/wiki
* https://github.com/tmux/tmux/wiki
* For the prefix key, '''ctrl+a''' is easier than "ctrl+b" to type. '''F1...F4''' works too but F1 will have a conflict with Gnome Terminal.  
* For the prefix key, '''ctrl+a''' is easier than "ctrl+b" to type. '''F1...F4''' works too but F1 will have a conflict with Gnome Terminal.  
Line 816: Line 815:
</pre>
</pre>


==== [http://byobu.co/ Byobu] ====
== [http://byobu.co/ Byobu] ==
Byobu is a GPLv3 open source text-based window manager and [https://en.wikipedia.org/wiki/Terminal_multiplexer terminal multiplexer]. It appeared at [http://dirk.eddelbuettel.com/blog/2018/01/26/#prrd_0.0.2 Think inside the box].
Byobu is a GPLv3 open source text-based window manager and [https://en.wikipedia.org/wiki/Terminal_multiplexer terminal multiplexer]. It appeared at [http://dirk.eddelbuettel.com/blog/2018/01/26/#prrd_0.0.2 Think inside the box].


Line 888: Line 887:
: [[File:Byobu.png|200px]]
: [[File:Byobu.png|200px]]


==== Guake ====
== Guake ==
* https://github.com/Guake/guake
* https://github.com/Guake/guake
* [https://www.linuxuprising.com/2019/05/new-guake-drop-down-terminal-ppa-ubuntu.html New Guake Drop-Down Terminal PPA (Ubuntu And Linux Mint Installation)]
* [https://www.linuxuprising.com/2019/05/new-guake-drop-down-terminal-ppa-ubuntu.html New Guake Drop-Down Terminal PPA (Ubuntu And Linux Mint Installation)]


=== [https://github.com/Guake/guake Guake] / Yakuake / Tilda ===  
= [https://github.com/Guake/guake Guake] / Yakuake / Tilda =  
Drop down terminals for the GNOME / KDE / GTK Environments. Great for quick access to a terminal!
Drop down terminals for the GNOME / KDE / GTK Environments. Great for quick access to a terminal!


=== System date/time, ntpd ===
= System date/time, ntpd =
* [http://www.ubuntugeek.com/install-and-configure-network-time-protocol-ntp-serverclients-on-ubuntu-16-10-server.html Install and configure Network Time Protocol (NTP) Server,Clients on Ubuntu 16.10 Server]
* [http://www.ubuntugeek.com/install-and-configure-network-time-protocol-ntp-serverclients-on-ubuntu-16-10-server.html Install and configure Network Time Protocol (NTP) Server,Clients on Ubuntu 16.10 Server]
* [https://www.cyberciti.biz/faq/how-to-bind-ntpd-to-specific-ip-addresses-on-linuxunix/ How to bind ntpd to specific IP addresses on Linux/Unix]
* [https://www.cyberciti.biz/faq/how-to-bind-ntpd-to-specific-ip-addresses-on-linuxunix/ How to bind ntpd to specific IP addresses on Linux/Unix]
Line 910: Line 909:
</syntaxhighlight>
</syntaxhighlight>


=== Change the date/timestamp of a file - touch ===
= Change the date/timestamp of a file - touch =
Modify the file relative to its existing modification time  
Modify the file relative to its existing modification time  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 920: Line 919:
See [http://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file How can I change the date modified/created of a file?]
See [http://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file How can I change the date modified/created of a file?]


=== Find binary file location ===
= Find binary file location =
* '''which''' - Display the full path of shell commands. See examples from [http://www.cyberciti.biz/faq/unix-linux-which-command-examples-syntax-to-locate-programs/ cyberciti.biz].
* '''which''' - Display the full path of shell commands. See examples from [http://www.cyberciti.biz/faq/unix-linux-which-command-examples-syntax-to-locate-programs/ cyberciti.biz].
: <syntaxhighlight lang='bash'>
: <syntaxhighlight lang='bash'>
Line 944: Line 943:
: See [https://superuser.com/a/705854 How to use updatedb command as an ordinary user?], [https://hpc.nih.gov/training/handouts/Data_Management_for_Groups.pdf#page=53 Use updatedb and locate to index files].
: See [https://superuser.com/a/705854 How to use updatedb command as an ordinary user?], [https://hpc.nih.gov/training/handouts/Data_Management_for_Groups.pdf#page=53 Use updatedb and locate to index files].


=== find: Find a file ===
= find: Find a file =
==== -iname ====
== -iname ==
Search by a file name
Search by a file name
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 962: Line 961:
</syntaxhighlight>
</syntaxhighlight>


==== -mtime, -ctime, -atime argument ====
== -mtime, -ctime, -atime argument ==
Find files modified in 10 days.
Find files modified in 10 days.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 994: Line 993:
* atime (access time) is the timestamp that indicates the time that a file has been accessed.
* atime (access time) is the timestamp that indicates the time that a file has been accessed.


==== xargs ====
== xargs ==
See [[Linux_Programming#xargs|Linux Programming]]
See [[Linux_Programming#xargs|Linux Programming]]


==== -exec COMMAND {} + ====
== -exec COMMAND {} + ==
* [https://unix.stackexchange.com/a/12904 How to run find -exec?], [https://stackoverflow.com/a/6085237 Using semicolon (;) vs plus (+) with exec in find]
* [https://unix.stackexchange.com/a/12904 How to run find -exec?], [https://stackoverflow.com/a/6085237 Using semicolon (;) vs plus (+) with exec in find]
: <syntaxhighlight lang='bash'>
: <syntaxhighlight lang='bash'>
Line 1,020: Line 1,019:
where '-c' produces a grand total, and will substitute {} with the filename(s) found in '''-exec'''.
where '-c' produces a grand total, and will substitute {} with the filename(s) found in '''-exec'''.


==== Application to backup ====
== Application to backup ==
[[#Delete_files_or_directories_older_than_XXX_days|Delete files/directories older than XXX days]]
[[#Delete_files_or_directories_older_than_XXX_days|Delete files/directories older than XXX days]]


==== Avoid Permission Denied Messages ====
== Avoid Permission Denied Messages ==
[https://www.cyberciti.biz/faq/bash-find-exclude-all-permission-denied-messages/ How to fix find command permission denied messages]  
[https://www.cyberciti.biz/faq/bash-find-exclude-all-permission-denied-messages/ How to fix find command permission denied messages]  
* Redirecting ALL standard error (not only permission denied error): '''2>/dev/null'''.
* Redirecting ALL standard error (not only permission denied error): '''2>/dev/null'''.
Line 1,034: Line 1,033:
</syntaxhighlight>
</syntaxhighlight>


=== '''grep''': Find a file by searching contents ===
= '''grep''': Find a file by searching contents =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
grep -r -i "Entering" ~/Downloads/R-3.0.0/
grep -r -i "Entering" ~/Downloads/R-3.0.0/
Line 1,100: Line 1,099:
* How to list only the names of matching files ("-l" option)
* How to list only the names of matching files ("-l" option)


==== GUI ====
== GUI ==
A GUI version of a tool to search files is [http://searchmonkey.embeddediq.com/ '''searchmonkey'''] (open source, Linux, Windows). On Ubuntu, we install it by
A GUI version of a tool to search files is [http://searchmonkey.embeddediq.com/ '''searchmonkey'''] (open source, Linux, Windows). On Ubuntu, we install it by
<pre>
<pre>
Line 1,107: Line 1,106:
It is also useful to change the settings so we can click a filename and open it in the desired text editor. To do that, go to Settings -> Preferences -> System Call -> Text Editor. I enter 'geany' since I want to use geany to open my C programs. '''Note'''. the v2.0 source code needs to be built using i386 gcc library and Qt 4.8.x. Still, I cannot get rid of some errors coming from the source code.  
It is also useful to change the settings so we can click a filename and open it in the desired text editor. To do that, go to Settings -> Preferences -> System Call -> Text Editor. I enter 'geany' since I want to use geany to open my C programs. '''Note'''. the v2.0 source code needs to be built using i386 gcc library and Qt 4.8.x. Still, I cannot get rid of some errors coming from the source code.  


==== Summary of '''find''' and '''grep''' commands ====
== Summary of '''find''' and '''grep''' commands ==
{| class="wikitable"
{| class="wikitable"
! Command
! Command
Line 1,123: Line 1,122:
|}
|}


=== Count number of columns: awk ===
= Count number of columns: awk =
The following command shows the number of columns for the first few rows of a text file.
The following command shows the number of columns for the first few rows of a text file.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 1,131: Line 1,130:
</syntaxhighlight>
</syntaxhighlight>


=== Count number of rows in a file: wc ===
= Count number of rows in a file: wc =
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
wc -l MYFILE
wc -l MYFILE
Line 1,162: Line 1,161:
As we can see from the ''coreutils-8.21/src'' directory, there are over 100 C programs including <cat.c>, <chmod.c>, <cp.c>, ...<wc.c>.
As we can see from the ''coreutils-8.21/src'' directory, there are over 100 C programs including <cat.c>, <chmod.c>, <cp.c>, ...<wc.c>.


=== Print certain rows/lines of a text file ===
= Print certain rows/lines of a text file =
The following example will print out lines 10 to 60 of FILENAME.
The following example will print out lines 10 to 60 of FILENAME.
<pre>
<pre>
Line 1,173: Line 1,172:
It seems this method is not as fast as I expected. For example, the '''tail''' command will immediately print out the result without waiting!
It seems this method is not as fast as I expected. For example, the '''tail''' command will immediately print out the result without waiting!


=== output colored console to html ===
= output colored console to html =
Use [https://raw.githubusercontent.com/pixelb/scripts/master/scripts/ansi2html.sh ansi2html.sh]. It only requires gawk.
Use [https://raw.githubusercontent.com/pixelb/scripts/master/scripts/ansi2html.sh ansi2html.sh]. It only requires gawk.
# Use wget to download it
# Use wget to download it
Line 1,180: Line 1,179:
# colordiff file1 file2 | ./ansi2html.sh > diff.html
# colordiff file1 file2 | ./ansi2html.sh > diff.html


=== using a the result of a diff in a if statement ===
= using a the result of a diff in a if statement =
<pre>
<pre>
ls -lR $dir > a
ls -lR $dir > a
Line 1,196: Line 1,195:
</pre>
</pre>


=== Prompt ===
= Prompt =
==== Colored prompt ====
== Colored prompt ==
* http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
* http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
* https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
* https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
Line 1,248: Line 1,247:
</pre>
</pre>


==== Add a timestamp to your Bash prompt ====
== Add a timestamp to your Bash prompt ==
* See '''man 3 strftime''' for the date, time format. In Linux Mint, the date applets uses the '''%A %B %e, %H:%M''' which gives a format like 'Friday July 15, 10:23'.  
* See '''man 3 strftime''' for the date, time format. In Linux Mint, the date applets uses the '''%A %B %e, %H:%M''' which gives a format like 'Friday July 15, 10:23'.  
* [http://www.foragoodstrftime.com For a Good Strftime] - Online date/time formatting tool
* [http://www.foragoodstrftime.com For a Good Strftime] - Online date/time formatting tool
Line 1,268: Line 1,267:
</syntaxhighlight>
</syntaxhighlight>


==== To the right hand side/Aligned to right and zsh ====
== To the right hand side/Aligned to right and zsh ==
* See an example from [[Ubuntu#BioLinux|Biolinux]]. '''echo $SHELL''' shows Bio-Linux is using zsh.
* See an example from [[Ubuntu#BioLinux|Biolinux]]. '''echo $SHELL''' shows Bio-Linux is using zsh.
* http://zsh.sourceforge.net/Intro/intro_14.html
* http://zsh.sourceforge.net/Intro/intro_14.html
Line 1,275: Line 1,274:
* https://superuser.com/questions/776759/switch-from-zsh-to-default-os-x. '''chsh -s /bin/bash'''
* https://superuser.com/questions/776759/switch-from-zsh-to-default-os-x. '''chsh -s /bin/bash'''


=== Proxy ===
= Proxy =
[https://www.makeuseof.com/tag/best-web-proxies/ The 15 Best Web Proxies for Geo-Blocked Content and Online Privacy]
[https://www.makeuseof.com/tag/best-web-proxies/ The 15 Best Web Proxies for Geo-Blocked Content and Online Privacy]


==== Listen to pandora in Europe: install squid proxy ====
== Listen to pandora in Europe: install squid proxy ==
http://www.cyberciti.biz/faq/access-pandora-radio-using-proxy-server-outside-usa/
http://www.cyberciti.biz/faq/access-pandora-radio-using-proxy-server-outside-usa/


Interestingly, the firefox connection settings should choose '''HTTP Proxy''' instead of 'SOCKS host'.
Interestingly, the firefox connection settings should choose '''HTTP Proxy''' instead of 'SOCKS host'.


=== scp ===
= scp =
==== file path with spaces ====
== file path with spaces ==
Use double quotes around the full path and a backslash to escape any space.
Use double quotes around the full path and a backslash to escape any space.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 1,290: Line 1,289:
</syntaxhighlight>
</syntaxhighlight>


==== Copy multiple files ====
== Copy multiple files ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
scp your_username@domain:~/\{foo.txt,bar.txt\} .
scp your_username@domain:~/\{foo.txt,bar.txt\} .
Line 1,297: Line 1,296:
Some uses double quotes around the files with the space character to separate files but it does not work when I try to copy files from biowulf to mac.
Some uses double quotes around the files with the space character to separate files but it does not work when I try to copy files from biowulf to mac.


==== Recursive copying ====
== Recursive copying ==
Use '''-r''' parameter.
Use '''-r''' parameter.


==== Preserve permissions and modes ====
== Preserve permissions and modes ==
Use '''-p''' parameter.
Use '''-p''' parameter.


==== scp files through one intermediate host ====
== scp files through one intermediate host ==
http://stackoverflow.com/questions/9139417/how-to-scp-with-a-second-remote-host
http://stackoverflow.com/questions/9139417/how-to-scp-with-a-second-remote-host


Line 1,321: Line 1,320:
</syntaxhighlight>
</syntaxhighlight>


==== scp with non-standard port: -P (capital) ====
== scp with non-standard port: -P (capital) ==
Use '''-P''' argument.
Use '''-P''' argument.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 1,327: Line 1,326:
</syntaxhighlight>
</syntaxhighlight>


==== scp or ssh without password ====
== scp or ssh without password ==
* http://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/
* http://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/
* https://toic.org/blog/2008/ssh-basics/
* https://toic.org/blog/2008/ssh-basics/
Line 1,343: Line 1,342:
Another option is to use '''ssh -i IDENTITY_FILE'''. See [http://superuser.com/questions/399876/scping-using-key-file-as-a-parameter-how-can-i-do-that-if-possible superuser.com].
Another option is to use '''ssh -i IDENTITY_FILE'''. See [http://superuser.com/questions/399876/scping-using-key-file-as-a-parameter-how-can-i-do-that-if-possible superuser.com].


==== ssh with password on the command line ====
== ssh with password on the command line ==
Install '''sshpass''' utility. See https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password
Install '''sshpass''' utility. See https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password


=== SSH ===
= SSH =
==== Best security practices ====
== Best security practices ==
[https://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html Top 20 OpenSSH Server Best Security Practices]
[https://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html Top 20 OpenSSH Server Best Security Practices]
# Use SSH public key based login
# Use SSH public key based login
Line 1,370: Line 1,369:
# Bonus tips from Mozilla
# Bonus tips from Mozilla


==== Install OpenSSL ====
== Install OpenSSL ==
[https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ How to Install the latest OpenSSL version from Source on Linux]
[https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ How to Install the latest OpenSSL version from Source on Linux]


==== Install ssh client ====
== Install ssh client ==
'''sudo apt install openssh-client'''
'''sudo apt install openssh-client'''


==== Way to avoid ssh connection timeout and ~/.ssh/config ====
== Way to avoid ssh connection timeout and ~/.ssh/config ==
* https://superuser.com/questions/98562/way-to-avoid-ssh-connection-timeout-freezing-of-gnome-terminal
* https://superuser.com/questions/98562/way-to-avoid-ssh-connection-timeout-freezing-of-gnome-terminal
* https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/
* https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/
Line 1,401: Line 1,400:
Also make sure to run chmod 600 ~/.ssh/config
Also make sure to run chmod 600 ~/.ssh/config


==== Change to a different port ====
== Change to a different port ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ sudo nano /etc/ssh/sshd_config  # looking for the line containing port  
$ sudo nano /etc/ssh/sshd_config  # looking for the line containing port  
Line 1,414: Line 1,413:
* [https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers Here] is a list of TCP and UDP port numbers.
* [https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers Here] is a list of TCP and UDP port numbers.


==== ssh alias ====
== ssh alias ==
* Using linux's alias; eg put the following inside ~/.bashrc
* Using linux's alias; eg put the following inside ~/.bashrc
<pre>alias sshnokey='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' </pre>
<pre>alias sshnokey='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' </pre>
Line 1,443: Line 1,442:
</pre>
</pre>


==== Running commands on a remote host ====
== Running commands on a remote host ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
ssh user@host 'COMMANDS'
ssh user@host 'COMMANDS'
Line 1,467: Line 1,466:
</syntaxhighlight>
</syntaxhighlight>


==== Disable root log in ====
== Disable root log in ==
Modify /etc/ssh/sshd_config. Change this line:
Modify /etc/ssh/sshd_config. Change this line:
<pre>
<pre>
Line 1,484: Line 1,483:
According to [https://askubuntu.com/questions/449364/what-does-without-password-mean-in-sshd-config-file this post], “without-password” means password authentication is disabled for root.
According to [https://askubuntu.com/questions/449364/what-does-without-password-mean-in-sshd-config-file this post], “without-password” means password authentication is disabled for root.


==== ssh log files ====
== ssh log files ==
* /var/log/syslog
* /var/log/syslog
* /var/log/auth.log  (see who is trying to connect; check out http://ip-lookup.net/index.php to see their geolocation)
* /var/log/auth.log  (see who is trying to connect; check out http://ip-lookup.net/index.php to see their geolocation)
Line 1,522: Line 1,521:
</pre>
</pre>


==== [http://denyhosts.sourceforge.net/ DenyHosts] ====
== [http://denyhosts.sourceforge.net/ DenyHosts] ==
Note that [https://askubuntu.com/questions/433924/package-denyhosts-in-ubuntu-trusty-tahr-is-deleted-temporary-or-forever denyhosts package is no longer available in Ubuntu 14.04, 16.04 now]. We can install install from its source DenyHosts-2.6.tar.gz.
Note that [https://askubuntu.com/questions/433924/package-denyhosts-in-ubuntu-trusty-tahr-is-deleted-temporary-or-forever denyhosts package is no longer available in Ubuntu 14.04, 16.04 now]. We can install install from its source DenyHosts-2.6.tar.gz.


Line 1,534: Line 1,533:
Procedures: follow the README.txt file.
Procedures: follow the README.txt file.


==== Log in history: last command ====
== Log in history: last command ==
The following command also shows how long a user has been logged in.
The following command also shows how long a user has been logged in.
<pre>
<pre>
Line 1,542: Line 1,541:
'''w/who''' can show who (and when) are currently logging in.
'''w/who''' can show who (and when) are currently logging in.


==== Generate a strong password ====
== Generate a strong password ==
[https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ 5 Ways To Generate A Random/Strong Password In Linux Terminal]: pwgen, openssl, gpg, mkpasswd, makepasswd, ...
[https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ 5 Ways To Generate A Random/Strong Password In Linux Terminal]: pwgen, openssl, gpg, mkpasswd, makepasswd, ...


Line 1,555: Line 1,554:
</syntaxhighlight>
</syntaxhighlight>


==== login banners/messages ====
== login banners/messages ==
https://kerneltalks.com/tips-tricks/how-to-configure-login-banners-in-linux/
https://kerneltalks.com/tips-tricks/how-to-configure-login-banners-in-linux/


Line 1,563: Line 1,562:
Banner message to display after user successfully logged in (configure in /etc/motd)
Banner message to display after user successfully logged in (configure in /etc/motd)


==== '''ssh -A''': forwarding of the authentication agent connection ====
== '''ssh -A''': forwarding of the authentication agent connection ==
* https://serverfault.com/a/838194
* https://serverfault.com/a/838194
* [https://www.wyeworks.com/blog/2015/08/05/when-is-ssh-a-insecure/ When is ssh -A insecure?]
* [https://www.wyeworks.com/blog/2015/08/05/when-is-ssh-a-insecure/ When is ssh -A insecure?]
* Mentioned in [https://opensource.com/article/17/4/5-projects-raspberry-pi-home 5 projects for Raspberry Pi at home]
* Mentioned in [https://opensource.com/article/17/4/5-projects-raspberry-pi-home 5 projects for Raspberry Pi at home]


=== ssh key ===
= ssh key =
SSH key is useful if you want a password-less login to a remote system. Some useful resources:
SSH key is useful if you want a password-less login to a remote system. Some useful resources:
* https://help.ubuntu.com/community/SSH/OpenSSH/Keys
* https://help.ubuntu.com/community/SSH/OpenSSH/Keys
Line 1,612: Line 1,611:
in sshd_config.
in sshd_config.


==== Multiple ssh keys ====
== Multiple ssh keys ==
<Method 1> If we want to use a specific key in ssh, use  
<Method 1> If we want to use a specific key in ssh, use  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 1,631: Line 1,630:
* [https://gist.github.com/jexchan/2351996 Multiple SSH Keys settings for different github account]
* [https://gist.github.com/jexchan/2351996 Multiple SSH Keys settings for different github account]


==== ssh key management ====
== ssh key management ==
* Using [https://www.howtoforge.com/tutorial/ssh-key-management-with-privacyidea/ privacyIDEA] (howtoforge.com).
* Using [https://www.howtoforge.com/tutorial/ssh-key-management-with-privacyidea/ privacyIDEA] (howtoforge.com).


==== Copy ssh keys to another computer ====
== Copy ssh keys to another computer ==
http://askubuntu.com/questions/134975/copy-ssh-private-keys-to-another-computer
http://askubuntu.com/questions/134975/copy-ssh-private-keys-to-another-computer


Line 1,645: Line 1,644:
If we do not change the permission correctly in <id_rsa>, we will get a warning: Unprotected private key file. Permissions 0664 for '/home/USERNAME/.ssh/id_rsa' are too open.
If we do not change the permission correctly in <id_rsa>, we will get a warning: Unprotected private key file. Permissions 0664 for '/home/USERNAME/.ssh/id_rsa' are too open.


==== Preserve ssh keys when upgrading computers ====
== Preserve ssh keys when upgrading computers ==
* An article from [http://www.bsdnewsletter.com/bsda-book/Preserve_existing_SSH_host_keys_during_a_system_upgrade.html bsdnewsletter.com].
* An article from [http://www.bsdnewsletter.com/bsda-book/Preserve_existing_SSH_host_keys_during_a_system_upgrade.html bsdnewsletter.com].
* https://askubuntu.com/questions/17097/how-to-backup-restore-the-host-key-in-ssh-server
* https://askubuntu.com/questions/17097/how-to-backup-restore-the-host-key-in-ssh-server
Line 1,682: Line 1,681:
</pre>
</pre>


==== Disable SSH host key checking ====
== Disable SSH host key checking ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
ssh -o UserKnownHostsFile=/dev/null \
ssh -o UserKnownHostsFile=/dev/null \
Line 1,703: Line 1,702:
</pre>
</pre>


==== Handling the ssh key change when connecting to a remote machine ====
== Handling the ssh key change when connecting to a remote machine ==
An article from [http://www.cyberciti.biz/faq/warning-remote-host-identification-has-changed-error-and-solution/ cybercitz.biz].
An article from [http://www.cyberciti.biz/faq/warning-remote-host-identification-has-changed-error-and-solution/ cybercitz.biz].


Line 1,716: Line 1,715:
* Method 3. Just delete the known_hosts file If you have only used one ssh server
* Method 3. Just delete the known_hosts file If you have only used one ssh server


=== SSH Port forwarding ===
= SSH Port forwarding =
* Chapter 9 Port forward. SSH Mastery OpenSSH, PuTTY, Tunnels and Keys by Michael W. Lucas
* Chapter 9 Port forward. SSH Mastery OpenSSH, PuTTY, Tunnels and Keys by Michael W. Lucas


==== Verizon Quantum Gateway Router ====
== Verizon Quantum Gateway Router ==
[https://www.verizon.com/cs/groups/public/documents/adacct/fios-qgr-userguide140925.pdf User guide] p98. Click 'Advanced' button first.
[https://www.verizon.com/cs/groups/public/documents/adacct/fios-qgr-userguide140925.pdf User guide] p98. Click 'Advanced' button first.
   
   
Line 1,726: Line 1,725:
* Forward to Port: Same as incoming port or the port used in the local computer
* Forward to Port: Same as incoming port or the port used in the local computer


==== What is tunnel ====
== What is tunnel ==
https://www.howtogeek.com/299845/why-is-a-network-tunnel-called-a-tunnel/. A tunnel provides a ''direct path'' that avoids some type of complexity you would otherwise have to deal with.
https://www.howtogeek.com/299845/why-is-a-network-tunnel-called-a-tunnel/. A tunnel provides a ''direct path'' that avoids some type of complexity you would otherwise have to deal with.


==== Local port forwarding ====
== Local port forwarding ==
* https://toic.org/blog/2010/ssh-port-forwarding/
* https://toic.org/blog/2010/ssh-port-forwarding/
* https://www.howtogeek.com/168145/how-to-use-ssh-tunneling/
* https://www.howtogeek.com/168145/how-to-use-ssh-tunneling/
Line 1,752: Line 1,751:
To stop the ssh session, use ps -ef to find the process id and kill it.
To stop the ssh session, use ps -ef to find the process id and kill it.


==== Remote port forwarding (Reverse port forwarding) ====
== Remote port forwarding (Reverse port forwarding) ==
* https://www.howtoforge.com/reverse-ssh-tunneling (use ssh option '''-f''' to detach ssh process from the tty, '''-N''' to not execute any command over ssh and option '''-i''' for key authentication)  
* https://www.howtoforge.com/reverse-ssh-tunneling (use ssh option '''-f''' to detach ssh process from the tty, '''-N''' to not execute any command over ssh and option '''-i''' for key authentication)  
* http://man.openbsd.org/ssh
* http://man.openbsd.org/ssh
Line 1,788: Line 1,787:
</syntaxhighlight>
</syntaxhighlight>


==== 'D'ynamic port forwarding, SOCKS proxy, bypass blocked websites from work computer ====
== 'D'ynamic port forwarding, SOCKS proxy, bypass blocked websites from work computer ==
* http://www.panix.com/~ruari/censorship.html
* http://www.panix.com/~ruari/censorship.html
* http://www.cyberciti.biz/faq/set-up-ssh-tunneling-on-a-linux-unix-bsd-server-to-bypass-nat/
* http://www.cyberciti.biz/faq/set-up-ssh-tunneling-on-a-linux-unix-bsd-server-to-bypass-nat/
Line 1,809: Line 1,808:
Linux journal also put a video on [http://www.youtube.com/watch?v=fgX04JS-7sA youtube]. We can use http://www.ipligence.com/geolocation to check the current location. The port number is 1080 in the example. The example actually also use '-N' option which means no interaction; i.e. ssh -N -D 1080 user@remoteip. So we won't see anything after we type our password. Once we want to stop SOCK proxy, we just need to hit Ctr+C on terminal.
Linux journal also put a video on [http://www.youtube.com/watch?v=fgX04JS-7sA youtube]. We can use http://www.ipligence.com/geolocation to check the current location. The port number is 1080 in the example. The example actually also use '-N' option which means no interaction; i.e. ssh -N -D 1080 user@remoteip. So we won't see anything after we type our password. Once we want to stop SOCK proxy, we just need to hit Ctr+C on terminal.


==== Backgrounding OpenSSH Forwarding ====
== Backgrounding OpenSSH Forwarding ==
Use the -N flag to tell ssh to not run anything, including a terminal, on the remote server, and the -f flag to tell ssh to go into the background on the client.
Use the -N flag to tell ssh to not run anything, including a terminal, on the remote server, and the -f flag to tell ssh to go into the background on the client.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 1,816: Line 1,815:
By backgrounding this command, you get your original terminal back.
By backgrounding this command, you get your original terminal back.


==== ssh through an intermediate server ====
== ssh through an intermediate server ==
* http://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/
* http://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/
* https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts#Port_Forwarding_via_an_Intermediate_Host (more examples)
* https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts#Port_Forwarding_via_an_Intermediate_Host (more examples)
Line 1,834: Line 1,833:
</syntaxhighlight>
</syntaxhighlight>


=== Graphical way to display disk usage ===
= Graphical way to display disk usage =
* http://www.makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux/
* http://www.makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux/
For example, to use xdiskusage, we run '''apt-get install xdiskusage''' and launch it by '''xdiskusage ~/'''.
For example, to use xdiskusage, we run '''apt-get install xdiskusage''' and launch it by '''xdiskusage ~/'''.
* Ubuntu has a built-in program called "Disk Usage Analyzer". Just search it from Dash. Looks useful!
* Ubuntu has a built-in program called "Disk Usage Analyzer". Just search it from Dash. Looks useful!


=== df : Display disk space ===
= df : Display disk space =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
df -h
df -h
Line 1,852: Line 1,851:
Note for the NTFS type, it will be reported as '''fuseblk''' by mount or df command.
Note for the NTFS type, it will be reported as '''fuseblk''' by mount or df command.


=== Disk encryption ===
= Disk encryption =
[https://guardianproject.info/code/luks/ LUKS]
[https://guardianproject.info/code/luks/ LUKS]


=== rm command and trash can ===
= rm command and trash can =
[https://www.2daygeek.com/rm-command-to-move-files-to-trash-can-rm-alias/ Make “rm” Command To Move The Files To “Trash Can” Instead Of Removing Them Completely]
[https://www.2daygeek.com/rm-command-to-move-files-to-trash-can-rm-alias/ Make “rm” Command To Move The Files To “Trash Can” Instead Of Removing Them Completely]


=== du and ncdu : Display directory size with sorting and human readable ===
= du and ncdu : Display directory size with sorting and human readable =
Use [http://www.cyberciti.biz/faq/unix-disk-usage-command-examples/ ncdu] program (more interactive). Although it is a command line program, we can use the mouse to move through each directory to see its sub-directories.
Use [http://www.cyberciti.biz/faq/unix-disk-usage-command-examples/ ncdu] program (more interactive). Although it is a command line program, we can use the mouse to move through each directory to see its sub-directories.


Line 1,897: Line 1,896:
So for example, if a file takes 150 blocks, and if a block takes 4096 bytes, then the file takes 150*4096/1024 KB on disk.
So for example, if a file takes 150 blocks, and if a block takes 4096 bytes, then the file takes 150*4096/1024 KB on disk.


=== Apache benchmark (ab) testing ===
= Apache benchmark (ab) testing =
<pre>
<pre>
ab -n 100 -c 10 http://taichimd.us/
ab -n 100 -c 10 http://taichimd.us/
Line 1,904: Line 1,903:
* http://en.wikipedia.org/wiki/ApacheBench
* http://en.wikipedia.org/wiki/ApacheBench


=== Monitor progress of copying/transferring files: pv ===
= Monitor progress of copying/transferring files: pv =
[https://www.howtoforge.com/tutorial/how-to-monitor-progress-of-linux-commands-using-pv-and-progress-utilities/ How to monitor progress of Linux commands using PV and Progress utilities]
[https://www.howtoforge.com/tutorial/how-to-monitor-progress-of-linux-commands-using-pv-and-progress-utilities/ How to monitor progress of Linux commands using PV and Progress utilities]


Line 1,925: Line 1,924:
</syntaxhighlight>
</syntaxhighlight>


=== rsync ===
= rsync =
==== Dry run ====
== Dry run ==
* '''--dry-run''' https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
* '''--dry-run''' https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
* '''-n''' https://linux.die.net/man/1/rsync
* '''-n''' https://linux.die.net/man/1/rsync
Line 1,933: Line 1,932:
</syntaxhighlight>
</syntaxhighlight>


==== Copy large file ====
== Copy large file ==
If we need to copy large file (say > 4GB), we shall
If we need to copy large file (say > 4GB), we shall
# format USB drive to NTFS (exFat seems not work)  
# format USB drive to NTFS (exFat seems not work)  
Line 1,941: Line 1,940:
The last step (rsync) is important. We can use '''sudo iotop''' to check if ''rsync'' is finished or not.
The last step (rsync) is important. We can use '''sudo iotop''' to check if ''rsync'' is finished or not.


==== speed comparison of cp vs rsync ====
== speed comparison of cp vs rsync ==
[http://withr.me/cp-rm-rsync/ BigData basic: copy & delete folder containing large number of files]
[http://withr.me/cp-rm-rsync/ BigData basic: copy & delete folder containing large number of files]


==== Incremental backup: '''--link-dest''' ====
== Incremental backup: '''--link-dest''' ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
rsync -aP --link-dest=PATHTO/$PREVIOUSBACKUP $SOURCE $CURRENTBACKUP
rsync -aP --link-dest=PATHTO/$PREVIOUSBACKUP $SOURCE $CURRENTBACKUP
Line 1,952: Line 1,951:
* [https://opensource.com/article/19/5/advanced-rsync How to use advanced rsync for large Linux backups]
* [https://opensource.com/article/19/5/advanced-rsync How to use advanced rsync for large Linux backups]


==== rsync with exclude files/directories ====
== rsync with exclude files/directories ==
See http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/. The key is excluded files are relative to the current directory even we specify the absolute path. For example /path1/path2/file does not mean the file is located under /path1/path2; it means the file is located under ./path1/path2.
See http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/. The key is excluded files are relative to the current directory even we specify the absolute path. For example /path1/path2/file does not mean the file is located under /path1/path2; it means the file is located under ./path1/path2.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 1,959: Line 1,958:
We add add multiple '''--exclude''' to exclude more files/directories.
We add add multiple '''--exclude''' to exclude more files/directories.


==== rsync to exclude hidden files/directories ====
== rsync to exclude hidden files/directories ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
--exclude=".*"  # exclude both hidden files and directories
--exclude=".*"  # exclude both hidden files and directories
Line 1,971: Line 1,970:
</syntaxhighlight>
</syntaxhighlight>


==== rsync with -a option ====
== rsync with -a option ==
The '''-a''' flag in there stands for “archive,” and it’s important to include. It makes sure that the sync command is recursive (meaning any sub-folders and files inside of old_movies are copied too) and it’s important for preserving all of those modification dates, symbolic links, permissions, and other goodies we talked about earlier.
The '''-a''' flag in there stands for “archive,” and it’s important to include. It makes sure that the sync command is recursive (meaning any sub-folders and files inside of old_movies are copied too) and it’s important for preserving all of those modification dates, symbolic links, permissions, and other goodies we talked about earlier.


==== rsync with non-standard port ====
== rsync with non-standard port ==
Use '''-e''' option
Use '''-e''' option
<pre>
<pre>
Line 1,980: Line 1,979:
</pre>
</pre>


==== rsync with progress bar ====
== rsync with progress bar ==
Use '''--progress''' option.
Use '''--progress''' option.
<pre>
<pre>
Line 1,989: Line 1,988:
Or it is better to use '''-P''' option which is the same as '''--partial --progress'''. When it is used you’ll get a progress dialog at the command line that shows you which file is currently transferring, what percentage of that transfer is complete, and how many more files are left to check. As each file completes, you’ll see an ever-growing list of completed file transfers, which is great for making sure everything transfers successfully. It also allows you to easily resume suspended or interrupted transfers. Combined, you can see how it’ll show you which file was the last one to go, where it failed, and if it failed, give you the option to resume. It’s a pretty powerful combination.
Or it is better to use '''-P''' option which is the same as '''--partial --progress'''. When it is used you’ll get a progress dialog at the command line that shows you which file is currently transferring, what percentage of that transfer is complete, and how many more files are left to check. As each file completes, you’ll see an ever-growing list of completed file transfers, which is great for making sure everything transfers successfully. It also allows you to easily resume suspended or interrupted transfers. Combined, you can see how it’ll show you which file was the last one to go, where it failed, and if it failed, give you the option to resume. It’s a pretty powerful combination.


==== rsync on Windows ====
== rsync on Windows ==
Download and install command line rsync from http://www.rsync.net/resources/howto/windows_rsync.html. The website also provides a documentation. Some people are concern about the license issue. The website [https://www.itefix.no/i2/content/cwrsync-free-edition here] provides a link to the free, old but usable version 4.0.5 which is newer than I tested v3.1.0.
Download and install command line rsync from http://www.rsync.net/resources/howto/windows_rsync.html. The website also provides a documentation. Some people are concern about the license issue. The website [https://www.itefix.no/i2/content/cwrsync-free-edition here] provides a link to the free, old but usable version 4.0.5 which is newer than I tested v3.1.0.


Line 2,001: Line 2,000:
</pre>
</pre>


=== sudo ===
= sudo =
==== How to Keep ‘sudo’ Password Timeout Session Longer in Linux ====
== How to Keep ‘sudo’ Password Timeout Session Longer in Linux ==
http://www.tecmint.com/set-sudo-password-timeout-session-longer-linux/
http://www.tecmint.com/set-sudo-password-timeout-session-longer-linux/


==== How to run multiple commands in sudo ====
== How to run multiple commands in sudo ==
https://www.cyberciti.biz/faq/how-to-run-multiple-commands-in-sudo-under-linux-or-unix/
https://www.cyberciti.biz/faq/how-to-run-multiple-commands-in-sudo-under-linux-or-unix/


==== How do I run specific sudo commands without a password? ====
== How do I run specific sudo commands without a password? ==
https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password
https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password


=== Text browser ===
= Text browser =
==== Links ====
== Links ==
* http://pcworld.com/article/3196428/linux/why-installing-a-text-mode-web-browser-is-a-good-idea.html
* http://pcworld.com/article/3196428/linux/why-installing-a-text-mode-web-browser-is-a-good-idea.html
* http://links.twibright.com/user_en.html
* http://links.twibright.com/user_en.html
* https://en.wikipedia.org/wiki/Links_%28web_browser%29
* https://en.wikipedia.org/wiki/Links_%28web_browser%29


=== Alternative browsers ===
= Alternative browsers =
==== Chrome or Chromium ====
== Chrome or Chromium ==
Install the latest version of chromium.
Install the latest version of chromium.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 2,035: Line 2,034:
</pre>
</pre>


==== Vivaldi ====
== Vivaldi ==
Based on Chromium.
Based on Chromium.


Line 2,049: Line 2,048:
To uninstall it, open the package manager to remove it.
To uninstall it, open the package manager to remove it.


==== Opera ====
== Opera ==
Based on Chromium.
Based on Chromium.


Like Chrome, Opera is closed source.  
Like Chrome, Opera is closed source.  


==== [https://wiki.gnome.org/Apps/Web GNOME Web] ====
== [https://wiki.gnome.org/Apps/Web GNOME Web] ==
There are browsers made specifically for Linux, and GNOME Web is the most mature of the bunch.
There are browsers made specifically for Linux, and GNOME Web is the most mature of the bunch.


Line 2,061: Line 2,060:
Web lacks the kind of extensions you see on Chrome and Firefox (though ad-block does come built-in).
Web lacks the kind of extensions you see on Chrome and Firefox (though ad-block does come built-in).


==== [https://gitlab.gnome.org/gnumdk/eolie Eolie] ====
== [https://gitlab.gnome.org/gnumdk/eolie Eolie] ==
Eolie is another browser built specifically for GNOME.
Eolie is another browser built specifically for GNOME.


The URL bar shows a site’s title rather than the web address.
The URL bar shows a site’s title rather than the web address.


==== [https://www.brave.com/ Brave] - private, secure, support Chrome extensions ====
== [https://www.brave.com/ Brave] - private, secure, support Chrome extensions ==
https://en.wikipedia.org/wiki/Brave_(web_browser)
https://en.wikipedia.org/wiki/Brave_(web_browser)


Line 2,075: Line 2,074:
[https://www.ithome.com.tw/news/127698 Chromium版隱私瀏覽器Brave 0.57出爐了,要給你Chrome方便性但不回傳資料給Google], [https://www.zdnet.com/article/brave-browser-moves-to-chromium-codebase-now-supports-chrome-extensions/ Brave browser moves to Chromium codebase, now supports Chrome extensions] Dec 2018
[https://www.ithome.com.tw/news/127698 Chromium版隱私瀏覽器Brave 0.57出爐了,要給你Chrome方便性但不回傳資料給Google], [https://www.zdnet.com/article/brave-browser-moves-to-chromium-codebase-now-supports-chrome-extensions/ Brave browser moves to Chromium codebase, now supports Chrome extensions] Dec 2018


==== [http://midori-browser.org/ Midori] ====
== [http://midori-browser.org/ Midori] ==


==== [https://www.falkon.org/ Falkon] and formally [https://github.com/QupZilla/qupzilla Qupzilla] ====
== [https://www.falkon.org/ Falkon] and formally [https://github.com/QupZilla/qupzilla Qupzilla] ==
QupZilla is a new and very fast QtWebEngine browser. It aims to be a ''lightweight'' web browser available through all major platforms.
QupZilla is a new and very fast QtWebEngine browser. It aims to be a ''lightweight'' web browser available through all major platforms.


Line 2,087: Line 2,086:
</pre>
</pre>


=== Filezilla ===
= Filezilla =
[https://wiki.filezilla-project.org/Keyboard_shortcuts Keyboard shortcut]. Especially, Alt+Down=Transfers the currently selected item to an item of the same name in the other pane.
[https://wiki.filezilla-project.org/Keyboard_shortcuts Keyboard shortcut]. Especially, Alt+Down=Transfers the currently selected item to an item of the same name in the other pane.


=== The device is busy ===
= The device is busy =
* http://oletange.blogspot.com/2012/04/umount-device-is-busy-why.html
* http://oletange.blogspot.com/2012/04/umount-device-is-busy-why.html
<pre>
<pre>
Line 2,123: Line 2,122:
</pre>
</pre>


=== Kill a process and the '''pstree''' command ===
= Kill a process and the '''pstree''' command =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
# find the PID
# find the PID
Line 2,139: Line 2,138:
[https://www.howtoforge.com/linux-pkill-command/ pkill] command. For example, ''pkill gedit''.
[https://www.howtoforge.com/linux-pkill-command/ pkill] command. For example, ''pkill gedit''.


=== Format a USB drive ===
= Format a USB drive =
[https://www.linuxuprising.com/2018/09/easily-format-usb-flash-drive-on-ubuntu.html Easily Format A USB Flash Drive On Ubuntu 18.04 Using USB Stick Formatter] (mintStick [http://packages.linuxmint.com/pool/main/m/mintstick/ deb] & [https://github.com/linuxmint/mintstick source])
[https://www.linuxuprising.com/2018/09/easily-format-usb-flash-drive-on-ubuntu.html Easily Format A USB Flash Drive On Ubuntu 18.04 Using USB Stick Formatter] (mintStick [http://packages.linuxmint.com/pool/main/m/mintstick/ deb] & [https://github.com/linuxmint/mintstick source])


Line 2,156: Line 2,155:
</syntaxhighlight>
</syntaxhighlight>


=== Create an ext3 file system on a USB flash drive ===
= Create an ext3 file system on a USB flash drive =
<pre>
<pre>
umount /dev/sdb1  (depending on the device of course)
umount /dev/sdb1  (depending on the device of course)
Line 2,167: Line 2,166:
</pre>
</pre>


=== Add a new user with home directory ===
= Add a new user with home directory =
<pre>
<pre>
adduser xxx
adduser xxx
Line 2,181: Line 2,180:
To view the user information, type '' '''id USERNAME''' '' or ''cat /etc/passwd''.
To view the user information, type '' '''id USERNAME''' '' or ''cat /etc/passwd''.


=== gzip with multi cores ===
= gzip with multi cores =
Use '''[http://zlib.net/pigz/ pigz]''' utility. It makes a lot of difference. For example for a 21GB file, gzip can't finish the job after 30 minutes. But pigz only took 7 minutes on a 12-core machine.
Use '''[http://zlib.net/pigz/ pigz]''' utility. It makes a lot of difference. For example for a 21GB file, gzip can't finish the job after 30 minutes. But pigz only took 7 minutes on a 12-core machine.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 2,193: Line 2,192:
The '-9' (best compression) option does not make difference (6.6G vs 6.5G).
The '-9' (best compression) option does not make difference (6.6G vs 6.5G).


=== Compress a folder without full path name ===
= Compress a folder without full path name =
Suppose we want to compress the folder ~/Documents and its subfolders. We want to include Documents folder name but not /home/brb/Documents name.
Suppose we want to compress the folder ~/Documents and its subfolders. We want to include Documents folder name but not /home/brb/Documents name.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 2,208: Line 2,207:
If we want to strip the upper directories when we uncompress a tar file, use '''--strip-components'''. For example, we can use '''--strip-components=1''' to remove the Documents folder.
If we want to strip the upper directories when we uncompress a tar file, use '''--strip-components'''. For example, we can use '''--strip-components=1''' to remove the Documents folder.


=== squashfs ===
= squashfs =
'''squashfs''' is a heavy-compression based read-only filesystem that is capable of compressing 2 to 3 GB of data onto a 700MB. Linux liveCD are built using squashfs. These CDs make use of a read-only compressed filesystem which keeps the root filesystem on a compressed file. It can be loopback mounted and loads a complete Linux env. Thus when some file are required by processes, they are decompressed and loaded onto the RAM and used.
'''squashfs''' is a heavy-compression based read-only filesystem that is capable of compressing 2 to 3 GB of data onto a 700MB. Linux liveCD are built using squashfs. These CDs make use of a read-only compressed filesystem which keeps the root filesystem on a compressed file. It can be loopback mounted and loads a complete Linux env. Thus when some file are required by processes, they are decompressed and loaded onto the RAM and used.


Line 2,231: Line 2,230:
</syntaxhighlight>
</syntaxhighlight>


=== List contents of tar.gz or tar.bz2 ===
= List contents of tar.gz or tar.bz2 =
<pre>
<pre>
tar -tzvf myfile.tar.gz
tar -tzvf myfile.tar.gz
Line 2,238: Line 2,237:
</pre>
</pre>


=== Extract files ===
= Extract files =
==== Extract tar.gz or zip to a specified directory ====
== Extract tar.gz or zip to a specified directory ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
tar xzvf XXXX.tar.gz -C DIRECTORY
tar xzvf XXXX.tar.gz -C DIRECTORY
Line 2,254: Line 2,253:
</syntaxhighlight>
</syntaxhighlight>


==== Extract gz file but keep the original gz file ====
== Extract gz file but keep the original gz file ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
gunzip -c x.txt.gz > x.txt
gunzip -c x.txt.gz > x.txt
Line 2,260: Line 2,259:
'''gunzip -c''' which simply writes the output stream to stdout
'''gunzip -c''' which simply writes the output stream to stdout


==== Extract .xz file ====
== Extract .xz file ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
xz -d archive.xz
xz -d archive.xz
</syntaxhighlight>
</syntaxhighlight>


==== Extract tar.xz file ====
== Extract tar.xz file ==
The bottomline is we don't need the 'z' parameter (used for [https://en.wikipedia.org/wiki/Gzip gz] ONLY but does not work for [https://en.wikipedia.org/wiki/Xz xz file])  in the tar command for tar.xz files. And the method also works for tar.gz files. The argument '-f' means the archive file. Recall that the '''tar''' command can be used to store and extract files, so no default parameters.
The bottomline is we don't need the 'z' parameter (used for [https://en.wikipedia.org/wiki/Gzip gz] ONLY but does not work for [https://en.wikipedia.org/wiki/Xz xz file])  in the tar command for tar.xz files. And the method also works for tar.gz files. The argument '-f' means the archive file. Recall that the '''tar''' command can be used to store and extract files, so no default parameters.


Line 2,273: Line 2,272:
</syntaxhighlight>
</syntaxhighlight>


==== Extract tar.bz2 file ====
== Extract tar.bz2 file ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
tar -xjvf archive.tar.bz2  # replace z with j as we compare it to tar.gz file
tar -xjvf archive.tar.bz2  # replace z with j as we compare it to tar.gz file
</syntaxhighlight>
</syntaxhighlight>


==== How To Extract and Decompress a .bz2/.tbz2 File ====
== How To Extract and Decompress a .bz2/.tbz2 File ==
See [http://www.cyberciti.biz/faq/linuxunix-how-to-extract-and-decompress-a-bz2-tbz2-file/ this article] from cyberciti.biz.
See [http://www.cyberciti.biz/faq/linuxunix-how-to-extract-and-decompress-a-bz2-tbz2-file/ this article] from cyberciti.biz.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 2,290: Line 2,289:
</syntaxhighlight>
</syntaxhighlight>


==== 10 Basic Encryption Terms Everyone Should Know and Understand ====
== 10 Basic Encryption Terms Everyone Should Know and Understand ==
https://www.makeuseof.com/tag/encryption-terms/
https://www.makeuseof.com/tag/encryption-terms/


==== How to Encrypt and Decrypt Files and Directories Using Tar and OpenSSL ====
== How to Encrypt and Decrypt Files and Directories Using Tar and OpenSSL ==
http://www.tecmint.com/encrypt-decrypt-files-tar-openssl-linux/
http://www.tecmint.com/encrypt-decrypt-files-tar-openssl-linux/


==== How to install and use 7zip file archiver ====
== How to install and use 7zip file archiver ==
https://www.howtoforge.com/tutorial/how-to-install-and-use-7zip-file-archiver-on-ubuntu-linux/
https://www.howtoforge.com/tutorial/how-to-install-and-use-7zip-file-archiver-on-ubuntu-linux/


==== Compare zip, tar.xz, tar.gz, 7z ====
== Compare zip, tar.xz, tar.gz, 7z ==
The compression rate comparison is (from best to worst) 7z > tar.xz > tar.gz > zip.  
The compression rate comparison is (from best to worst) 7z > tar.xz > tar.gz > zip.  


Line 2,308: Line 2,307:
* 7z 297M
* 7z 297M


==== Extract one files from tar.gz ====
== Extract one files from tar.gz ==
Extract a file called etc/default/sysstat from config.tar.gz tarball:
Extract a file called etc/default/sysstat from config.tar.gz tarball:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 2,326: Line 2,325:
</syntaxhighlight>
</syntaxhighlight>


==== remove leading directory components on extraction with tar ====
== remove leading directory components on extraction with tar ==
* [https://serverfault.com/questions/330127/tar-remove-leading-directory-components-on-extraction --strip-components] option
* [https://serverfault.com/questions/330127/tar-remove-leading-directory-components-on-extraction --strip-components] option
* Real examples
* Real examples
** [https://github.com/wikimedia/mediawiki-docker/blob/2dea40647eb85d6e0fc607904e0779644cf869c9/stable/Dockerfile Strip the top directory after extracting mediawiki tar ball]. "tar -xz --strip-components=1 -f mediawiki.tar.gz"
** [https://github.com/wikimedia/mediawiki-docker/blob/2dea40647eb85d6e0fc607904e0779644cf869c9/stable/Dockerfile Strip the top directory after extracting mediawiki tar ball]. "tar -xz --strip-components=1 -f mediawiki.tar.gz"


==== [https://github.com/lb1a/avfs AVFS] and [https://github.com/bramp/archivemount Archivemount] ====
== [https://github.com/lb1a/avfs AVFS] and [https://github.com/bramp/archivemount Archivemount] ==
If we want to extract certain files from a tarballj/archive, it is more efficient to use a virtual filesystem like AVFS. PS. for a large archive file, even extracting only a single file at the top directory it is terribly slow if we use the '''tar''' command directly.
If we want to extract certain files from a tarballj/archive, it is more efficient to use a virtual filesystem like AVFS. PS. for a large archive file, even extracting only a single file at the top directory it is terribly slow if we use the '''tar''' command directly.


Line 2,428: Line 2,427:
</syntaxhighlight>
</syntaxhighlight>


=== Show folder size for one level only ===
= Show folder size for one level only =
<pre>
<pre>
du --max-depth=1 -h
du --max-depth=1 -h
Line 2,434: Line 2,433:
The graphical tool is called '''Disk Usage Analyze''' which is already available on Ubuntu.
The graphical tool is called '''Disk Usage Analyze''' which is already available on Ubuntu.


=== Soft link ===
= Soft link =
<pre>
<pre>
ln -s /full/path/of/original/file /full/path/of/soft/link/file
ln -s /full/path/of/original/file /full/path/of/soft/link/file
Line 2,440: Line 2,439:
Understanding Linux Links [https://www.linux.com/blog/intro-to-linux/2018/10/linux-links-part-1 Part 1] & [https://www.linux.com/blog/2018/10/understanding-linux-links-part-2 Part 2]
Understanding Linux Links [https://www.linux.com/blog/intro-to-linux/2018/10/linux-links-part-1 Part 1] & [https://www.linux.com/blog/2018/10/understanding-linux-links-part-2 Part 2]


=== Self-hosted servers ===
= Self-hosted servers =
* https://github.com/Kickball/awesome-selfhosted This is a list of Free Software network services and web applications which can be hosted locally. Selfhosting is the process of locally hosting and managing applications instead of renting from SaaS providers.
* https://github.com/Kickball/awesome-selfhosted This is a list of Free Software network services and web applications which can be hosted locally. Selfhosting is the process of locally hosting and managing applications instead of renting from SaaS providers.
* [https://github.com/sovereign/sovereign Sovereign]: A set of Ansible playbooks to build and maintain your own private cloud: email, calendar, contacts, file sync, IRC bouncer, VPN, and more.  
* [https://github.com/sovereign/sovereign Sovereign]: A set of Ansible playbooks to build and maintain your own private cloud: email, calendar, contacts, file sync, IRC bouncer, VPN, and more.  


=== DNSCrypt ===
= DNSCrypt =
* https://en.wikipedia.org/wiki/DNSCrypt
* https://en.wikipedia.org/wiki/DNSCrypt
* [https://github.com/jedisct1/dnscrypt-proxy dnscrypt-proxy 2 - A flexible DNS proxy, with support for encrypted DNS protocols]
* [https://github.com/jedisct1/dnscrypt-proxy dnscrypt-proxy 2 - A flexible DNS proxy, with support for encrypted DNS protocols]
* [https://www.linuxuprising.com/2018/10/install-and-enable-dnscrypt-proxy-2-in.html Install and Enable DNSCrypt Proxy 2 in Ubuntu 18.04 Or 18.10 / Debian Unstable Or Testing]
* [https://www.linuxuprising.com/2018/10/install-and-enable-dnscrypt-proxy-2-in.html Install and Enable DNSCrypt Proxy 2 in Ubuntu 18.04 Or 18.10 / Debian Unstable Or Testing]


=== DNS server ===
= DNS server =
* [https://opensource.com/article/17/4/introduction-domain-name-system-dns Introduction to the Domain Name System (DNS)]
* [https://opensource.com/article/17/4/introduction-domain-name-system-dns Introduction to the Domain Name System (DNS)]
* [https://opensource.com/article/17/4/build-your-own-name-server Build your own DNS name server on Linux]
* [https://opensource.com/article/17/4/build-your-own-name-server Build your own DNS name server on Linux]


==== setup ====
== setup ==
* https://support.rackspace.com/how-to/changing-dns-settings-on-linux/
* https://support.rackspace.com/how-to/changing-dns-settings-on-linux/
* https://helix.nih.gov/user_guides/kerb5_config.html
* https://helix.nih.gov/user_guides/kerb5_config.html


=== DNSmasq (DNS + DHCP server) ===
= DNSmasq (DNS + DHCP server) =
* [http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html Man page] and [http://www.thekelleys.org.uk/dnsmasq/docs/setup.html Setup]
* [http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html Man page] and [http://www.thekelleys.org.uk/dnsmasq/docs/setup.html Setup]
* [https://www.linux.com/learn/dnsmasq-easy-lan-name-services Dnsmasq For Easy LAN Name Services]
* [https://www.linux.com/learn/dnsmasq-easy-lan-name-services Dnsmasq For Easy LAN Name Services]
Line 2,465: Line 2,464:
* https://blogging.dragon.org.uk/howto-setup-dnsmasq-as-dns-dhcp/
* https://blogging.dragon.org.uk/howto-setup-dnsmasq-as-dns-dhcp/


==== Local forwarding server ====
== Local forwarding server ==
dnsmasq program is running on my Ubuntu and Linux/Mint machines.  
dnsmasq program is running on my Ubuntu and Linux/Mint machines.  


Line 2,475: Line 2,474:
</syntaxhighlight>
</syntaxhighlight>


=== Change DNS setting ===
= Change DNS setting =
* [https://www.makeuseof.com/tag/change-dns-increase-internet-speed/ Why Changing DNS Settings Increases Your Internet Speed], [https://www.makeuseof.com/tag/best-dns-providers-security/ 5 DNS Servers Guaranteed to Improve Your Online Safety]
* [https://www.makeuseof.com/tag/change-dns-increase-internet-speed/ Why Changing DNS Settings Increases Your Internet Speed], [https://www.makeuseof.com/tag/best-dns-providers-security/ 5 DNS Servers Guaranteed to Improve Your Online Safety]
** https://1.1.1.1/, [https://www.ithome.com.tw/news/122215 隱私優先、速度最快,公共DNS服務1.1.1.1上線了]
** https://1.1.1.1/, [https://www.ithome.com.tw/news/122215 隱私優先、速度最快,公共DNS服務1.1.1.1上線了]
Line 2,489: Line 2,488:
* [https://www.makeuseof.com/tag/cloudflare-1111-dns-mobile/ You Can Now Use Cloudflare’s 1.1.1.1 DNS on Mobile]
* [https://www.makeuseof.com/tag/cloudflare-1111-dns-mobile/ You Can Now Use Cloudflare’s 1.1.1.1 DNS on Mobile]


==== Flush DNS cache ====
== Flush DNS cache ==
[https://support.opendns.com/hc/en-us/articles/227988627-How-to-clear-the-DNS-Cache- How to clear the DNS Cache?]
[https://support.opendns.com/hc/en-us/articles/227988627-How-to-clear-the-DNS-Cache- How to clear the DNS Cache?]


==== Test if you are using OpenDNS ====
== Test if you are using OpenDNS ==
https://welcome.opendns.com/
https://welcome.opendns.com/


==== Query DNS server ====
== Query DNS server ==
To [https://askubuntu.com/questions/152593/command-line-to-list-dns-servers-used-by-my-system list the current DNS servers used by my system],  
To [https://askubuntu.com/questions/152593/command-line-to-list-dns-servers-used-by-my-system list the current DNS servers used by my system],  


Line 2,514: Line 2,513:
Another way is to use the R packages: [https://cran.r-project.org/web/packages/gdns/index.html gdns] and [https://github.com/hrbrmstr/dnsflare dnsflare]. [https://rud.is/b/2018/04/01/more-options-for-querying-dns-from-r-with-1-1-1-1/ More Options For Querying DNS From R with 1.1.1.1].
Another way is to use the R packages: [https://cran.r-project.org/web/packages/gdns/index.html gdns] and [https://github.com/hrbrmstr/dnsflare dnsflare]. [https://rud.is/b/2018/04/01/more-options-for-querying-dns-from-r-with-1-1-1-1/ More Options For Querying DNS From R with 1.1.1.1].


==== 3 Ways to Check DNS Propagation Status ====
== 3 Ways to Check DNS Propagation Status ==
https://www.makeuseof.com/tag/check-dns-propagation-status/
https://www.makeuseof.com/tag/check-dns-propagation-status/


=== Email server ===
= Email server =
==== POP, IMAP and Exchange ====
== POP, IMAP and Exchange ==
* https://support.office.com/en-US/article/What-are-IMAP-and-POP-ca2c5799-49f9-4079-aefe-ddca85d5b1c9?ui=en-US&rs=en-US&ad=US&fromAR=1
* https://support.office.com/en-US/article/What-are-IMAP-and-POP-ca2c5799-49f9-4079-aefe-ddca85d5b1c9?ui=en-US&rs=en-US&ad=US&fromAR=1
* https://www.howtogeek.com/99423/email-whats-the-difference-in-pop3-imap-and-exchange/
* https://www.howtogeek.com/99423/email-whats-the-difference-in-pop3-imap-and-exchange/
Line 2,528: Line 2,527:
'''Exchange''' offers the same syncing capabilities as IMAP, plus much more. Exchange is a Microsoft product, giving you the ability to still use Outlook as your email service and benefit from Exchange functionality.
'''Exchange''' offers the same syncing capabilities as IMAP, plus much more. Exchange is a Microsoft product, giving you the ability to still use Outlook as your email service and benefit from Exchange functionality.


==== Configure Postfix to use Gmail as a Mail Relay ====
== Configure Postfix to use Gmail as a Mail Relay ==
https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/
https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/


Note one comment says to use '''[https://support.google.com/accounts/answer/185833 App Passwords]''' instead of the regular google account password.
Note one comment says to use '''[https://support.google.com/accounts/answer/185833 App Passwords]''' instead of the regular google account password.


==== How to Build an Email Server on Ubuntu Linux ====
== How to Build an Email Server on Ubuntu Linux ==
* https://www.linux.com/learn/how-build-email-server-ubuntu-linux, [https://www.linux.com/learn/sysadmin/building-email-server-ubuntu-linux-part-3 Part 2] & [https://www.linux.com/learn/sysadmin/building-email-server-ubuntu-linux-part-3 Part 3]
* https://www.linux.com/learn/how-build-email-server-ubuntu-linux, [https://www.linux.com/learn/sysadmin/building-email-server-ubuntu-linux-part-3 Part 2] & [https://www.linux.com/learn/sysadmin/building-email-server-ubuntu-linux-part-3 Part 3]
* https://help.ubuntu.com/community/Postfix
* https://help.ubuntu.com/community/Postfix
Line 2,540: Line 2,539:
* [https://www.howtoforge.com/tutorial/how-to-setup-iredmail-server-on-ubuntu-1804/ How to Setup IRedMail Server on Ubuntu 18.04 LTS]
* [https://www.howtoforge.com/tutorial/how-to-setup-iredmail-server-on-ubuntu-1804/ How to Setup IRedMail Server on Ubuntu 18.04 LTS]


==== Send from google emails on Ubuntu ====
== Send from google emails on Ubuntu ==
* [https://askubuntu.com/questions/1059245/how-to-configure-postfix-to-use-gmail-smtp-on-ubuntu-16-04-17-10 How to configure Postfix to use Gmail SMTP on Ubuntu 16.04 / 17.10].  
* [https://askubuntu.com/questions/1059245/how-to-configure-postfix-to-use-gmail-smtp-on-ubuntu-16-04-17-10 How to configure Postfix to use Gmail SMTP on Ubuntu 16.04 / 17.10].  
* [https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/ Configure Postfix to use Gmail as a Mail Relay]
* [https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/ Configure Postfix to use Gmail as a Mail Relay]
Line 2,571: Line 2,570:
</syntaxhighlight>
</syntaxhighlight>


==== Webmail ====
== Webmail ==
[https://www.howtoforge.com/tutorial/install-webmail-lite-on-debian-9/ Install WebMail Lite PHP based Webmail Client on Debian 9.1]
[https://www.howtoforge.com/tutorial/install-webmail-lite-on-debian-9/ Install WebMail Lite PHP based Webmail Client on Debian 9.1]


==== [http://caspian.dotconf.net/menu/Software/SendEmail/ sendemail] package ====
== [http://caspian.dotconf.net/menu/Software/SendEmail/ sendemail] package ==
* http://bhfsteve.blogspot.com/2013/03/monitoring-web-page-for-changes-using.html
* http://bhfsteve.blogspot.com/2013/03/monitoring-web-page-for-changes-using.html
* '''sudo apt-get install sendemail'''
* '''sudo apt-get install sendemail'''
Line 2,592: Line 2,591:
</syntaxhighlight>
</syntaxhighlight>


==== Kolab ====
== Kolab ==
[https://www.howtoforge.com/tutorial/install-and-configure-kolab-groupware-on-ubuntu-1604/ Install and Configure Kolab Groupware on Ubuntu 16.04 LTS]
[https://www.howtoforge.com/tutorial/install-and-configure-kolab-groupware-on-ubuntu-1604/ Install and Configure Kolab Groupware on Ubuntu 16.04 LTS]


==== Criptext: private email service ====
== Criptext: private email service ==
* https://www.criptext.com/
* https://www.criptext.com/
* https://www.linuxuprising.com/2018/10/criptext-is-new-encrypted-email-service.html
* https://www.linuxuprising.com/2018/10/criptext-is-new-encrypted-email-service.html


==== Zimbra ====
== Zimbra ==
[https://www.howtoforge.com/tutorial/install-zimbra-collaboration-suite-88-on-ubuntu/ How to Install Zimbra Collaboration Suite 8.8 on Ubuntu]
[https://www.howtoforge.com/tutorial/install-zimbra-collaboration-suite-88-on-ubuntu/ How to Install Zimbra Collaboration Suite 8.8 on Ubuntu]


=== Backup ===
= Backup =


==== 13 open source backup solutions ====
== 13 open source backup solutions ==
[https://opensource.com/article/19/3/backup-solutions 13 open source backup solutions]
[https://opensource.com/article/19/3/backup-solutions 13 open source backup solutions]


Line 2,610: Line 2,609:
* 13 tools:  BorgBackup,  UrBackup, LuckyBackup, Casync, Syncthing, Duplicati, Dirvish, Bacula, BackupPC, Amanda, Back in Time, Timeshift, Kup.
* 13 tools:  BorgBackup,  UrBackup, LuckyBackup, Casync, Syncthing, Duplicati, Dirvish, Bacula, BackupPC, Amanda, Back in Time, Timeshift, Kup.


==== rdiff-backup ====
== rdiff-backup ==
[http://rdiff-backup.nongnu.org/index.html rdiff-backup]. See  
[http://rdiff-backup.nongnu.org/index.html rdiff-backup]. See  
* [https://opensource.com/life/16/3/turn-your-old-raspberry-pi-automatic-backup-server Turn your old Raspberry Pi into an automatic backup server]
* [https://opensource.com/life/16/3/turn-your-old-raspberry-pi-automatic-backup-server Turn your old Raspberry Pi into an automatic backup server]
* [https://www.tecmint.com/rdiff-backup-remote-incremental-backup-for-linux/ rdiff-backup – A Remote Incremental Backup Tool for Linux]
* [https://www.tecmint.com/rdiff-backup-remote-incremental-backup-for-linux/ rdiff-backup – A Remote Incremental Backup Tool for Linux]


==== Dropbox ====
== Dropbox ==
If we don't want to install dropbox software, we can install bash dropbox uploader: http://www.andreafabrizi.it/?dropbox_uploader OR https://github.com/andreafabrizi/Dropbox-Uploader
If we don't want to install dropbox software, we can install bash dropbox uploader: http://www.andreafabrizi.it/?dropbox_uploader OR https://github.com/andreafabrizi/Dropbox-Uploader


Line 2,631: Line 2,630:
</pre>
</pre>


==== Clone ====
== Clone ==
[https://www.makeuseof.com/tag/2-methods-to-clone-your-linux-hard-drive/ 4 Methods To Clone Your Linux Hard Drive ]
[https://www.makeuseof.com/tag/2-methods-to-clone-your-linux-hard-drive/ 4 Methods To Clone Your Linux Hard Drive ]
# dd can clone an entire HDD or disk partition
# dd can clone an entire HDD or disk partition
Line 2,638: Line 2,637:
# Clonezilla
# Clonezilla


==== back up DVDs ====
== back up DVDs ==
See [[Ubuntu#Create_an_iso_file_from_a_CD.2FDVD_or_HD|Create an iso file from a DVD/CD]]
See [[Ubuntu#Create_an_iso_file_from_a_CD.2FDVD_or_HD|Create an iso file from a DVD/CD]]


==== [https://opensource.com/article/18/7/how-use-dd-linux back up a remote drive using SSH and save the resulting archive to your local machine] ====
== [https://opensource.com/article/18/7/how-use-dd-linux back up a remote drive using SSH and save the resulting archive to your local machine] ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
# ssh [email protected] "dd if=/dev/sda | gzip -1 -" | dd of=backup.gz
# ssh [email protected] "dd if=/dev/sda | gzip -1 -" | dd of=backup.gz
Line 2,647: Line 2,646:
where "-1" (one) indicates the fastest compression method and the dash means ‘standard input’.
where "-1" (one) indicates the fastest compression method and the dash means ‘standard input’.


==== Backups vs. Archives ====
== Backups vs. Archives ==
[https://www.howtogeek.com/356473/how-to-archive-your-data-for-virtually-forever/ How to Archive Your Data (Virtually) Forever]
[https://www.howtogeek.com/356473/how-to-archive-your-data-for-virtually-forever/ How to Archive Your Data (Virtually) Forever]


==== Delete files or directories older than XXX days ====
== Delete files or directories older than XXX days ==
Suppose we have a cron job to run backup and that creates a lot of directories. We like to erase them to avoid our system running out of space. You can run a space-checking program that'll alert you when the filesystem is low on free space. In addition we can run a cron job that uses ''find'' to erase all files.
Suppose we have a cron job to run backup and that creates a lot of directories. We like to erase them to avoid our system running out of space. You can run a space-checking program that'll alert you when the filesystem is low on free space. In addition we can run a cron job that uses ''find'' to erase all files.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 2,670: Line 2,669:
* [https://www.linuxjournal.com/content/avoiding-server-disaster Avoding server disaster]
* [https://www.linuxjournal.com/content/avoiding-server-disaster Avoding server disaster]


==== [http://www.teejeetech.in/p/timeshift.html Timeshift] ====
== [http://www.teejeetech.in/p/timeshift.html Timeshift] ==
* [https://itsfoss.com/backup-restore-linux-timeshift/ How To Backup And Restore Linux With Timeshift]
* [https://itsfoss.com/backup-restore-linux-timeshift/ How To Backup And Restore Linux With Timeshift]
* [https://linuxhint.com/timeshift-backup-tutorial/ Linux TimeShift for Backup Tutorial]
* [https://linuxhint.com/timeshift-backup-tutorial/ Linux TimeShift for Backup Tutorial]


==== Vorta (BorgBackup GUI) ====
== Vorta (BorgBackup GUI) ==
* [https://www.linuxuprising.com/2019/02/securely-and-efficiently-backup-data-on.html?m=1 Securely And Efficiently Backup Data On Linux Or macOS With Vorta (BorgBackup GUI)], [https://www.linuxuprising.com/2019/06/vorta-borgbackup-gui-now-available-for.html Vorta BorgBackup GUI Now Available For Install On Linux From Flathub ]
* [https://www.linuxuprising.com/2019/02/securely-and-efficiently-backup-data-on.html?m=1 Securely And Efficiently Backup Data On Linux Or macOS With Vorta (BorgBackup GUI)], [https://www.linuxuprising.com/2019/06/vorta-borgbackup-gui-now-available-for.html Vorta BorgBackup GUI Now Available For Install On Linux From Flathub ]
* [https://borgbackup.readthedocs.io/en/stable/ BorgBackup]
* [https://borgbackup.readthedocs.io/en/stable/ BorgBackup]
* [https://github.com/borgbase/vorta Vorta]
* [https://github.com/borgbase/vorta Vorta]


==== CloudBerry ====
== CloudBerry ==
[https://www.makeuseof.com/tag/cloudberry-backup-protects-files-on-windows-mac-and-linux/ CloudBerry Backup Protects Files on Windows, Mac, and Linux]
[https://www.makeuseof.com/tag/cloudberry-backup-protects-files-on-windows-mac-and-linux/ CloudBerry Backup Protects Files on Windows, Mac, and Linux]


==== Github, Bitbucket, Gitlab ====
== Github, Bitbucket, Gitlab ==
We can use these git services to get real-time data (eg temperature, IP, etc).
We can use these git services to get real-time data (eg temperature, IP, etc).


=== Running a cron job as a user ===
= Running a cron job as a user =
==== Some examples ====
== Some examples ==
* http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
* http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
* https://crontab.guru/examples.html and [https://crontab.guru/tips.html tips]
* https://crontab.guru/examples.html and [https://crontab.guru/tips.html tips]
Line 2,713: Line 2,712:
</pre>
</pre>


==== crontab ====
== crontab ==
* crontab SOME-CRON-FILE; crontab -l
* crontab SOME-CRON-FILE; crontab -l


Line 2,729: Line 2,728:
To disable everything on ''crontab -l'', run ''crontab -e'' then comment out each line you don't want to run with #. OR run ''crontab -r'' to empty the current crontab.
To disable everything on ''crontab -l'', run ''crontab -e'' then comment out each line you don't want to run with #. OR run ''crontab -r'' to empty the current crontab.


==== PATH and Shell ====
== PATH and Shell ==
Cron knows nothing about your shell; it is started by the system, so it has a minimal environment. If you want anything, you need to have that brought in yourself. For example, to use 'ifconfig' command, I need to give it a complete path in my script file.  
Cron knows nothing about your shell; it is started by the system, so it has a minimal environment. If you want anything, you need to have that brought in yourself. For example, to use 'ifconfig' command, I need to give it a complete path in my script file.  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 2,741: Line 2,740:
See [http://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables here] on how to add environment variable into cron environment.
See [http://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables here] on how to add environment variable into cron environment.


==== Disable mail alert ====
== Disable mail alert ==
If something went wrong with executing a cron job, cron will output a message "You have new mail in /var/mail/$USER". You can open this file using a text editor. To disable this alert, run ''''crontab -e''' (see [http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/ this post]
If something went wrong with executing a cron job, cron will output a message "You have new mail in /var/mail/$USER". You can open this file using a text editor. To disable this alert, run ''''crontab -e''' (see [http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/ this post]
<pre>
<pre>
Line 2,749: Line 2,748:
</pre>
</pre>


=== Running crontab as root ===
= Running crontab as root =
Use '''sudo crontab -e''' to edit. After saving it, no need to initialize it. Use '''sudo crontab -l''' to list the cron job.
Use '''sudo crontab -e''' to edit. After saving it, no need to initialize it. Use '''sudo crontab -l''' to list the cron job.


=== GUI cron ===
= GUI cron =
* [https://www.ostechnix.com/how-to-easily-and-safely-manage-cron-jobs-in-linux/ How To Easily And Safely Manage Cron Jobs In Linux]
* [https://www.ostechnix.com/how-to-easily-and-safely-manage-cron-jobs-in-linux/ How To Easily And Safely Manage Cron Jobs In Linux]
* [https://github.com/alseambusher/crontab-ui Crontab UI]
* [https://github.com/alseambusher/crontab-ui Crontab UI]
* http://corntab.com/#!
* http://corntab.com/#!


=== md5sum ===
= md5sum =
[https://www.howtoforge.com/linux-md5sum-command/ Linux md5sum Command Explained For Beginners (5 Examples)]
[https://www.howtoforge.com/linux-md5sum-command/ Linux md5sum Command Explained For Beginners (5 Examples)]


Line 2,766: Line 2,765:
</pre>
</pre>


=== fsck ===
= fsck =
* [https://www.cyberciti.biz/tips/repairing-linux-ext2-or-ext3-file-system.html Repairing Linux ext2 or ext3 or ext4 File System (fsck)]
* [https://www.cyberciti.biz/tips/repairing-linux-ext2-or-ext3-file-system.html Repairing Linux ext2 or ext3 or ext4 File System (fsck)]
* [https://www.thegeekstuff.com/2012/08/fsck-command-examples 10 Linux Fsck Command Examples to Check and Repair Filesystem]
* [https://www.thegeekstuff.com/2012/08/fsck-command-examples 10 Linux Fsck Command Examples to Check and Repair Filesystem]
Line 2,772: Line 2,771:
* [https://www.maketecheasier.com/repair-mac-hard-disk-with-fsck/ How to Repair Hard Disks with fsck on macOS]
* [https://www.maketecheasier.com/repair-mac-hard-disk-with-fsck/ How to Repair Hard Disks with fsck on macOS]


==== Force fsck on the Next Reboot or Boot Sequence ====
== Force fsck on the Next Reboot or Boot Sequence ==
https://www.linuxuprising.com/2019/05/how-to-force-fsck-filesystem.html
https://www.linuxuprising.com/2019/05/how-to-force-fsck-filesystem.html


Line 2,782: Line 2,781:
The fsck was used to fix a [https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums#Journal journal checksum] error on a USB drive which has been formatted as Ext4 was used on a security camera application; see [[Raspberry#Security_Camera:_motion_and_motionEyeOS|motionEyeOS]].
The fsck was used to fix a [https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums#Journal journal checksum] error on a USB drive which has been formatted as Ext4 was used on a security camera application; see [[Raspberry#Security_Camera:_motion_and_motionEyeOS|motionEyeOS]].


==== Can I run fsck or e2fsck when Linux file system is mounted? ====
== Can I run fsck or e2fsck when Linux file system is mounted? ==
https://www.cyberciti.biz/faq/can-i-run-fsck-or-e2fsck-when-linux-file-system-is-mounted/
https://www.cyberciti.biz/faq/can-i-run-fsck-or-e2fsck-when-linux-file-system-is-mounted/


==== What is the difference between fsck and e2fsck? ====
== What is the difference between fsck and e2fsck? ==
https://superuser.com/a/19984
https://superuser.com/a/19984


=== Swap partition ===
= Swap partition =
* [https://www.tecmint.com/disable-swap-partition-in-centos-ubuntu/ How to Permanently Disable Swap in Linux]
* [https://www.tecmint.com/disable-swap-partition-in-centos-ubuntu/ How to Permanently Disable Swap in Linux]


=== Mount drive, add a new hard drive ===
= Mount drive, add a new hard drive =
[https://kerneltalks.com/hardware-config/how-to-add-new-disk-in-linux/ How to add new disk in Linux]
[https://kerneltalks.com/hardware-config/how-to-add-new-disk-in-linux/ How to add new disk in Linux]


==== /etc/fstab and blkid ====
== /etc/fstab and blkid ==
* https://help.ubuntu.com/community/Fstab
* https://help.ubuntu.com/community/Fstab
** Format: [Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]
** Format: [Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]
Line 2,858: Line 2,857:
</syntaxhighlight>
</syntaxhighlight>


==== autofs, /etc/auto.master ====
== autofs, /etc/auto.master ==
[https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi Building a network attached storage device with a Raspberry Pi]
[https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi Building a network attached storage device with a Raspberry Pi]


==== Fix a malfunctioning USB device or port ====
== Fix a malfunctioning USB device or port ==
[https://www.makeuseof.com/tag/fix-usb-device-port-linux/ 5 Ways to Fix a Malfunctioning USB Device or Port on Linux]
[https://www.makeuseof.com/tag/fix-usb-device-port-linux/ 5 Ways to Fix a Malfunctioning USB Device or Port on Linux]


==== USB drive ====
== USB drive ==
* [https://help.ubuntu.com/community/RenameUSBDrive Rename USB drive]
* [https://help.ubuntu.com/community/RenameUSBDrive Rename USB drive]


Line 2,900: Line 2,899:
</syntaxhighlight>
</syntaxhighlight>


==== Mount an iso file ====
== Mount an iso file ==
* http://www.shellhacks.com/en/Mounting-an-ISO-Image-in-Linux
* http://www.shellhacks.com/en/Mounting-an-ISO-Image-in-Linux
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 2,908: Line 2,907:
</syntaxhighlight>
</syntaxhighlight>


==== Mount remote Windows share ====
== Mount remote Windows share ==
* http://www.shellhacks.com/en/HowTo-Mount-Remote-Windows-Partition-Share-under-Linux
* http://www.shellhacks.com/en/HowTo-Mount-Remote-Windows-Partition-Share-under-Linux


==== Sharing files with Windows by using NitroShare ====
== Sharing files with Windows by using NitroShare ==
[http://www.ubuntugeek.com/simple-way-of-sharing-files-between-ubuntu-16-04-and-windows-10.html Simple way of Sharing files between Ubuntu 16.04 and Windows 10] by using open-source [https://nitroshare.net/ NitroShare] which is based on Qt framework.
[http://www.ubuntugeek.com/simple-way-of-sharing-files-between-ubuntu-16-04-and-windows-10.html Simple way of Sharing files between Ubuntu 16.04 and Windows 10] by using open-source [https://nitroshare.net/ NitroShare] which is based on Qt framework.


==== exFat - cross platform partition format ====
== exFat - cross platform partition format ==
*[[Mac#ExFat:_Best_drive.2Fpartition_format_to_share_data_between_Mac.2C_Linux_and_OS_X|Mac]]
*[[Mac#ExFat:_Best_drive.2Fpartition_format_to_share_data_between_Mac.2C_Linux_and_OS_X|Mac]]
* Gparted cannot create exFAT partition (it is greyed out)
* Gparted cannot create exFAT partition (it is greyed out)
Line 2,927: Line 2,926:
This should delivery a working exfat file system (read and write support, but not formatting the drives with exfat via Gnome Disks and GParted).
This should delivery a working exfat file system (read and write support, but not formatting the drives with exfat via Gnome Disks and GParted).


==== NTFS usb drive in xubuntu ====
== NTFS usb drive in xubuntu ==
http://xflinux.blogspot.com/2011/01/mount-ntfs-volumes-automatically-in.html
http://xflinux.blogspot.com/2011/01/mount-ntfs-volumes-automatically-in.html
<pre>
<pre>
Line 2,938: Line 2,937:
Make sure the " Enable write support for internal devices" option is selected. Now click Close.
Make sure the " Enable write support for internal devices" option is selected. Now click Close.


==== Many drives, one folder ====
== Many drives, one folder ==
* [http://www.linuxjournal.com/content/many-drives-one-folder mhddfs] program.
* [http://www.linuxjournal.com/content/many-drives-one-folder mhddfs] program.


==== Partition tables ====
== Partition tables ==
[http://www.makeuseof.com/tag/partition-table-edit-error/ Partition Tables and the Dangers of Editing Them]
[http://www.makeuseof.com/tag/partition-table-edit-error/ Partition Tables and the Dangers of Editing Them]


==== parted command ====
== parted command ==
[https://opensource.com/article/18/6/how-partition-disk-linux How to partition a disk in Linux]
[https://opensource.com/article/18/6/how-partition-disk-linux How to partition a disk in Linux]


==== Recommended partition schemes ====
== Recommended partition schemes ==
* [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s2-diskpartrecommend-x86.html Redhat]
* [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s2-diskpartrecommend-x86.html Redhat]
* [https://www.debian.org/releases/stable/i386/apcs03.html.en Debian]
* [https://www.debian.org/releases/stable/i386/apcs03.html.en Debian]
Line 2,954: Line 2,953:
* [https://wiki.archlinux.org/index.php/partitioning#Discrete_partitions Arch] Linux
* [https://wiki.archlinux.org/index.php/partitioning#Discrete_partitions Arch] Linux


==== Why put things other than /home to a separate partition? ====
== Why put things other than /home to a separate partition? ==
[https://unix.stackexchange.com/questions/685/why-put-things-other-than-home-to-a-separate-partition Why put things other than /home to a separate partition?]
[https://unix.stackexchange.com/questions/685/why-put-things-other-than-home-to-a-separate-partition Why put things other than /home to a separate partition?]


Line 2,961: Line 2,960:
[https://unix.stackexchange.com/a/84764 /home, /boot and /var partitions] can be separated.
[https://unix.stackexchange.com/a/84764 /home, /boot and /var partitions] can be separated.


=== Process/job ===
= Process/job =


==== How do I send an already-running process into the background ====
== How do I send an already-running process into the background ==
* http://stackoverflow.com/questions/625409/how-do-i-put-an-already-running-process-under-nohup
* http://stackoverflow.com/questions/625409/how-do-i-put-an-already-running-process-under-nohup
* [https://www.cyberciti.biz/faq/unix-linux-bg-command-examples-usage-syntax/ bg Command Examples]
* [https://www.cyberciti.biz/faq/unix-linux-bg-command-examples-usage-syntax/ bg Command Examples]
Line 2,973: Line 2,972:
# '''disown -h [job-spec]''' where [job-spec] is the job number (like '''%1''' for the first running job; find about your number with the '''jobs''' command) so that the job isn't killed when the terminal closes.
# '''disown -h [job-spec]''' where [job-spec] is the job number (like '''%1''' for the first running job; find about your number with the '''jobs''' command) so that the job isn't killed when the terminal closes.


==== Stopped job ====
== Stopped job ==
A [https://unix.stackexchange.com/questions/116959/there-are-stopped-jobs-on-bash-exit stopped job] is one that has been temporarily put into the background and is no longer running, but is still using resources (i.e. system memory). Because that job is not attached to the current terminal, it cannot produce output and is not receiving input from the user.
A [https://unix.stackexchange.com/questions/116959/there-are-stopped-jobs-on-bash-exit stopped job] is one that has been temporarily put into the background and is no longer running, but is still using resources (i.e. system memory). Because that job is not attached to the current terminal, it cannot produce output and is not receiving input from the user.


Line 2,986: Line 2,985:
* '''kill -9 $(jobs -p)'''
* '''kill -9 $(jobs -p)'''


==== nice ====
== nice ==
[https://www.howtogeek.com/411979/how-to-set-process-priorities-with-the-nice-and-renice-commands-in-linux/ How to Set Process Priorities With nice and renice on Linux]
[https://www.howtogeek.com/411979/how-to-set-process-priorities-with-the-nice-and-renice-commands-in-linux/ How to Set Process Priorities With nice and renice on Linux]


=== run commands in a background and allow log off ===
= run commands in a background and allow log off =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
nohup /path/to/script >output 2>&1 &
nohup /path/to/script >output 2>&1 &
Line 3,001: Line 3,000:
See also [https://en.wikipedia.org/wiki/Process_substitution#Anonymous_named_pipe Anonymous named pipe].
See also [https://en.wikipedia.org/wiki/Process_substitution#Anonymous_named_pipe Anonymous named pipe].


=== Notepadqq - Notepad++-like editor ===
= Notepadqq - Notepad++-like editor =
[http://www.ubuntugeek.com/notepadqq-the-linux-source-editor.html Notepadqq]. It is written using Qt. It does not have printing function:(
[http://www.ubuntugeek.com/notepadqq-the-linux-source-editor.html Notepadqq]. It is written using Qt. It does not have printing function:(


=== Note apps that can sync ===
= Note apps that can sync =
[http://www.makeuseof.com/tag/top-notepad-apps-linux-can-sync/ Top 8 Notepad Apps for Linux That You Can Sync]. Some are compatible with Evernote.
[http://www.makeuseof.com/tag/top-notepad-apps-linux-can-sync/ Top 8 Notepad Apps for Linux That You Can Sync]. Some are compatible with Evernote.


=== Evernote ===
= Evernote =
==== Evernote alternative ====
== Evernote alternative ==
[https://www.howtoforge.com/tutorial/how-to-install-turtl-server-evernote-alternative-on-ubuntu-1604/ How to Install Turtl Server - Evernote Alternative - on Ubuntu 16.04]
[https://www.howtoforge.com/tutorial/how-to-install-turtl-server-evernote-alternative-on-ubuntu-1604/ How to Install Turtl Server - Evernote Alternative - on Ubuntu 16.04]


==== Backup/restore Evernote ====
== Backup/restore Evernote ==
https://www.makeuseof.com/tag/backup-restore-evernote/
https://www.makeuseof.com/tag/backup-restore-evernote/


=== Markdown ===
= Markdown =
==== Preview markdown/view markdown offline ====
== Preview markdown/view markdown offline ==
* [https://atom.io/ Atom] text editor has a built-in function to preview HTML or markdown files. Menu -> Packages -> Markdown Preview -> Toggle Preview.  
* [https://atom.io/ Atom] text editor has a built-in function to preview HTML or markdown files. Menu -> Packages -> Markdown Preview -> Toggle Preview.  
* http://stackoverflow.com/questions/9843609/view-markdown-files-offline. [https://github.com/joeyespo/grip Grip] works fine.   
* http://stackoverflow.com/questions/9843609/view-markdown-files-offline. [https://github.com/joeyespo/grip Grip] works fine.   
Line 3,029: Line 3,028:
* Chrome ''markdown preview plus'' extension does not show images from github.
* Chrome ''markdown preview plus'' extension does not show images from github.


==== Markdown editor ====
== Markdown editor ==
* [http://pad.haroopress.com/ Harropad]
* [http://pad.haroopress.com/ Harropad]
* http://linuxbsdos.com/2014/10/05/the-best-markdown-editors-for-linux/
* http://linuxbsdos.com/2014/10/05/the-best-markdown-editors-for-linux/


=== Text editor with navigation ===
= Text editor with navigation =
[[Text_editor#Text_editor_with_navigation|Text editor with navigation]]
[[Text_editor#Text_editor_with_navigation|Text editor with navigation]]


=== nano/pico editor ===
= nano/pico editor =
The nano editor is also called pico in R. See ?edit in R.
The nano editor is also called pico in R. See ?edit in R.


[[Text_editor#nano_editor|nano editor]]
[[Text_editor#nano_editor|nano editor]]


=== vi editor ===
= vi editor =
[[Text_editor#vi_editor|vi editor]]
[[Text_editor#vi_editor|vi editor]]


=== Cloud ===
= Cloud =


http://slidedecks.wilmoore.com/2012-confoo/diy-private-cloud-using-virtualBox-and-chef/#66
http://slidedecks.wilmoore.com/2012-confoo/diy-private-cloud-using-virtualBox-and-chef/#66
Line 3,063: Line 3,062:
* Microsoft Azure
* Microsoft Azure


==== Manage all your cloud storage ====
== Manage all your cloud storage ==
http://www.makeuseof.com/tag/chrome-extensions-you-need-manage-cloud-storage/
http://www.makeuseof.com/tag/chrome-extensions-you-need-manage-cloud-storage/


==== Dropbox ====
== Dropbox ==
[https://www.ostechnix.com/dbxfs-mount-dropbox-folder-locally-as-virtual-file-system-in-linux/ Dbxfs – Mount Dropbox Folder Locally As Virtual File System In Linux]. It is a command line dropbox client and requires no disk space for access.
[https://www.ostechnix.com/dbxfs-mount-dropbox-folder-locally-as-virtual-file-system-in-linux/ Dbxfs – Mount Dropbox Folder Locally As Virtual File System In Linux]. It is a command line dropbox client and requires no disk space for access.


==== Comparison of Linux VPS providers ====
== Comparison of Linux VPS providers ==
https://www.ghacks.net/2017/06/15/a-comparison-of-linux-vps-providers-for-beginner-hosting/
https://www.ghacks.net/2017/06/15/a-comparison-of-linux-vps-providers-for-beginner-hosting/


=== Boot ===
= Boot =
* [https://opensource.com/article/18/1/analyzing-linux-boot-process Analyzing the Linux boot process]
* [https://opensource.com/article/18/1/analyzing-linux-boot-process Analyzing the Linux boot process]
* [https://utcc.utoronto.ca/~cks/space/blog/linux/LinuxBootOverview? A broad overview of how modern Linux systems boot]
* [https://utcc.utoronto.ca/~cks/space/blog/linux/LinuxBootOverview? A broad overview of how modern Linux systems boot]


==== U-boot ====
== U-boot ==
http://www.denx.de/wiki/U-Boot
http://www.denx.de/wiki/U-Boot


=== Pandora linux client ===
= Pandora linux client =
* [http://kevinmehall.net/p/pithos/ Pithos] (GUI)
* [http://kevinmehall.net/p/pithos/ Pithos] (GUI)
* [http://6xq.net/projects/pianobar/ Pianobar] (Command line)
* [http://6xq.net/projects/pianobar/ Pianobar] (Command line)


=== COW (copy on write) file system ===
= COW (copy on write) file system =
The cow filesystem was found on xubuntu live CD. See http://en.wikipedia.org/wiki/Copy-on-write
The cow filesystem was found on xubuntu live CD. See http://en.wikipedia.org/wiki/Copy-on-write


[https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-dirty-cow-linux-vulnerability How To Protect Your Server Against the Dirty COW Linux Vulnerability] (10/21/2016)
[https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-dirty-cow-linux-vulnerability How To Protect Your Server Against the Dirty COW Linux Vulnerability] (10/21/2016)


=== Apache redirection ===
= Apache redirection =
http://cran.r-project.org/mirror-howto.html
http://cran.r-project.org/mirror-howto.html


[http://www.tecmint.com/redirect-website-url-from-one-server-to-different-server/ Redirect a Website URL from One Server to Different Server in Apache]
[http://www.tecmint.com/redirect-website-url-from-one-server-to-different-server/ Redirect a Website URL from One Server to Different Server in Apache]


=== Important linux directories ===
= Important linux directories =
* /bin - executables used by the base system
* /bin - executables used by the base system
* /boot  
* /boot  
Line 3,106: Line 3,105:
* /var - variable data such as databases, mails spools and system logs.
* /var - variable data such as databases, mails spools and system logs.


=== Difference of /bin, /sbin, /usr/local/bin, ... ===
= Difference of /bin, /sbin, /usr/local/bin, ... =
* /bin : For essential binaries; e.g. bash, cat, ls.
* /bin : For essential binaries; e.g. bash, cat, ls.
* /sbin : is similar to /bin but for scripts with superuser (root) privileges required; e.g. shutdown command is located here. Local users have to use sudo to run binaries here.
* /sbin : is similar to /bin but for scripts with superuser (root) privileges required; e.g. shutdown command is located here. Local users have to use sudo to run binaries here.
Line 3,115: Line 3,114:
If you want to create your own scripts and make them available to all users, you’re pretty safe adding them to /usr/local/bin. Or to add my scripts to my local bin (~/bin) and then I create a symbolic link in /usr/local/bin to the commands I want to make public. As a result, I can manage all my scripts from the same directory but still make some of them publicly available since /usr/local/bin is added to $PATH. See [http://blog.taylormcgann.com/2014/04/11/difference-bin-sbin/ this post].
If you want to create your own scripts and make them available to all users, you’re pretty safe adding them to /usr/local/bin. Or to add my scripts to my local bin (~/bin) and then I create a symbolic link in /usr/local/bin to the commands I want to make public. As a result, I can manage all my scripts from the same directory but still make some of them publicly available since /usr/local/bin is added to $PATH. See [http://blog.taylormcgann.com/2014/04/11/difference-bin-sbin/ this post].


=== DHCP lease time ===
= DHCP lease time =


On Windows, it is 8 days.
On Windows, it is 8 days.


==== Get a New IP Address ====
== Get a New IP Address ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
dhclient -r  #  release your IP Address
dhclient -r  #  release your IP Address
Line 3,126: Line 3,125:
</syntaxhighlight>
</syntaxhighlight>


=== Open a file/URL using the default application from the command line ===
= Open a file/URL using the default application from the command line =
* '''gnome-open''' (works on Mint)
* '''gnome-open''' (works on Mint)
* '''kde-open''' (KDE users)
* '''kde-open''' (KDE users)
Line 3,135: Line 3,134:
* [https://www.howtogeek.com/117709/how-to-change-your-default-applications-on-ubuntu-4-ways/ How to Change Your Default Applications on Ubuntu: 4 Ways]
* [https://www.howtogeek.com/117709/how-to-change-your-default-applications-on-ubuntu-4-ways/ How to Change Your Default Applications on Ubuntu: 4 Ways]


=== Check a file's encoding ===
= Check a file's encoding =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
file -bi myfile
file -bi myfile
Line 3,145: Line 3,144:
</syntaxhighlight>
</syntaxhighlight>


=== Know you system using the command line ===
= Know you system using the command line =
* https://www.howtoforge.com/tutorial/get-to-know-your-system/
* https://www.howtoforge.com/tutorial/get-to-know-your-system/


=== Alerting and visualization tools ===
= Alerting and visualization tools =
[https://opensource.com/article/18/10/alerting-and-visualization-tools-sysadmins 5 alerting and visualization tools for sysadmins]
[https://opensource.com/article/18/10/alerting-and-visualization-tools-sysadmins 5 alerting and visualization tools for sysadmins]


=== System monitor tools (TUI) ===
= System monitor tools (TUI) =
==== [https://github.com/brndnmtthws/conky conky] ====
== [https://github.com/brndnmtthws/conky conky] ==
* [[Ubuntu#Conky|Ubuntu > Conky]] (internal link)
* [[Ubuntu#Conky|Ubuntu > Conky]] (internal link)
* [[Raspberry#Conky_approach|Raspberry Pi]] case (internal link)
* [[Raspberry#Conky_approach|Raspberry Pi]] case (internal link)


==== '''htop''' command ====
== '''htop''' command ==
* [http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages Understand Linux CPU Load]
* [http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages Understand Linux CPU Load]


==== glances command ====
== glances command ==
* https://nicolargo.github.io/glances/ and its [http://glances.readthedocs.io/en/latest/ Documentation]
* https://nicolargo.github.io/glances/ and its [http://glances.readthedocs.io/en/latest/ Documentation]
* [http://www.ubuntugeek.com/install-glances-on-ubuntu-16-04.html Glances] includes disk i/o, network too. Its official website at http://glances.readthedocs.io/en/latest/.
* [http://www.ubuntugeek.com/install-glances-on-ubuntu-16-04.html Glances] includes disk i/o, network too. Its official website at http://glances.readthedocs.io/en/latest/.
Line 3,166: Line 3,165:
Glances is similar to htop but it provides network stats too. Install it by '''sudo apt-get install glances'''.
Glances is similar to htop but it provides network stats too. Install it by '''sudo apt-get install glances'''.


==== [https://scoutapp.github.io/scout_realtime/ scout_realtimep] ====
== [https://scoutapp.github.io/scout_realtime/ scout_realtimep] ==
This is used by [https://docs.dataplicity.com/docs/remotely-monitor-your-pi Dataplicity]
This is used by [https://docs.dataplicity.com/docs/remotely-monitor-your-pi Dataplicity]


==== [https://github.com/aksakalli/gtop gtop] command (100% Javascript) ====
== [https://github.com/aksakalli/gtop gtop] command (100% Javascript) ==
https://www.cyberciti.biz/howto/gtop-awesome-system-monitoring-dashboard-for-terminal/.  
https://www.cyberciti.biz/howto/gtop-awesome-system-monitoring-dashboard-for-terminal/.  


Line 3,218: Line 3,217:
</pre>
</pre>


==== [https://github.com/cjbassi/gotop gotop] ====
== [https://github.com/cjbassi/gotop gotop] ==
A terminal based graphical activity monitor inspired by gtop and vtop. It is quite beautiful.
A terminal based graphical activity monitor inspired by gtop and vtop. It is quite beautiful.


Line 3,233: Line 3,232:
Note the temperatures do not show up in Raspbian (raspberry pi 3 b+).
Note the temperatures do not show up in Raspbian (raspberry pi 3 b+).


===== termui: Golang terminal dashboard =====
=== termui: Golang terminal dashboard ===
https://github.com/gizak/termui
https://github.com/gizak/termui


==== S-tui command ====
== S-tui command ==
[https://www.cyberciti.biz/python-tutorials/monitor-linux-cpu-temperature-frequency-power-in-a-graphical-way/ Monitor Linux CPU temperature, frequency, power in a graphical way]
[https://www.cyberciti.biz/python-tutorials/monitor-linux-cpu-temperature-frequency-power-in-a-graphical-way/ Monitor Linux CPU temperature, frequency, power in a graphical way]


=== System monitor tools (GUI) ===
= System monitor tools (GUI) =
Comparisons:
Comparisons:
* https://www.tecmint.com/linux-performance-monitoring-tools/  
* https://www.tecmint.com/linux-performance-monitoring-tools/  
Line 3,283: Line 3,282:
**# You can view the real-time plot (shown on the right panel) by clicking kSar -> CPU -> CPU all (left panel).  
**# You can view the real-time plot (shown on the right panel) by clicking kSar -> CPU -> CPU all (left panel).  


==== Stacer ====
== Stacer ==
[[Ubuntu#Stacer_-_Linux_System_Optimizer_and_Monitoring|Linux System Optimizer and Monitoring]]
[[Ubuntu#Stacer_-_Linux_System_Optimizer_and_Monitoring|Linux System Optimizer and Monitoring]]


=== [https://en.wikipedia.org/wiki/Curses_%28programming_library%29 Curses] and [https://en.wikipedia.org/wiki/Ncurses ncurses]: TUI library ===
= [https://en.wikipedia.org/wiki/Curses_%28programming_library%29 Curses] and [https://en.wikipedia.org/wiki/Ncurses ncurses]: TUI library =
==== Calcurse ====
== Calcurse ==
[https://opensource.com/article/18/10/calcurse Keep up with your calendar and to-do list with Calcurse]
[https://opensource.com/article/18/10/calcurse Keep up with your calendar and to-do list with Calcurse]


=== Bitbucket (free for 5 users) ===
= Bitbucket (free for 5 users) =
[https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+101  Bitbucket 101]
[https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+101  Bitbucket 101]


Line 3,303: Line 3,302:
See [http://blog.bitbucket.org/2011/12/21/mobile-apps-for-bitbucket/ here] for a list of Android apps related to bitbucket.
See [http://blog.bitbucket.org/2011/12/21/mobile-apps-for-bitbucket/ here] for a list of Android apps related to bitbucket.


=== Image ===
= Image =
[https://opensource.com/article/17/8/imagemagick English original], [https://linux.cn/article-8851-1.html ImageMagick 入门:使用命令行来编辑图片]
[https://opensource.com/article/17/8/imagemagick English original], [https://linux.cn/article-8851-1.html ImageMagick 入门:使用命令行来编辑图片]


==== Convert a color image to black and white ====
== Convert a color image to black and white ==
* https://linux.cn/article-8851-1.html
* https://linux.cn/article-8851-1.html
* https://www.imagemagick.org/script/command-line-options.php#canny
* https://www.imagemagick.org/script/command-line-options.php#canny
Line 3,322: Line 3,321:
[https://www.imagemagick.org/script/download.php The current imagemagick version] is 7.0.7-15.
[https://www.imagemagick.org/script/download.php The current imagemagick version] is 7.0.7-15.


==== Install/build the latest imagemagick ====
== Install/build the latest imagemagick ==
* https://www.imagemagick.org/script/install-source.php
* https://www.imagemagick.org/script/install-source.php
* https://gist.github.com/makenova/78bb63aaa1050e2ad8019ee1e7e7b433
* https://gist.github.com/makenova/78bb63aaa1050e2ad8019ee1e7e7b433
Line 3,376: Line 3,375:
</syntaxhighlight>
</syntaxhighlight>


==== Convert an image to sketch (online tool) ====
== Convert an image to sketch (online tool) ==
http://www.snapstouch.com/sketch.aspx
http://www.snapstouch.com/sketch.aspx


==== Convert an image file to a different format (eg icon) ====
== Convert an image file to a different format (eg icon) ==
Using the [http://www.imagemagick.org/script/index.php imagemagic] program.
Using the [http://www.imagemagick.org/script/index.php imagemagic] program.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,387: Line 3,386:
[http://www.tecmint.com/linux-image-conversion-tools/ 4 Ways to Batch Convert Your PNG to JPG and Vice-Versa]
[http://www.tecmint.com/linux-image-conversion-tools/ 4 Ways to Batch Convert Your PNG to JPG and Vice-Versa]


==== Rotate an image ====
== Rotate an image ==
http://www.imagemagick.org/script/command-line-options.php#rotate
http://www.imagemagick.org/script/command-line-options.php#rotate
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,394: Line 3,393:


One problem with this simple approach is the picture size (not image file) changed (become smaller) if the degree is not one of 90,180 or 270.
One problem with this simple approach is the picture size (not image file) changed (become smaller) if the degree is not one of 90,180 or 270.
==== Create an animated gif file ====
== Create an animated gif file ==
Use the script [http://www.imagemagick.org/Usage/warping/animate_distort_rot here]. See the last example on [http://www.imagemagick.org/Usage/warping/#animations here]. The rotation speed looks good too! Just change the source image file in the script.
Use the script [http://www.imagemagick.org/Usage/warping/animate_distort_rot here]. See the last example on [http://www.imagemagick.org/Usage/warping/#animations here]. The rotation speed looks good too! Just change the source image file in the script.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,419: Line 3,418:
</syntaxhighlight>
</syntaxhighlight>


==== Convert Video to GIF ====
== Convert Video to GIF ==
[https://www.makeuseof.com/tag/convert-video-to-gif/ The Best Ways to Convert Video to GIF]
[https://www.makeuseof.com/tag/convert-video-to-gif/ The Best Ways to Convert Video to GIF]


==== Edit gif file ====
== Edit gif file ==
[https://www.maketecheasier.com/create-gifs-command-tool-ubuntu/ gifsicle] package
[https://www.maketecheasier.com/create-gifs-command-tool-ubuntu/ gifsicle] package


==== Replace transparency in PNG images with white background ====
== Replace transparency in PNG images with white background ==
http://stackoverflow.com/questions/2322750/replace-transparency-in-png-images-with-white-background
http://stackoverflow.com/questions/2322750/replace-transparency-in-png-images-with-white-background
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,431: Line 3,430:
</syntaxhighlight>
</syntaxhighlight>


==== Remove GPS metadata from jpg files - [http://www.sno.phy.queensu.ca/~phil/exiftool/ exiftool]====
== Remove GPS metadata from jpg files - [http://www.sno.phy.queensu.ca/~phil/exiftool/ exiftool]==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo apt-get install libimage-exiftool-perl
sudo apt-get install libimage-exiftool-perl
Line 3,448: Line 3,447:
</syntaxhighlight>
</syntaxhighlight>


==== Edit Svg image ====
== Edit Svg image ==
* [https://inkscape.org/en/ Inkscape]
* [https://inkscape.org/en/ Inkscape]
* Inkscape from [https://fedoramagazine.org/ Fedora magazine]
* Inkscape from [https://fedoramagazine.org/ Fedora magazine]
Line 3,455: Line 3,454:
** [https://fedoramagazine.org/inkscape-design-imagination/ Create a simple wallpaper with Fedora and Inkscape]
** [https://fedoramagazine.org/inkscape-design-imagination/ Create a simple wallpaper with Fedora and Inkscape]


==== Animated gif ====
== Animated gif ==
* [https://www.howtoforge.com/tutorial/how-to-generate-a-animated-gif-or-movie-out-of-images-on-linux/#using-photofilmstrip How to generate a animated GIF or movie out of images on Linux] (GIMP or PhotoFilmStrip)
* [https://www.howtoforge.com/tutorial/how-to-generate-a-animated-gif-or-movie-out-of-images-on-linux/#using-photofilmstrip How to generate a animated GIF or movie out of images on Linux] (GIMP or PhotoFilmStrip)
* [http://superuser.com/questions/558790/how-do-i-convert-gif-to-png-this-image-to-get-the-original-view convert (.gif to .png) this image to get the original view?] (ImageMagick)
* [http://superuser.com/questions/558790/how-do-i-convert-gif-to-png-this-image-to-get-the-original-view convert (.gif to .png) this image to get the original view?] (ImageMagick)


==== Display images in the terminal ====
== Display images in the terminal ==
[https://www.ostechnix.com/how-to-display-images-in-the-terminal/ Using FIM]
[https://www.ostechnix.com/how-to-display-images-in-the-terminal/ Using FIM]


=== [https://www.gimp.org/ GIMP] ===
= [https://www.gimp.org/ GIMP] =


=== login shell (.bash_profile) vs interactive shell (.bashrc) ===
= login shell (.bash_profile) vs interactive shell (.bashrc) =
* http://stackoverflow.com/questions/18186929/differences-between-login-shell-and-interactive-shell
* http://stackoverflow.com/questions/18186929/differences-between-login-shell-and-interactive-shell
8 http://serverfault.com/questions/8882/what-is-the-difference-between-a-login-and-an-interactive-bash-shell
8 http://serverfault.com/questions/8882/what-is-the-difference-between-a-login-and-an-interactive-bash-shell
Line 3,474: Line 3,473:
# When a shell runs a script or a command passed on its command line, it's a '''non-interactive, non-login shell'''.
# When a shell runs a script or a command passed on its command line, it's a '''non-interactive, non-login shell'''.


=== History of commands ===
= History of commands =
* [http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/ 15 Examples To Master Linux Command Line History]
* [http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/ 15 Examples To Master Linux Command Line History]


==== history command with date and time ====
== history command with date and time ==
* http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/
* http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/


Line 3,486: Line 3,485:
Note that the original post asks to write the line to ~/.bash_profile but [http://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal this is not working in the desktop environment].
Note that the original post asks to write the line to ~/.bash_profile but [http://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal this is not working in the desktop environment].


==== Bang bang - Run a command/Fetch parameters from previous history ====
== Bang bang - Run a command/Fetch parameters from previous history ==
* http://unixhelp.ed.ac.uk/shell/tcsh_hist3.html
* http://unixhelp.ed.ac.uk/shell/tcsh_hist3.html
* http://codytaylor.org/2009/09/linux-bang-commands.html
* http://codytaylor.org/2009/09/linux-bang-commands.html
Line 3,507: Line 3,506:
</pre>
</pre>


==== Increase history limit ====
== Increase history limit ==
http://unix.stackexchange.com/questions/17574/is-there-a-maximum-size-to-the-bash-history-file
http://unix.stackexchange.com/questions/17574/is-there-a-maximum-size-to-the-bash-history-file


==== Not to add to bash history ====
== Not to add to bash history ==
[https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu#Configure_MySQL Add a space after the command].
[https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu#Configure_MySQL Add a space after the command].


==== [https://www.howtoforge.com/clear-bash-history/ How to Clear Bash History on Linux] ====
== [https://www.howtoforge.com/clear-bash-history/ How to Clear Bash History on Linux] ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ cat /dev/null > ~/.bash_history && history -c && exit
$ cat /dev/null > ~/.bash_history && history -c && exit
</syntaxhighlight>
</syntaxhighlight>


=== Listen to HiChannel internet radio ===
= Listen to HiChannel internet radio =
Use [http://radiotray.sourceforge.net/ Radio Tray]
Use [http://radiotray.sourceforge.net/ Radio Tray]


Line 3,526: Line 3,525:
I use it to listen m3u file (VLC also supports it too).
I use it to listen m3u file (VLC also supports it too).


=== [http://en.wikipedia.org/wiki/Web_analytics Web Analytics Reporting Tools] ===
= [http://en.wikipedia.org/wiki/Web_analytics Web Analytics Reporting Tools] =
* [http://piwik.org/ Piwik] (open source). [https://www.howtoforge.com/tutorial/how-to-install-piwik-with-nginx-on-ubuntu-15-10/ How to Install Piwik with Nginx on Ubuntu 15.10]
* [http://piwik.org/ Piwik] (open source). [https://www.howtoforge.com/tutorial/how-to-install-piwik-with-nginx-on-ubuntu-15-10/ How to Install Piwik with Nginx on Ubuntu 15.10]
* [https://www.howtoforge.com/tutorial/how-to-install-matomo-web-analytics-on-centos-7/ How to Install Matomo (formerly Piwik) Web Analytics on CentOS 7]
* [https://www.howtoforge.com/tutorial/how-to-install-matomo-web-analytics-on-centos-7/ How to Install Matomo (formerly Piwik) Web Analytics on CentOS 7]
Line 3,532: Line 3,531:
* [http://www.google.com/analytics/ Google Analytics]
* [http://www.google.com/analytics/ Google Analytics]


=== Painting software ===
= Painting software =
* [https://krita.org/en/ Krita] - professional painting program made by artists that want to see affordable art tools for everyone. [https://www.makeuseof.com/tag/krita-free-gimp-alternative/ Krita Is the Free GIMP Alternative You Should Be Using].  
* [https://krita.org/en/ Krita] - professional painting program made by artists that want to see affordable art tools for everyone. [https://www.makeuseof.com/tag/krita-free-gimp-alternative/ Krita Is the Free GIMP Alternative You Should Be Using].  
* [http://pinta-project.com/ Pinta]. It can be install by apt-get command. It works just line Window's paint. Ctr + v to paste an image and save to a file. To crop an image, click the selection tool (1st one) on the left hand side, then select a rectangle. Now click 'Image' > 'Crop to Selection' to finish.
* [http://pinta-project.com/ Pinta]. It can be install by apt-get command. It works just line Window's paint. Ctr + v to paste an image and save to a file. To crop an image, click the selection tool (1st one) on the left hand side, then select a rectangle. Now click 'Image' > 'Crop to Selection' to finish.
Line 3,538: Line 3,537:
* [http://www.ubuntugeek.com/install-mypaint-on-ubuntu-15-10.html MyPaint]
* [http://www.ubuntugeek.com/install-mypaint-on-ubuntu-15-10.html MyPaint]


==== Take a screenshot (and edit them) ====
== Take a screenshot (and edit them) ==
See [[#Take_screenshots_.28and_edit_them.29|Take screenshots]].
See [[#Take_screenshots_.28and_edit_them.29|Take screenshots]].


=== [https://cozy.geigi.de/ Cozy] - audiobook player ===
= [https://cozy.geigi.de/ Cozy] - audiobook player =
* [https://www.linuxuprising.com/2018/09/cozy-is-nice-linux-audiobook-player-for.html Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files]
* [https://www.linuxuprising.com/2018/09/cozy-is-nice-linux-audiobook-player-for.html Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files]
* [https://www.lifewire.com/free-audio-books-3481748 Top 14 Websites For Free Audiobooks]
* [https://www.lifewire.com/free-audio-books-3481748 Top 14 Websites For Free Audiobooks]


=== ebook readers ===
= ebook readers =
[https://itsfoss.com/best-ebook-readers-linux 7 Best eBook Readers for Linux]: Calibre, FBReader, Okular, Lucidor, Bookworm, Easy Ebook Viewer and Buka.
[https://itsfoss.com/best-ebook-readers-linux 7 Best eBook Readers for Linux]: Calibre, FBReader, Okular, Lucidor, Bookworm, Easy Ebook Viewer and Buka.


==== [http://calibre-ebook.com/download_linux Calibre] - Read ebook in epub format ====
== [http://calibre-ebook.com/download_linux Calibre] - Read ebook in epub format ==
See [[Calibre|Calibre]]
See [[Calibre|Calibre]]


=== RSS reader ===
= RSS reader =
Some references:
Some references:
# [https://itsfoss.com/feed-reader-apps-linux/ 5 Best Feed Reader Apps for Linux]
# [https://itsfoss.com/feed-reader-apps-linux/ 5 Best Feed Reader Apps for Linux]
Line 3,566: Line 3,565:
* Firefox and Thunderbird have built-in support for RSS.
* Firefox and Thunderbird have built-in support for RSS.


=== Display/screen ===
= Display/screen =
==== Turn off/on your monitor via command line ====
== Turn off/on your monitor via command line ==
* https://systembash.com/how-to-turn-off-your-monitor-via-command-line-in-ubuntu/
* https://systembash.com/how-to-turn-off-your-monitor-via-command-line-in-ubuntu/
* http://askubuntu.com/questions/62858/turn-off-monitor-using-command-line
* http://askubuntu.com/questions/62858/turn-off-monitor-using-command-line
Line 3,586: Line 3,585:
</syntaxhighlight>
</syntaxhighlight>


==== autoxrandr ====
== autoxrandr ==
Plug your laptop into different monitor setups. https://www.donarmstrong.com/posts/autorandr/
Plug your laptop into different monitor setups. https://www.donarmstrong.com/posts/autorandr/


==== Add new screen/display resolutions ====
== Add new screen/display resolutions ==
* http://ubuntuforums.org/showthread.php?t=1112186 (tested on UDOObuntu 2 beta 2running Ubuntu 14.04 + SainSmart 9" LCD display. The commands (not persistent) are
* http://ubuntuforums.org/showthread.php?t=1112186 (tested on UDOObuntu 2 beta 2running Ubuntu 14.04 + SainSmart 9" LCD display. The commands (not persistent) are
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,601: Line 3,600:
I cannot find the file /etc/X11/xorg.conf in my UDOObuntu 2 beta 2. It seems this file does not exist anymore. See [http://askubuntu.com/questions/4662/where-is-the-x-org-config-file-how-do-i-configure-x-there this post] about how to re-create it.
I cannot find the file /etc/X11/xorg.conf in my UDOObuntu 2 beta 2. It seems this file does not exist anymore. See [http://askubuntu.com/questions/4662/where-is-the-x-org-config-file-how-do-i-configure-x-there this post] about how to re-create it.


==== Wayland ====
== Wayland ==
* [https://liliputing.com/2018/08/linux-on-the-gpd-pocket-2-ubuntu-debian-and-fedora.html Linux on the GPD Pocket 2 (Ubuntu, Debian, and Fedora)]
* [https://liliputing.com/2018/08/linux-on-the-gpd-pocket-2-ubuntu-debian-and-fedora.html Linux on the GPD Pocket 2 (Ubuntu, Debian, and Fedora)]
** “xrandr -o right” command can be used to rotate the screen
** “xrandr -o right” command can be used to rotate the screen
** But it does not work in Fedora because Fedora uses the Wayland display server rather than xserver.
** But it does not work in Fedora because Fedora uses the Wayland display server rather than xserver.


==== export DISPLAY ====
== export DISPLAY ==
If we want to run a GUI app on a remote computer (such as Raspberry Pi/Beaglebone Black) and show the GUI app on the remote computer's screen using ssh, we can issue the following command before running the app.
If we want to run a GUI app on a remote computer (such as Raspberry Pi/Beaglebone Black) and show the GUI app on the remote computer's screen using ssh, we can issue the following command before running the app.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,612: Line 3,611:
</syntaxhighlight>
</syntaxhighlight>


=== LVM Demystified ===
= LVM Demystified =
http://www.linuxjournal.com/content/lvm-demystified
http://www.linuxjournal.com/content/lvm-demystified


=== See which groups you belong to, id & group commands ===
= See which groups you belong to, id & group commands =
* [https://www.2daygeek.com/how-to-check-which-groups-a-user-belongs-to-on-linux/ How To Check Which Groups A User Belongs To On Linux]
* [https://www.2daygeek.com/how-to-check-which-groups-a-user-belongs-to-on-linux/ How To Check Which Groups A User Belongs To On Linux]
<pre>
<pre>
Line 3,622: Line 3,621:
</pre>
</pre>


=== groupadd, chgrp, usermod, ACL (access control lists) ===
= groupadd, chgrp, usermod, ACL (access control lists) =
* [http://www.tecmint.com/create-a-shared-directory-in-linux/ Create a Shared Directory for All Users in Linux]
* [http://www.tecmint.com/create-a-shared-directory-in-linux/ Create a Shared Directory for All Users in Linux]
* [https://www.tecmint.com/give-read-write-access-to-directory-in-linux/ Assign Read/Write Access to a User on Specific Directory in Linux]
* [https://www.tecmint.com/give-read-write-access-to-directory-in-linux/ Assign Read/Write Access to a User on Specific Directory in Linux]
Line 3,647: Line 3,646:
</syntaxhighlight>
</syntaxhighlight>


=== Shared library management ===
= Shared library management =
http://www.cyberciti.biz/tips/linux-shared-library-management.html
http://www.cyberciti.biz/tips/linux-shared-library-management.html


Line 3,655: Line 3,654:
# ld.so/ld-linux.so: Dynamic linker/loader.
# ld.so/ld-linux.so: Dynamic linker/loader.


=== Install binary software using sudo ===
= Install binary software using sudo =
One example ([http://calibre-ebook.com/download_linux Calibre]) is like  
One example ([http://calibre-ebook.com/download_linux Calibre]) is like  
<pre>
<pre>
Line 3,676: Line 3,675:
</pre>
</pre>


=== Log files ===
= Log files =
[https://www.digitalocean.com/community/articles/how-to-view-and-configure-linux-logs-on-ubuntu-and-centos DigitalOcean]
[https://www.digitalocean.com/community/articles/how-to-view-and-configure-linux-logs-on-ubuntu-and-centos DigitalOcean]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,682: Line 3,681:
</syntaxhighlight>
</syntaxhighlight>


==== ssh log files: '''/var/log/auth.log''' ====
== ssh log files: '''/var/log/auth.log''' ==
* /var/log/syslog
* /var/log/syslog
* /var/log/auth.log: it includes ssh log in information and lots of CRON sessions opened and closed ''every minutes''.
* /var/log/auth.log: it includes ssh log in information and lots of CRON sessions opened and closed ''every minutes''.
Line 3,691: Line 3,690:
* [https://www.linuxquestions.org/questions/linux-security-4/what-the-%24-%40-is-pam_unix-cron-session-doing-every-ten-minutes-var-log-auth-log-702381/ What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log)]
* [https://www.linuxquestions.org/questions/linux-security-4/what-the-%24-%40-is-pam_unix-cron-session-doing-every-ten-minutes-var-log-auth-log-702381/ What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log)]


==== Apache log ====
== Apache log ==
* /var/log/apache2/error.log (small 83K). Useful to troubleshoot errors/crashes of Apache.
* /var/log/apache2/error.log (small 83K). Useful to troubleshoot errors/crashes of Apache.
<pre>
<pre>
Line 3,698: Line 3,697:
* /var/log/apache2/access.log (large 10M)
* /var/log/apache2/access.log (large 10M)


==== mail ====
== mail ==
/var/log/maillog
/var/log/maillog


=== '''uptime''' command ===
= '''uptime''' command =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
uptime
uptime
Line 3,707: Line 3,706:
</syntaxhighlight>
</syntaxhighlight>


=== '''timeout''' command ===
= '''timeout''' command =
* https://www.howtoforge.com/linux-timeout-command/
* https://www.howtoforge.com/linux-timeout-command/
* https://www.howtogeek.com/423286/how-to-use-the-timeout-command-on-linux/
* https://www.howtogeek.com/423286/how-to-use-the-timeout-command-on-linux/


=== Linux command similar to ''top'' to show hard disk activity ===
= Linux command similar to ''top'' to show hard disk activity =
Use '''iotop'''. On ubuntu, we can use sudo apt-get install to install it. Use '''sudo iotop''' to launch it.
Use '''iotop'''. On ubuntu, we can use sudo apt-get install to install it. Use '''sudo iotop''' to launch it.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,726: Line 3,725:
[http://www.thegeekstuff.com/2011/07/iostat-vmstat-mpstat-examples/ 24 iostat, vmstat and mpstat Examples for Linux Performance Monitoring]
[http://www.thegeekstuff.com/2011/07/iostat-vmstat-mpstat-examples/ 24 iostat, vmstat and mpstat Examples for Linux Performance Monitoring]


=== Install [http://hbase.apache.org/ Apache HBase] ===
= Install [http://hbase.apache.org/ Apache HBase] =
Follow the [http://hbase.apache.org/book/quickstart.html Quick Start] to downloaded hbase tar ball. Suppose we save the tar ball under ~/Downloads folder and extract it in the same directory. We shall edit '''conf/hbase-site.xml''' file according to their instruction. The following is my case.
Follow the [http://hbase.apache.org/book/quickstart.html Quick Start] to downloaded hbase tar ball. Suppose we save the tar ball under ~/Downloads folder and extract it in the same directory. We shall edit '''conf/hbase-site.xml''' file according to their instruction. The following is my case.
<pre>
<pre>
Line 3,828: Line 3,827:
</pre>
</pre>


=== Files downloaded from a browser and wget ===
= Files downloaded from a browser and wget =
Same file downloaded through a browser and the wget command has a different file size and behavior.
Same file downloaded through a browser and the wget command has a different file size and behavior.


Line 3,848: Line 3,847:
</syntaxhighlight>
</syntaxhighlight>


=== [http://daniel.haxx.se/docs/curl-vs-wget.html curl vs wget] ===
= [http://daniel.haxx.se/docs/curl-vs-wget.html curl vs wget] =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo apt-get install curl
sudo apt-get install curl
Line 3,925: Line 3,924:
</pre>
</pre>


==== curl man page, supported protocols ====
== curl man page, supported protocols ==
https://curl.haxx.se/docs/manpage.html
https://curl.haxx.se/docs/manpage.html


==== wget overwrites the existing file ====
== wget overwrites the existing file ==
Use the '''-N''' or --timestamping option to turn on time-stamping. Don't re-retrieve files unless newer than local.
Use the '''-N''' or --timestamping option to turn on time-stamping. Don't re-retrieve files unless newer than local.


==== wget and username/password ====
== wget and username/password ==
http://www.cyberciti.biz/faq/wget-command-with-username-password/
http://www.cyberciti.biz/faq/wget-command-with-username-password/


====  Download and Un-tar(Extract) in One Step ====
==  Download and Un-tar(Extract) in One Step ==
If we don't want to avoid saving a temporary file, we can use one piped statement.  
If we don't want to avoid saving a temporary file, we can use one piped statement.  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,948: Line 3,947:
The "-c" in gunzip is to have [https://stackoverflow.com/questions/16262980/redirect-pipe-wget-download-directly-into-gunzip?answertab=active#tab-top gzip output to the console]. PS. it seems not necessary to use the "-c" option.
The "-c" in gunzip is to have [https://stackoverflow.com/questions/16262980/redirect-pipe-wget-download-directly-into-gunzip?answertab=active#tab-top gzip output to the console]. PS. it seems not necessary to use the "-c" option.


==== Download and execute the script in one step ====
== Download and execute the script in one step ==
See [http://stackoverflow.com/questions/5735666/execute-bash-script-from-url Execute bash script from URL].
See [http://stackoverflow.com/questions/5735666/execute-bash-script-from-url Execute bash script from URL].
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,958: Line 3,957:
</syntaxhighlight>
</syntaxhighlight>


==== curl and POST request ====
== curl and POST request ==
* http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
* http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
* https://learn.adafruit.com/raspberry-pi-physical-dashboard?view=all (the original post I saw)
* https://learn.adafruit.com/raspberry-pi-physical-dashboard?view=all (the original post I saw)
* http://conqueringthecommandline.com/book/curl
* http://conqueringthecommandline.com/book/curl


==== curl and proxy ====
== curl and proxy ==
[https://www.cyberciti.biz/faq/linux-unix-curl-command-with-proxy-username-password-http-options/ How to use curl command with proxy username/password on Linux/ Unix]
[https://www.cyberciti.biz/faq/linux-unix-curl-command-with-proxy-username-password-http-options/ How to use curl command with proxy username/password on Linux/ Unix]


==== Website performance ====
== Website performance ==
[http://www.tecmint.com/httpstat-curl-statistics-tool-check-website-performance/ httpstat – A Curl Statistics Tool to Check Website Performance]
[http://www.tecmint.com/httpstat-curl-statistics-tool-check-website-performance/ httpstat – A Curl Statistics Tool to Check Website Performance]


==== wget/curl a file with correct name when redirected ====
== wget/curl a file with correct name when redirected ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
wget --trust-server-names <url>  
wget --trust-server-names <url>  
Line 3,978: Line 3,977:
</syntaxhighlight>
</syntaxhighlight>


==== wget to download a folder ====
== wget to download a folder ==
https://stackoverflow.com/questions/8755229/how-to-download-all-files-but-not-html-from-a-website-using-wget
https://stackoverflow.com/questions/8755229/how-to-download-all-files-but-not-html-from-a-website-using-wget
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 3,984: Line 3,983:
</syntaxhighlight>
</syntaxhighlight>


==== wget to download a website ====
== wget to download a website ==
* http://linux.about.com/od/commands/a/Example-Uses-Of-The-Command-Wget.htm
* http://linux.about.com/od/commands/a/Example-Uses-Of-The-Command-Wget.htm
* https://www.gnu.org/software/wget/manual/wget.html
* https://www.gnu.org/software/wget/manual/wget.html
Line 3,996: Line 3,995:
</syntaxhighlight>
</syntaxhighlight>


=== Torrent ===
= Torrent =
==== [https://github.com/kryptxy/torrench Torrench] ====
== [https://github.com/kryptxy/torrench Torrench] ==
[https://fossbytes.com/review-torrench-download-torrents-using-terminal-linux/ Torrench: How To Search And Download Torrent Files Using Terminal (Linux, Mac, Windows)]
[https://fossbytes.com/review-torrench-download-torrents-using-terminal-linux/ Torrench: How To Search And Download Torrent Files Using Terminal (Linux, Mac, Windows)]


==== aria2 - command line downloader supports torrents and multi-connection ====
== aria2 - command line downloader supports torrents and multi-connection ==
[http://www.2daygeek.com/aria2-command-line-download-utility-tool/ aria2 command examples]
[http://www.2daygeek.com/aria2-command-line-download-utility-tool/ aria2 command examples]


Line 4,010: Line 4,009:
</pre>
</pre>


=== Axel ===
= Axel =
It can create an unlimited number of worker threads to download any kind of data.  
It can create an unlimited number of worker threads to download any kind of data.  
See https://www.beginnersheap.com/top-5-command-line-download-accelerators-linux/
See https://www.beginnersheap.com/top-5-command-line-download-accelerators-linux/


=== [http://lftp.yar.ru/ lftp] ===
= [http://lftp.yar.ru/ lftp] =
* [http://www.linuxquestions.org/questions/linux-software-2/command-line-ftp-client-94510/ It supports FXP (site-to-site transfers) and dropping to background]
* [http://www.linuxquestions.org/questions/linux-software-2/command-line-ftp-client-94510/ It supports FXP (site-to-site transfers) and dropping to background]
* [https://www.cyberciti.biz/tips/linux-unix-download-accelerator.html How to use lftp to accelerate ftp/https download speed on Linux/UNIX]. It can launch several commands in parallel in the background.
* [https://www.cyberciti.biz/tips/linux-unix-download-accelerator.html How to use lftp to accelerate ftp/https download speed on Linux/UNIX]. It can launch several commands in parallel in the background.


=== Apply a patch to source code ===
= Apply a patch to source code =
* http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/.  
* http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/.  
* http://www.thegeekstuff.com/2014/12/patch-command-examples/
* http://www.thegeekstuff.com/2014/12/patch-command-examples/
Line 4,040: Line 4,039:
</syntaxhighlight>
</syntaxhighlight>


=== IP address fundamental ===
= IP address fundamental =
http://www.howtogeek.com/133943/geek-school-learning-windows-7-ip-addressing-fundamentals/.  
http://www.howtogeek.com/133943/geek-school-learning-windows-7-ip-addressing-fundamentals/.  


Line 4,050: Line 4,049:
[[#Subnet|Subnet]]
[[#Subnet|Subnet]]


=== Get internal IP address ===
= Get internal IP address =
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ hostname -I
$ hostname -I
Line 4,056: Line 4,055:
* https://www.raspberrypi.org/documentation/remote-access/ip-address.md
* https://www.raspberrypi.org/documentation/remote-access/ip-address.md


=== Get external IP address ===
= Get external IP address =
[https://opensource.com/article/18/5/how-find-ip-address-linux How to find your IP address in Linux]
[https://opensource.com/article/18/5/how-find-ip-address-linux How to find your IP address in Linux]


Line 4,097: Line 4,096:
</syntaxhighlight>
</syntaxhighlight>


==== IP geolocation ====
== IP geolocation ==
Test url: ubuntu.mirrors.pair.com
Test url: ubuntu.mirrors.pair.com
* https://www.ipligence.com/geolocation
* https://www.ipligence.com/geolocation
Line 4,107: Line 4,106:
* [https://www.makeuseof.com/tag/ip-geolocation-api-tool/ The Free IP Geolocation API Is a Valuable Webmaster Tool]
* [https://www.makeuseof.com/tag/ip-geolocation-api-tool/ The Free IP Geolocation API Is a Valuable Webmaster Tool]


=== Domain ===
= Domain =
* [https://www.whois.net/ WHOIS LOOKUP]. For example, consider "r-pkg.org" domain,  
* [https://www.whois.net/ WHOIS LOOKUP]. For example, consider "r-pkg.org" domain,  
** The 'Sponsoring Registrar' shows who is the sponsoring registrar (eg GoDaddy.com).
** The 'Sponsoring Registrar' shows who is the sponsoring registrar (eg GoDaddy.com).
Line 4,122: Line 4,121:
* [http://www.whoishostingthis.com/ WhoIsHostingThis] or [https://www.webhostinghero.com/who-is-hosting/ webhostinghero] (the returned result will be like Amazon, GoDaddy, CloudFlare, Github, Verizon, etc).
* [http://www.whoishostingthis.com/ WhoIsHostingThis] or [https://www.webhostinghero.com/who-is-hosting/ webhostinghero] (the returned result will be like Amazon, GoDaddy, CloudFlare, Github, Verizon, etc).


=== Subnet ===
= Subnet =
[http://en.wikipedia.org/wiki/IPv4_subnetting_reference IPv4]
[http://en.wikipedia.org/wiki/IPv4_subnetting_reference IPv4]


Line 4,137: Line 4,136:
* [https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 Testing IPv6 Networking in KVM: Part 1]
* [https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 Testing IPv6 Networking in KVM: Part 1]


=== ping command ===
= ping command =
ping uses the '''ICMP''' Echo Message to force a remote host to echo a packet back to the local host. If packets can travel to and from a remote host, it indicates that the two hosts can successfully communicate.
ping uses the '''ICMP''' Echo Message to force a remote host to echo a packet back to the local host. If packets can travel to and from a remote host, it indicates that the two hosts can successfully communicate.


=== Build a home network ===
= Build a home network =
* [https://www.youtube.com/watch?v=dhLKwzVIRzI&index=1&list=PL1l78n6W8zyr-wZWJzRppQUjz6gc_EWzt Virtual router] using vSphere. (Good ! It includes an introduction to vSphere installation)
* [https://www.youtube.com/watch?v=dhLKwzVIRzI&index=1&list=PL1l78n6W8zyr-wZWJzRppQUjz6gc_EWzt Virtual router] using vSphere. (Good ! It includes an introduction to vSphere installation)
* http://rbgeek.wordpress.com/2012/05/14/ubuntu-as-a-firewallgateway-router/
* http://rbgeek.wordpress.com/2012/05/14/ubuntu-as-a-firewallgateway-router/


==== IP Subnet Calculator ====
== IP Subnet Calculator ==
https://www.dan.me.uk/ipsubnets?ip=10.0.0.0
https://www.dan.me.uk/ipsubnets?ip=10.0.0.0


Line 4,152: Line 4,151:
* 10.0.0.0/8    10.0.0.0 - 10.255.255.255    255.0.0.0  16777216=256^3
* 10.0.0.0/8    10.0.0.0 - 10.255.255.255    255.0.0.0  16777216=256^3


=== How Use Your Router and ISP’s Modem/Router Combo In Tandem ===
= How Use Your Router and ISP’s Modem/Router Combo In Tandem =
http://www.howtogeek.com/255206/how-use-your-router-and-isps-modemrouter-combo-in-tandem/
http://www.howtogeek.com/255206/how-use-your-router-and-isps-modemrouter-combo-in-tandem/


=== Troubleshoot and repair network problems ===
= Troubleshoot and repair network problems =
http://www.linuxuser.co.uk/features/troubleshot-repair-linux-networks
http://www.linuxuser.co.uk/features/troubleshot-repair-linux-networks


==== Computer 1 can ping Computer 2 but not reverse ====
== Computer 1 can ping Computer 2 but not reverse ==
Use the [[#route|route]] command to solve. See also [http://serverfault.com/questions/391954/linux-router-ping-doesnt-route-back this post].
Use the [[#route|route]] command to solve. See also [http://serverfault.com/questions/391954/linux-router-ping-doesnt-route-back this post].


=== Simple Network Management Protocol (snmp) ===
= Simple Network Management Protocol (snmp) =
* https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
* https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
* Default port number is 161
* Default port number is 161
Line 4,169: Line 4,168:
* [https://routersecurity.org/testrouter.php DDoS attack]
* [https://routersecurity.org/testrouter.php DDoS attack]


=== Monitor network by Cacti (GUI) ===
= Monitor network by Cacti (GUI) =
* http://www.ubuntugeek.com/install-cacti-monitoring-tool-on-ubuntu-15-10-server.html
* http://www.ubuntugeek.com/install-cacti-monitoring-tool-on-ubuntu-15-10-server.html
* http://www.cacti.net/
* http://www.cacti.net/


=== Monitor network by command line ===
= Monitor network by command line =
[https://www.linux.com/learn/intro-to-linux/2017/10/3-simple-excellent-linux-network-monitors 3 Simple, Excellent Linux Network Monitors]: iftop, nethogs and vnstat.
[https://www.linux.com/learn/intro-to-linux/2017/10/3-simple-excellent-linux-network-monitors 3 Simple, Excellent Linux Network Monitors]: iftop, nethogs and vnstat.


==== iftop ====
== iftop ==
Use the interface top '''[http://www.ex-parrot.com/pdw/iftop/ iftop]''' command. On ubuntu, we need to use '''sudo apt-get install iftop''' and then run it by '''sudo iftop -i eth0'''.
Use the interface top '''[http://www.ex-parrot.com/pdw/iftop/ iftop]''' command. On ubuntu, we need to use '''sudo apt-get install iftop''' and then run it by '''sudo iftop -i eth0'''.
After that, we can press some keys to toggle options.
After that, we can press some keys to toggle options.
Line 4,193: Line 4,192:
</pre>
</pre>


==== nethogs ====
== nethogs ==
<pre>
<pre>
$ sudo nethogs wlan0
$ sudo nethogs wlan0
</pre>
</pre>


==== nload ====
== nload ==
<pre>
<pre>
nload -m
nload -m
Line 4,207: Line 4,206:
The result is the same as [[#gtop_command|gtop]] (gtop is cooler) gives.
The result is the same as [[#gtop_command|gtop]] (gtop is cooler) gives.


==== bmon ====
== bmon ==
https://www.tecmint.com/bmon-network-bandwidth-monitoring-debugging-linux/
https://www.tecmint.com/bmon-network-bandwidth-monitoring-debugging-linux/


==== [http://humdi.net/vnstat/ vnstat] ====
== [http://humdi.net/vnstat/ vnstat] ==
http://www.thegeekstuff.com/2011/11/vnstat-network-traffic-monitor/
http://www.thegeekstuff.com/2011/11/vnstat-network-traffic-monitor/


Line 4,244: Line 4,243:
</syntaxhighlight>
</syntaxhighlight>


=== Network related linux commands ===
= Network related linux commands =


==== nmcli and nmtui (useful for getting DNS IPs) ====
== nmcli and nmtui (useful for getting DNS IPs) ==
* [https://www.cyberciti.biz/faq/how-to-add-network-bridge-with-nmcli-networkmanager-on-linux/ How to add network bridge with nmcli (NetworkManager) on Linux]
* [https://www.cyberciti.biz/faq/how-to-add-network-bridge-with-nmcli-networkmanager-on-linux/ How to add network bridge with nmcli (NetworkManager) on Linux]
* [https://www.tecmint.com/configure-network-connections-using-nmcli-tool-in-linux/ How to Configure and Manage Network Connections Using ‘nmcli’ Tool]
* [https://www.tecmint.com/configure-network-connections-using-nmcli-tool-in-linux/ How to Configure and Manage Network Connections Using ‘nmcli’ Tool]
Line 4,262: Line 4,261:
</syntaxhighlight>
</syntaxhighlight>


==== ifconfig - spoof the hardware address at the software level ====
== ifconfig - spoof the hardware address at the software level ==
To change the MAC address temporarily on a '''NIC''' (network interface controller),
To change the MAC address temporarily on a '''NIC''' (network interface controller),
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,283: Line 4,282:
* [https://serverfault.com/questions/106647/what-does-ifconfig-promisc-mode-do-or-promiscuous-mode-in-general What does ifconfig promisc mode do, or promiscuous mode in general?]
* [https://serverfault.com/questions/106647/what-does-ifconfig-promisc-mode-do-or-promiscuous-mode-in-general What does ifconfig promisc mode do, or promiscuous mode in general?]


==== ip command ====
== ip command ==
It is said [http://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/ '''ip''' is replacing the old '''ifconfig''' command on modern Linux distributions].
It is said [http://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/ '''ip''' is replacing the old '''ifconfig''' command on modern Linux distributions].


Line 4,297: Line 4,296:
</syntaxhighlight>
</syntaxhighlight>


==== iptables ====
== iptables ==
* See the [[#ufw_.28uncomplicated_firewall.29|ufw]] command which provides an easy way to configure iptables.
* See the [[#ufw_.28uncomplicated_firewall.29|ufw]] command which provides an easy way to configure iptables.
* [https://kerneltalks.com/howto/how-to-disable-iptables-firewall-temporarily/ How to disable iptables firewall temporarily]
* [https://kerneltalks.com/howto/how-to-disable-iptables-firewall-temporarily/ How to disable iptables firewall temporarily]


==== route ====
== route ==
[http://www.thegeekstuff.com/2012/04/route-examples/ 7 Linux Route Command Examples]
[http://www.thegeekstuff.com/2012/04/route-examples/ 7 Linux Route Command Examples]


Line 4,329: Line 4,328:
Flag value 'U' means ''up'' and 'G' means ''gateway'.
Flag value 'U' means ''up'' and 'G' means ''gateway'.


==== Connect two networks ====
== Connect two networks ==
The trick is explained in [http://unix.stackexchange.com/questions/68418/how-to-add-two-gateway-on-same-machine this post] or the above '''route''' command.
The trick is explained in [http://unix.stackexchange.com/questions/68418/how-to-add-two-gateway-on-same-machine this post] or the above '''route''' command.


Line 4,356: Line 4,355:
[https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 One article] from linux.com using the '''ip''' command.
[https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 One article] from linux.com using the '''ip''' command.


==== traceroute ====
== traceroute ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo apt-get install traceroute
sudo apt-get install traceroute
Line 4,364: Line 4,363:
On Windows, we can use the '''tracert''' command. For example, '''tracert www.microsoft.com'''.
On Windows, we can use the '''tracert''' command. For example, '''tracert www.microsoft.com'''.


==== netstat: get a list of all open port ====
== netstat: get a list of all open port ==
[https://www.ghacks.net/2018/03/21/how-to-use-netstat-in-gnu-linux/ How to use netstat in GNU/Linux]
[https://www.ghacks.net/2018/03/21/how-to-use-netstat-in-gnu-linux/ How to use netstat in GNU/Linux]


Line 4,394: Line 4,393:
</syntaxhighlight>
</syntaxhighlight>


==== nmap - port scanning & IPs in local network ====
== nmap - port scanning & IPs in local network ==
nmap - Network exploration tool and security / port scanner
nmap - Network exploration tool and security / port scanner
* https://nmap.org/book/nmap-os-db.html. Local OS database is located at '''/usr/share/nmap/nmap-os-db'''. The 2nd line will show the revision number.  
* https://nmap.org/book/nmap-os-db.html. Local OS database is located at '''/usr/share/nmap/nmap-os-db'''. The 2nd line will show the revision number.  
Line 4,458: Line 4,457:
[https://phoenixnap.com/kb/nmap-scan-open-ports A List of Common Ports]
[https://phoenixnap.com/kb/nmap-scan-open-ports A List of Common Ports]


==== nslookup and host ====
== nslookup and host ==
* https://en.wikipedia.org/wiki/Nslookup
* https://en.wikipedia.org/wiki/Nslookup
* https://en.wikipedia.org/wiki/Host_(Unix)
* https://en.wikipedia.org/wiki/Host_(Unix)
Line 4,483: Line 4,482:
The first two lines show the IP address of my DNS. If we run the command inside a Docker container where DNS was specified manually, the IP address we specified will be shown here.
The first two lines show the IP address of my DNS. If we run the command inside a Docker container where DNS was specified manually, the IP address we specified will be shown here.


==== dig ====
== dig ==
[https://toolbox.googleapps.com/apps/dig/ Dig] provided by Google G Suite Toolbox. If the office internet is interrupted, we can use a cell phone to search for the IP address of a website for trouble shooting. Other providers include [http://www.kloth.net/services/dig.php kloth.net].
[https://toolbox.googleapps.com/apps/dig/ Dig] provided by Google G Suite Toolbox. If the office internet is interrupted, we can use a cell phone to search for the IP address of a website for trouble shooting. Other providers include [http://www.kloth.net/services/dig.php kloth.net].


Line 4,508: Line 4,507:
</syntaxhighlight>
</syntaxhighlight>


==== arp (Address Resolution Protocol) ====
== arp (Address Resolution Protocol) ==
The '''arp ''' command can be used to show the MAC addresss of all hosts in LAN
The '''arp ''' command can be used to show the MAC addresss of all hosts in LAN
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,514: Line 4,513:
</syntaxhighlight>
</syntaxhighlight>


=== Copy text to a clipboard to be used in other apps ===
= Copy text to a clipboard to be used in other apps =
Install the '''xclip''' program. See [http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/ here] or [http://stackoverflow.com/questions/5130968/how-can-i-copy-the-output-of-a-command-directly-into-my-clipboard here].  
Install the '''xclip''' program. See [http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/ here] or [http://stackoverflow.com/questions/5130968/how-can-i-copy-the-output-of-a-command-directly-into-my-clipboard here].  
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,525: Line 4,524:
Works.
Works.


=== Start Emacs without X ===
= Start Emacs without X =
Add '''-nw''' (no window) option.
Add '''-nw''' (no window) option.
<pre>
<pre>
Line 4,531: Line 4,530:
</pre>
</pre>


=== Audio ===
= Audio =
==== Record audio from mic ====
== Record audio from mic ==
[https://lifehacker.com/how-to-save-important-voicemails-for-both-iphone-and-an-1833241417 How to Save Important Voicemails for Both iPhone and Android]. Hint: use Audacity.
[https://lifehacker.com/how-to-save-important-voicemails-for-both-iphone-and-an-1833241417 How to Save Important Voicemails for Both iPhone and Android]. Hint: use Audacity.


==== mp3 codecs ====
== mp3 codecs ==
https://help.ubuntu.com/community/RestrictedFormats
https://help.ubuntu.com/community/RestrictedFormats
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,541: Line 4,540:
</syntaxhighlight>
</syntaxhighlight>


==== Concatenate mp3 files ====
== Concatenate mp3 files ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo apt-get install mp3wrap
sudo apt-get install mp3wrap
Line 4,547: Line 4,546:
</syntaxhighlight>
</syntaxhighlight>


==== Reduce the size of an mp3 file ====
== Reduce the size of an mp3 file ==
Specify a new lower bitrate using the -b option in '''lame'''. For example if your starting mp3 has a quality of 256kbs you can lower its bitrate to 128kbps (or even lower like 64kbps) by:
Specify a new lower bitrate using the -b option in '''lame'''. For example if your starting mp3 has a quality of 256kbs you can lower its bitrate to 128kbps (or even lower like 64kbps) by:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,553: Line 4,552:
</syntaxhighlight>
</syntaxhighlight>


==== Convert ogg to mp3 ====
== Convert ogg to mp3 ==
'''ffmpeg''' is not included in Ubuntu repository. Use the '''avconv''' command. http://superuser.com/questions/15327/how-to-convert-ogg-to-mp3
'''ffmpeg''' is not included in Ubuntu repository. Use the '''avconv''' command. http://superuser.com/questions/15327/how-to-convert-ogg-to-mp3
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,560: Line 4,559:
</syntaxhighlight>
</syntaxhighlight>


==== Convert m4a to mp3 ====
== Convert m4a to mp3 ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
avconv -i input.m4a output.mp3
avconv -i input.m4a output.mp3
</syntaxhighlight>
</syntaxhighlight>


==== Remove the vocals from any song using Audacity ====
== Remove the vocals from any song using Audacity ==
https://www.makeuseof.com/tag/remove-vocals-song-audacity/
https://www.makeuseof.com/tag/remove-vocals-song-audacity/


==== Normalize the volume of an audio file ====
== Normalize the volume of an audio file ==
* [http://www.howtogeek.com/280739/can-you-losslessly-increase-the-volume-of-mp3-files/ Can You Losslessly Increase the Volume of MP3 Files?]
* [http://www.howtogeek.com/280739/can-you-losslessly-increase-the-volume-of-mp3-files/ Can You Losslessly Increase the Volume of MP3 Files?]
* Use [http://www.thebest3d.com/audacity/tutorials/make-louder/audacity-tutorial-make-louder-more-volume-increased-amplitude.html Audacity]. To raise (Amplify) volume:  
* Use [http://www.thebest3d.com/audacity/tutorials/make-louder/audacity-tutorial-make-louder-more-volume-increased-amplitude.html Audacity]. To raise (Amplify) volume:  
Line 4,593: Line 4,592:
where '--norm' will normalize the audio and the 'trim' option set to skip the first 10 seconds. The silence parameter allows to trim silence at the beginning without a need to specify the number of seconds.
where '--norm' will normalize the audio and the 'trim' option set to skip the first 10 seconds. The silence parameter allows to trim silence at the beginning without a need to specify the number of seconds.


==== cut, delete or trim an audio ====
== cut, delete or trim an audio ==
# Open the audio file in audacity.
# Open the audio file in audacity.
# select a region in the '''waveform''' area. Do not select in the time interval area (above the waveform).  
# select a region in the '''waveform''' area. Do not select in the time interval area (above the waveform).  
Line 4,607: Line 4,606:
# [http://manual.audacityteam.org/o/man/tutorial_editing_an_existing_file.html Tutorial - Editing an Existing Audio File]
# [http://manual.audacityteam.org/o/man/tutorial_editing_an_existing_file.html Tutorial - Editing an Existing Audio File]


==== Fade out at the end of an audio ====
== Fade out at the end of an audio ==
# Select a region.
# Select a region.
# Effect -> Fade out
# Effect -> Fade out


=== Wireshark ===
= Wireshark =
* http://www.howtogeek.com/204458/why-you-shouldn%E2%80%99t-use-mac-address-filtering-on-your-wi-fi-router/
* http://www.howtogeek.com/204458/why-you-shouldn%E2%80%99t-use-mac-address-filtering-on-your-wi-fi-router/
* http://www.howtogeek.com/191482/how-an-attacker-could-crack-your-wireless-network-security/
* http://www.howtogeek.com/191482/how-an-attacker-could-crack-your-wireless-network-security/
Line 4,620: Line 4,619:
</pre>
</pre>


=== Track the Time a Command Takes ===
= Track the Time a Command Takes =
[https://www.ostechnix.com/how-to-find-the-execution-time-of-a-command-or-process-in-linux/ How To Find The Execution Time Of A Command Or Process In Linux]
[https://www.ostechnix.com/how-to-find-the-execution-time-of-a-command-or-process-in-linux/ How To Find The Execution Time Of A Command Or Process In Linux]


==== time command ====
== time command ==
* [https://stackoverflow.com/a/556411 What do 'real', 'user' and 'sys' mean in the output of time(1)?]
* [https://stackoverflow.com/a/556411 What do 'real', 'user' and 'sys' mean in the output of time(1)?]
* [https://www.howtoforge.com/linux-time-command/ Linux time Command Tutorial for Beginners (with Examples)]
* [https://www.howtoforge.com/linux-time-command/ Linux time Command Tutorial for Beginners (with Examples)]
Line 4,642: Line 4,641:
Here we see the real time is about 16m and the user time is about 6-7 times the real time. Indicating the parallel executing works.
Here we see the real time is about 16m and the user time is about 6-7 times the real time. Indicating the parallel executing works.


==== /usr/bin/time command ====
== /usr/bin/time command ==
'''[http://man7.org/linux/man-pages/man1/time.1.html /usr/bin/time]''' provides more information then ''time'' command.
'''[http://man7.org/linux/man-pages/man1/time.1.html /usr/bin/time]''' provides more information then ''time'' command.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 4,648: Line 4,647:
</syntaxhighlight>
</syntaxhighlight>


=== Magazines ===
= Magazines =
* [http://www.linuxuser.co.uk/ Linux User & Developer]
* [http://www.linuxuser.co.uk/ Linux User & Developer]
* [http://www.linuxformat.com/ Linux Format]
* [http://www.linuxformat.com/ Linux Format]
Line 4,654: Line 4,653:
* [http://www.linuxjournal.com/ Linux Journal]
* [http://www.linuxjournal.com/ Linux Journal]


=== Latex ===
= Latex =


==== Editors ====
== Editors ==
* [https://itsfoss.com/Latex-editors-linux/ 10 Best LaTeX Editors For Linux].  
* [https://itsfoss.com/Latex-editors-linux/ 10 Best LaTeX Editors For Linux].  
* [http://www.xm1math.net/texmaker/ Texmaker]. R's installr package has a function to install Texmaker. Cross platforms.
* [http://www.xm1math.net/texmaker/ Texmaker]. R's installr package has a function to install Texmaker. Cross platforms.
Line 4,662: Line 4,661:
* [http://texstudio.sourceforge.net/ TexStudio]. See a dark theme [https://robjhyndman.com/hyndsight/dark-themes-for-writing/ example].
* [http://texstudio.sourceforge.net/ TexStudio]. See a dark theme [https://robjhyndman.com/hyndsight/dark-themes-for-writing/ example].


==== Online editing ====
== Online editing ==
* [https://latexbase.com/ Latex Base]. You can start to try it without registration. Free accounts cannot publish but still can download.
* [https://latexbase.com/ Latex Base]. You can start to try it without registration. Free accounts cannot publish but still can download.
* [https://www.overleaf.com/ Overleaf]. Free account for 1GB space.
* [https://www.overleaf.com/ Overleaf]. Free account for 1GB space.
* [https://www.sharelatex.com/ ShareLatex]
* [https://www.sharelatex.com/ ShareLatex]


==== Missing cls ====
== Missing cls ==
* [http://packages.ubuntu.com/trusty/all/texlive-latex-extra/filelist texlive-latex-extra] packages and [http://packages.ubuntu.com/trusty/all/texlive-publishers/filelist texlive-publishers] packages.
* [http://packages.ubuntu.com/trusty/all/texlive-latex-extra/filelist texlive-latex-extra] packages and [http://packages.ubuntu.com/trusty/all/texlive-publishers/filelist texlive-publishers] packages.
* https://tex.stackexchange.com/questions/179214/elsarticle-cls-not-found-when-using-texmaker-but-texlive-latex-extra-is-install/179250
* https://tex.stackexchange.com/questions/179214/elsarticle-cls-not-found-when-using-texmaker-but-texlive-latex-extra-is-install/179250
Line 4,678: Line 4,677:
</syntaxhighlight>
</syntaxhighlight>


==== Missing sty ====
== Missing sty ==
<syntaxhighlight lang='rsplus'>
<syntaxhighlight lang='rsplus'>
$ apt-cache search pseudocode
$ apt-cache search pseudocode
Line 4,688: Line 4,687:
</syntaxhighlight>
</syntaxhighlight>


=== PDF ===
= PDF =
==== Change the default viewer ====
== Change the default viewer ==
Right Click(pdf)-> Properties-> Open With-> Okular (or anything) -> Set as default.
Right Click(pdf)-> Properties-> Open With-> Okular (or anything) -> Set as default.


==== PDF reader ====
== PDF reader ==
The default one '''Evince''' seems slow when I try to view odroid magazine.  
The default one '''Evince''' seems slow when I try to view odroid magazine.  


Line 4,737: Line 4,736:
* Foxit or PDF-XChange Viewer(needs wine)
* Foxit or PDF-XChange Viewer(needs wine)


==== PDF crop ====
== PDF crop ==
'''pdfcrop''' (briss is better)
'''pdfcrop''' (briss is better)


Line 4,768: Line 4,767:
# Now we can click 'Action -> Preview' to preview the result. If we are satisfied with the result, we can click 'Action -> Crop PDF'. Done.
# Now we can click 'Action -> Preview' to preview the result. If we are satisfied with the result, we can click 'Action -> Crop PDF'. Done.


==== Remove certain pages ====
== Remove certain pages ==
https://www.linux.com/learn/manipulating-pdfs-pdf-toolkit
https://www.linux.com/learn/manipulating-pdfs-pdf-toolkit
<pre>
<pre>
Line 4,783: Line 4,782:
</pre>
</pre>


==== PDF highlight and annotation ====
== PDF highlight and annotation ==
Install [https://docs.kde.org/stable/en/kdegraphics/okular/annotations.html Okular] by  
Install [https://docs.kde.org/stable/en/kdegraphics/okular/annotations.html Okular] by  
<pre>sudo apt-get install okular</pre>
<pre>sudo apt-get install okular</pre>
Line 4,793: Line 4,792:
Another method is to use a windows program and run it using Wine. See the discussion [http://askubuntu.com/questions/36696/foxit-reader-on-wine-runs-but-does-not-install here].
Another method is to use a windows program and run it using Wine. See the discussion [http://askubuntu.com/questions/36696/foxit-reader-on-wine-runs-but-does-not-install here].


==== Merge multiple pdf files into one pdf file ====
== Merge multiple pdf files into one pdf file ==
https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf
https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf
<pre>
<pre>
Line 4,799: Line 4,798:
</pre>
</pre>


==== Arrange, merge, split, rotate, crop ====
== Arrange, merge, split, rotate, crop ==
[https://www.linuxuprising.com/2018/12/pdfarranger-merge-split-rotate-crop-or.html PDFArranger: Merge, Split, Rotate, Crop Or Rearrange PDF Documents (PDF-Shuffler Fork) ]
[https://www.linuxuprising.com/2018/12/pdfarranger-merge-split-rotate-crop-or.html PDFArranger: Merge, Split, Rotate, Crop Or Rearrange PDF Documents (PDF-Shuffler Fork) ]


==== Editing ====
== Editing ==
* [https://www.linuxuprising.com/2019/04/download-master-pdf-editor-4-for-linux.html Download Master PDF Editor 4 For Linux (Free To Use Version)]
* [https://www.linuxuprising.com/2019/04/download-master-pdf-editor-4-for-linux.html Download Master PDF Editor 4 For Linux (Free To Use Version)]
* [http://xournal.sourceforge.net/ Xournal]
* [http://xournal.sourceforge.net/ Xournal]


==== Print multiple pages per sheet: [https://linux.die.net/man/1/pdfnup pdfnup] ====
== Print multiple pages per sheet: [https://linux.die.net/man/1/pdfnup pdfnup] ==
The program is similar to psnup.
The program is similar to psnup.
<pre>
<pre>
Line 4,812: Line 4,811:
</pre>
</pre>


==== Extract tables from pdf ====
== Extract tables from pdf ==
[[R#Extracting_tables_from_PDFs|Extracting tables from PDFs]]
[[R#Extracting_tables_from_PDFs|Extracting tables from PDFs]]


=== Flow chart ===
= Flow chart =
* LibreOffice Draw OR MS_PowerPoint (insert > shape). Check youtube.  
* LibreOffice Draw OR MS_PowerPoint (insert > shape). Check youtube.  
* [https://www.yworks.com/products/yed yEd]
* [https://www.yworks.com/products/yed yEd]
Line 4,821: Line 4,820:
* (online) www.draw.io
* (online) www.draw.io


=== Clock ===
= Clock =
==== xclock (analog) ====
== xclock (analog) ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
oclock -geometry 500x500+100+0 &
oclock -geometry 500x500+100+0 &
</syntaxhighlight>
</syntaxhighlight>


==== oclock (analog) ====
== oclock (analog) ==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
oclock -bg blue -geometry 500x500+100+0 -bd purple -transparent &
oclock -bg blue -geometry 500x500+100+0 -bd purple -transparent &
Line 4,834: Line 4,833:
See [http://manpages.ubuntu.com/manpages/hardy/man1/oclock.1.html oclock], [http://manpages.ubuntu.com/manpages/hardy/man7/X.7.html X - a portable, network-transparent window system] which includes an example of specifying the ''geometry'' parameter.
See [http://manpages.ubuntu.com/manpages/hardy/man1/oclock.1.html oclock], [http://manpages.ubuntu.com/manpages/hardy/man7/X.7.html X - a portable, network-transparent window system] which includes an example of specifying the ''geometry'' parameter.


==== dclock (digital) ====
== dclock (digital) ==
Digital clock for the X Window System with flexible display.
Digital clock for the X Window System with flexible display.
* http://manpages.org/dclock
* http://manpages.org/dclock
Line 4,850: Line 4,849:
</pre>
</pre>


==== Lubuntu digital clock format ====
== Lubuntu digital clock format ==
http://netgator.blogspot.com/2012/09/change-edit-panel-digital-clock-format.html. My format is
http://netgator.blogspot.com/2012/09/change-edit-panel-digital-clock-format.html. My format is
<pre>
<pre>
Line 4,860: Line 4,859:
</pre>
</pre>


==== xdaliclock (digital) ====
== xdaliclock (digital) ==
https://www.mankier.com/1/xdaliclock
https://www.mankier.com/1/xdaliclock


Line 4,868: Line 4,867:
</syntaxhighlight>
</syntaxhighlight>


=== Reminder take a break, relieve eye strain ===
= Reminder take a break, relieve eye strain =
[https://github.com/hovancik/stretchly/ Stretchly]. It's open-source and cross-platform. Nodejs is required.
[https://github.com/hovancik/stretchly/ Stretchly]. It's open-source and cross-platform. Nodejs is required.


Line 4,875: Line 4,874:
[https://www.linuxuprising.com/2019/02/prevent-eye-strain-while-working-on.html?m=1 Prevent Eye Strain While Working On Your Linux Desktop With Safe Eyes], [https://slgobinath.github.io/SafeEyes/ Github] source code
[https://www.linuxuprising.com/2019/02/prevent-eye-strain-while-working-on.html?m=1 Prevent Eye Strain While Working On Your Linux Desktop With Safe Eyes], [https://slgobinath.github.io/SafeEyes/ Github] source code


=== wine and winetricks ===
= wine and winetricks =
* https://www.howtoforge.com/tutorial/how-to-use-winetricks/
* https://www.howtoforge.com/tutorial/how-to-use-winetricks/


=== Running Linux in the AWS/Amazon Web Services ===
= Running Linux in the AWS/Amazon Web Services =
* http://www.linuxuser.co.uk/tutorials/run-linux-in-the-aws-cloud
* http://www.linuxuser.co.uk/tutorials/run-linux-in-the-aws-cloud


=== Forum software ===
= Forum software =
* [http://www.simplemachines.org/ Simple Machines® Forum (SMF)]. For example http://pibot.org/forum/
* [http://www.simplemachines.org/ Simple Machines® Forum (SMF)]. For example http://pibot.org/forum/


=== RAID ===
= RAID =
* http://www.maximumpc.com/what-every-pc-builder-should-know-about-raid-levels/
* http://www.maximumpc.com/what-every-pc-builder-should-know-about-raid-levels/


=== Timer ===
= Timer =
* http://zeegaree.com/. Require 3 libraries that we need to install them using apt-get install. See the [https://github.com/mivoligo/Zeegaree#zeegaree github] page.
* http://zeegaree.com/. Require 3 libraries that we need to install them using apt-get install. See the [https://github.com/mivoligo/Zeegaree#zeegaree github] page.


=== How to track you laptop using Prey ===
= How to track you laptop using Prey =
https://www.howtoforge.com/tutorial/how-to-track-your-linux-laptop/
https://www.howtoforge.com/tutorial/how-to-track-your-linux-laptop/


=== last command ===
= last command =
[https://www.howtoforge.com/linux-last-command/ Linux last Command Tutorial for Beginners (8 Examples)]
[https://www.howtoforge.com/linux-last-command/ Linux last Command Tutorial for Beginners (8 Examples)]


==== Display a list of system shutdown/reboot date/time ====
== Display a list of system shutdown/reboot date/time ==
[https://www.cyberciti.biz/tips/linux-last-reboot-time-and-date-find-out.html Linux Find Out Last System Reboot Time and Date Command]
[https://www.cyberciti.biz/tips/linux-last-reboot-time-and-date-find-out.html Linux Find Out Last System Reboot Time and Date Command]
<pre>
<pre>
Line 4,904: Line 4,903:
</pre>
</pre>


=== Automatic reboot after power failure ===
= Automatic reboot after power failure =
It seems there is no reliable way to find out when the power failed.
It seems there is no reliable way to find out when the power failed.


Line 4,911: Line 4,910:
Another way is to modify the BIOS to select the option like 'Power off and Reboot'. This won't automatically boot your computer when it is shutdown normally.
Another way is to modify the BIOS to select the option like 'Power off and Reboot'. This won't automatically boot your computer when it is shutdown normally.


=== Wake up and Shut Down Linux Automatically ===
= Wake up and Shut Down Linux Automatically =
* https://help.ubuntu.com/community/WakeOnLan
* https://help.ubuntu.com/community/WakeOnLan
* https://www.cyberciti.biz/faq/ubuntu-linux-wake-on-lan-client-command-installation-examples/
* https://www.cyberciti.biz/faq/ubuntu-linux-wake-on-lan-client-command-installation-examples/
Line 4,922: Line 4,921:
** Send a wake up command: (from a second linux) '''/usr/bin/wakeonlan D0:50:99:82:E7:2B''' where D0:50:99:82:E7:2B is the IP on the machine you want to wake it up
** Send a wake up command: (from a second linux) '''/usr/bin/wakeonlan D0:50:99:82:E7:2B''' where D0:50:99:82:E7:2B is the IP on the machine you want to wake it up


=== How to update Lenovo BIOS from Linux without using Windows ===
= How to update Lenovo BIOS from Linux without using Windows =
https://www.cyberciti.biz/faq/update-lenovo-bios-from-linux-usb-stick-pen/
https://www.cyberciti.biz/faq/update-lenovo-bios-from-linux-usb-stick-pen/


=== Internet speed test ===
= Internet speed test =
==== Web ====
== Web ==
* https://fast.com/ (automatically run)
* https://fast.com/ (automatically run)
* https://www.bing.com/search?q=internet+speed+test
* https://www.bing.com/search?q=internet+speed+test
* http://www.speedtest.net/
* http://www.speedtest.net/


==== Speedtest-cli ====
== Speedtest-cli ==
See [[Raspberry#Track_Internet_Dropouts|Track_Internet_Dropouts]].
See [[Raspberry#Track_Internet_Dropouts|Track_Internet_Dropouts]].


Line 4,950: Line 4,949:
NOTE: 1. the results differ from the network connection. For example, the speed is good when I test it on the machine directly connected to the router. 2. It is helpful to modify the last line of the bash script to output what I need. 3. The separator is ";" in the output.
NOTE: 1. the results differ from the network connection. For example, the speed is good when I test it on the machine directly connected to the router. 2. It is helpful to modify the last line of the bash script to output what I need. 3. The separator is ";" in the output.


=== '''uname''' - Print system information ===
= '''uname''' - Print system information =
https://www.lifewire.com/display-system-information-uname-command-3964321
https://www.lifewire.com/display-system-information-uname-command-3964321


Line 4,966: Line 4,965:
[https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux How to check if running in Cygwin, Mac or Linux?]
[https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux How to check if running in Cygwin, Mac or Linux?]


=== Hardware information ===
= Hardware information =
[https://www.2daygeek.com/how-to-check-system-hardware-manufacturer-model-and-serial-number-in-linux/ How To Check System Hardware Manufacturer, Model And Serial Number In Linux]
[https://www.2daygeek.com/how-to-check-system-hardware-manufacturer-model-and-serial-number-in-linux/ How To Check System Hardware Manufacturer, Model And Serial Number In Linux]


==== [https://github.com/rdobson/python-hwinfo python--hwinfo] ====
== [https://github.com/rdobson/python-hwinfo python--hwinfo] ==
https://www.2daygeek.com/python-hwinfo-check-display-system-hardware-configuration-information-linux/
https://www.2daygeek.com/python-hwinfo-check-display-system-hardware-configuration-information-linux/


=== Linux Logo and the current system information ===
= Linux Logo and the current system information =
* http://www.cyberciti.biz/hardware/howto-display-linux-logo-in-bash-terminal-using-screenfetch-linux_logo/
* http://www.cyberciti.biz/hardware/howto-display-linux-logo-in-bash-terminal-using-screenfetch-linux_logo/
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 5,048: Line 5,047:
[[File:Neofetch.png|200px]]
[[File:Neofetch.png|200px]]


=== Dictionary - [http://artha.sourceforge.net/wiki/index.php/Home Artha] ===
= Dictionary - [http://artha.sourceforge.net/wiki/index.php/Home Artha] =
* [http://lifehacker.com/5916656/artha-is-a-feature-packed-offline-thesaurus-and-dictionary Lifehacker]. Once it is launched, it is sitting on the task bar. Press Ctrl+Alt+W after selecting a word to look it up in Artha (a balloon tip will pop up on the screen top-right). It also supports using regular expressions to search words.
* [http://lifehacker.com/5916656/artha-is-a-feature-packed-offline-thesaurus-and-dictionary Lifehacker]. Once it is launched, it is sitting on the task bar. Press Ctrl+Alt+W after selecting a word to look it up in Artha (a balloon tip will pop up on the screen top-right). It also supports using regular expressions to search words.
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 5,054: Line 5,053:
</syntaxhighlight>
</syntaxhighlight>


==== Translation ====
== Translation ==
* [https://www.soimort.org/translate-shell/ Translate Shell]. No installation is needed. It is just a bash script (4990 lines) so it works on ODroid SOC. See also [https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ A Tool To Use Google Translate From Command Line In Linux]
* [https://www.soimort.org/translate-shell/ Translate Shell]. No installation is needed. It is just a bash script (4990 lines) so it works on ODroid SOC. See also [https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/ A Tool To Use Google Translate From Command Line In Linux]
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 5,096: Line 5,095:
</syntaxhighlight>
</syntaxhighlight>


=== ASCII art/ word art ===
= ASCII art/ word art =
* figlet. [https://www.tecmint.com/create-ascii-text-banners-in-linux-terminal/ How to Create ASCII Text Banners in Terminal], [https://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/ lolcat]
* figlet. [https://www.tecmint.com/create-ascii-text-banners-in-linux-terminal/ How to Create ASCII Text Banners in Terminal], [https://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/ lolcat]
* http://patorjk.com/software/taag/#p=display&f=Ivrit&t=BRR-SeqTools
* http://patorjk.com/software/taag/#p=display&f=Ivrit&t=BRR-SeqTools
Line 5,127: Line 5,126:
</pre>
</pre>


=== Software that scan Malware and rootkits ===
= Software that scan Malware and rootkits =
* https://www.howtoforge.com/tutorial/how-to-scan-linux-for-malware-and-rootkits/
* https://www.howtoforge.com/tutorial/how-to-scan-linux-for-malware-and-rootkits/


=== Text to speech ===
= Text to speech =
* http://www.eguidedog.net/ekho.php. Compilation/build works on x86 Ubuntu 14 and Odroid Ubuntu 15.10. On Odroid I have to follow their instruction to use 'make CXXFLAGS=-DNO_SSE' instead of 'make'. However, sound feels shaky on Odroid xu4.  
* http://www.eguidedog.net/ekho.php. Compilation/build works on x86 Ubuntu 14 and Odroid Ubuntu 15.10. On Odroid I have to follow their instruction to use 'make CXXFLAGS=-DNO_SSE' instead of 'make'. However, sound feels shaky on Odroid xu4.  
* http://audiobookmaker.com/
* http://audiobookmaker.com/
* http://project-modelino.com/online-resources-category.php?site_language=english&learn_language=chinese&category=tts
* http://project-modelino.com/online-resources-category.php?site_language=english&learn_language=chinese&category=tts


=== VPN ===
= VPN =
* [http://lifehacker.com/the-biggest-misconceptions-about-vpns-1794038237 The Biggest Misconceptions About VPNs]
* [http://lifehacker.com/the-biggest-misconceptions-about-vpns-1794038237 The Biggest Misconceptions About VPNs]
* [http://lifehacker.com/why-is-everyone-talking-about-vpns-1793768312 Why Is Everyone Talking About VPNs?]
* [http://lifehacker.com/why-is-everyone-talking-about-vpns-1793768312 Why Is Everyone Talking About VPNs?]
Line 5,144: Line 5,143:
* remoteaccessvpn.nih.gov for [https://isdp.nih.gov/isdp/version.action?prodid=140 NIH]. Download and unzip the profile and place the profile (.xml)in “/opt/cisco/anyconnect/profile/” directory  
* remoteaccessvpn.nih.gov for [https://isdp.nih.gov/isdp/version.action?prodid=140 NIH]. Download and unzip the profile and place the profile (.xml)in “/opt/cisco/anyconnect/profile/” directory  


==== OpenVPN ====
== OpenVPN ==
* [https://nordvpn.com/tutorials/linux/openvpn/ Tutorial from nordvpn] (free 3-day trial)
* [https://nordvpn.com/tutorials/linux/openvpn/ Tutorial from nordvpn] (free 3-day trial)
* [https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04 How To Set Up an OpenVPN Server on Ubuntu 14.04]
* [https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04 How To Set Up an OpenVPN Server on Ubuntu 14.04]
Line 5,150: Line 5,149:
* [https://www.howtoforge.com/tutorial/openvpn-secure-server-administration/ Secure you server administration with multiplatform VPN connection] by howtoforge.
* [https://www.howtoforge.com/tutorial/openvpn-secure-server-administration/ Secure you server administration with multiplatform VPN connection] by howtoforge.


==== List of free and fast VPNs ====
== List of free and fast VPNs ==
* [https://www.ostechnix.com/7-best-opensource-vpn-services-for-2019/ 7 Best VPN Services For 2019]
* [https://www.ostechnix.com/7-best-opensource-vpn-services-for-2019/ 7 Best VPN Services For 2019]
* [https://www.makeuseof.com/tag/best-free-vpn-for-linux/ The 7 Best VPNs for Linux] Oct 2018
* [https://www.makeuseof.com/tag/best-free-vpn-for-linux/ The 7 Best VPNs for Linux] Oct 2018
Line 5,162: Line 5,161:
** with vpnsecure trial i get 30 down
** with vpnsecure trial i get 30 down


==== How to Set Up a VPN on Your Router ====
== How to Set Up a VPN on Your Router ==
https://www.makeuseof.com/tag/setup-vpn-router/
https://www.makeuseof.com/tag/setup-vpn-router/


=== [http://www.mono-project.com/ Mono Project] ===
= [http://www.mono-project.com/ Mono Project] =
'''Mono''' is a software platform designed to allow developers to easily create cross platform applications part of the .NET Foundation
'''Mono''' is a software platform designed to allow developers to easily create cross platform applications part of the .NET Foundation


Mono is required for [https://www.repetier.com/download-now/ Repetier-Host] software for 3D printing.
Mono is required for [https://www.repetier.com/download-now/ Repetier-Host] software for 3D printing.


=== NAS server ===
= NAS server =
==== [http://www.openmediavault.org/ OpenMediaVault] ====
== [http://www.openmediavault.org/ OpenMediaVault] ==
[http://www.pcworld.com/article/3150765/linux/4-easy-linux-projects-for-newbies-and-intermediate-users.html 4 easy Linux projects for newbies and intermediate users]. OpenMediaVault is a linux-based system.
[http://www.pcworld.com/article/3150765/linux/4-easy-linux-projects-for-newbies-and-intermediate-users.html 4 easy Linux projects for newbies and intermediate users]. OpenMediaVault is a linux-based system.


[https://github.com/ikogan/docker-openmediavault Docker container for OpenMediaVault]. [http://www.songming.me/docker.html OpenMediaVault插件之Docker教程]
[https://github.com/ikogan/docker-openmediavault Docker container for OpenMediaVault]. [http://www.songming.me/docker.html OpenMediaVault插件之Docker教程]


==== [http://www.freenas.org/ FreeNAS] ====
== [http://www.freenas.org/ FreeNAS] ==
ZFS system (FreeBSD-based).
ZFS system (FreeBSD-based).


Line 5,186: Line 5,185:
* [https://forums.servethehome.com/index.php?threads/freenas-as-hypervisor-host.4888/ FreeNAS as hypervisor host]
* [https://forums.servethehome.com/index.php?threads/freenas-as-hypervisor-host.4888/ FreeNAS as hypervisor host]


=== Change detection ===
= Change detection =
http://bhfsteve.blogspot.com/2013/03/monitoring-web-page-for-changes-using.html
http://bhfsteve.blogspot.com/2013/03/monitoring-web-page-for-changes-using.html


=== 3 command-line tools for feigning productivity ===
= 3 command-line tools for feigning productivity =
https://opensource.com/article/18/2/command-line-tools-productivity: [https://github.com/yaronn/blessed-contrib Blessed-contrib] (javascript), Genact, Hollywood.
https://opensource.com/article/18/2/command-line-tools-productivity: [https://github.com/yaronn/blessed-contrib Blessed-contrib] (javascript), Genact, Hollywood.


=== Mind mapping ===
= Mind mapping =
* [https://www.freeplane.org/wiki/index.php/Home Freeplane]
* [https://www.freeplane.org/wiki/index.php/Home Freeplane]


=== Diagram ===
= Diagram =
* [https://www.calligra.org/flow/ Calligra Flow]. Microsoft Visio alternative.
* [https://www.calligra.org/flow/ Calligra Flow]. Microsoft Visio alternative.


=== Open source surveillance ===
= Open source surveillance =
[https://www.zoneminder.com/downloads/ ZoneMinder]
[https://www.zoneminder.com/downloads/ ZoneMinder]


=== Systemctl, systemd ===
= Systemctl, systemd =
* Linux 系统开机启动项清理 [https://linux.cn/article-8835-1.html 中文] & [https://www.linux.com/learn/cleaning-your-linux-startup-process English]
* Linux 系统开机启动项清理 [https://linux.cn/article-8835-1.html 中文] & [https://www.linux.com/learn/cleaning-your-linux-startup-process English]
* [https://www.tecmint.com/chkservice-manage-systemd-units-in-terminal/ Chkservice – An Easy Way to Manage Systemd Units in Terminal]
* [https://www.tecmint.com/chkservice-manage-systemd-units-in-terminal/ Chkservice – An Easy Way to Manage Systemd Units in Terminal]
* [[Raspberry#Use_a_systemd_unit.2Fservice_file_to_control_an_application_to_start_when_Raspberry_pi_boots_up|Control an application to run when Raspberry pi boots up]]
* [[Raspberry#Use_a_systemd_unit.2Fservice_file_to_control_an_application_to_start_when_Raspberry_pi_boots_up|Control an application to run when Raspberry pi boots up]]


==== Systemd vs SysVinit ====
== Systemd vs SysVinit ==
* https://kernelmastery.com/systemd-vs-sysvinit/
* https://kernelmastery.com/systemd-vs-sysvinit/
* https://linoxide.com/linux-command/systemd-vs-sysvinit-cheatsheet/
* https://linoxide.com/linux-command/systemd-vs-sysvinit-cheatsheet/
* https://www.2daygeek.com/sysvinit-vs-systemd-cheatsheet-systemctl-command-usage/
* https://www.2daygeek.com/sysvinit-vs-systemd-cheatsheet-systemctl-command-usage/


=== Bitcoin ===
= Bitcoin =
* [https://www.makeuseof.com/tag/mine-bitcoin-linux/ Mine Bitcoin on Linux With These Best Free Apps]
* [https://www.makeuseof.com/tag/mine-bitcoin-linux/ Mine Bitcoin on Linux With These Best Free Apps]
* [https://www.howtogeek.com/347210/how-to-buy-bitcoin-the-easy-way/ How to Buy Bitcoin the Easy Way]
* [https://www.howtogeek.com/347210/how-to-buy-bitcoin-the-easy-way/ How to Buy Bitcoin the Easy Way]


=== Check weather ===
= Check weather =
* [https://www.linuxuprising.com/2018/07/display-weather-forecast-in-your.html Display Weather Forecast In Your Terminal With Wttr.in] <syntaxhighlight lang='bash'>
* [https://www.linuxuprising.com/2018/07/display-weather-forecast-in-your.html Display Weather Forecast In Your Terminal With Wttr.in] <syntaxhighlight lang='bash'>
$ curl wttr.in
$ curl wttr.in
Line 5,225: Line 5,224:
* [https://www.makeuseof.com/tag/check-weather-linux-desktop/ 10 Ways to Check the Weather From Your Linux Desktop]
* [https://www.makeuseof.com/tag/check-weather-linux-desktop/ 10 Ways to Check the Weather From Your Linux Desktop]


=== Game ===
= Game =
* [https://itsfoss.com/download-linux-games/ Fantastic Linux Games and Where to Find Them]
* [https://itsfoss.com/download-linux-games/ Fantastic Linux Games and Where to Find Them]
* [https://www.makeuseof.com/tag/best-linux-games/ The 10 Best Linux Games You Can Play for Free] (2019)
* [https://www.makeuseof.com/tag/best-linux-games/ The 10 Best Linux Games You Can Play for Free] (2019)


=== Best Linux Adobe Alternatives You Need to Know ===
= Best Linux Adobe Alternatives You Need to Know =
* https://linux.cn/article-8928-1.html and https://www.maketecheasier.com/adobe-alternatives-for-linux/
* https://linux.cn/article-8928-1.html and https://www.maketecheasier.com/adobe-alternatives-for-linux/


=== Linux distributions ===
= Linux distributions =
[https://www.fossmint.com/linux-distros-you-never-heard-about/ The Top 10 Open Source Distros You Haven’t Heard About]
[https://www.fossmint.com/linux-distros-you-never-heard-about/ The Top 10 Open Source Distros You Haven’t Heard About]


==== Popular Linux distributions ====
== Popular Linux distributions ==
[https://www.ithome.com.tw/news/121357 2017年度最佳Linux版本出爐], https://www.linuxquestions.org/questions/linux-news-59/2017-linuxquestions-org-members-choice-award-winners-4175623289/
[https://www.ithome.com.tw/news/121357 2017年度最佳Linux版本出爐], https://www.linuxquestions.org/questions/linux-news-59/2017-linuxquestions-org-members-choice-award-winners-4175623289/


==== Small/lightweight Linux distributions ====
== Small/lightweight Linux distributions ==
* [http://www.makeuseof.com/tag/linux-distro-space/ Install Linux to Save Space! These Tiny Linux Distros Are Super Small] 10/10/2017
* [http://www.makeuseof.com/tag/linux-distro-space/ Install Linux to Save Space! These Tiny Linux Distros Are Super Small] 10/10/2017
* [https://www.makeuseof.com/tag/6-lightweight-linux-distributions-give-pc-lease-life/ 13 Lightweight Linux Distributions to Give Your Old PC a New Lease of Life] 5/5/2017. Some distributions that can be run in RAM: Macpup, Porteus.
* [https://www.makeuseof.com/tag/6-lightweight-linux-distributions-give-pc-lease-life/ 13 Lightweight Linux Distributions to Give Your Old PC a New Lease of Life] 5/5/2017. Some distributions that can be run in RAM: Macpup, Porteus.


==== 10 Best And Most Secure Linux Distributions ====
== 10 Best And Most Secure Linux Distributions ==
https://fossbytes.com/secure-linux-distros-privacy-anonymity/
https://fossbytes.com/secure-linux-distros-privacy-anonymity/


==== Kids ====
== Kids ==
[https://www.maketecheasier.com/configure-linux-for-children/ How to Configure Linux for Children]
[https://www.maketecheasier.com/configure-linux-for-children/ How to Configure Linux for Children]

Revision as of 17:18, 23 June 2019

man

How to Easily Read a Linux Man Page

  • Underlined or Italicized Text: It means you need to replace it with an appropriate argument.
  • Ellipses: It means that argument or expression is repeatable.

Navigation

Gentoo and fossbytes

  • Enter – Move down one line
  • Space – Move down one page
  • g – Move to the top of the page
  • G – Move to the bottom of the page
  • q – Quit

Search within a man page

Use / and type your search pattern.

Use 'n' for forward search and 'N' for reverse search.

The matched line will be moved to the top of the screen.

By default, the search is case insensitive or we can use man -i COMMAND.

Regular expression is supported. For example to find all of the long arguments with: /(--)[a-Z]

Colored man pages

This is a cool tip!

By default, the man program normally uses a terminal pager program such as less to format its output.

Add the following to "~/.bashrc" file

export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'

Navigate to another man page within a man page

See here.

When inside the man page, press ! followed by a valid shell command.

For example : !man cat

View a specific "Section"

$ whatis printf
printf (1)           - format and print data
printf (3)           - formatted output conversion
Printf (3o)          - Formatted output functions.
$ man 3 printf

Read man pages in vi without using temporary files

What is a way to read man pages in vim without using temporary files

man find | vi -

Search man page referenced by

man -f KEYWORD

This command is equivalent to whatis -r KEYWORD

Search from all man pages

man -k KEYWORD will give you a list of all man pages which relate to 'KEYWORD'.

TLDR pages: alternative to Man

TLDR pages: Simplified Alternative To Linux Man Pages. Note I got a syntax error when running tldr --update.

Some books

Beautiful desktop

.desktop file

This is not related to beautiful desktop. It is used to launch applications in Linux. Without the .desktop file, your application won’t show up in the Applications menu and you can’t launch it with third-party launchers such as Synapse and Albert Launcher.

The .desktop files are commonly saved in

  • ~/local/share/applications
  • /usr/share/applications

List of installed desktop environment

ls -l /usr/share/xsessions/

Themes

5 of the Best Linux Dark Themes that Are Easy on the Eyes

Virtual consoles/virtual terminals

Linux allows virtual consoles (aka virtual terminals) to be opened while an X Window System is executing.

Use Ctrl + Alt + FX to open a virtual console-- there are six virtual text-based consoles (F1 to F6). Use Alt + F7 (or possibly other keybinds) to return to the X Window System.

Managing devices in Linux -> Fun with device files.

Change console fonts

https://www.linux.com/learn/intro-to-linux/2018/1/how-change-your-linux-console-fonts

Desktops/Workspaces

Ctrl + Alt + -> or Ctrl + Alt + <- to switch workspaces.

Ctrl + Alt + down can list the open applications on the current workspace.

Ctrl + Alt + up can show all workspaces and the open applications. We can use mouse to move an app to any workspace.

SuperKey + left tile a window to left. SuperKey + right tile a window to right.

Complete List of Linux Mint 18 Keyboard Shortcuts for Cinnamon for more examples.

Virtual memory

vmstat

hcache

A tool fork from pcstat, with a feature that showing top X biggest cache files globally

Memory

Is Linux Eating Your RAM? How to Manage Your Memory

Three types of memory reported by the free command.

  • Used: RAM that is currently in use by an application.
  • Available: RAM that may be in use for disk caching but can be freed up for applications.
  • Free: RAM that is not in use by an application or disk caching.

How to Clear RAM Memory Cache and Buffer

# To clear pagecache, enter the following command:
echo 1 > /proc/sys/vm/drop_caches

# To clear dentries and inodes, change the number to 2:
echo 2 > /proc/sys/vm/drop_caches

# To clear pagecache, dentries, and inodes all together, change the number to 3:
echo 3 > /proc/sys/vm/drop_caches

Logging memory

ps_mem: Shows Per-Program Memory Usage On Linux

https://www.linuxuprising.com/2019/04/psmem-shows-per-program-memory-usage-on.html. In this case I have 6 tabs open in chrome and 12 tabs for firefox.

$ pip install ps_mem
$ ps_mem -p $(pgrep -d, -u $USER)
 Private  +   Shared  =  RAM used	Program
...
249.9 MiB +  43.9 MiB = 293.9 MiB	firefox
549.7 MiB +  82.2 MiB = 631.9 MiB	Web Content (6)
  1.0 GiB + 149.6 MiB =   1.2 GiB	chrome (16)
---------------------------------
                          3.2 GiB

Check RAM information

sudo dmidecode -t 17

Monitor Memory Utilization And Send an Email

Bash Script to Monitor Memory Usage on Linux

ps, pgrep and pidof: How much resource is used by a process

Find the process ID first by ps -ef | grep APPLICATIONAME where "-e" is to show the running processes and "-f" is for a full listing. Then

ps -p <pid> -o %cpu,%mem,cmd

For example,

$ ps -ef | grep akregator
brb      15013  1942  1 10:41 ?        00:00:05 akregator --icon akregator -caption Akregator
brb      15186 24045  0 10:50 pts/11   00:00:00 grep --color=auto akregator
$ ps -p 15013 -o %cpu,%mem,cmd
%CPU %MEM CMD
 1.0  0.8 akregator --icon akregator -caption Akregator

pgrep

08:49AM ~$ ps -ef | grep firefox
brb       7798  7778  0 08:49 pts/2    00:00:00 grep --color=auto firefox
brb      25486 24869  0 Sep10 ?        00:42:48 /usr/lib/firefox/firefox
brb      25612 25486  0 Sep10 ?        00:19:49 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 17405 -schedulerPrefs 0001,2 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 25486 true tab
brb      25961 25486  0 Sep10 ?        00:41:50 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 20505 -schedulerPrefs 0001,2 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 25486 true tab
brb      27951 25486  0 Sep10 ?        01:35:41 /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -prefsLen 20570 -schedulerPrefs 0001,2 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 25486 true tab
08:49AM ~$ pgrep firefox
25486

pidof

08:49AM ~$ pidof firefox
27951 25961 25612 25486
08:51AM ~$ pidof /usr/lib/firefox/firefox
27951 25961 25612 25486

All You Need To Know About Processes in Linux

http://www.tecmint.com/linux-process-management/

Things to do after a fresh install of GNU/Linux

  1. Run upgrade such as apt-get update; apt-get upgrade. It helps to resolve the unmet dependencies issue too.
  2. Increase audio quality
  3. Make sure firewall is enabled.
  4. Disable any unnecessary services
  5. Install Timeshift
  6. Install ClamAV / Clamtk antivirus

Query whether the OS is 64-bit or 32-bit

SYSTEM_ARCH=getconf LONG_BIT
echo $SYSTEM_ARCH

Switch user in command line

use

su newusername

to switch to another user.

Command line improved

https://remysharp.com/2018/08/23/cli-improved

Directory permission / attribute

See http://unix.stackexchange.com/questions/21251/how-do-directory-permissions-in-linux-work

When applying permissions to directories on Linux, the permission bits have different meanings than on regular files.

  • The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes
  • The read bit allows the affected user to list the files within the directory
  • The execute bit allows the affected user to enter the directory, and access files and directories inside

When we create a new directory, the attribute is 775. Some pre-created directories (Desktop, Documents, Music, Pictures, Public) have an attribute 755.

Making a new temporary directory

https://www.howtoforge.com/linux-mktemp-command/

mktemp  # temp directory is under /tmp
mktemp -d tempdirXXX # temp directory is under the current directory
mktemp tempfileXXX # temp file under the current directory

Special permissions

s bit - setuid, getuid

Shell

Change to root shell

The following command will switch to an environment similar to what the user would expect had the user logged in directly.

sudo su -
# OR
sudo su
# OR
sudo -s

This can be useful when running 'su' or 'su -' failed because of an authentication failure error (note Ubuntu locked the root account).

See also

For sudo to work, my account ('debian' in this case) has to be included in the config file /etc/sudoers.

debian  ALL=NOPASSWD: ALL

When sudo is invoked, it asks for the password of the user who started it.

Switch to another user and run a command

runuser -l command

runuser -l  userNameHere -c 'command'

su - command (keep the dash sign after su)

su - username -c 'command'

sudo su -  # switch to root account
whoami

sudo su - -c "R -q -e \"install.packages('mypackage', repos='http://cran.rstudio.com/')\""
# OR
sudo su -c "COMMAND_REQUIRE_ROOT_ACCESS"
# OR
sudo "COMMAND_REQUIRE_ROOT_ACCESS"

man su

What’s the Difference Between Bash, Zsh, and Other Linux Shells

https://www.howtogeek.com/68563/htg-explains-what-are-the-differences-between-linux-shells/

Bash shell programming

http://bash.cyberciti.biz/guide/Main_Page

Fish shell

Oh My Fish! Make Your Shell Beautiful

Tools To Record Your Terminal And Generate Animated Gif or SVG Images

Redirect standard error

http://bash.cyberciti.biz/guide/Standard_error. Use 2> operator.

command 2> errors.txt

Quotes and asterisk

Combining these two will not work. For example

brb@T3600 ~ $ ls -l ~/GSE48215/*.fastq
-rw-r--r-- 1 brb brb 16226673016 Jun 14 14:13 /home/brb/GSE48215/SRR925751_1.fastq
-rw-r--r-- 1 brb brb 16226673016 Jun 14 14:13 /home/brb/GSE48215/SRR925751_2.fastq
brb@T3600 ~ $ ls -l '~/GSE48215/*.fastq'
ls: cannot access ~/GSE48215/*.fastq: No such file or directory
brb@T3600 ~ $ ls -l "~/GSE48215/*.fastq"
ls: cannot access ~/GSE48215/*.fastq: No such file or directory

ls command

To use UID/GID instead of the user name and group name in ls -l, use the -n option.

ls -n

To make a pretty output by showing selected columns (col 9 is the file name and col 5 is the file size)

$ ls -nt bad |  grep -v ^total | awk '{ printf  "%-20s %15i\n", $9, $5}'
recal.bai                    8069704
recal.bam                12275091222
recal_data.table             1012453
realigned_reads.bai          8065496

Follow the symbolic link

Use -H option

ls -lH myDir

ls | more without lose color

$ ls --color=auto
$ ls --color | more

Most likely your ls is aliased to ls --color=auto. If you do ls --color (which is morally equivalent to ls --color=always), that will force it to turn on colors.

ls output with color background

stackexchange or askubuntu.

In my case, after I apply chmod 755 -R XXXX, the weird green background color goes away.

ls on BSD/macOS

Use the -G option to get a color output

$ ls -G

tree command

tree -d: show directories only

cp command

Linux cp command tutorial for beginners (8 examples)

copy a directory

cp -avr Dir1 Dir2

where -a will preserve the attributes of files/directories, -v means verbally and -r means copy the directory recursively.

Copy a file with progress bar with pv (plus how to eject the USB drive)

http://www.tecmint.com/monitor-copy-backup-tar-progress-in-linux-using-pv-command/

sudo apt-get install pv
pv file1 > file2    # don't forget the ">" operator and the destination is a file, not a directory

After that, instead of clicking the reject icon from the file manager to eject it, it is better to use a command line to do that because there is no expect time for users to know when it will take for finish writing the data to a USB drive.

sudo apt-get install udisks

sudo udisks --unmount /dev/sdb1   # /dev/sdb1 is the partition
sudo udisks --detach /dev/sdb     # /dev/sdb is the device

My testing shows this procedure works (tested by running md5sum after eject/plug-in) when I need to copy a 9GB file.

Reliable way: Split the large file and copy smaller chunks

# Use 'sudo iotop -o' to monitor the I/O
split -b 4G inputFile  # create xaa, xab, ... files
cat x* > outputFile    # merge them. md5sum check succeeds

type  x* > outputFile  # Windows OS. http://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows

It is interesting copying smaller files (eg 4GB) to USB drives is quite stable (just use the cp command). Even for a not-too large file (6.7GB), pv step looks OK but the unmount/detach step failed.

For a 6.7GB file, it will split it into a 4GB and 2.7GB files. Merge takes longer time if it is done on the USB drive. That is, it is best to do merge in the final destination (internal disk/storage).

  • split in the internal hdd: 1min 38sec
  • merge in the internal hdd: 37sec
  • merge in the USB 3.0 drive: 2min 17sec

Remember: Use a reliable USB drives.

The operation could not be completed because the volume is dirty

On a USB 2.0 drive, I can copy files to there but the drive cannot be rejected (Ubuntu has a pop-up showing it is still writing data to it).

When I forcibly rejects the drive and plug it in a Windows PC, Windows shows the message The operation could not be completed because the volume is dirty. This gives a way to run chkdsk (check and repair a file system).

  1. Open a Windows File Manager
  2. Right click the USB drive
  3. Properties
  4. Tools -> Check now... Start

Done. Now I can use the drive again.

The Linux equivalent to chkdsk is fsck. fsck is a front end that calls the appropriate tool (fsck.ex2, fsck.ex3, e2fsck, ...) for the filesystem in question.

 
umount /dev/sdb1        # thumb drive
sudo fsck /dev/sdb1

sudo fsck -a /dev/sdb1  # auto repair

For the root disk, you have to use a live CD. Otherwise, you will see a message like

$ fsck /dev/sdb1
fsck from util-linux 2.20.1
e2fsck 1.42.9 (4-Feb-2014)
/dev/sdb1 is mounted.

WARNING!!!  The filesystem is mounted.   If you continue you ***WILL***
cause ***SEVERE*** filesystem damage.

Do you really want to continue<n>? no

Files

List files by sorting according to the file size

Use the -S option in ls.

List files using wildcard without showing files under subdirectories

Use the -d option in ls. For example, the following command will not showing files under R-3.4.4 and R-3.5.3

$ ls -d R*
drwxr-xr-x 15 brb brb     4096 Mar 14 09:48 R-3.4.4
-rw-rw-r--  1 brb brb 30474612 Mar 15  2018 R-3.4.4.tar.gz
drwxr-xr-x 15 brb brb     4096 Mar 14 09:31 R-3.5.3
-rw-rw-r--  1 brb brb 30205979 Mar 11 04:04 R-3.5.3.tar.gz

Delete multiple files

How to Remove Multiple Subdirectories with One Linux Command

rm -r ~/Documents/htg/{done,ideas,notes}

Delete a certain type of files recursively under a directory

For example to delete *.o files under the current directory,

find . -type f -name '*.o' -delete

Create a new directory and cd to it

How to Make a New Directory and Change to It with a Single Command in Linux

mkdircd MyNewDirectory

chown and chmod recursively (-R)

Use -R (capital R).

Display files sorted by modified date in a directory recursively

stat --printf="%y %n\n" $(ls -tr $(find DIRNAME -type f))
find -type f -printf '%T+\t%p\n' | sort -n

Both of methods give the same output. Note the latest changed file is shown at the bottom of the output.

Sort files by their size

use the '-S' option.

ls -lS

alias

https://www.cyberciti.biz/faq/how-to-turn-on-or-off-colors-in-bash/

$ alias # list all aliases
$ alias | grep ls
$ unalias ls
$ alias ls='ls --color=auto' # save it in ~/.bash_profile or ~/.bashrc
$ alias server_name="ssh -v -l john 192.168.1.11" # or modify /etc/hosts

To avoid using the alias, use one of the following ways (eg use the command's full path)

$ \ls
$ /bin/ls
$ command ls
$ 'ls'

Useful aliases (Added to ~/.bashrc)

alias nano="nano -c --softwrap"

lolcat - bring color to text

sudo apt-get install ruby	
sudo gem install lolcat
lolcat -h
lolcat --version
fortune | lolcat

ps | lolcat
man ls | lolcat

lolcat test.R

sudo apt install figlet
figlet Merry Christmas | lolcat

alias lolls="ls -l | lolcat"
lolls

File manager

Cloud commander

Meld and Diffuse

To make meld to be in the right click menu, follow

Another method of comparing two files without using the 'browse' button will be to use the command line.

The 'nautilus-compare' program does not work from my testing on Ubuntu 14.04.

Refresh does not work

On Ubuntu 14, Meld version is 1.8.4. The current version is 1.16.2 (Jul 30 2016). The current version requires GTK+ 3.14 or higher.

brb@brb-P45T-A:$ ~/binary/meld-3.16.2/bin/meld
Meld requires GTK+ 3.14 or higher.

Final though

  • I install kdiff3 (<2 MB to download) and the 'File' -> 'Reload' (F5) function there works though it shows an extra space on the place I modified.
  • Beyond Compare (commercial $60, trial version can be downloaded)
  • diffuse. When I modified a file, diffuse can detect a change and ask me to reload the file. I am using the apt-get to install the software and the version number is 0.4.7 (2014). To copy lines from left panel to right panel, use 'Ctrl + Shift + >' or the Copy Selection Right icon. One drawback is it cannot save the history from the GUI though we can use the command line to include the file names in the arguments.
  • Alternatively we can use WinMerge on Linux. To do that, install Wine on Ubuntu. Download Winmerge (I am using 2.14.0). Then on a terminal, run the following command. At the end, WinMerge will be launched. WinMerge can also be launched from Mint Menu -> Wine -> WinMerge. One problem is I cannot increase the font size (though acceptable) from View -> Select Font.
wine WinMerge-2.14.0-Setup.exe

diff

Run diff with large files

Meld freezes When I tested it with two large files (800k & 936k lines coming from human gtf files). Actually the whole linux system became unresponsive.

Actually Meld is sluggish when it is used in small files in Odroid XU4 running Ubuntu 16.04 MATE. I have used Meld 3.14.2 and the latest 3.16.2.

Directory

diff -qr dir1 dir2

where -q means to report only when files differ and -r is to recursively compare any subdirectories found.

diff & colordiff-color in terminal

PS. For a GUI version of diff, Meld works fine. Need to install first. apt-get install colordiff. http://www.cyberciti.biz/programming/color-terminal-highlighter-for-diff-files/

sudo apt-get install colordiff
diff -y file1 file2 | colordiff
# Ignore same rows (two ways):
# diff -C0 file1 file2 | colordiff
# diff -U0 file1 file2 | colordiff

# On systems that I have no root right, I need to install it from the source (just need to run the 'make')
$ diff file1 file2 | ~/bin/colordiff-1.0.18/colordiff.pl

where -y option means to show the output in two columns.

Colordiff.png

Interpretation of the diff output:

The first line of the diff output will contain:

  • line numbers corresponding to the first file,
  • a letter (a for add, c for change, or d for delete), and
  • line numbers corresponding to the second file.

In our output above, 2,4c2,4 means: "Lines 2 through 4 in the first file need to be changed in order to match lines 2 through 4 in the second file." It then tells us what those lines are in each file:

  • Lines preceded by a < are lines from the first file;
  • lines preceded by > are lines from the second file.
  • The three dashes ("---") merely separate the lines of file 1 and file 2.
2,4c2,4
< I need to run the laundry.
< I need to wash the dog.
< I need to get the car detailed.
---
> I need to do the laundry.
> I need to wash the car.
> I need to get the dog detailed.
colordiff -ur path1 path2
# If you change -ur to -urN then that will also show the contents of files that are only present in one of the paths.

Colordiff2.png

The meaning of colors can be found in /etc/colordiffrc (man colordiff)

  • plain=off
  • newtext=darkgreen
  • oldtext=darkred
  • diffstuff=darkcyan
  • cvsstuff=cyan

gnome-terminal

Remember the session

The following is proved working on Ubuntu 18.04

gnome-terminal --tab --working-directory=$HOME/Downloads --tab --working-directory=$HOME/Documents

Fun: piano

Let Us Play Piano In Terminal Using Our PC Keyboard

Terminals in grids

Terminator

GNU screen

How to do it...

  • Run screen command first (run sudo apt-get install screen if necessary). You are now inside of a window within screen. This functions just like a normal shell except for a few special characters.
  • Create screen windows: Ctrl + a, then c. To close a screen window: exit. Once you close all screen windows, you shall see a message [screen is terminating] on the terminal.
  • View a list of open windows: Ctrl + a, then ".
  • Switch between windows: Ctrl + a and n for the next window and Ctrl +a and p for the previous window.
  • Attaching to and detaching screens: To detach (save) from the current screen session, Ctrl +a, and d (these keyboard shortcuts won't affect current execution). This will drop you into your shell. This is useful when you need to run a time-consuming job or your connection is dropped. To attach to an existing screen, use:
screen -r -d
  • Split screen:
    • To split the screen horizontally, Ctrl +a and S (capital).
    • To unsplit the screen, Ctrl +a and Q (capital).
    • To switch from one to the other: Ctrl +a and TAB.
    • Note: After splitting, you need to go into the new region and start a new session via Ctrl + a then c before you can use that area.

tmux*

Features:

  • Split screens
  • Don't worry about connection broken (if used remotely) or computer shutdown unexpectedly (it used locally)
  • Remember the session including split screens even computer shutdown for any reason. Useful for running a long job (wget, rsync, et al).

Most important keyboard shortcuts:

Keyboard Action
(ctrl+b), " split the pane horizontally
(ctrl+b), up/down arrow key move around panes
(ctrl+b), d

exit

detach

quit a session

$ tmux ls list sessions
$ tmux attach -t 0 re-attach session 0
(ctrl+b), :

resize-pane -U 10

resize-pane -D 10

resize pane

increase pane height by 10

decrease pane height by 10

(ctrl+b), [

'q' to quit

scrollback (Enter copy model)
(ctrl+b), [

Space

Enter

(ctrl+b), ]

$ tmux save-buffer foo.txt

copy mode in vi style keybindings

select the top of the text

select the Bottom of the text and copy

Paste (works in tmux window only. To get the tmux buffer in system clipboard, see here)

Save the buffer to a file

My ~/.tmux.conf file

set -g prefix C-a  # change prefix from (C-b) to (C-a)
unbind C-b
bind C-a send-prefix
set -g mouse on                   # use mouse to scroll and switch panes
set-window-option -g mode-keys vi # for copy-paste

Byobu

Byobu is a GPLv3 open source text-based window manager and terminal multiplexer. It appeared at Think inside the box.

Resources:

Most important keyboard shortcuts:

Keyboard Action
Shift + F2 split the pane horizontally
Shift + up/down arrow key move around panes
Shift + Alt + up/down key resize panes
F6 detach

Summary:

  • Mouse is useless
  • When used with iTerm on Mac, some keys may have a different behaviors.
  • If we want to use the 'byobu' command remotely, we first run a ssh connection to a remote computer. Then we type 'byobu' to start a new session. After some operations, we can type 'exit' to quit the session or use "F6" to detach the session and return to a normal ssh connection.
  • Kill a frozen session by byobu kill-session -t 1 where "1" is the session number obtained by byobu list-session
  • Cf Session (a complete new terminal), Windows (count from 0, see the status bar), Split (also called pane)
  • Some all keyboard shotcuts rely on the Fx keys. It is not easy or may fail to do that on Mac (needs to hold the 'fn' key) keyboard on a ssh connection.
  • F1 to go to help, e.g. key bindings. ESC to go back.
    • Shift-F1 will open a new window (check the status bar for a new number). 'q' to quit the Help Window.
    • Use Alt + Left/Right to move focus among windows
  • F2 - create a new window. F3/F4 (or Alt-Left/Alt-Right) - move to previous/next window
    • Ctrl-Shift-F2 - create a new session (not work on Mac keyboard?)
    • Alt-Up/Down to move between sessions
  • Split screen
    • Horizontal (up and down): Shift + F2.
    • Vertical: Ctrl + F2.
    • Again you cannot use mouse to move the focus:(
    • Shift + Left/Right/Up/Down to move focus among splits
    • 'exit' to close a split
    • Shift-F6 to kill a split
    • Shift + Alt + arrow keys: resize split screen
  • F5 reload profile, refresh status
  • F6 Detach session and then log out (type 'byobu' to connect again). That is, even you closed a byobu window, it is still in the background. We can test it by using 'htop' or 'ping' commands.
    • Type 'ps -ef | grep byobu' in the ssh connection to find out detached byobu sessions
  • F7 Enter scrollback mode
    • Move the cursor to the start of the text you want to copy, hit "Space"
    • Move the cursor to the end of the text you want to copy and hit "Enter"
    • To paste text, open a text editor and hit Alt + Insert or ctrl-a-]. The first time to use ctrl-a, we need to choose either Screen or Emacs mode (I choose Screen). Use byobu-ctrl-a to reconfigure change this selection. See Ubuntu page.
    • Alt-PageUp/PageDown - enter and move through scrollback (fn+Alt+Up/Down on Mac keyboard)
  • F8 Rename the current window
    • Shift-F8 Rename the current session (not work on Mac keyboard)
  • F11
    • Shift-F11 Zoom in/out a split
    • Alt-F11 Break a split to a full window
  • F12
    • Shift-F12 Toggle on/off Byobu's keybindings (say, Byobu's keybindings conflict with some other program)
    • Alt-F12 Toggle on/off Byobu's mouse support (move around splits and resize split size). It becomes more complex when we want to select text.
Byobu.png

Guake

Guake / Yakuake / Tilda

Drop down terminals for the GNOME / KDE / GTK Environments. Great for quick access to a terminal!

System date/time, ntpd

$ timedatectl
      Local time: Mon 2019-06-10 08:37:09 EDT
  Universal time: Mon 2019-06-10 12:37:09 UTC
        RTC time: Mon 2019-06-10 12:37:09
       Time zone: America/New_York (EDT, -0400)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

Change the date/timestamp of a file - touch

Modify the file relative to its existing modification time

filename=MyFileName
touch -d "$(date -R -r $filename) - 2 hours" $filename # 2 hours before
touch -d "$(date -R -r $filename) + 2 hours" $filename # 2 hours later

See How can I change the date modified/created of a file?

Find binary file location

  • which - Display the full path of shell commands. See examples from cyberciti.biz.
$ which ls
/bin/ls
  • whereis - locate the binary, source, and manual page files for a command. See examples from cyberciti.biz.
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz
  • type -a
$ type -a ls
ls is aliased to `ls --color=tty'
ls is /bin/ls
  • locate. Use locate command mindfully. It is used to find the location of files and directories. Note that locate does not search the files on disk rather it searches for file paths in a database. For example, the following command will search .png files over the system (not only the personal directory).
locate "*.png"
See How to use updatedb command as an ordinary user?, Use updatedb and locate to index files.

find: Find a file

-iname

Search by a file name

$ find . -iname '*.txt'  # -iname or -name is necessary

It also works for searching files on subdirectories.

$ find . -name transcripts.gtf
./RH_bio/transcripts.gtf
./dT_ori/transcripts.gtf
./dT_tech/transcripts.gtf
./dT_bio/transcripts.gtf
./RH_ori/transcripts.gtf
./RH_tech/transcripts.gtf

-mtime, -ctime, -atime argument

Find files modified in 10 days.

$ find . -ctime -10 # include subdirectories
.
./mediawiki-1.32.0.tar.gz
./d
./d/deepSurv.pdf

Find files modified in one day and contain string 'est'

$ find . -mtime -1 -exec grep --with-filename est {} \;

If the search directory is not the current directory, we need to add a forward slash to the directory name.

$ find ~/Desktop -iname '*.txt'  # Not working
$ find ~/Desktop/ -iname '*.txt' # Working

The following example shows we can list multiple search criteria. The “‑r” option in tar appends files to an archive. xargs is a handy utility that converts a stream of input (in this case the output of find) into command line arguments for the supplied command (in this case tar, used to create a backup archive).

find / -type f -mtime -7 | xargs tar -rf weekly_incremental.tar
gzip weekly_incremental.tar

What is the difference between mtime, atime and ctime?

  • mtime (modification time) indicates the time the contents of the file has been changed. Mind you, only the contents. Not the attributes.
  • ctime (change time) is the timestamp of a file that indicates the time that it was changed. Now, the modification can be in terms of its content or in terms of its attributes.
  • atime (access time) is the timestamp that indicates the time that a file has been accessed.

xargs

See Linux Programming

-exec COMMAND {} +

find . -exec grep chrome {} \;
# or
find . -exec grep chrome {} +
find will execute grep and will substitute {} with the filename(s) found. The difference between ; and + is that with ; a single grep command for each file is executed whereas with + as many files as possible are given as parameters to grep at once. The backslash before ; is to escape ; so linux won't interpret it directly.
  • Find files and execute something (google: find --exec)
$ find ./ -name "*.tar.gz" -exec tar zxvf {} \;

The following will find out the total file size of the 'accepted_hits.bam' file under all sub-directories.

find ./ -iname "accepted_hits*" -exec du -ch {} + | grep total$

where '-c' produces a grand total, and will substitute {} with the filename(s) found in -exec.

Application to backup

Delete files/directories older than XXX days

Avoid Permission Denied Messages

How to fix find command permission denied messages

  • Redirecting ALL standard error (not only permission denied error): 2>/dev/null.
find . -iname "data*.txt" -print 2>/dev/null
  • Focus on the 'permission denied' message: grep -v "Permission denied"
find / -name foo 2>&1 | grep -v "Permission denied"

grep: Find a file by searching contents

grep -r -i "Entering" ~/Downloads/R-3.0.0/

where -r means recursively searching the directory and -i means case insensitive.

Sometimes using -R is more effective because of the symbolic links issue.

$ grep -r -i phpmyadmin /etc/apache2/  # nothing returned
$ grep -R -i phpmyadmin /etc/apache2/
/etc/apache2/conf-enabled/phpmyadmin.conf:# phpMyAdmin default Apache configuration
...
/etc/apache2/conf-available/phpmyadmin.conf:# phpMyAdmin default Apache configuration
...

We can also display the row numbers for matches by using the -n parameter in grep.

# What variants appear in dbsnp
grep -n 'rs[0-9]' XXX.vcf

To exclude lines with a pattern, using the -v parameter.

# How many variant were called
grep -v "^#" XXX.vcf | head

To show only matched filenames, using the -l parameter.

grep -l "iterator" *.cpp
# if we add '-n', the '-n' option won't work.

To search with certain file extensions, use --include argument; see this post.

grep -r -i --include \*.h --include \*.cpp KEYWORD ~/path[12345]  
# escape with \ just in case you have a directory with asterisks in the filenames

If the pattern is saved in a file, use the -f parameter

grep -f PATTERNFILE INPUTFILE

If there are two keywords, use the following

$ grep "begin\|completed" --color swarm_58606147_0.o  # needs an escape
begin 2018-01-12 14:46:05
alignment is completed 2018-01-12 16:45:24
marking duplication is completed 2018-01-12 17:52:01
assign read group is completed 2018-01-12 18:22:49
indel re-alignment is completed 2018-01-12 19:29:32
BQSR is completed 2018-01-12 22:26:22
GATK is completed 2018-01-12 23:43:3
$ egrep "begin|completed" --color swarm_58606147_0.o # no need an escape if we use extended regular expressions

We can use R to compute the time spent in each step; see Dealing with dates.

Check https://www.howtoforge.com/tutorial/linux-grep-command/ for more examples

  • Using grep to search only for words ("-w" option)
  • Using grep to search two different words (egrep -w 'word1|word2' /path/to/file)
  • Count line for matched words ("-c" option)
  • Grep invert match ("-v" option)
  • How to list only the names of matching files ("-l" option)

GUI

A GUI version of a tool to search files is searchmonkey (open source, Linux, Windows). On Ubuntu, we install it by

sudo apt-get install searchmonkey

It is also useful to change the settings so we can click a filename and open it in the desired text editor. To do that, go to Settings -> Preferences -> System Call -> Text Editor. I enter 'geany' since I want to use geany to open my C programs. Note. the v2.0 source code needs to be built using i386 gcc library and Qt 4.8.x. Still, I cannot get rid of some errors coming from the source code.

Summary of find and grep commands

Command Examples
find find [DIRECTORY] -iname '*.txt'

find [DIRECTORY] -maxdepth 2 -iname *.php

find -name '*.php' -o -name '*.txt' # OR operator

grep grep -r -i "check_samtools" DIRECTORY/

dpkg -l libgtk* | grep '^i'

Count number of columns: awk

The following command shows the number of columns for the first few rows of a text file.

head MYFILE | awk '{ print NF}'

head MYFILE | awk -F '\t'  '{ print NF}'

Count number of rows in a file: wc

wc -l MYFILE

The source code of wc (or any Linux command) can be found by using this method

brb@brb-T3500:~/Downloads$ which wc
/usr/bin/wc
brb@brb-T3500:~/Downloads$ dpkg -S /usr/bin/wc
coreutils: /usr/bin/wc
brb@brb-T3500:~/Downloads$ sudo apt-get source coreutils
[sudo] password for brb: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 12.3 MB of source archives.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main coreutils 8.21-1ubuntu5.1 (dsc) [1,635 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main coreutils 8.21-1ubuntu5.1 (tar) [12.3 MB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main coreutils 8.21-1ubuntu5.1 (diff) [31.6 kB]
Fetched 12.3 MB in 22s (559 kB/s)                                              
gpgv: Signature made Tue 13 Jan 2015 10:33:04 PM EST using RSA key ID 9D8D2E97
gpgv: Cannot check signature: public key not found
dpkg-source: warning: failed to verify signature on ./coreutils_8.21-1ubuntu5.1.dsc
dpkg-source: info: extracting coreutils in coreutils-8.21
dpkg-source: info: unpacking coreutils_8.21.orig.tar.gz
dpkg-source: info: applying coreutils_8.21-1ubuntu5.1.diff.gz

As we can see from the coreutils-8.21/src directory, there are over 100 C programs including <cat.c>, <chmod.c>, <cp.c>, ...<wc.c>.

Print certain rows/lines of a text file

The following example will print out lines 10 to 60 of FILENAME.

sed -n '10,60p' FILENAME

Or to print out line 60,

sed -n '60p' FILENAME

It seems this method is not as fast as I expected. For example, the tail command will immediately print out the result without waiting!

output colored console to html

Use ansi2html.sh. It only requires gawk.

  1. Use wget to download it
  2. sudo apt-get install gawk
  3. chmod +x ansi2html.sh
  4. colordiff file1 file2 | ./ansi2html.sh > diff.html

using a the result of a diff in a if statement

ls -lR $dir > a
ls -lR $dir > b

DIFF=$(diff a b) 
if [ "$DIFF" != "" ] 
then
    echo "The directory was modified"
fi

Another example

if [ "$(diff file1.html file2.html)" == "" ]; then echo Same; else echo Different; fi

Prompt

Colored prompt

For example, the following code will change the prompt to a light blue color. NOTE that we need ∖[ and ∖] in order to avoid a problem of miscalculating the cursor's starting position.

# blue   
export PS1='\[\e[1;34m\]\u@\h:\w\$ \[\e[0m\]'     # bright blue (good)
export PS1='\[\e[0;34m\]\u@\h:\w\$ \[\e[0m\]'     # darker blue

# yellow
export PS1='\[\e[1;33m\]\u@\h:\w\$ \[\e[0m\]'     # bright yellow
export PS1='\[\e[0;33m\]\u@\h:\w\$ \[\e[0m\]'     # dark yellow (good)

# red
export PS1='\[\e[1;31m\]\u@\h:\w\$ \[\e[0m\]'     # bright red
export PS1='\[\e[0;31m\]\u@\h:\w\$ \[\e[0m\]'     # dark red (good)

# green
export PS1='\[\e[1;32m\]\u@\h:\w\$ \[\e[0m\]'     # bright green
export PS1='\[\e[0;32m\]\u@\h:\w\$ \[\e[0m\]'     # dark green

# cyan
export PS1='\[\e[1;36m\]\u@\h:\w\$ \[\e[0m\]'     # bright cyan
export PS1='\[\e[0;36m\]\u@\h:\w\$ \[\e[0m\]'     # dark cyan (good)

# purple
export PS1='\[\e[1;35m\]\u@\h:\w\$ \[\e[0m\]'     # bright purple (good)
export PS1='\[\e[0;35m\]\u@\h:\w\$ \[\e[0m\]'     # dark purple

Ps1tweak.png

To make a permanent change, we can add the line to ~/.bashrc file and (is it necessary) un-comment the following line

force_color_prompt=yes


Some of my settings in .bashrc file

# Office Linux Mint, bright blue, display current time
# Example: 12:45PM ~/Downloads$
PS1="\[\033[1;34m\]\$(date +%H:%M%p) \w$\[\033[0m\] "

# Biowulf and Helix, dark yellow
# Example: biowulf:~/R$
PS1='\[\e[0;33m\]\h:\w\$ \[\e[0m\]'
alias nano="nano -c --softwrap"

Add a timestamp to your Bash prompt

PS1 Prompt
default brb@p45t:~/Downloads$
PS1='[\D{%F %T}] \u@\h \W\$ ' [2016-07-08 16:56:48] brb@brb-P45T-A ~/Downloads$
PS1="\[\033[1;34m\]\$(date +%H:%M%p) \w$\[\033[0m\] " 10:54AM ~/Downloads$
From here, we can skip %F (not showing the date), \W (not showing the current directory) and change %T to %H:%M (not showing seconds).

To the right hand side/Aligned to right and zsh

Proxy

The 15 Best Web Proxies for Geo-Blocked Content and Online Privacy

Listen to pandora in Europe: install squid proxy

http://www.cyberciti.biz/faq/access-pandora-radio-using-proxy-server-outside-usa/

Interestingly, the firefox connection settings should choose HTTP Proxy instead of 'SOCKS host'.

scp

file path with spaces

Use double quotes around the full path and a backslash to escape any space.

scp [email protected]:"web/tmp/Master\ File\ 18\ 10\ 13.xls" .

Copy multiple files

scp your_username@domain:~/\{foo.txt,bar.txt\} .

Some uses double quotes around the files with the space character to separate files but it does not work when I try to copy files from biowulf to mac.

Recursive copying

Use -r parameter.

Preserve permissions and modes

Use -p parameter.

scp files through one intermediate host

http://stackoverflow.com/questions/9139417/how-to-scp-with-a-second-remote-host

The following command is tested.

scp -o 'ProxyCommand ssh user@remote1 nc %h %p' user@remote2:path/to/file .

A second method which is useful for ssh and scp commands

$ ssh -L 9999:host2:22 user1@host1 # leave the terminal
# Open a new terminal
$ scp -P 9999 fileName user2@localhost:/path/to/dest/fileName   # transfer from local to remote. Note: Upper P.
$ scp -P 9999 user2@localhost:/path/to/source/fileName fileName # transfer from remote to local. Note: Upper P.
# If we only want to use ssh
$ ssh -p 9999 user2@localhost # Note: lower p.

scp with non-standard port: -P (capital)

Use -P argument.

scp -P 23 myfile user@remoteip:

scp or ssh without password

Steps:

  1. Verify that local-host and remote-host is running openSSH (ssh -V)
  2. Generate key-pair on the local-host using ssh-keygen (Enter a passphrase here, do not leave it empty. A passphrase should be at least several words long, something you can easily remember. It's a bad idea to use a single word as a passphrase.)
  3. Install public key on the remote-host
  4. Give appropriate permission to the .ssh directory on the remote-host (chmod 755 ~/.ssh; chmod 644 ~/.ssh/authorized_keys)
  5. Login from the local-host to remote-host using the SSH key authentication to verify whether it works properly
  6. Start the SSH Agent on local-host to perform ssh and scp without having to enter the passphrase several times (ssh-agent $SHELL)
  7. Load the private key to the SSH agent on the local-host (ssh-add, need to enter the passphrase 1 time only)
  8. Perform SSH or SCP to remote-home from local-host without entering the password. It works for all remote machines containing the key from local-local.

Another option is to use ssh -i IDENTITY_FILE. See superuser.com.

ssh with password on the command line

Install sshpass utility. See https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password

SSH

Best security practices

Top 20 OpenSSH Server Best Security Practices

  1. Use SSH public key based login
  2. Disable root user login
  3. Disable password based login
  4. Limit Users’ ssh access
  5. Disable Empty Passwords
  6. Use strong passwords and passphrase for ssh users/keys
  7. Firewall SSH TCP port # 22
  8. Change SSH Port and limit IP binding
  9. Use TCP wrappers (optional)
  10. Thwart SSH crackers/brute force attacks such as using fail2ban and DenyHosts software
  11. Rate-limit incoming traffic at TCP port # 22 (optional)
  12. Use port knocking (optional)
  13. Configure idle log out timeout interval
  14. Enable a warning banner for ssh users
  15. Disable .rhosts files (verification)
  16. Disable host-based authentication (verification)
  17. Patch OpenSSH and operating systems
  18. Chroot OpenSSH (Lock down users to their home directories)
  19. Disable OpenSSH server on client computer
  20. Bonus tips from Mozilla

Install OpenSSL

How to Install the latest OpenSSL version from Source on Linux

Install ssh client

sudo apt install openssh-client

Way to avoid ssh connection timeout and ~/.ssh/config

Put the following in your ~/.ssh/config.

Host remotehost
  HostName remotehost.com
  Port 4242
  User abcd
  ServerAliveInterval 240
  IdentityFile "~/.ssh/id_rsa"

After that we can run ssh remotehost.

To enable it for all hosts use:

Host *
  ServerAliveInterval 240

Also make sure to run chmod 600 ~/.ssh/config

Change to a different port

$ sudo nano /etc/ssh/sshd_config  # looking for the line containing port 
$ sudo service ssh restart # tested on Ubuntu 14.04

Remember to change the Router settings.

On the client PC, use ssh USERNAME@HOSTNAME -p NEWPORT for a connection.

For security reason, use the port < 1024 (privileged ports and can only be opened by root)

ssh alias

  • Using linux's alias; eg put the following inside ~/.bashrc
alias sshnokey='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 

With this trick, ssh and scp (scp alias_name:Downloads/myfile .) work perfectly.

Modify ~/.ssh/config

Host *
  ServiceAliveInterval 120
  ServiceAliveCountMax 30

Host your-alias_name
  User username
  HostName remote.sshserver.com
  Port 50001
  IdentifyFile ~/.ssh/id_file
  ServiceAliveInterval 120

Host work
  User abcde
  HostName work.workserver.com
  ServiceAliveCountMax 5
  StrictHostKeyChecking yes

Running commands on a remote host

ssh user@host 'COMMANDS'

ssh user@host "command1; command2; command3"

COMMANDS="command1; command2; command3"
ssh user@host "$COMMANDS"

A practical example

#!/bin/bash

IP_LIST="192.168.0.1 192.168.0.5 192.168.0.9"
USER="test"

for IP in $IP_LIST;
do
  utime=$(ssh ${USER}@${IP} uptime  | awk '{ print $3 }' )
  echo $IP uptime:  $utime
done

Disable root log in

Modify /etc/ssh/sshd_config. Change this line:

#PermitRootLogin yes

to

PermitRootLogin no

and run /etc/init.d/sshd restart.

However, that line in my Ubuntu is

PermitRootLogin without-password

According to this post, “without-password” means password authentication is disabled for root.

ssh log files

It is also helpful to check /etc/hosts.allow and /etc/hosts.deny for any possible wrong configuration.

Note that auth.log can show ssh security attacks.

$ grep sshd /var/log/auth.log
Feb 19 11:04:12 phenom sshd[16922]: Failed password for root from 92.62.131.23 port 49383 ssh2
Feb 19 11:04:12 phenom sshd[16922]: Received disconnect from 92.62.131.23: 11: Bye Bye [preauth]
Feb 19 11:04:14 phenom sshd[16924]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=92.62.131.23  user=root

Feb 19 11:04:36 phenom sshd[16998]: Invalid user enea from 113.160.227.93
Feb 19 11:04:36 phenom sshd[16998]: input_userauth_request: invalid user enea [preauth]
Feb 19 11:04:37 phenom sshd[16998]: pam_unix(sshd:auth): check pass; user unknown
Feb 19 11:04:37 phenom sshd[16998]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=113.160.227.93 
Feb 19 11:04:39 phenom sshd[16998]: Failed password for invalid user enea from 113.160.227.93 port 36090 ssh2
Feb 19 11:04:39 phenom sshd[16998]: Connection closed by 113.160.227.93 [preauth]
Feb 19 11:05:11 phenom sshd[17060]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:05:55 phenom sshd[17353]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:06:38 phenom sshd[17732]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:07:20 phenom sshd[17850]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:07:40 phenom sshd[17874]: refused connect from 221.194.47.221 (221.194.47.221)
Feb 19 11:08:01 phenom sshd[17955]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:08:41 phenom sshd[18118]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:09:22 phenom sshd[18280]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:10:02 phenom sshd[18353]: Invalid user support from 103.89.89.223
Feb 19 11:10:02 phenom sshd[18353]: input_userauth_request: invalid user support [preauth]
Feb 19 11:10:02 phenom sshd[18353]: pam_unix(sshd:auth): check pass; user unknown
Feb 19 11:10:02 phenom sshd[18353]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=103.89.89.223 
Feb 19 11:10:03 phenom sshd[18424]: refused connect from 58.218.198.170 (58.218.198.170)
Feb 19 11:10:04 phenom sshd[18353]: Failed password for invalid user support from 103.89.89.223 port 54218 ssh2
Feb 19 11:10:05 phenom sshd[18353]: fatal: Read from socket failed: Connection reset by peer [preauth]
Feb 19 11:10:07 phenom sshd[18425]: Did not receive identification string from 103.89.89.223
Feb 19 11:10:17 phenom sshd[18443]: Address 113.160.227.93 maps to static.vnpt.vn, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

DenyHosts

Note that denyhosts package is no longer available in Ubuntu 14.04, 16.04 now. We can install install from its source DenyHosts-2.6.tar.gz.

Procedures: follow the README.txt file.

Log in history: last command

The following command also shows how long a user has been logged in.

last <username> | less

w/who can show who (and when) are currently logging in.

Generate a strong password

5 Ways To Generate A Random/Strong Password In Linux Terminal: pwgen, openssl, gpg, mkpasswd, makepasswd, ...

Put in your ~/.bashrc. See Top 20 OpenSSH Server Best Security Practices.

$ genpasswd() {
	local l=$1
       	[ "$l" == "" ] && l=20
      	tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
$ genpasswd 16

login banners/messages

https://kerneltalks.com/tips-tricks/how-to-configure-login-banners-in-linux/

There are two types of banners you can configure.

Banner message to display before user log in (configure in file of your choice eg. /etc/login.warn) Banner message to display after user successfully logged in (configure in /etc/motd)

ssh -A: forwarding of the authentication agent connection

ssh key

SSH key is useful if you want a password-less login to a remote system. Some useful resources:

Also there are different kinds of keys (see for example <~/.ssh/known_hosts file>): RSA, DSA and ECDSA (newer). They're keys generated using different encryption algorithms. See SSH key-type, rsa, dsa, ecdsa, are there easy answers for which to choose when?

The steps are

  • Check if there is an existing key
ls -al ~/.ssh
  • Create a new RSA key pair:
ssh-keygen -t rsa
ssh-keygen -f ~/.ssh/personalid -C "bitbucket"

where the comment 'bitbucket' will appear at the end of <~/.ssh/personalid> file.

  • Copy the public key to a remote host ([email protected]) over ssh. The current user (eg brb) and the remote user (eg git)have not any relationship (they most likely have different user names):
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] # this will 'append' the key to the remote-host’s .ssh/authorized_key.

Or (may not work:()

cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
  • Delete the authorized key. Open the text file '.ssh/authorized_keys' and remove the offending lines.
  • Test if this is working by trying 'ssh [email protected]'.
  • To disable the password for root login. Type sudo nano /etc/ssh/sshd_config
PermitRootLogin without-password

Then run the following to put the changes into effect:

reload ssh
# Or service ssh restart

If we like to ask all users to use key-based to log in, we can modify the line

PasswordAuthentication no

in sshd_config.

Multiple ssh keys

<Method 1> If we want to use a specific key in ssh, use

ssh -i ~/.ssh/xxx_id_rsa [email protected]

<Method 2> Another way is to use ssh-add & ssh-agent to manager your keys. ssh-agent keeps your key in its memory and pulls it up whenever it is asked for it.

$ ssh-keygen -f ~/.ssh/personalid -C "bitbucket"
$ eval $(ssh-agent -s)       # Ensure ssh-agent is enabled:
$ ssh-add ~/.ssh/personalid  # ssh-add program will ask you for your passphrase
$ ssh-add -l

<Method 3> <~/.ssh/config> file.

ssh key management

Copy ssh keys to another computer

http://askubuntu.com/questions/134975/copy-ssh-private-keys-to-another-computer

$ chown brb:brb ~/.ssh/id_rsa*
$ chmod 600 ~/.ssh/id_rsa
$ chmod 644 ~/.ssh/id_rsa.pub

If we do not change the permission correctly in <id_rsa>, we will get a warning: Unprotected private key file. Permissions 0664 for '/home/USERNAME/.ssh/id_rsa' are too open.

Preserve ssh keys when upgrading computers

ls -l /etc/ssh/*key* > ~/key_list  # optional
mkdir ~/serverkeys && sudo cp -p /etc/ssh/*key* ~/serverkeys/ # back up, -p will preserve mode, ownership and timestamps
sudo cp -p ~/serverkeys/*key* /etc/ssh  # copy back
ls -l /etc/ssh/*key* | diff - ~/key_list # optional

If diff produces no output, you're finished.

Pay attention to the permissions. All the /etc/ssh/* files should be owned by root:root, with 644 permissions except for those that end in *key, which should be 600.

udooer@udoo:~$ ls -l /etc/ssh/*key*
total 32
-rw------- 1 root root  668 Dec  8 14:43 ssh_host_dsa_key
-rw-r--r-- 1 root root  599 Dec  8 14:43 ssh_host_dsa_key.pub
-rw------- 1 root root  227 Dec  8 14:43 ssh_host_ecdsa_key
-rw-r--r-- 1 root root  171 Dec  8 14:43 ssh_host_ecdsa_key.pub
-rw------- 1 root root  399 Dec  8 14:43 ssh_host_ed25519_key
-rw-r--r-- 1 root root   91 Dec  8 14:43 ssh_host_ed25519_key.pub
-rw------- 1 root root 1679 Dec  8 14:43 ssh_host_rsa_key
-rw-r--r-- 1 root root  391 Dec  8 14:43 ssh_host_rsa_key.pub

udooer@udoo:~$ cd /etc/ssh; sudo tar -czvf ~/Downloads/sshkeys.tar.gz *key*
-rw------- root/root       668 2017-12-08 14:43 ssh_host_dsa_key
-rw-r--r-- root/root       599 2017-12-08 14:43 ssh_host_dsa_key.pub
-rw------- root/root       227 2017-12-08 14:43 ssh_host_ecdsa_key
-rw-r--r-- root/root       171 2017-12-08 14:43 ssh_host_ecdsa_key.pub
-rw------- root/root       399 2017-12-08 14:43 ssh_host_ed25519_key
-rw-r--r-- root/root        91 2017-12-08 14:43 ssh_host_ed25519_key.pub
-rw------- root/root      1679 2017-12-08 14:43 ssh_host_rsa_key
-rw-r--r-- root/root       391 2017-12-08 14:43 ssh_host_rsa_key.pub

udooer@udoo:~/$ cd /etc/ssh; sudo tar -xzvf ~/Downloads/sshkeys.tar.gz  

Disable SSH host key checking

ssh -o UserKnownHostsFile=/dev/null \
    -o StrictHostKeyChecking=no \
     USERNAME@DOMAIN

To disable the checking for all hosts, in your ~/.ssh/config (if this file doesn't exist, just create it):

Host *
    StrictHostKeyChecking no

Or for certain domains https://superuser.com/a/433621

Host *.mydomain.com 
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  User foo
  LogLevel QUIET

Handling the ssh key change when connecting to a remote machine

An article from cybercitz.biz.

  • Method 1. Remove the key using ssh-keygen -R command.
$ ssh-keygen -R {server.name.com}
$ ssh-keygen -R {ssh.server.ip.address}
$ ssh-keygen -R server.example.com
$ ssh-keygen -f "/home/$USERNAME/.ssh/known_hosts" -R "xxx.xxx.x.xx"
  • Method 2. Add correct host key in /home/user/.ssh/known_hosts
  • Method 3. Just delete the known_hosts file If you have only used one ssh server

SSH Port forwarding

  • Chapter 9 Port forward. SSH Mastery OpenSSH, PuTTY, Tunnels and Keys by Michael W. Lucas

Verizon Quantum Gateway Router

User guide p98. Click 'Advanced' button first.

  • Source port: Any (this is the key)
  • Destination Ports: the port you want to use (connect from outside)
  • Forward to Port: Same as incoming port or the port used in the local computer

What is tunnel

https://www.howtogeek.com/299845/why-is-a-network-tunnel-called-a-tunnel/. A tunnel provides a direct path that avoids some type of complexity you would otherwise have to deal with.

Local port forwarding

This port forwarding involves three computers (local, remote/application server, host/secure shell server). If the remote is the same as the host, it will be reduced to involving 2 computers.

For example, we like to access home's router (192.168.1.1) information from an outsider computer. Suppose the host 'hostname' is one computer in the home network and it can be accessed from outside world.

Another example is if we want to use Jupyter running on a remote machine from local browser.

# ssh -L localPort:remoteIP:remotePort username@hostname
ssh -L 8080:192.168.1.1:80 username@hostname
ssh -i someKey.pem -L 443:127.0.0.1:8888 username@hostname

The -L option specifies local port forwarding. In this case, port 8080 on the local machine was forwarded to port 80 on the remote machine. For the duration of the SSH session, pointing your browser at http://localhost:8080/ would send you to http://192.168.1.1/ as if you are in the same local network of 'hostname'.

The reason it works is because the 'ssh' trick. In addition to being able to make yourself in the home network environment, the traffic on http://localhost:8080 is encrypted too.

Note that this forwarding uses port 8080 on the client rather than port 80. Binding to port 80 would require using root privileges every time we SSH.

To stop the ssh session, use ps -ef to find the process id and kill it.

Remote port forwarding (Reverse port forwarding)

This is most useful in situations where you have a machine which isn't publicly accessible from the internet, but you want others to be able to access a service on this machine. In this case, if you have SSH access to a remote machine which is publicly accessible on the internet, you can set up a reverse port forward on that remote machine to the local machine which is running the service.

ssh -R 8000:localhost:80 user@REMOTE_MACHINE

This will forward port 8000 on the remote machine to port 80 on the local machine. Using this method, if you browse to http://localhost on the remote machine, you will actually connected to a web server running on port 8000 of the local machine.

Example 2: Suppose you have two machine

  • machine A (userA): under firewall. cannot be directly accessed (like corporate machines)
  • machine B (userB): local machine (like home machines)

Our goal is to access machine A directly from machine B.

We can run the following on the machine A

# ssh -R remoteIP:remoteport:localIP:localport hostname
# ssh -R remoteport:localIP:localport hostname
ssh -R 2222:localhost:22 userB@machineB_IP
ssh -i /path/to/priv/key/id_rsa -f -N -R 2222:localhost:22 userB@machineB_IP

Then we can access machine A from machine B by

ssh -p 2222 userA@localhost

If you want remote port forwarding configured every time you connect to a host, use the RemoteForward option in ssh_config .

LocalForward server-IP:server-port client-IP:client-port

'D'ynamic port forwarding, SOCKS proxy, bypass blocked websites from work computer

ssh -D 4096 user@remoteip
ssh -D 4096 -p 23 user@remoteip

This will require you to enter the password and leave you in the remote machine. If a nonstandard port is required, we can use -p option.

Now in the firefox, we need to go to Edit -> Preferences -> Advanced -> Network tab -> Settings... Check 'Manual proxy configuration' (The default is 'Use system proxy settings') and enter 'localhost' for SOCKS (SOCKS5 by default) Host and '4096' for the Port. Don't enter 'localhost' in the HTTP Proxy.

Note that in addition to the Firefox, we can use

  • Chrome or chromium
  • SeaMonkey (seems better than Firefox since the form works better on 1024x600 resolution).
  • Brave browser does not support proxy

On Windows, we can use Putty. In short, in the left-hand panel, navigate through Connection > SSH > Tunnels. Enter 4096 in the Source Port box and select the Dynamic radio button. Click Add and “D4096″ will appear in the Forwarded Ports list. The setting in the firefox end is the same. See also my Windows wiki page.

Linux journal also put a video on youtube. We can use http://www.ipligence.com/geolocation to check the current location. The port number is 1080 in the example. The example actually also use '-N' option which means no interaction; i.e. ssh -N -D 1080 user@remoteip. So we won't see anything after we type our password. Once we want to stop SOCK proxy, we just need to hit Ctr+C on terminal.

Backgrounding OpenSSH Forwarding

Use the -N flag to tell ssh to not run anything, including a terminal, on the remote server, and the -f flag to tell ssh to go into the background on the client.

ssh -fNL 2222:localhost:22 user@remotehost &

By backgrounding this command, you get your original terminal back.

ssh through an intermediate server

Simple method is

$ ssh -tt vivek@Jumphost ssh -tt vivek@FooServer

Another method is to use ssh ProxyCommand to tunnel connections.

A third method is to

$ ssh -L 9999:host2:22 user1@host1  # leave this terminal 
# open a new terminal tab
$ ssh -p 9999 user2@localhost

Graphical way to display disk usage

For example, to use xdiskusage, we run apt-get install xdiskusage and launch it by xdiskusage ~/.

  • Ubuntu has a built-in program called "Disk Usage Analyzer". Just search it from Dash. Looks useful!

df : Display disk space

df -h
df -h -T  # show the 't'ype of the file system
df -h -t ext4 # show file systems of given type (ext4 in this example)
df -a     # show all file system (include ones that have a size of zero blocks)

df -h | grep -v snap # ignore snap partitions
df -h | grep -v loop

Note for the NTFS type, it will be reported as fuseblk by mount or df command.

Disk encryption

LUKS

rm command and trash can

Make “rm” Command To Move The Files To “Trash Can” Instead Of Removing Them Completely

du and ncdu : Display directory size with sorting and human readable

Use ncdu program (more interactive). Although it is a command line program, we can use the mouse to move through each directory to see its sub-directories.

ncdu can show the hidden directory size. This is useful. For example, ~/.local/share/Trash and ~/.singularity/docker can take a lot of space.

sudo apt-get install ncdu
ncdu

And the du method.

du -sh ~/*              # won't include hidden directories, Fast
du -h ~/ --max-depth=1  # include hidden directories, SLOW
du -h ~/ --max-depth=1 --exclude ".*" | sort -nr | cut -f2 | xargs -d '\n' du -sh
du -a -h ~/  # kilobytes will be used, '-a' is to see all files, not just directories.
du -a ~/ | sort -nr | head -n 10   # sort from the largest file size first

The --exclude is to hide hidden directories, '-n' is to compare according to string numerical value, and '-r' is to reverse the result.

Note that the 'du' commands may be cheating. See the following screenshot.

DiskUsage.png

The discrepancy is explained by 'sector'. See http://askubuntu.com/questions/122091/difference-between-filesize-and-size-on-disk.

$ sudo dumpe2fs /dev/sda1 | grep -i "block size"
dumpe2fs 1.41.14 (22-Dec-2010)
Block size:               4096

To show a file size in terms of blocks, we can use

ls -s

So for example, if a file takes 150 blocks, and if a block takes 4096 bytes, then the file takes 150*4096/1024 KB on disk.

Apache benchmark (ab) testing

ab -n 100 -c 10 http://taichimd.us/

Monitor progress of copying/transferring files: pv

How to monitor progress of Linux commands using PV and Progress utilities

# Method 1: rsync
rsync --progress -a sourceDirectory destinationDirectory
rsync --info=progress2 source dest

# Method 2: pv
sudo apt-get install pv
## copy a single file
pv inputfile > outputfile

## multiple files or directories 
tar c sourceDirectory | pv | tar x -C destinationDirectory

## https://stackoverflow.com/a/26226261
docker save <image> | bzip2 | pv | \
     ssh user@host 'bunzip2 | docker load'

rsync

Dry run

rsync -avn master.bioconductor.org::release

Copy large file

If we need to copy large file (say > 4GB), we shall

  1. format USB drive to NTFS (exFat seems not work)
  2. Run rsync --progress source dest
  3. Run sync

The last step (rsync) is important. We can use sudo iotop to check if rsync is finished or not.

speed comparison of cp vs rsync

BigData basic: copy & delete folder containing large number of files

Incremental backup: --link-dest

rsync -aP --link-dest=PATHTO/$PREVIOUSBACKUP $SOURCE $CURRENTBACKUP

rsync with exclude files/directories

See http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/. The key is excluded files are relative to the current directory even we specify the absolute path. For example /path1/path2/file does not mean the file is located under /path1/path2; it means the file is located under ./path1/path2.

rsync -avz --exclude '/path1/path2/file' source/ destination/

We add add multiple --exclude to exclude more files/directories.

rsync to exclude hidden files/directories

--exclude=".*"  # exclude both hidden files and directories
--exclude ".*"  # same as above

--exclude ".*/" # exclude hidden directories ONLY

--exclude ".DS_Store"

--exclude ".git" # exclude .git directory ONLY; relative to the directory to be synchronized.

rsync with -a option

The -a flag in there stands for “archive,” and it’s important to include. It makes sure that the sync command is recursive (meaning any sub-folders and files inside of old_movies are copied too) and it’s important for preserving all of those modification dates, symbolic links, permissions, and other goodies we talked about earlier.

rsync with non-standard port

Use -e option

rsync -avz -e "ssh -p 23" mydir user@remoteip:

rsync with progress bar

Use --progress option.

rsync -avz --progress file1 file2

The 'rsync' command works on transferring files local to local too.

Or it is better to use -P option which is the same as --partial --progress. When it is used you’ll get a progress dialog at the command line that shows you which file is currently transferring, what percentage of that transfer is complete, and how many more files are left to check. As each file completes, you’ll see an ever-growing list of completed file transfers, which is great for making sure everything transfers successfully. It also allows you to easily resume suspended or interrupted transfers. Combined, you can see how it’ll show you which file was the last one to go, where it failed, and if it failed, give you the option to resume. It’s a pretty powerful combination.

rsync on Windows

Download and install command line rsync from http://www.rsync.net/resources/howto/windows_rsync.html. The website also provides a documentation. Some people are concern about the license issue. The website here provides a link to the free, old but usable version 4.0.5 which is newer than I tested v3.1.0.

Below are my note by using cwrsync v3.1.0 installer got from http://www.rsync.net.

cd C:\Program Files (x86)\cwRsync\bin
ssh-keygen -t rsa -N ''
rsync -av "/cygdrive/c/Users/brb/.ssh/id_rsa.pub" [email protected]:.ssh/authorized_keys

rsync -av "/cygdrive/c/Users/brb/Downloads/cytokineMC.txt" [email protected]:Downloads/

sudo

How to Keep ‘sudo’ Password Timeout Session Longer in Linux

http://www.tecmint.com/set-sudo-password-timeout-session-longer-linux/

How to run multiple commands in sudo

https://www.cyberciti.biz/faq/how-to-run-multiple-commands-in-sudo-under-linux-or-unix/

How do I run specific sudo commands without a password?

https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password

Text browser

Links

Alternative browsers

Chrome or Chromium

Install the latest version of chromium.

sudo apt install curl git
git clone https://github.com/scheib/chromium-latest-linux.git
cd chromium-latest-linux
./update-and-run.sh

# next time
./run.sh

To use a proxy server,

chromium --proxy-server="10.130.5.180:3128"

Vivaldi

Based on Chromium.

A sidebar provides a place to quickly access your bookmarks, downloads, and history. Less standard is the built-in ability to write and save notes, also available in the sidebar.

While cool, Vivaldi is also a proprietary browser.

The proxy setting is not found in the latest version. To use it,

$ vivaldi --proxy-server="127.0.0.1:8118"

To uninstall it, open the package manager to remove it.

Opera

Based on Chromium.

Like Chrome, Opera is closed source.

GNOME Web

There are browsers made specifically for Linux, and GNOME Web is the most mature of the bunch.

It looks and feels like a program intended to run on Linux.

Web lacks the kind of extensions you see on Chrome and Firefox (though ad-block does come built-in).

Eolie

Eolie is another browser built specifically for GNOME.

The URL bar shows a site’s title rather than the web address.

Brave - private, secure, support Chrome extensions

https://en.wikipedia.org/wiki/Brave_(web_browser)

The browser uses a fork of Electron, called Muon, designed with a focus on browser features. For example, it has support for Chrome extensions, and a higher level of security.

Lacks the in-browser proxy (even version 0.57)

Chromium版隱私瀏覽器Brave 0.57出爐了,要給你Chrome方便性但不回傳資料給Google, Brave browser moves to Chromium codebase, now supports Chrome extensions Dec 2018

Midori

Falkon and formally Qupzilla

QupZilla is a new and very fast QtWebEngine browser. It aims to be a lightweight web browser available through all major platforms.

Wikipedia. Download: only Windows and Linux binaries are available.

When I tested Falkon-3.0.1.AppImage - for 64-bit Linux on Mint 18.3, it gives an error

10:39AM ~/Downloads$ ./Falkon-3.0.1.AppImage 
QApplication: invalid style override passed, ignoring it.
Could not find QtWebEngineProcess

Filezilla

Keyboard shortcut. Especially, Alt+Down=Transfers the currently selected item to an item of the same name in the other pane.

The device is busy

brb@brb-P45T-A:~$ sudo umount /media/brb/TOSHIBA 
[sudo] password for brb: 
umount: /media/brb/TOSHIBA: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
brb@brb-P45T-A:~$ sudo umount /dev/sdc1
umount: /media/brb/TOSHIBA: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
brb@brb-P45T-A:~$ lsof /media/brb/TOSHIBA/
COMMAND  PID USER   FD   TYPE DEVICE   SIZE/OFF NODE NAME
VBoxSVC 5600  brb   18w   REG   8,33 4294967295    3 /media/brb/TOSHIBA/Windows 10.ova (deleted)
brb@brb-P45T-A:~$ kill -9 5600
brb@brb-P45T-A:~$ lsof /media/brb/TOSHIBA/
brb@brb-P45T-A:~$ sudo umount /dev/sdc1
brb@brb-P45T-A:~$ 
# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

Another handy one is:

umount -l /dev/sdwhatever

Kill a process and the pstree command

# find the PID
pgrep ProgramName
# Kill the ProgramName process
kill -9 PID

Another command is killall. For example, if Firefox is acting up (as Firefox will do from time to time) simply type killall firefox and it should kill the application completely.

In the rare circumstances that this doesn’t work you can always type xkill and then click on the window that won’t close; this will completely close a given window immediately. See this.

How To kill An Inactive OR Idle SSH Sessions. The pstree -p command can show a tree diagram of all the processes.

pkill command. For example, pkill gedit.

Format a USB drive

Easily Format A USB Flash Drive On Ubuntu 18.04 Using USB Stick Formatter (mintStick deb & source)

This is a GUI application. After the installation, search "USB Stick Formatter".

For some reason, it doesn't have the 'exFAT' option. My system has installed exFAT drivers. This post said installing exFAT related drivers only helps reading/writing but not formatting.

If I want exFAT format, I need to use the USB Stick Formatter to format the drive first (for example fat32), plug it and then using the following command to format it to exFAT.

sudo mkfs.exfat -n Staples /dev/sdc1

Note that fdisk or sfdisk cannot differentiate NTFS/exFAT. But cfdisk or GParted can.

sudo cfdisk /dev/sdX

Create an ext3 file system on a USB flash drive

umount /dev/sdb1   (depending on the device of course)
sudo mkfs.ext3 /dev/sdb1
sudo e2label /dev/sdb1 usbdrive   (change the label)

We can create MS-DOS file system by

sudo mkfs.vfat /dev/sdb1

Add a new user with home directory

adduser xxx

adduser is better than useradd since useradd does not create home directory and it does not even ask the password for new user. adduser will interactively ask user information.

To delete the user and home directory, use

deluser --remove-home xxx

To view the user information, type id USERNAME or cat /etc/passwd.

gzip with multi cores

Use pigz utility. It makes a lot of difference. For example for a 21GB file, gzip can't finish the job after 30 minutes. But pigz only took 7 minutes on a 12-core machine.

sudo apt-get install pigz
pigz -9 FILENAME   # compress & convert the file to FILENAME.gz

tar cf - paths-to-archive | pigz -9 -p 12 > archive.tar.gz

There is no need to use pigz to un-compress the file. gunzip is fast enough and only takes 4 minutes to decompress.

The '-9' (best compression) option does not make difference (6.6G vs 6.5G).

Compress a folder without full path name

Suppose we want to compress the folder ~/Documents and its subfolders. We want to include Documents folder name but not /home/brb/Documents name.

# Method 1. Include 'Documents' as the top folder name
cd ~/
tar -czvf tmp.tar.gz Documents
# Method 2. Mind the last dot. Not include 'Documents' as the top folder.
tar -czvf tmp.tar.gz -C /home/brb/Documents .

# Double check the tarball
tar -tzvf tmp.tar.gz

If we want to strip the upper directories when we uncompress a tar file, use --strip-components. For example, we can use --strip-components=1 to remove the Documents folder.

squashfs

squashfs is a heavy-compression based read-only filesystem that is capable of compressing 2 to 3 GB of data onto a 700MB. Linux liveCD are built using squashfs. These CDs make use of a read-only compressed filesystem which keeps the root filesystem on a compressed file. It can be loopback mounted and loads a complete Linux env. Thus when some file are required by processes, they are decompressed and loaded onto the RAM and used.

# create a squashfs file
sudo mksquashfs /etc test.squashfs 

# mount the squashfs file 
mkdir /mnt/squash
mount -o loop compressedfs.squashfs /mnt/squash
# you can acess the contents at /mnt/squashfs

# exclude files 
sudo mksquashfs /etc test.squashfs -e /etc/passwd /etc/shadow
# or specify a list of exclude files given in a file
cat excludelist  # /etc/passwd
sudo mksquashfs /etc test.squashfs -ef excludelist

List contents of tar.gz or tar.bz2

tar -tzvf myfile.tar.gz

tar -tjvf myfile.tar.bz2  # replace z with j

Extract files

Extract tar.gz or zip to a specified directory

tar xzvf XXXX.tar.gz -C DIRECTORY
# single or double quotes will give an error
#
# tar xzvf ~/Downloads/inSilicoDb_2.7.0.tar.gz -C "~/Downloads"
# tar: ~/Downloads: Cannot open: No such file or directory
# tar: Error is not recoverable: exiting now
# $ tar xzvf ~/Downloads/inSilicoDb_2.7.0.tar.gz -C '~/Downloads'
# tar: ~/Downloads: Cannot open: No such file or directory
# tar: Error is not recoverable: exiting now

unzip XXX.zip -d DIRECTORY

Extract gz file but keep the original gz file

gunzip -c x.txt.gz > x.txt

gunzip -c which simply writes the output stream to stdout

Extract .xz file

xz -d archive.xz

Extract tar.xz file

The bottomline is we don't need the 'z' parameter (used for gz ONLY but does not work for xz file) in the tar command for tar.xz files. And the method also works for tar.gz files. The argument '-f' means the archive file. Recall that the tar command can be used to store and extract files, so no default parameters.

tar xf archive.tar.xz
tar xf archive.tar.gz

Extract tar.bz2 file

tar -xjvf archive.tar.bz2  # replace z with j as we compare it to tar.gz file

How To Extract and Decompress a .bz2/.tbz2 File

See this article from cyberciti.biz.

bzip2 -d your-filename-here.bz2
# OR
bzip2 -d -v your-filename-here.bz2
# OR
bzip2 -d -k your-filename-here.bz2
# OR
bunzip2 filename.bz2

10 Basic Encryption Terms Everyone Should Know and Understand

https://www.makeuseof.com/tag/encryption-terms/

How to Encrypt and Decrypt Files and Directories Using Tar and OpenSSL

http://www.tecmint.com/encrypt-decrypt-files-tar-openssl-linux/

How to install and use 7zip file archiver

https://www.howtoforge.com/tutorial/how-to-install-and-use-7zip-file-archiver-on-ubuntu-linux/

Compare zip, tar.xz, tar.gz, 7z

The compression rate comparison is (from best to worst) 7z > tar.xz > tar.gz > zip.

For example, consider qt-everywhere-opensource-src-5.5.0 from http://download.qt.io/official_releases/qt/5.5/5.5.0/single/

  • zip 540M
  • tar.xz 305M
  • tar.gz 436M
  • 7z 297M

Extract one files from tar.gz

Extract a file called etc/default/sysstat from config.tar.gz tarball:

$ tar -zxvf config.tar.gz etc/default/sysstat

Noe that a new directory etc/default will be created under the current directory if it does not exist.

Wildcard based extracting

You can also extract those files that match a specific globbing pattern (wildcards). For example, to extract from cbz.tar all files that begin with pic, no matter their directory prefix, you could type:

$ tar -xf cbz.tar --wildcards --no-anchored 'pic*'

To extract all php files, enter:

$ tar -xf cbz.tar --wildcards --no-anchored '*.php'

remove leading directory components on extraction with tar

AVFS and Archivemount

If we want to extract certain files from a tarballj/archive, it is more efficient to use a virtual filesystem like AVFS. PS. for a large archive file, even extracting only a single file at the top directory it is terribly slow if we use the tar command directly.

Before we install the utility, let's look at the package dependecies of AVFS and Archivemount.

$ apt-cache showpkg archivemount
Package: archivemount
Versions: 
0.8.1-1 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages)
 Description Language: 
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages
                  MD5: d6302be9f06a91afa32326ab175e2086
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_i18n_Translation-en
                  MD5: d6302be9f06a91afa32326ab175e2086


Reverse Depends: 
  archivemount:i386,archivemount
Dependencies: 
0.8.1-1 - libarchive13 (0 (null)) libc6 (2 2.4) libfuse2 (2 2.8.1) fuse (2 2.8.5-2) archivemount:i386 (0 (null)) 
Provides: 
0.8.1-1 - 
Reverse Provides: 
brb@T3600 ~ $ apt-cache showpkg avfs
Package: avfs
Versions: 
1.0.1-2 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages
                  MD5: bce08fbc36fd7b8e3c454f36f0daf699
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_i18n_Translation-en
                  MD5: bce08fbc36fd7b8e3c454f36f0daf699


Reverse Depends: 
  avfs:i386,avfs
  worker,avfs
Dependencies: 
1.0.1-2 - libc6 (2 2.14) libfuse2 (2 2.8.1) fuse (0 (null)) unzip (0 (null)) zip (0 (null)) arj (0 (null)) lha (0 (null))
 zoo (0 (null)) rpm (0 (null)) p7zip (16 (null)) p7zip-full (0 (null)) cdparanoia (0 (null)) 
wget (0 (null)) avfs:i386 (0 (null)) 
Provides: 
1.0.1-2 - 
Reverse Provides:

Install it now.

sudo apt-get install avfs
mountavfs
# Assume MyFile.tar.gz exists in the current directory
ls ~/.avfs/$PWD/MyFile.tar.gz#       
# Alternatively, browse the content in Nautilus, but you need to add a trailing # character by hand to the path 
# (Ctrl-L to access the address bar).
...
cat ~/.avfs/$PWD/MyFile.tar.gz#/README
# another tarball
ls ~/.avfs/$PWD/MyFile2.tar.gz#       
umountavfs

For some reason, avfs sometimes does not work:( In this case, Ubuntu's Archive Manager does work. Maybe the file is too large.

brb@T3600 ~/Downloads $ time ls ~/.avfs/$PWD/Homo_sapiens_UCSC_hg19.tar.gz#/
ls: cannot access /home/brb/.avfs//home/brb/Downloads/Homo_sapiens_UCSC_hg19.tar.gz#/nown	exact	1	SingleClassTriAllelic,InconsistentAlleles	2	1000GENOMES,SSMP,	2	A,T,	22.000000,2274.000: Input/output error
ls: cannot access /home/brb/.avfs//home/brb/Downloads/Homo_sapiens_UCSC_hg19.tar.gz#/chr12	25482890	rs544684287	G	A	0	.	molType=genomic;class=single
chr12	25482914	rs558575390	T	G	0	.	m: Input/output error
000,?0.999500,0.000500,??797?chr3?27877637?27877638?rs1478557?0?+?G?G?A
4?rs555100828?0?+?T?T?C
76?chr2?103777623?103777624?rs181283085?0?+?A?A?A
chr12?25482890?rs544684287?G?A?0?.?molType=genomic;class=single?chr12?25482914?rs558575390?T?G?0?.?m
G?A
Homo_sapiens
nown?exact?1?SingleClassTriAllelic,InconsistentAlleles?2?1000GENOMES,SSMP,?2?A,T,?22.000000,2274.000
README.txt
T?C

real	25m51.340s
user	0m0.000s
sys	0m0.003s
brb@T3600 ~/Downloads $ ls ~/.avfs/$PWD/annovar.latest.tar.gz#/
annovar

For archivemount, see Cool User File Systems: ArchiveMount

archivemount files.tgz mntDir
umount mntDir

Show folder size for one level only

du --max-depth=1 -h

The graphical tool is called Disk Usage Analyze which is already available on Ubuntu.

Soft link

ln -s /full/path/of/original/file /full/path/of/soft/link/file

Understanding Linux Links Part 1 & Part 2

Self-hosted servers

  • https://github.com/Kickball/awesome-selfhosted This is a list of Free Software network services and web applications which can be hosted locally. Selfhosting is the process of locally hosting and managing applications instead of renting from SaaS providers.
  • Sovereign: A set of Ansible playbooks to build and maintain your own private cloud: email, calendar, contacts, file sync, IRC bouncer, VPN, and more.

DNSCrypt

DNS server

setup

DNSmasq (DNS + DHCP server)

Local forwarding server

dnsmasq program is running on my Ubuntu and Linux/Mint machines.

See nameserver 127.0.1.1 in resolv.conf won't go away!

$ ps -ef | grep -i dnsmasq

$ sudo netstat -anp | grep -i dnsmasq

Change DNS setting

Flush DNS cache

How to clear the DNS Cache?

Test if you are using OpenDNS

https://welcome.opendns.com/

Query DNS server

To list the current DNS servers used by my system,

Method 1:

# Ubuntu >= 15
$ nmcli dev show | grep 'IP4.DNS'
$ nmcli device show <interfacename> | grep IP4.DNS
# Ubuntu <= 14
$ nmcli dev list iface <interfacename> | grep IP4

Method 2:

$ cat /etc/resolv.conf

Another way is to use the R packages: gdns and dnsflare. More Options For Querying DNS From R with 1.1.1.1.

3 Ways to Check DNS Propagation Status

https://www.makeuseof.com/tag/check-dns-propagation-status/

Email server

POP, IMAP and Exchange

POP works by contacting your email service and downloading all of your new messages from it. Once they are downloaded onto your PC or Mac, they are deleted from the email service.

IMAP allows you to access your email wherever you are, from any device. When you read an email message using IMAP, you aren't actually downloading or storing it on your computer; instead, you're reading it from the email service. As a result, you can check your email from different devices, anywhere in the world: your phone, a computer, a friend's computer.

Exchange offers the same syncing capabilities as IMAP, plus much more. Exchange is a Microsoft product, giving you the ability to still use Outlook as your email service and benefit from Exchange functionality.

Configure Postfix to use Gmail as a Mail Relay

https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/

Note one comment says to use App Passwords instead of the regular google account password.

How to Build an Email Server on Ubuntu Linux

Send from google emails on Ubuntu

Change your google account to use less secure authentication. Otherwise it won't work and you will receive an email with a subject "Critical security alert" after you try to send out an email.

sudo apt install mailutils
sudo nano /etc/postfix/main.cf   # no account information
sudo nano /etc/postfix/sasl_passwd # contains account information
cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/cacert.pem
sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo apt-get install --reinstall postfix
sudo /etc/init.d/postfix restart
sudo /etc/init.d/postfix reload
echo "Test Email message body" | mail -s "Email test subject" [email protected] # works

We can actually send to other email accounts. For example, we can use mailR package to send emails in R

send.mail(from = "[email protected]",
  to = c("[email protected]"),
  replyTo = c("[email protected]"),
  subject = "Test",
  body = "test",
  smtp = list(host.name = "smtp.gmail.com", port = 465, 
              user.name = "yourname", passwd = "XX", ssl = TRUE),
  authenticate = TRUE,
  send = TRUE)

Webmail

Install WebMail Lite PHP based Webmail Client on Debian 9.1

sendemail package

sendEmail -f $USERNAME -s smtp.gmail.com:587 \
            -xu $USERNAME -xp $PASSWORD -t $USERNAME \
            -o tls=yes \
            -u "Web page changed" \
            -m "Visit it at $URL"

sendEmail -f [email protected] -t [email protected] \
            -s smtp.gmail.com:587 -xu [email protected] -xp YOURPASSWORD \
            -o tls=yes \
            -u "Hello from sendEmail" \
            -m "How are you? I'm testing sendEmail from the command line."

Kolab

Install and Configure Kolab Groupware on Ubuntu 16.04 LTS

Criptext: private email service

Zimbra

How to Install Zimbra Collaboration Suite 8.8 on Ubuntu

Backup

13 open source backup solutions

13 open source backup solutions

  • 6 tools: Cronopete, Deja Dup, Rclone, Rdiff-backup, Restic, and Rsync.
  • 13 tools: BorgBackup, UrBackup, LuckyBackup, Casync, Syncthing, Duplicati, Dirvish, Bacula, BackupPC, Amanda, Back in Time, Timeshift, Kup.

rdiff-backup

rdiff-backup. See

Dropbox

If we don't want to install dropbox software, we can install bash dropbox uploader: http://www.andreafabrizi.it/?dropbox_uploader OR https://github.com/andreafabrizi/Dropbox-Uploader

It allows to upload/download/delete/list files and show info of user. The version I am using is v0.9.7. It works on linux, Windows/Cygwin, Raspberry Pi, etc.

I install it under ~/Downloads/andreafabrizi-Dropbox-Uploader-cdc2466 directory

Instruction with screenshots: http://www.jobnix.in/dropbox-command-line-interface-cli-client/

Sample usages:

./dropbox_uploader.sh  list /
./dropbox_uploader.sh  upload ~/Desktop/ConfigurateNote.txt

Clone

4 Methods To Clone Your Linux Hard Drive

  1. dd can clone an entire HDD or disk partition
  2. Partimage. partimage does not support the ext4 filesystem
  3. Partclone
  4. Clonezilla

back up DVDs

See Create an iso file from a DVD/CD

back up a remote drive using SSH and save the resulting archive to your local machine

# ssh [email protected] "dd if=/dev/sda | gzip -1 -" | dd of=backup.gz

where "-1" (one) indicates the fastest compression method and the dash means ‘standard input’.

Backups vs. Archives

How to Archive Your Data (Virtually) Forever

Delete files or directories older than XXX days

Suppose we have a cron job to run backup and that creates a lot of directories. We like to erase them to avoid our system running out of space. You can run a space-checking program that'll alert you when the filesystem is low on free space. In addition we can run a cron job that uses find to erase all files.

cp -p -r ~/Downloads/SomeOldDirectory /tmp/
ls -lt /tmp
# List only
# Older than 2 days. Note the plus sign after "-mtime".
# Quotes in "{}" is to deal with names with spaces
find /tmp -type d -mtime +2 -exec ls -ld "{}" +

find /tmp -type d -mtime +2 -exec rm -rf "{}" +  
# Or if we don't mind some extra warning messages
# find /tmp -type d -mtime +2 -exec rm -rf "{}" \;
ls -lt /tmp

See

Timeshift

Vorta (BorgBackup GUI)

CloudBerry

CloudBerry Backup Protects Files on Windows, Mac, and Linux

Github, Bitbucket, Gitlab

We can use these git services to get real-time data (eg temperature, IP, etc).

Running a cron job as a user

Some examples

MIN HOUR DOM MON DOW CMD
30 08 10 06 * /home/ramesh/full-backup 
#   30 – 30th Minute
#   08 – 08 AM
#   10 – 10th Day
#   06 – 6th Month (June)
#   * – Every day of the week
  • Twice a day
00 11,16 * * * /home/ramesh/bin/incremental-backup 
#    00 – 0th Minute (Top of the hour)
#    11,16 – 11 AM and 4 PM
#    * – Every day
#    * – Every month
#    * – Every day of the week
  • Every 10 minutes
*/10 * * * * /home/ramesh/check-disk-space

crontab

  • crontab SOME-CRON-FILE; crontab -l

Make sure the .sh file gives a complete path. For example,

#!/bin/sh
R --vanilla  < arraytoolsip.R

does not work in cron job although it works perfect when we manually run it from the right path. The sh file should be

#!/bin/sh
R --vanilla  < $HOME/Dropbox/scripts/arraytoolsip.R

To disable everything on crontab -l, run crontab -e then comment out each line you don't want to run with #. OR run crontab -r to empty the current crontab.

PATH and Shell

Cron knows nothing about your shell; it is started by the system, so it has a minimal environment. If you want anything, you need to have that brought in yourself. For example, to use 'ifconfig' command, I need to give it a complete path in my script file.

$ cat syncIP 
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'

and the cron job

06 15 * * * /home/MYUSERNAME/Ubuntu\ One/syncIP > $HOME/Ubuntu\ One/ip.txt 2>&1

See here on how to add environment variable into cron environment.

Disable mail alert

If something went wrong with executing a cron job, cron will output a message "You have new mail in /var/mail/$USER". You can open this file using a text editor. To disable this alert, run 'crontab -e (see this post

0 1 5 10 * /path/to/script.sh >/dev/null 2>&1
# OR
0 1 5 10 * /path/to/script.sh > /dev/null

Running crontab as root

Use sudo crontab -e to edit. After saving it, no need to initialize it. Use sudo crontab -l to list the cron job.

GUI cron

md5sum

Linux md5sum Command Explained For Beginners (5 Examples)

How to verify files?

md5sum file1.txt file2.txt file3.txt > hashes
md5sum --check hashes

fsck

Force fsck on the Next Reboot or Boot Sequence

https://www.linuxuprising.com/2019/05/how-to-force-fsck-filesystem.html

https://www.cyberciti.biz/faq/linux-force-fsck-on-the-next-reboot-or-boot-sequence/ Create a blank file /forcefsck and fsck will check your drive next time your reboot.

sudo touch /forcefsck

The fsck was used to fix a journal checksum error on a USB drive which has been formatted as Ext4 was used on a security camera application; see motionEyeOS.

Can I run fsck or e2fsck when Linux file system is mounted?

https://www.cyberciti.biz/faq/can-i-run-fsck-or-e2fsck-when-linux-file-system-is-mounted/

What is the difference between fsck and e2fsck?

https://superuser.com/a/19984

Swap partition

Mount drive, add a new hard drive

How to add new disk in Linux

/etc/fstab and blkid

$ sudo blkid  #  list devices even not mounted yet

and the result should be compared with

$ sudo fdisk -l
  • Run sudo mount -a to remount /etc/fstab without reboot, except the partitions with noauto option.

The following example shows a problem (as found from the output of df command) with </etc/fstab> where we use /dev/sdXY instead of UUID for specifying hard disks.

$ sudo blkid
/dev/sda1: LABEL="WD640" UUID="d3a0a512-bf96-4199-9674-f410f22f0a92" TYPE="ext4"
/dev/sdb1: UUID="afaa4bde-1172-4c54-8b0a-a324ad855355" TYPE="ext4"
/dev/sdb5: UUID="fb2a4ada-d80a-4e23-b4a2-67376b8b7e72" TYPE="swap"

$ sudo fdisk -l
Disk /dev/sda: 640.1 GB, 640135028736 bytes
...
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  1250263039   625130496   83  Linux

Disk /dev/sdb: 640.1 GB, 640135028736 bytes
...
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048  1217761279   608879616   83  Linux
/dev/sdb2      1217763326  1250263039    16249857    5  Extended
/dev/sdb5      1217763328  1250263039    16249856   82  Linux swap / Solaris

$ cat /etc/fstab
proc            /proc                                 proc    nodev,noexec,nosuid 0 0
UUID=afaa4bde-1172-4c54-8b0a-a324ad855355 /           ext4    errors=remount-ro   0 1
UUID=fb2a4ada-d80a-4e23-b4a2-67376b8b7e72 none        swap    sw                  0 0
/dev/sdb1       /mnt/WD640                            ext4    rw,nosuid,nodev     0 2
UUID=fb2a4ada-d80a-4e23-b4a2-67376b8b7e70 /mnt/extUSB auto nosuid,nodev,nofail 0 2

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       572G  413G  130G  77% /
...
/dev/sdb1       572G  413G  130G  77% /mnt/WD640

To fix the error here, modify the line starting /dev/sdb1 in /etc/fstab and replace it with the UUID. Then run sudo umount /mnt/WD640 and sudo mount -a. Done!

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       572G  413G  130G  77% /
...
/dev/sda1       587G  283G  275G  51% /mnt/WD640

autofs, /etc/auto.master

Building a network attached storage device with a Raspberry Pi

Fix a malfunctioning USB device or port

5 Ways to Fix a Malfunctioning USB Device or Port on Linux

USB drive

Run the following to confirm the USB device is detected.

sudo fdisk -l
# OR
dmesg | grep -i "SCSI"

Now suppose the usb device is found in dev/sdb1.

sudo mkdir /mnt/usb
sudo mount -t vfat -o rw,users /dev/sdb1 /mnt/usb

The above mount command assumes the usb drive has Windows vfat partition and users give non-root users the ability to unmount the drive. If the USB drive is partitioned linux ext2/3, we can merely run mount command as

sudo mount /dev/sdb1 /mnt/usb

At the end, run umount command like

sudo umount /mnt/usb

To make the mounting automatically, edit the file /etc/fstab.

/dev/sdb1       /mnt/usb           vfat    defaults        0       0 
/dev/sdb1       /mnt/usb           ext3    defaults        0       0

and run

sudo mount -a

Mount an iso file

sudo mkdir -p /mnt/mount_point # create a mount point
sudo mount -o loop /home/user/disk.iso /mnt/mount_point
mount  # verify

Mount remote Windows share

Sharing files with Windows by using NitroShare

Simple way of Sharing files between Ubuntu 16.04 and Windows 10 by using open-source NitroShare which is based on Qt framework.

exFat - cross platform partition format

sudo apt-get install exfat-utils exfat-fuse
# Still need to create a partition (ex. FAT32) first using gparted in order to get it mounted
sudo fdisk -l 
sudo mkfs.exfat -n LABEL /dev/sd**  #  LABEL with whatever you want to label your drive

This should delivery a working exfat file system (read and write support, but not formatting the drives with exfat via Gnome Disks and GParted).

NTFS usb drive in xubuntu

http://xflinux.blogspot.com/2011/01/mount-ntfs-volumes-automatically-in.html

sudo apt-get install ntfs-config

Now go to Applications>> System>> Ntfs Configuration Tool

Expand the "Advanced Configuration" and select all those partitions you want to be auto mounted and writable( The tool will detect all partitions at its startup).

Make sure the " Enable write support for internal devices" option is selected. Now click Close.

Many drives, one folder

Partition tables

Partition Tables and the Dangers of Editing Them

parted command

How to partition a disk in Linux

Recommended partition schemes

Why put things other than /home to a separate partition?

Why put things other than /home to a separate partition?

The /var partition is used by Docker and Apache.

/home, /boot and /var partitions can be separated.

Process/job

How do I send an already-running process into the background

Steps:

  1. 'Ctrl+Z' to stop (pause) the program and get back to the shell.
  2. bg to run it in the background.
  3. jobs -l to get the jobID and process ID
  4. disown -h [job-spec] where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs command) so that the job isn't killed when the terminal closes.

Stopped job

A stopped job is one that has been temporarily put into the background and is no longer running, but is still using resources (i.e. system memory). Because that job is not attached to the current terminal, it cannot produce output and is not receiving input from the user.

  • jobs -s showing stopped jobs
  • jobs -l showing the job PID

Send kill to a stopped job, it will do nothing but queue than bring it in in foreground, it will terminate. So don't repeatly sending a 'kill' command.

  • fg %1 move the stopped job ID #1 to the foreground (works)
  • kill %1 # kill job ID #1
  • kill 12345 # kill job PID 12345
  • kill -9 `jobs -ps` may not work
  • kill -9 $(jobs -p)

nice

How to Set Process Priorities With nice and renice on Linux

run commands in a background and allow log off

nohup /path/to/script >output 2>&1 &

Or to disable output and be more safe. It also explains the concept of file descriptor/fd in Unix.

nohup command </dev/null >/dev/null 2>&1 &

See also Anonymous named pipe.

Notepadqq - Notepad++-like editor

Notepadqq. It is written using Qt. It does not have printing function:(

Note apps that can sync

Top 8 Notepad Apps for Linux That You Can Sync. Some are compatible with Evernote.

Evernote

Evernote alternative

How to Install Turtl Server - Evernote Alternative - on Ubuntu 16.04

Backup/restore Evernote

https://www.makeuseof.com/tag/backup-restore-evernote/

Markdown

Preview markdown/view markdown offline

sudo pip install grip
grip readme.md
# title 1
![screenshot](myfile.png?raw=true)
  • Chrome markdown preview plus extension does not show images from github.

Markdown editor

Text editor with navigation

Text editor with navigation

nano/pico editor

The nano editor is also called pico in R. See ?edit in R.

nano editor

vi editor

vi editor

Cloud

http://slidedecks.wilmoore.com/2012-confoo/diy-private-cloud-using-virtualBox-and-chef/#66

http://www.datacentermap.com/blog/cloud-software-389.html

Commercial cloud services

  • DigitalOcean - simple pricing. One droplet = one server.
  • Amazon EC2
  • Google cloud
  • Microsoft Azure

Manage all your cloud storage

http://www.makeuseof.com/tag/chrome-extensions-you-need-manage-cloud-storage/

Dropbox

Dbxfs – Mount Dropbox Folder Locally As Virtual File System In Linux. It is a command line dropbox client and requires no disk space for access.

Comparison of Linux VPS providers

https://www.ghacks.net/2017/06/15/a-comparison-of-linux-vps-providers-for-beginner-hosting/

Boot

U-boot

http://www.denx.de/wiki/U-Boot

Pandora linux client

COW (copy on write) file system

The cow filesystem was found on xubuntu live CD. See http://en.wikipedia.org/wiki/Copy-on-write

How To Protect Your Server Against the Dirty COW Linux Vulnerability (10/21/2016)

Apache redirection

http://cran.r-project.org/mirror-howto.html

Redirect a Website URL from One Server to Different Server in Apache

Important linux directories

  • /bin - executables used by the base system
  • /boot
  • /dev
  • /etc - configuration files
  • /media
  • /mnt
  • /opt - optional application packages
  • /proc - process information only
  • /sbin - critical executables for running the system, but should be used by superuser
  • /usr - non-critical files. Inside is /usr/bin, which contains most of the libraries used by apps.
  • /var - variable data such as databases, mails spools and system logs.

Difference of /bin, /sbin, /usr/local/bin, ...

  • /bin : For essential binaries; e.g. bash, cat, ls.
  • /sbin : is similar to /bin but for scripts with superuser (root) privileges required; e.g. shutdown command is located here. Local users have to use sudo to run binaries here.
  • /usr/bin : Same as first, but for general system-wide & non-essential binaries; e.g. grep, zip, docker, etc.
  • /usr/sbin : Same as above, but for scripts with superuser (root) privileges required.
  • /usr/local/bin or /usr/local/sbin for system-wide available (personal) scripts.

If you want to create your own scripts and make them available to all users, you’re pretty safe adding them to /usr/local/bin. Or to add my scripts to my local bin (~/bin) and then I create a symbolic link in /usr/local/bin to the commands I want to make public. As a result, I can manage all my scripts from the same directory but still make some of them publicly available since /usr/local/bin is added to $PATH. See this post.

DHCP lease time

On Windows, it is 8 days.

Get a New IP Address

dhclient -r   #  release your IP Address

dhclient   #  get your DHCP to issue you a new IP Address based on how it’s been configured.

Open a file/URL using the default application from the command line

See also

Check a file's encoding

file -bi myfile

For example,

file -bi Downloads/hmv_.rc 
# text/x-c++; charset=utf-16le

Know you system using the command line

Alerting and visualization tools

5 alerting and visualization tools for sysadmins

System monitor tools (TUI)

conky

htop command

glances command

Glances is similar to htop but it provides network stats too. Install it by sudo apt-get install glances.

scout_realtimep

This is used by Dataplicity

gtop command (100% Javascript)

https://www.cyberciti.biz/howto/gtop-awesome-system-monitoring-dashboard-for-terminal/.

Pros:

  • CPU history graph in time
  • Memory history graph in time (not useful)
  • Network bandwidth usage is real-time. It is accurate as what nload gives.
  • Percentage usage of memory, swap, disk usage
  • Top processes
$ sudo apt install npm nodejs
$ npm install gtop -g
$ gtop
  • Press p to sort by process ID (PID).
  • Press c to sort by CPU usage.
  • Press m to sort by memory usage.

It can be installed on Linux Mint 18.2 but not in Ubuntu 14.04 or raspbian (9 stretch).

$ npm install gtop -g
npm http GET https://registry.npmjs.org/gtop
npm http GET https://registry.npmjs.org/gtop

npm http GET https://registry.npmjs.org/gtop
npm ERR! Error: CERT_UNTRUSTED
npm ERR!     at SecurePair.<anonymous> (tls.js:1370:32)
npm ERR!     at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:982:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:469:13)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:366:25)
npm ERR!     at doWrite (_stream_writable.js:223:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:213:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:180:11)
npm ERR!     at write (_stream_readable.js:583:24)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 4.4.0-119-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "gtop" "-g"
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10

gotop

A terminal based graphical activity monitor inspired by gtop and vtop. It is quite beautiful.

Gotop – Yet Another TUI Graphical Activity Monitor, Written In Go

Compared to gtop, it has a temperature monitor. However, it can only show the average CPU usage (one line) on my Xeon computer.

git clone --depth 1 https://github.com/cjbassi/gotop /tmp/gotop
/tmp/gotop/scripts/download.sh
sudo cp gotop /usr/local/bin; rm gotop
gotop

Note the temperatures do not show up in Raspbian (raspberry pi 3 b+).

termui: Golang terminal dashboard

https://github.com/gizak/termui

S-tui command

Monitor Linux CPU temperature, frequency, power in a graphical way

System monitor tools (GUI)

Comparisons:

Some lists:

Stacer

Linux System Optimizer and Monitoring

Curses and ncurses: TUI library

Calcurse

Keep up with your calendar and to-do list with Calcurse

Bitbucket (free for 5 users)

Bitbucket 101

  • Unlimited private repos
  • Code reviews
  • JIRA integration
  • REST API
  • Custom domains

See this post to know how to fix the problem of unknown author. In short, when I uncheck "Use global user setting" from Repository-> Repository Settings -> Advanced does the commit author change as expected.

See here for a list of Android apps related to bitbucket.

Image

English original, ImageMagick 入门:使用命令行来编辑图片

Convert a color image to black and white

$ convert filename.jpg -canny 0x1 -negate canny.jpg
convert.im6: unrecognized option `-canny' @ error/convert.c/ConvertImageCommand/1107.

$ convert --version
Version: ImageMagick 6.7.7-10 2017-07-31 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP  

The current imagemagick version is 7.0.7-15.

Install/build the latest imagemagick

# remove version installed with apt-get
sudo apt-get remove imagemagick && sudo apt-get autoremove

# install dependencies
sudo apt-get install build-essential
sudo apt-get build-dep imagemagick -y

# download ImageMagick source
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xzvf ImageMagick.tar.gz

# build source
cd ImageMagick-*
./configure
make

# install and verify
sudo make install

sudo checkinstall

**********************************************************************

 Done. The new package has been installed and saved to

 /home/XXX/Downloads/ImageMagick-7.0.7-15/imagemagick-7.0.7_15-1_amd64.deb

 You can remove it from your system anytime using: 

      dpkg -r imagemagick-7.0.7

**********************************************************************

$ convert --version
# bash: /usr/bin/convert: No such file or directory

$ which convert
/usr/local/bin/convert
$ whereis convert
convert: /usr/local/bin/convert
$ /usr/local/bin/convert -version
Version: ImageMagick 7.0.7-15 Q16 x86_64 2017-12-20 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): bzlib fontconfig freetype jbig jng jpeg lzma pangocairo png tiff x xml zlib

Convert an image to sketch (online tool)

http://www.snapstouch.com/sketch.aspx

Convert an image file to a different format (eg icon)

Using the imagemagic program.

convert winamp-ncrow.png -resize 32x32 winamp-ncrow.ico

4 Ways to Batch Convert Your PNG to JPG and Vice-Versa

Rotate an image

http://www.imagemagick.org/script/command-line-options.php#rotate

convert winamp-ncrow.png -rotate 45 winamp-ncrow2.png  # 45 degrees

One problem with this simple approach is the picture size (not image file) changed (become smaller) if the degree is not one of 90,180 or 270.

Create an animated gif file

Use the script here. See the last example on here. The rotation speed looks good too! Just change the source image file in the script.

#!/bin/sh
#
# Create a rotating figure using Distort SRT transformations
#
command='convert -delay 10 koala.gif -virtual-pixel white'

for i in `seq 5 5 360`; do
  command="$command \\( -clone 0 -distort SRT $i \\)"
done

command="$command -delete 0 -loop 0 animate_distort_rot.gif"

eval $command

chmod 644 animate_distort_rot.gif

Tool to convert a sequence of numbered PNG files to an animated GIF?. Convert command line option. The option '-loop 0' means repeats infinitely and '-delay 200' means 2 seconds delay between each frame.

convert -delay 200 -loop 0 file_1.png file_2.png file_3.png animated.gif

Convert Video to GIF

The Best Ways to Convert Video to GIF

Edit gif file

gifsicle package

Replace transparency in PNG images with white background

http://stackoverflow.com/questions/2322750/replace-transparency-in-png-images-with-white-background

convert image.png -background white -alpha remove white.png

Remove GPS metadata from jpg files - exiftool

sudo apt-get install libimage-exiftool-perl
exiftool -gps:all= -xmp:geotag= image.jpg

The image file will be updated. To check the current metadata, use

exiftool image.jpg

Note that the above command only remove gps information. The other information like date/time of creation, camera model are not changed.

Exitftool can also be used to edit the metadata on PDF files.

exiftool -Title="This is the Title" -Author="Happy Man" -Subject="PDF Metadata" drawing.pdf

Edit Svg image

Animated gif

Display images in the terminal

Using FIM

GIMP

login shell (.bash_profile) vs interactive shell (.bashrc)

8 http://serverfault.com/questions/8882/what-is-the-difference-between-a-login-and-an-interactive-bash-shell

  1. login shell - non desktop environment. ~/.bash_profile is sourced for the bash shell.
  2. interactive shell - Ctrl+Alt+t to open a terminal from a graphical mode (desktop environment). ~/.bashrc is source. We usually edit ~/.bashrc to set up the environment to include fancy prompt, set aliases, set history options, or define custom shell functions.

export environment variables

  1. Both a login shell and an interactive one. SSH (Putty) to connect to a remote machine.
  2. When a shell runs a script or a command passed on its command line, it's a non-interactive, non-login shell.

History of commands

history command with date and time

Running the following code once and history will give date and time the next time you issue the history command.

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc

Note that the original post asks to write the line to ~/.bash_profile but this is not working in the desktop environment.

Bang bang - Run a command/Fetch parameters from previous history

  1. ^P: Move up through the command history list one command at a time.
  2. ^N: Move down through the command history list one command at a time.
  3. !!: Run the previous command.
  4. !n: Run command number n
  5. !string: Run most recent command starting with characters in string
  6. !?string: Run most recent command containing characters that match string
  7. !!*: Fetch parameters from last command

For example,

!-1
!4
!tail

Increase history limit

http://unix.stackexchange.com/questions/17574/is-there-a-maximum-size-to-the-bash-history-file

Not to add to bash history

Add a space after the command.

How to Clear Bash History on Linux

$ cat /dev/null > ~/.bash_history && history -c && exit

Listen to HiChannel internet radio

Use Radio Tray

I use it to listen m3u file (VLC also supports it too).

Web Analytics Reporting Tools

Painting software

  • Krita - professional painting program made by artists that want to see affordable art tools for everyone. Krita Is the Free GIMP Alternative You Should Be Using.
  • Pinta. It can be install by apt-get command. It works just line Window's paint. Ctr + v to paste an image and save to a file. To crop an image, click the selection tool (1st one) on the left hand side, then select a rectangle. Now click 'Image' > 'Crop to Selection' to finish.
  • mtPaint. It is included in Odroid - xu4 - Lubuntu 14.04. To crop an image, just select an area and click Image > Crop. It can be used to take a screenshot from the desktop by using either the application or through the command line (mtpaint -s). It will then display the screenshot in the application if you use the command line.
  • MyPaint

Take a screenshot (and edit them)

See Take screenshots.

Cozy - audiobook player

ebook readers

7 Best eBook Readers for Linux: Calibre, FBReader, Okular, Lucidor, Bookworm, Easy Ebook Viewer and Buka.

Calibre - Read ebook in epub format

See Calibre

RSS reader

Some references:

  1. 5 Best Feed Reader Apps for Linux
  2. 14 Best RSS Feed Readers for Linux in 2018. It contains nice screenshots.

Some examples:

  • Akregator. KDE based. This is preinstalled in CentOS-KDE under the Internet category. It is also called 'Feed Reader'.
  • QuiteRSS. It works on Linux, Windows and MacOS.
  • Liferea. GTK based. It is considered one of the best RSS feed readers on Ubuntu Linux. It can synchronize with several online feed managers such as InoReader among others.
  • FeedReader. Looks nice. Works with several online feed managers.
  • Newsbeuter: RSS feed in terminal
  • Newsboat: terminal
  • RSSOwl. Depends on Java. Cross platform.
  • Firefox and Thunderbird have built-in support for RSS.

Display/screen

Turn off/on your monitor via command line

xset dpms force off # Press any key to turn it on 
xset dpms force on
xset -q # check the status of the X server settings

If we want to turn off/on the screen via ssh, add

export DISPLAY=:0.0

first before calling the xset command, or use '-display' argument

xset -display :0.0 dpms force off 
xset -display :0.0 dpms force on

autoxrandr

Plug your laptop into different monitor setups. https://www.donarmstrong.com/posts/autorandr/

Add new screen/display resolutions

xrandr | grep maximum
gtf 800 480 59.9  # give some output used in the following line
xrandr --newmode "800x480_59.90" 29.53 800 816 896 992 480 481 484 497 -HSync +Vsync
xrandr --addmode "DISP3 BG" 800x480_59.90
xrandr --output "DISP3 BG" --mode 800x480_59.90

I cannot find the file /etc/X11/xorg.conf in my UDOObuntu 2 beta 2. It seems this file does not exist anymore. See this post about how to re-create it.

Wayland

export DISPLAY

If we want to run a GUI app on a remote computer (such as Raspberry Pi/Beaglebone Black) and show the GUI app on the remote computer's screen using ssh, we can issue the following command before running the app.

export DISPLAY=:0.0

LVM Demystified

http://www.linuxjournal.com/content/lvm-demystified

See which groups you belong to, id & group commands

groups 
groups <username>

groupadd, chgrp, usermod, ACL (access control lists)

sudo mkdir -p /var/www/reports/
sudo groupadd project 

sudo usermod -a -G project tecmint 
sudo chgrp -R project /var/www/reports/
sudo chmod -R 2775 /var/www/reports/

create more system users and add them to the directory group as follows:

sudo useradd -m -c "Aaron" -s/bin/bash -G project aaron
sudo useradd -m -c "John" -s/bin/bash -G project john
sudo useradd -m -c "Ravi" -s/bin/bash -G project ravi

sudo mkdir -p /var/www/reports/aaron_reports
sudo mkdir -p /var/www/reports/john_reports
sudo mkdir -p /var/www/reports/ravi_reports

Shared library management

http://www.cyberciti.biz/tips/linux-shared-library-management.html

  1. ldconfig : Updates the necessary links for the run time link bindings.
  2. ldd : Tells what libraries a given program needs to run.
  3. ltrace : A library call tracer.
  4. ld.so/ld-linux.so: Dynamic linker/loader.

Install binary software using sudo

One example (Calibre) is like

sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | \
sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"

Note that in wget the option "-O-" means writing to standard output (so the file from the URL is NOT written to the disk) and "-nv" means no verbose.

If the option "-O-" is not used, we'd better to use "-N" option in wget to overwrite an existing file.

See the Logging and Download options in wget's manual.

       -O file
       --output-document=file
           The documents will not be written to the appropriate files, but all
           will be concatenated together and written to file.  If - is used as
           file, documents will be printed to standard output, disabling link
           conversion.  (Use ./- to print to a file literally named -.)

Log files

DigitalOcean

$ ls -lt /var/log

ssh log files: /var/log/auth.log

  • /var/log/syslog
  • /var/log/auth.log: it includes ssh log in information and lots of CRON sessions opened and closed every minutes.

And

Apache log

  • /var/log/apache2/error.log (small 83K). Useful to troubleshoot errors/crashes of Apache.
grep "May 08" /var/log/apache2/error.log
  • /var/log/apache2/access.log (large 10M)

mail

/var/log/maillog

uptime command

uptime
watch -n 60 uptime

timeout command

Linux command similar to top to show hard disk activity

Use iotop. On ubuntu, we can use sudo apt-get install to install it. Use sudo iotop to launch it.

sudo apt-get install iotop

sudo iotop -o -u $USER

Another program is iostat and the -d (disk) option. The -x option will display extension I/O status.

sudo apt-get install sysstat
iostat -dx 5 # every 5 seconds

24 iostat, vmstat and mpstat Examples for Linux Performance Monitoring

Install Apache HBase

Follow the Quick Start to downloaded hbase tar ball. Suppose we save the tar ball under ~/Downloads folder and extract it in the same directory. We shall edit conf/hbase-site.xml file according to their instruction. The following is my case.

$ tar xzvf hbase-0.98.3-hadoop2-bin.tar.gz 
$ cd hbase-0.98.3-hadoop2/
$ cat conf/hbase-site.xml 
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/brb/Downloads/hbase-0.98.3-hadoop2/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/brb/Downloads/hbase-0.98.3-hadoop2/zookeeper</value>
  </property>
</configuration>

Before we follow the getting started guide to launch HBase, we shall make sure JAVA_HOME environment variable is created.

$ ls /usr/lib/java
$ export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64

Note that the last line may be replaced by

export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::")

Then we can launch HBase,

$ ./bin/start-hbase.sh 

starting master, logging to /home/brb/Downloads/hbase-0.98.3-hadoop2/bin/../logs/hbase-brb-master-brb-P45T-A.out
brb@brb-P45T-A:~/Downloads/hbase-0.98.3-hadoop2$ ./bin/hbase shell
2014-07-06 09:51:34,621 INFO  [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.3-hadoop2, rd5e65a9144e315bb0a964e7730871af32f5018d5, Sat May 31 19:56:09 PDT 2014

hbase(main):001:0> create 'test', 'cf'
2014-07-06 09:51:49,510 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
0 row(s) in 2.0770 seconds

=> Hbase::Table - test
hbase(main):002:0> list 'test'
TABLE                                                                           
test                                                                            
1 row(s) in 0.0530 seconds

=> ["test"]
hbase(main):003:0> exit

brb@brb-P45T-A:~/Downloads/hbase-0.98.3-hadoop2$ ./bin/hbase 

shell2014-07-06 09:53:37,480 INFO  [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.3-hadoop2, rd5e65a9144e315bb0a964e7730871af32f5018d5, Sat May 31 19:56:09 PDT 2014

hbase(main):001:0> list 'test'
TABLE                                                                           
2014-07-06 09:53:44,373 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
test                                                                            
1 row(s) in 1.4800 seconds

=> ["test"]
hbase(main):002:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.4460 seconds

hbase(main):003:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0140 seconds

hbase(main):004:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0050 seconds

hbase(main):005:0> scan 'test'
ROW                   COLUMN+CELL                                               
 row1                 column=cf:a, timestamp=1404654837532, value=value1        
 row2                 column=cf:b, timestamp=1404654856976, value=value2        
 row3                 column=cf:c, timestamp=1404654866298, value=value3        
3 row(s) in 0.0560 seconds

hbase(main):006:0> get 'test', 'row1'
COLUMN                CELL                                                      
 cf:a                 timestamp=1404654837532, value=value1                     
1 row(s) in 0.0280 seconds

hbase(main):007:0> disable 'test'
0 row(s) in 1.6050 seconds

hbase(main):008:0> drop 'test'
0 row(s) in 0.2290 seconds

hbase(main):009:0> exit
brb@brb-P45T-A:~/Downloads/hbase-0.98.3-hadoop2$ 

Files downloaded from a browser and wget

Same file downloaded through a browser and the wget command has a different file size and behavior.

$ ls -lh biotrip*.gz
-rw-r--r-- 1 brb brb 198M May 15 09:11 biotrip_0.1.0_may19.tar.gz
-rw-rw-r-- 1 brb brb 195M May 14 16:57 biotrip_0.1.0.tar.gz

$ file biotrip_0.1.0_may19.tar.gz # downloaded from a browser (chrome browser, Mac or Linux)
biotrip_0.1.0_may19.tar.gz: POSIX tar archive

$ file biotrip_0.1.0.tar.gz       # downloaded from the wget command
biotrip_0.1.0.tar.gz: gzip compressed data, from HPFS filesystem (OS/2, NT)

$ tar xzvf biotrip_0.1.0_may19.tar.gz 
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

curl vs wget

sudo apt-get install curl

For example, the Download link at the National Geographic Travel Photo Contest 2014 works for curl but not wget. I can use curl with -o option but wget with -o will not work in this case. Note with curl, we can also use the -O (capital O) option which will write output to a local file named like the remote file.

curl \
 http://travel.nationalgeographic.com/u/TvyamNb-BivtNwcoxtkc5xGBuGkIMh_nj4UJHQKuoXEsSpOVjL0t9P0vY7CvlbxSYeJUAZrEdZUAnSJk2-sJd-XIwQ_nYA/ \
 -o owl.jpg

Should I Use Curl Or Wget? and curl vs Wget

  • The main benefit of using the wget command is that it can be used to recursively download files.
  • The curl command lets you use wildcards to specify the URLs you wish to retrieve. And curl supports more protocols than wget (HTTP, HTTPS, FTP) does.
  • The wget command can recover when a download fails whereas the curl command cannot.

Actually curl supports continuous downloading too. But not all FTP connection supports continuous downloading. The following examples show it is possible to use the continuous downloading option in wget/curl for downloading file from ncbi FTP but not from illumina FTP.

$ wget -c ftp://igenome:[email protected]/Drosophila_melanogaster/Ensembl/BDGP6/Drosophila_melanogaster_Ensembl_BDGP6.tar.gz
--2017-04-13 10:46:16--  ftp://igenome:*password*@ussd-ftp.illumina.com/Drosophila_melanogaster/Ensembl/BDGP6/Drosophila_melanogaster_Ensembl_BDGP6.tar.gz
           => ‘Drosophila_melanogaster_Ensembl_BDGP6.tar.gz’
Resolving ussd-ftp.illumina.com (ussd-ftp.illumina.com)... 66.192.10.36
Connecting to ussd-ftp.illumina.com (ussd-ftp.illumina.com)|66.192.10.36|:21... connected.
Logging in as igenome ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /Drosophila_melanogaster/Ensembl/BDGP6 ... done.
==> SIZE Drosophila_melanogaster_Ensembl_BDGP6.tar.gz ... 762893718
==> PASV ... done.    ==> REST 1706053 ... 
REST failed, starting from scratch.
 
==> RETR Drosophila_melanogaster_Ensembl_BDGP6.tar.gz ... done.
Length: 762893718 (728M), 761187665 (726M) remaining (unauthoritative)
 
 0% [                                                                                                                   ] 374,832     79.7KB/s  eta 2h 35m ^C
 
$ curl -L -O -C - ftp://igenome:[email protected]/Drosophila_melanogaster/Ensembl/BDGP6/Drosophila_melanogaster_Ensembl_BDGP6.tar.gz
** Resuming transfer from byte position 1706053
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  727M    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (31) Couldn't use REST

$ wget -c ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b147_GRCh37p13/VCF/common_all_20160601.vcf.gz
--2017-04-13 10:52:02--  ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b147_GRCh37p13/VCF/common_all_20160601.vcf.gz
           => ‘common_all_20160601.vcf.gz’
Resolving ftp.ncbi.nih.gov (ftp.ncbi.nih.gov)... 2607:f220:41e:250::7, 130.14.250.10
Connecting to ftp.ncbi.nih.gov (ftp.ncbi.nih.gov)|2607:f220:41e:250::7|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /snp/organisms/human_9606_b147_GRCh37p13/VCF ... done.
==> SIZE common_all_20160601.vcf.gz ... 1023469198
==> EPSV ... done.    ==> RETR common_all_20160601.vcf.gz ... done.
Length: 1023469198 (976M) (unauthoritative)
 
24% [===========================>                                                                                       ] 255,800,120 55.2MB/s  eta 15s    ^C
 
$ wget -c ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b147_GRCh37p13/VCF/common_all_20160601.vcf.gz
--2017-04-13 10:52:11--  ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b147_GRCh37p13/VCF/common_all_20160601.vcf.gz
           => ‘common_all_20160601.vcf.gz’
Resolving ftp.ncbi.nih.gov (ftp.ncbi.nih.gov)... 2607:f220:41e:250::7, 130.14.250.10
Connecting to ftp.ncbi.nih.gov (ftp.ncbi.nih.gov)|2607:f220:41e:250::7|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /snp/organisms/human_9606_b147_GRCh37p13/VCF ... done.
==> SIZE common_all_20160601.vcf.gz ... 1023469198
==> EPSV ... done.    ==> REST 267759996 ... done.    
==> RETR common_all_20160601.vcf.gz ... done.
Length: 1023469198 (976M), 755709202 (721M) remaining (unauthoritative)
 
47% [++++++++++++++++++++++++++++++========================>                                                            ] 491,152,032 50.6MB/s  eta 12s    ^C

$ curl -L -O -C - ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b147_GRCh37p13/VCF/common_all_20160601.vcf.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 65  976M   65  639M    0     0  83.7M      0  0:00:11  0:00:07  0:00:04 90.4M^C

curl man page, supported protocols

https://curl.haxx.se/docs/manpage.html

wget overwrites the existing file

Use the -N or --timestamping option to turn on time-stamping. Don't re-retrieve files unless newer than local.

wget and username/password

http://www.cyberciti.biz/faq/wget-command-with-username-password/

Download and Un-tar(Extract) in One Step

If we don't want to avoid saving a temporary file, we can use one piped statement.

curl http://download.osgeo.org/geos/geos-3.5.0.tar.bz2 | tar xvz
# OR
wget http://download.osgeo.org/geos/geos-3.5.0.tar.bz2 -O - | tar jx

# For .gz file
wget -O - ftp://ftp.direcory/file.gz | gunzip -c > gunzip.out

See shellhacks.com. Note that the magic part of the wget option "-O -"; it will output the document to the standard output instead of a file.

The "-c" in gunzip is to have gzip output to the console. PS. it seems not necessary to use the "-c" option.

Download and execute the script in one step

See Execute bash script from URL.

curl -s https://server/path/script.sh | sudo sh

curl -s http://server/path/script.sh | sudo bash /dev/stdin arg1 arg2

sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin

curl and POST request

curl and proxy

How to use curl command with proxy username/password on Linux/ Unix

Website performance

httpstat – A Curl Statistics Tool to Check Website Performance

wget/curl a file with correct name when redirected

wget --trust-server-names <url> 
# Or
wget --content-disposition <url>
# Or
curl -JLO <url>

wget to download a folder

https://stackoverflow.com/questions/8755229/how-to-download-all-files-but-not-html-from-a-website-using-wget

wget -A pdf,jpg,PDF,JPG -m -p -E -k -K -np http://site/path/

wget to download a website

To download a copy of a complete web site, use the recursive option ('-r') By default it will go up to five levels deep. You can change the default level by using the '-l' option.

All files linked to in the documents are are downloaded to enable complete offline viewing ('-p' and '--convert-links' options). Instead of having the progress messages displayed on the standard output, you can save it to a log file with the -o option.

wget -p --convert-links -r -l2 linux.about.com -o logfile
wget -p --convert-links -r -l1 https://csgillespie.github.io/efficientR # create csgillespie/efficientR

Torrent

Torrench

Torrench: How To Search And Download Torrent Files Using Terminal (Linux, Mac, Windows)

aria2 - command line downloader supports torrents and multi-connection

aria2 command examples

The -x argument helps a little bit.

# Download a file 112MB; see https://www.archlinux.org/download/
$ time aria2c  http://mirror.jmu.edu/pub/archlinux/iso/2016.11.01/archlinux-bootstrap-2016.11.01-i686.tar.gz # 16 seconds
$ time aria2c -x10 http://mirror.jmu.edu/pub/archlinux/iso/2016.11.01/archlinux-bootstrap-2016.11.01-i686.tar.gz # 11 seconds

Axel

It can create an unlimited number of worker threads to download any kind of data. See https://www.beginnersheap.com/top-5-command-line-download-accelerators-linux/

lftp

Apply a patch to source code

For example Tophat 2.0.12 compatibility with Samtools 1.0,

$ ls
support_for_tophat_1.patch  tophat-2.0.12  tophat-2.0.12.tar.gz

$ grep -r -i "check_samtools" tophat-2.0.12/
tophat-2.0.12/src/tophat.py:def check_samtools():
tophat-2.0.12/src/tophat.py:        check_samtools()

$ cp support_for_tophat_1.patch tophat-2.0.12/src/
$ cd tophat-2.0.12/src/
$ patch tophat.py < support_for_tophat_1.patch 
patching file tophat.py
Hunk #1 succeeded at 1540 (offset 3 lines).
Hunk #2 succeeded at 1563 (offset 3 lines).

IP address fundamental

http://www.howtogeek.com/133943/geek-school-learning-windows-7-ip-addressing-fundamentals/.

There are three classes for private IP ranges.

  • 10.0.0.1 – 10.255.255.254 from Class A
  • 172.16.0.1 – 172.31.255.254 from Class B
  • 192.168.0.1 – 192.168.255.254 from Class C

Subnet

Get internal IP address

$ hostname -I

Get external IP address

How to find your IP address in Linux

https://www.iplocation.net or https://www.ipify.org/

https://github.com/jakewmeyer/Geo (one shell script)

It seems there is no way to get the external IP address without not using external services.

# http://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-a-shell-script
sudo apt-get install dnsutils
dig +short myip.opendns.com @resolver1.opendns.com
# OR
curl http://ipecho.net/plain; echo
# OR
curl ipv4.ipogre.com

To store my IP in a shell variable

myip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
echo "My WAN/Public IP address: ${myip}"

The above only gives the IP. The following method gives geo information too.

curl ipinfo.io # ifconfig.me, icanhazip.com, ipecho.net/plain, ifconfig.co
# OR give a specific IP (domain name does not work)
curl ipinfo.io/216.58.194.46

{
  "ip": "216.58.194.46",
  "hostname": "dfw25s12-in-f14.1e100.net",
  "city": "Mountain View",
  "region": "California",
  "country": "US",
  "loc": "37.4192,-122.0574",
  "org": "AS15169 Google Inc.",
  "postal": "94043"
}

IP geolocation

Test url: ubuntu.mirrors.pair.com

Domain

  • WHOIS LOOKUP. For example, consider "r-pkg.org" domain,
    • The 'Sponsoring Registrar' shows who is the sponsoring registrar (eg GoDaddy.com).
    • The 'Registrant Name' shows who registered this domain.
    • Command Line Interface.
sudo apt-get install whois
whois r-pkg.org
  • IP-Lookup. For example, consider "r-pkg.org" domain.
    • The linux command line tool 'ping' shows the ip address.
    • When we use the ip address to search in the IP-Lookup, the IP owner info > 'Organization' or 'OrgName' field shows the owner of this IP (eg Digital Ocean, Inc).
    • The Domain owner info there gives the same (or less) information as WHOIS LOOKUP.
  • WhoIsHostingThis or webhostinghero (the returned result will be like Amazon, GoDaddy, CloudFlare, Github, Verizon, etc).

Subnet

IPv4

  • Class A: 255.0.0.0 or /8;
  • Class B, 255.255.0.0 or /16;
  • Class C, 255.255.255.0 or /24.

For example, in the subnet 192.168.5.0/255.255.255.0 (192.168.5.0/24) the identifier 192.168.5.0 commonly is used to refer to the entire subnet.

In the /16 subnet 192.168.0.0/255.255.0.0, which is equivalent to the address range 192.168.0.0–192.168.255.255

IPv6

ping command

ping uses the ICMP Echo Message to force a remote host to echo a packet back to the local host. If packets can travel to and from a remote host, it indicates that the two hosts can successfully communicate.

Build a home network

IP Subnet Calculator

https://www.dan.me.uk/ipsubnets?ip=10.0.0.0

  • CIDR block IP range (network - broadcast) Subnet Mask IP Quantity
  • 10.0.0.0/24 10.0.0.0 - 10.0.0.255 255.255.255.0 256
  • 10.0.0.0/16 10.0.0.0 - 10.0.255.255 255.255.0.0 65536=256^2
  • 10.0.0.0/8 10.0.0.0 - 10.255.255.255 255.0.0.0 16777216=256^3

How Use Your Router and ISP’s Modem/Router Combo In Tandem

http://www.howtogeek.com/255206/how-use-your-router-and-isps-modemrouter-combo-in-tandem/

Troubleshoot and repair network problems

http://www.linuxuser.co.uk/features/troubleshot-repair-linux-networks

Computer 1 can ping Computer 2 but not reverse

Use the route command to solve. See also this post.

Simple Network Management Protocol (snmp)

Monitor network by Cacti (GUI)

Monitor network by command line

3 Simple, Excellent Linux Network Monitors: iftop, nethogs and vnstat.

iftop

Use the interface top iftop command. On ubuntu, we need to use sudo apt-get install iftop and then run it by sudo iftop -i eth0. After that, we can press some keys to toggle options.

  • p: port
  • s: source
  • d: destination

See thegeekstuff.

It is strange that the output shows other devices names in my network.

$ dig A pandora.com
$ ipcalc -b 208.85.40.20
$ sudo iftop -F 208.85.40.20/24 -i wlan0

nethogs

$ sudo nethogs wlan0

nload

nload -m

nload – Monitor Linux Network Bandwidth Usage in Real Time

The result is the same as gtop (gtop is cooler) gives.

bmon

https://www.tecmint.com/bmon-network-bandwidth-monitoring-debugging-linux/

vnstat

http://www.thegeekstuff.com/2011/11/vnstat-network-traffic-monitor/

# 1. Install vnStat
sudo apt-get install vnstat

# 2. Pick a Interface to Monitor using vnStat
vnstat -u -i eth0
vnstat --iflist
vnstatd -d # start the daemon
ps -ef | grep vnst

# 3. vnStat Basic Usage
vnstat

# 4. vnStat hours, days, months, weeks Network Data
vnstat -d
vnstat -m

# 5. Export the data to Excel or other DB
vnstat --dumpdb

# 6. Display Live Network Statistics
vnstat -l

# 7. Change the default vnstat output format
vnstat -s (--short)
vnstat --style 0

# 8. Display Top 10 Traffic Days
vnstat --top10

Network related linux commands

nmcli and nmtui (useful for getting DNS IPs)

# Find the up network adaptors
$ nmcli dev status
DEVICE           TYPE      STATE        CONNECTION         
docker0          bridge    connected    docker0            
eno1             ethernet  connected    Wired connection 1 

# Find the DNS 
$ nmcli dev show | grep 'IP4.DNS'

ifconfig - spoof the hardware address at the software level

To change the MAC address temporarily on a NIC (network interface controller),

sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 00:11:22:33:44:55
sudo ifconfig eth0 up

And it seems there is no need to modify /etc/network/interfaces.

For wlan

sudo ifconfig wlan0 down
sudo ifconfig wlan0 hw ether 00:11:22:33:44:55
sudo ifconfig wlan0 up

See

ip command

It is said ip is replacing the old ifconfig command on modern Linux distributions.

http://www.makeuseof.com/tag/networking-commands-linux-terminal/

ip a
ip addr
ip address show

ip link set DEVICE down # eg ip link set eth0 down

ip link set DEVICE up

iptables

route

7 Linux Route Command Examples

  1. Display Existing Routes (route -n)
  2. Adding a Default Gateway (route add default gw 192.168.1.1)
  3. List Kernel’s Routing Cache Information (route -Cn)
  4. Reject Routing to a Particular Host or Network (route add -host 192.168.1.51 reject)
  5. Make 192.168.3.* Accessible from 192.168.1.* (route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.10)
  6. Make 192.168.1.* Accessible from 192.168.3.* (route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.10)
  7. Allow Internet Access/External World (route add default gw 125.250.60.59)

On Ubuntu 16.04, it shows

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         FIOS_Quantum_Ga 0.0.0.0         UG    600    0        0 wlp3s0
link-local      *               255.255.0.0     U     1000   0        0 wlp3s0
192.168.1.0     *               255.255.255.0   U     600    0        0 wlp3s0
$ route -n   # showing numerical IP address instead of host name.
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    600    0        0 wlp3s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp3s0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp3s0

Flag value 'U' means up and 'G' means gateway'.

Connect two networks

The trick is explained in this post or the above route command.

For example, my network structure is

  • Modem/router: LAN IP 192.168.1.*/24
  • PC1: connect to Modem/router
  • Second router (ASUS) connect to Modem/router: its WAN IP is 192.168.1.ASUS. It's LAN IP 192.168.2.*/24
  • PC2 (raspberry pi): connect to the second router (ASUS): its IP is 192.168.1.212

By default, PC2 can ssh to PC1 but PC1 cannot access PC2.

The following command will solve the problem that PC1 cannot access PC2:

# From PC1
$ sudo route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.ASUS
$ ssh [email protected]    # 192.168.2.212 is the IP address for the Raspberry Pi

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.2.0     192.168.1.ASUS   255.255.255.0   UG        0 0          0 eth0

One article from linux.com using the ip command.

traceroute

sudo apt-get install traceroute
traceroute 8.8.8.8

On Windows, we can use the tracert command. For example, tracert www.microsoft.com.

netstat: get a list of all open port

How to use netstat in GNU/Linux

  • -l or --listening shows only the sockets currently listening for incoming connection.
  • -a or --all shows all sockets currently in use.
  • -e --show extended/additional information
  • -t or --tcp shows the tcp sockets.
  • -u or --udp shows the udp sockets.
  • -n or --numeric shows the hosts and ports as numbers, instead of resolving in dns and looking in /etc/services.
  • -s --Print network stats
  • -r --Print the network routing information
  • -p --Print PID and name of the program to which each socket belongs
netstat -l             # only listening ports
netstat -rn            # displays the system's routing table
netstat -at
netstat -ant           # For tcp
sudo netstat -pant     # show ports and programs (pant = 喘氣). Best of the best!!!
sudo netstat -peanut   # (output is too wide)
netstat -anp | grep 3306 | wc -l  # print the number of connections for the port mysql port i.e. 3306.

Other commands

sudo lsof -i -P -n | grep LISTEN
sudo ss -tulpn
sudo netstat -tulpn

nmap - port scanning & IPs in local network

nmap - Network exploration tool and security / port scanner

  • https://nmap.org/book/nmap-os-db.html. Local OS database is located at /usr/share/nmap/nmap-os-db. The 2nd line will show the revision number.
    • Modifying the nmap-os-db Database Yourself
    • Download the latest from https://svn.nmap.org/nmap/nmap-os-db. Note that the current revision number has to be found from the website. You can edit the file and insert the revision number on the 2nd line of your local copy.
    • Even I update the database, it cannot detect my Ubuntu 14.04 OS (it only shows OS details: Linux 3.8 - 4.9). For the Raspberry Pi, it can show information from the network adapter; e.g. MAC Address: AA:BB:CC:DD:EE:FF (Raspberry Pi Foundation) but not the OS name (OS details: Linux 3.2 - 4.8).
sudo mv /usr/share/nmap/nmap-os-db /usr/share/nmap/nmap-os-db-old

cd /usr/share/nmap
sudo wget https://svn.nmap.org/nmap/nmap-os-db
sudo apt-get install nmap

nmap 192.168.1.100   # does not require root privileges
                     # used to check open ports

nmap 192.168.1.*     # show IPs and ports in LAN

sudo nmap -sP 192.168.1.1/24 # show connected IPs (no hostnames?) and MAC addresses
                             # If you don't use 'sudo' only partial devices can be found
                             # The output may contains the hostname. For example,
                             # Nmap scan report for brb-P45T-A.fios-router.home (192.168.1.xxx)
nmap -sV 192.168.1.1 # show Daemon name (in VERSION column) together with port number

nmap -T4 -F 192.168.1.99-255 # show connected IPs and open ports
                             # -F means fast
nmap -F taichimd.us  # Note that domain name != server
nmap -v taichimd.us

nmap -A 192.168.1.1  # Aggressive scan (more output)

nmap -p http,ssh,mysql taichimd.us  # scan ports/services
                                    # note that mysql will be shown as closed
                                    # ssh port is not correct. 
                                    # Not sure how to get the correct ssh port using nmap
nmap --open taichimd.us   # scan open ports

sudo nmap -traceroute nih.gov

sudo nmap -sS -O 192.168.1.99 # -O shows operating system
                              # eth0 MAC

$ nmap localhost # showing the true ports from the server

Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-09 15:01 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00016s latency).
Not shown: 996 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
80/tcp  open  http
631/tcp open  ipp

A gui version of nmap is called Zenmap.

A List of Common Ports

nslookup and host

$ host google.com
google.com has address 172.217.5.238
google.com has IPv6 address 2607:f8b0:4004:802::200e
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.

$ nslookup google.com
Server:         127.0.1.1
Address:        127.0.1.1#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.7.238

The first two lines show the IP address of my DNS. If we run the command inside a Docker container where DNS was specified manually, the IP address we specified will be shown here.

dig

Dig provided by Google G Suite Toolbox. If the office internet is interrupted, we can use a cell phone to search for the IP address of a website for trouble shooting. Other providers include kloth.net.

$ dig world.std.com
; <<>> DiG 9.9.5-3ubuntu0.16-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49227
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             130     IN      A       172.217.5.238

;; Query time: 11 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Fri Dec 01 17:32:37 EST 2017
;; MSG SIZE  rcvd: 55

arp (Address Resolution Protocol)

The arp command can be used to show the MAC addresss of all hosts in LAN

arp -a

Copy text to a clipboard to be used in other apps

Install the xclip program. See here or here.

sudo apt-get install xclip
# Examples
sort -n -k 3, -k 2 file.txt | xclip -selection clipboard

cat ~/.ssh/id_rsa.pub | xclip -sel clip

Works.

Start Emacs without X

Add -nw (no window) option.

emacs -nw

Audio

Record audio from mic

How to Save Important Voicemails for Both iPhone and Android. Hint: use Audacity.

mp3 codecs

https://help.ubuntu.com/community/RestrictedFormats

sudo apt-get install ubuntu-restricted-extras

Concatenate mp3 files

sudo apt-get install mp3wrap
mp3wrap output.mp3 *.mp3

Reduce the size of an mp3 file

Specify a new lower bitrate using the -b option in lame. For example if your starting mp3 has a quality of 256kbs you can lower its bitrate to 128kbps (or even lower like 64kbps) by:

lame --mp3input -b 128 input.mp3 output.mp3

Convert ogg to mp3

ffmpeg is not included in Ubuntu repository. Use the avconv command. http://superuser.com/questions/15327/how-to-convert-ogg-to-mp3

sudo apt-get install libav-tools
avconv -i input.ogg -c:a libmp3lame -q:a 2 output.mp3

Convert m4a to mp3

avconv -i input.m4a output.mp3

Remove the vocals from any song using Audacity

https://www.makeuseof.com/tag/remove-vocals-song-audacity/

Normalize the volume of an audio file

  • Can You Losslessly Increase the Volume of MP3 Files?
  • Use Audacity. To raise (Amplify) volume:
    1. Edit > Select All.
    2. Effect > Amplify. Increase db. Adjust the sound until the highest peaks and lowest valleys of the waveform reach the top and bottom of the window.
    3. Check clip3. Export > MP3 or just start to listen.
  • Command line tool: avconv (replace ffmpeg program). See this post.
avconv -ss 00:00:10 -i OLD.mp3 -vol 2560 NEW.mp3

The anconv/ffmpeg -vol parameter amplifies the sound. The default value is 256 (no amplification), and you can adjust the number accordingly. Here it’s 2560, as it’s 10 times louder. Note that these are not decibel values or anything that sophisticated, but just an integer value. 512 equals to twice the volume, 768 three times, 1024 four times, etc. The -ss parameter specifies the start time offset. Here it will skip the first 10 seconds.

I found the converted file by sox has about one half file size compared to anconv/ffmpeg program (source file=47MB, anconv converted=135MB, sox converted file=54MB).

sudo apt-get install sox libsox-fmt-all
sox --norm OLD.mp3 NEW.mp3 trim 10
sox --norm OLD.mp3 NEW.mp3 silence 1 0.1 1%
sox -v 4.0 OLD.mp3 NEW.mp3             # increase volume

where '--norm' will normalize the audio and the 'trim' option set to skip the first 10 seconds. The silence parameter allows to trim silence at the beginning without a need to specify the number of seconds.

cut, delete or trim an audio

  1. Open the audio file in audacity.
  2. select a region in the waveform area. Do not select in the time interval area (above the waveform).
    1. To precisely select a range from one position to the end. Click Zoom in several times. Click one position in the waveform and click Edit -> Select -> Cursor to the track end to select
    2. Similarly, if we want to precisely select a range from the start to some position, we can click one position in the waveform and then click Edit -> Select -> Track start to cursor.
    3. To move around the track, use the scrollbar (below the waveform and above the bottom toolbar, not quite clear in Ubuntu/Unity)
  3. Click Edit -> Remove Audio or labels -> Cut/Delete/Trim Audio
  4. play the new audio by clicking the green triangle.
  5. File -> Export -> mp3 format.

Helpful resource for Audacity.

  1. Different Toolbars
  2. Tutorial - Editing an Existing Audio File

Fade out at the end of an audio

  1. Select a region.
  2. Effect -> Fade out

Wireshark

sudo apt-get install wireshark
sudo chmod 4711 `which dumpcap`

Track the Time a Command Takes

How To Find The Execution Time Of A Command Or Process In Linux

time command

time COMMAND
time (COMMAND1; COMMAND2)
time (COMMAND1 && COMMAND2)

help time

When I run a set of 7 jobs using parallel, time command gives an output

real  15m53.788s # the wall clock time the command took from execution till termination
user  95m20.238s # the time taken by the user space
sys   9m1.320s   # the time taken by kernel space

Here we see the real time is about 16m and the user time is about 6-7 times the real time. Indicating the parallel executing works.

/usr/bin/time command

/usr/bin/time provides more information then time command.

man time

Magazines

Latex

Editors

Online editing

  • Latex Base. You can start to try it without registration. Free accounts cannot publish but still can download.
  • Overleaf. Free account for 1GB space.
  • ShareLatex

Missing cls

$ apt-cache search IEEEtran
texlive-publishers - TeX Live: Publisher styles, theses, etc.
sudo apt-get install texlive-publishers

Missing sty

$ apt-cache search pseudocode
gpt - G-Portugol is a portuguese structured programming language
libgportugol-dev - Development files for the G-Portugol library
libgportugol0 - G-Portugol library
texlive-science - TeX Live: Natural and computer sciences
$ sudo apt-get install texlive-science

PDF

Change the default viewer

Right Click(pdf)-> Properties-> Open With-> Okular (or anything) -> Set as default.

PDF reader

The default one Evince seems slow when I try to view odroid magazine.

MuPDF is good at speed. Okular is good at annotation.

I installed and tried MuPDF (github source code). It seems faster and I don't see blank pages when I view one odroid magazine. In terms of speed, mupdf >> xpdf >> okular >> Evince.

To change it to be the default program for opening PDF files, right click the file and select Property. Go to the Open With tab. Choose your file viewer.

sudo apt-get install mupdf

Keyboard shortcuts for mupdf (man mupdf) or http://mupdf.com/docs/manual. Note these are case-sensitive.

W    - fit to width
H    - fit to height
L    - rotate page left (clockwise)
R    - rotate page right (counter-clockwise)
12g  - go to page 12
>,<  - go to the next or previous page
+,-  - zoom in or out
/    - search for text
n,N  - Find the next or previous search result.
h,j,k,l - Scroll page left, down, up, or right.

Tip: to copy a text, use the right mouse button to select a text. Then use Ctrl+c to copy it. It seems it does not work all the time:(

Other pdf viewer choices are

  • acroread
    • Allow to have custom colors for page background and document text.
    • The custom colors works well on Macbook Pro (2880 x 1440). Background color #494949 and text color #494949.
  • xpdf. old-fashioned. slow.
  • evince. slow.
  • okular (KDE/Qt application)
    • Annotation tool such as highlighter is under Tools > Review (F6).
    • Allow to change its background color. Though it works, the result using 'invert colors' option is not good on Dell U2312HM. We can try other option like 'dark & light colors' where we can change the individual colors for the background (say #494949) and text.
    • Not as fast as mupdf. It can open a variety of ebook formats.
    • MacOS should work but it needs to install KDE.
    • Able to show file properties eg Page Size (eg 50x36 in), Creator (eg PowerPoint), Producer (eg Mac OS X Quartz PDFContext), PDF version (eg 1.3)
  • kpdf
  • gv
  • qpdfview. slow. Used by Raspbian june 2018.
  • Foxit or PDF-XChange Viewer(needs wine)

PDF crop

pdfcrop (briss is better)

https://askubuntu.com/questions/124692/command-line-tool-to-crop-pdf-files

sudo apt-get install texlive-extra-utils

pdfcrop input.pdf output.pdf  # no margins, works but seems too tight

pdfcrop --margins 5 input.pdf output.pdf   # crop pdf but keep 5 bp from each side of page

pdfcrop --margins '5 10 20 30' input.pdf output.pdf  
#  left, top, right and bottom margins of 5, 10, 20, and 30 pt 

# To actually crop something away, use negative values in the argument for crop.
# For example, to crops 50 pts from the left, top, right, bottom (in this order).
pdfcrop --margins '-50 -50 -50 -50' input.pdf output.pdf

One problem I found is (for newer PDFs with meta data) --margins initially removes the entire margin before implementing the adjustment. This will cause some pages being chopped out.

briss

This java program gives me a better control on cropping

  1. Download the file briss-0.9.tar.gz (8.7 MB) and extract it
  2. Run java -jar briss-0.9.jar
  3. Load the pdf file. It will ask what pages to be excluded from merging (This function does not work). Click 'Cancel' to continue.
  4. It will automatically create two rectangle areas; one for odd (left) pages and the other for even (right)pages
  5. Now we work on the left page first. Enlarge the selection to suit our need. Then right click & choose 'Select/Deselect rectangle' (a dash line will be added to the edges of the rectangle) and then 'Copy rectangles'.
  6. Work on the right page. Right click and choose 'Delete rectangle'. Then 'Paste rectangles'.
  7. Now we can click 'Action -> Preview' to preview the result. If we are satisfied with the result, we can click 'Action -> Crop PDF'. Done.

Remove certain pages

https://www.linux.com/learn/manipulating-pdfs-pdf-toolkit

sudo apt install pdftk

# remove pages 10 to 25 from a PDF file
pdftk myDocument.pdf cat 1-9 26-end output removedPages.pdf

# remove the last page
pdftk infile.pdf cat 1-r2 output outfile.pdf

# remove the last 2 pages
pdftk infile.pdf cat 1-r3 output outfile.pdf

PDF highlight and annotation

Install Okular by

sudo apt-get install okular

To highlight a line, click F6 (Tools -> Review) to turn on the annotation tool bar (it will be shown on the left hand side of the documentation). You can then click

  1. the 4th icon to highlight a line (it may not be able to select the right texts we want. But when it works the result is nice)
  2. the last icon to draw an ellipse or a rectangle (to change from an ellipse to a rectange you can click Settings -> configure Okular... -> annotation)

Another method is to use a windows program and run it using Wine. See the discussion here.

Merge multiple pdf files into one pdf file

https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf

pdfunite in-1.pdf in-2.pdf in-n.pdf out.pdf

Arrange, merge, split, rotate, crop

PDFArranger: Merge, Split, Rotate, Crop Or Rearrange PDF Documents (PDF-Shuffler Fork)

Editing

Print multiple pages per sheet: pdfnup

The program is similar to psnup.

sudo apt install texlive-extra-utils

Extract tables from pdf

Extracting tables from PDFs

Flow chart

  • LibreOffice Draw OR MS_PowerPoint (insert > shape). Check youtube.
  • yEd
  • Dia & wikipedia
  • (online) www.draw.io

Clock

xclock (analog)

oclock -geometry 500x500+100+0 &

oclock (analog)

oclock -bg blue -geometry 500x500+100+0 -bd purple -transparent &
oclock -bg blue -geometry 500x500+100+0 -bd purple -jewel green &

See oclock, X - a portable, network-transparent window system which includes an example of specifying the geometry parameter.

dclock (digital)

Digital clock for the X Window System with flexible display.

sudo apt-get install dclock
dclock -h
dclock -d
dclock -date "Today is %A %B %Y" -led_off black -bg black -fg yellow -geometry 577x194+119+139         # 'q' to quit
dclock -date "Today is %m/%d/%y" -led_off black -bg black -fg yellow -geometry 400x150+0+0 # width x hight + X + Y

In practice, I create a shell script file <bin/clock> with the following content. The first ampersand sign is to hide warnings messages and the 2nd ampersand sign is to put the process in the background.

dclock -date "Today is %A %B %Y" -led_off black -bg black -fg yellow -geometry 577x194+119+139 &>/dev/null &

Lubuntu digital clock format

http://netgator.blogspot.com/2012/09/change-edit-panel-digital-clock-format.html. My format is

%a, %x, %r
# Tue, 05/17/2016, 09:42:27 PM

%a %m-%d-%y, %I:%M %p
# Mon 05-30-16, 08:31 AM

xdaliclock (digital)

https://www.mankier.com/1/xdaliclock

Scaling is not good. Colors is changing with time.

xdaliclock -noseconds -cycle  # 'q' to quit

Reminder take a break, relieve eye strain

Stretchly. It's open-source and cross-platform. Nodejs is required.

Workrave is another choice. The source code is available too.

Prevent Eye Strain While Working On Your Linux Desktop With Safe Eyes, Github source code

wine and winetricks

Running Linux in the AWS/Amazon Web Services

Forum software

RAID

Timer

How to track you laptop using Prey

https://www.howtoforge.com/tutorial/how-to-track-your-linux-laptop/

last command

Linux last Command Tutorial for Beginners (8 Examples)

Display a list of system shutdown/reboot date/time

Linux Find Out Last System Reboot Time and Date Command

# Works on Linux and Mac
last shutdown
last reboot

Automatic reboot after power failure

It seems there is no reliable way to find out when the power failed.

The linux command 'last' can show some information about system reboot.

Another way is to modify the BIOS to select the option like 'Power off and Reboot'. This won't automatically boot your computer when it is shutdown normally.

Wake up and Shut Down Linux Automatically

Two best options

  • Bios: BIOS may have an easy-to-use wakeup scheduler
  • wakeonlan:
    • Eanble it: Check if it is enabled by default. If not, we can 1) enable it through a command (ethtool -s eth0 wol g) or 2) using the Network Manager
    • Send a wake up command: (from a second linux) /usr/bin/wakeonlan D0:50:99:82:E7:2B where D0:50:99:82:E7:2B is the IP on the machine you want to wake it up

How to update Lenovo BIOS from Linux without using Windows

https://www.cyberciti.biz/faq/update-lenovo-bios-from-linux-usb-stick-pen/

Internet speed test

Web

Speedtest-cli

See Track_Internet_Dropouts.

sudo apt-get intall python-pip
sudo pip install speedtest-cli
# A slightly modified code that will create a one-line space/semi-colon 
# delimited result is 
git clone https://github.com/HenrikBengtsson/speedtest-cli-extras.git

speedtest-cli-extras/bin/speedtest-csv

works. But if I want to put it in cron, cron will issue an error speedtest-cli cannot be found. So I need to modify line 52 of the code in <speedtest-cli-extras/bin/speedtest-csv> to explicitly specify the location of speedtest-cli.

    /usr/local/bin/speedtest-cli --share > $log

NOTE: 1. the results differ from the network connection. For example, the speed is good when I test it on the machine directly connected to the router. 2. It is helpful to modify the last line of the bash script to output what I need. 3. The separator is ";" in the output.

uname - Print system information

https://www.lifewire.com/display-system-information-uname-command-3964321

uname -a will give you

  • OS (uname = uname -s if you are under a Linux environment)
  • OS (uname -s) eg Linux
  • node name (uname -n=hostname)
  • kernel release (uname -r) eg 3.16.0-38-generic
  • kernel version (uname -v)
  • machine architecture (uname -m) eg x86_64
  • processor (uname -p)
  • hardware platform (uname -i)
  • operating system (uname -o)

How to check if running in Cygwin, Mac or Linux?

Hardware information

How To Check System Hardware Manufacturer, Model And Serial Number In Linux

python--hwinfo

https://www.2daygeek.com/python-hwinfo-check-display-system-hardware-configuration-information-linux/

Linux Logo and the current system information

odroid@odroid:~$ sudo apt-get install screenfetch
odroid@odroid:~$ screenfetch
                          ./+o+-       odroid@odroid
                  yyyyy- -yyyyyy+      OS: Ubuntu 15.10 wily
               ://+//////-yyyyyyo      Kernel: armv7l Linux 3.10.96-77
           .++ .:/++++++/-.+sss/`      Uptime: 4d 23h 8m
         .:++o:  /++++++++/:--:/-      Packages: 2000
        o:+o+:++.`..```.-/oo+++++/     Shell: 2263
       .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
  .++/+:+oo+o:`             /sssooo.   DE: MATE 1.10.2
 /+++//+:`oo+o               /::--:.   WM: Metacity (Marco)
 \+/+o+++`o++o               ++////.   GTK Theme: 'Ambiant-MATE' [GTK2/3]
  .++.o+++oo+:`             /dddhhh.   Icon Theme: Ambiant-MATE
       .+.o+oo:.          `oddhhhh+    Font: Ubuntu 10
        \+.++o+o``-````.:ohdhhhhh+     CPU: ARMv7 rev 3 (v7l) @ 1.4GHz
         `:o+++ `ohhhhhhhhyo++os:      GPU: Gallium 0.4 on llvmpipe (LLVM 3.6, 128 bits)
           .o:`.syhhhhhhh/.oo++o`      RAM: 537MiB / 1990MiB
               /osyyyyyyo++ooo+++/    
                   ````` +oo+++o\:    
                          `oo++.      

odroid@odroid:~$ screenfetch -s  # take a screenshot and auto save it to ~/ directory.

odroid@odroid:~$ sudo apt-get install linuxlogo
odroid@odroid:~$ linuxlogo
        _,met$$$$$gg.                                                           
     ,g$$$$$$$$$$$$$$$P.                                                        
   ,g$$P""       """Y$$.".                                                      
  ,$$P'              `$$$.                                                      
',$$P       ,ggs.     `$$b:                                                     
`d$$'     ,$P"'   .    $$$                               ,#.                    
 $$P      d$'     ,    $$P      ##:          :##        :###:                   
 $$:      $$.   -    ,d$$'      ##'          `##         `#'                    
 $$;      Y$b._   _,d$P'    __  ##     __     ##  __      _     __          _   
 Y$$.    `.`"Y$$$$P"'     ,####:##  ,######.  ##.#####. :### ,######. ###.####: 
 `$$b      "-.__         ,##' `###  ##:  :##  ###' `###  ##' #:   `## `###' `##:
  `Y$$b                  ##    `##  ##    ##  ##'   `##  ##    ___,##  ##:   `##
   `Y$$.                 ##     ##  #######:  ##     ##  ##  .#######  ##'    ##
     `$$b.               ##     ##  ##'       ##     ##  ##  ##'  `##  ##     ##
       `Y$$b.            ##.   ,##  ##        ##    ,##  ##  ##    ##  ##     ##
         `"Y$b._         :#:._,###  ##:__,##  ##:__,##' ,##. ##.__:##. ##     ##
             `""""       `:#### ###  ######'  `######'  #### `#####"## ##     ##

 Linux Version 3.10.96-77, Compiled #1 SMP PREEMPT Fri Feb 5 04:47:32 BRST 2016
             Eight ARM  Processors, 2GB RAM, 456.00 Bogomips Total
                                     odroid

odroid@odroid:~$ linuxlogo -f -L list
odroid@odroid:~$ linuxlogo -f -L ubuntu
              .-. 
        .-'``(|||) 
     ,`\ \    `-`.                 88                         88 
    /   \ '``-.   `                88                         88 
  .-.  ,       `___:      88   88  88,888,  88   88  ,88888, 88888  88   88 
 (:::) :        ___       88   88  88   88  88   88  88   88  88    88   88 
  `-`  `       ,   :      88   88  88   88  88   88  88   88  88    88   88 
    \   / ,..-`   ,       88   88  88   88  88   88  88   88  88    88   88 
     `./ /    .-.`        '88888'  '88888'  '88888'  88   88  '8888 '88888' 
        `-..-(   ) 
              `-` 


 Linux Version 3.10.96-77, Compiled #1 SMP PREEMPT Fri Feb 5 04:47:32 BRST 2016
             Eight ARM  Processors, 2GB RAM, 192.00 Bogomips Total
                                     odroid

odroid@odroid:~$ screenfetch -h
odroid@odroid:~$ linuxlogo -h

Neofetch.png

Dictionary - Artha

  • Lifehacker. Once it is launched, it is sitting on the task bar. Press Ctrl+Alt+W after selecting a word to look it up in Artha (a balloon tip will pop up on the screen top-right). It also supports using regular expressions to search words.
sudo apt-get install artha

Translation

odroid@odroid:~/binary$ ./trans :zh-TW word
word
/wərd/

字
(Zì)

Definitions of word
[ English -> 正體中文 ]

noun
    字
        word, character, letter, calligraphy, symbol, style of writing
    詞
        word, term, speech, statement
    單詞
        word, individual word
    話
        words, word, dialect, saying, talk, speech
    言
        word, speech, character
    言辭
        words, word, what one says
    筆墨
        pen and ink, words, word, writings
    約言
        pledge, promise, word

verb
    為 ... 措辭
        word
odroid@odroid:~/binary$ time ./trans -brief :zh-TW word
字

real	0m4.249s
user	0m2.670s
sys	0m1.330s

ASCII art/ word art

  ____  ____  ____       ____            _____           _     
 | __ )|  _ \| __ )     / ___|  ___  __ |_   _|__   ___ | |___ 
 |  _ \| |_) |  _ \ ____\___ \ / _ \/ _` || |/ _ \ / _ \| / __|
 | |_) |  _ <| |_) |_____|__) |  __/ (_| || | (_) | (_) | \__ \
 |____/|_| \_\____/     |____/ \___|\__, ||_|\___/ \___/|_|___/
                                       |_|                     
  ____  _____  ____        _____         _______          _     
 |  _ \|  __ \|  _ \      / ____|       |__   __|        | |    
 | |_) | |__) | |_) |____| (___   ___  __ _| | ___   ___ | |___ 
 |  _ <|  _  /|  _ <______\___ \ / _ \/ _` | |/ _ \ / _ \| / __|
 | |_) | | \ \| |_) |     ____) |  __/ (_| | | (_) | (_) | \__ \
 |____/|_|  \_\____/     |_____/ \___|\__, |_|\___/ \___/|_|___/
                                         | |                    
                                         |_|                    
  ___ ___ ___     ___          _____         _    
 | _ ) _ \ _ )___/ __| ___ __ |_   _|__  ___| |___
 | _ \   / _ \___\__ \/ -_) _` || |/ _ \/ _ \ (_-<
 |___/_|_\___/   |___/\___\__, ||_|\___/\___/_/__/
                             |_|                  

Software that scan Malware and rootkits

Text to speech

VPN

OpenVPN

List of free and fast VPNs

How to Set Up a VPN on Your Router

https://www.makeuseof.com/tag/setup-vpn-router/

Mono Project

Mono is a software platform designed to allow developers to easily create cross platform applications part of the .NET Foundation

Mono is required for Repetier-Host software for 3D printing.

NAS server

OpenMediaVault

4 easy Linux projects for newbies and intermediate users. OpenMediaVault is a linux-based system.

Docker container for OpenMediaVault. OpenMediaVault插件之Docker教程

FreeNAS

ZFS system (FreeBSD-based).

10 Reasons Why You Should Store Your Data on a FreeNAS Box. Note With the current version of FreeNAS (FreeNAS 11) comes a hypervisor. See

Change detection

http://bhfsteve.blogspot.com/2013/03/monitoring-web-page-for-changes-using.html

3 command-line tools for feigning productivity

https://opensource.com/article/18/2/command-line-tools-productivity: Blessed-contrib (javascript), Genact, Hollywood.

Mind mapping

Diagram

Open source surveillance

ZoneMinder

Systemctl, systemd

Systemd vs SysVinit

Bitcoin

Check weather

Game

Best Linux Adobe Alternatives You Need to Know

Linux distributions

The Top 10 Open Source Distros You Haven’t Heard About

Popular Linux distributions

2017年度最佳Linux版本出爐, https://www.linuxquestions.org/questions/linux-news-59/2017-linuxquestions-org-members-choice-award-winners-4175623289/

Small/lightweight Linux distributions

10 Best And Most Secure Linux Distributions

https://fossbytes.com/secure-linux-distros-privacy-anonymity/

Kids

How to Configure Linux for Children