Linux hardware information

# sources:
# http://askubuntu.com/questions/18372/how-can-i-find-out-what-ram-a-computer-system-has

RAM
sudo lshw -short -C memory
sudo lshw -C memory
sudo dmidecode -t memory

VGA memory
sudo dmesg | grep Reserving
[    0.000000] Reserving Intel graphics stolen memory at 0x5ef00000-0x7eefffff
compute now using a hexadecimal calculator 7eefffff - 5ef00000 + 1
the result is 512 * 1024 * 1024 which means 512 MB of memory
other related commands:
sudo dmesg | grep memory
lspci -v | grep -A10 VGA
grep -i mem /var/log/Xorg.0.log
sudo dmesg | grep drm
sudo dmesg | grep "Memory usable by graphics device"

BIOS
dmesg | grep -i BIOS

Linux youtube downloader errors

first, let's see the youtube-dl error
youtube-dl https://www.youtube.com/playlist?list=PLEmVsSEEP5HDTSik5ZSyOWz0qsS1tPos_
[youtube:playlist] PLEmVsSEEP5HDTSik5ZSyOWz0qsS1tPos_: Downloading webpage
[download] Downloading playlist: cantece pt copii in germana
[youtube:playlist] playlist cantece pt copii in germana: Downloading 6 videos
[download] Downloading video 1 of 6
[youtube] dtZ7U7csvcw: Downloading webpage
[youtube] dtZ7U7csvcw: Downloading video info webpage
[youtube] dtZ7U7csvcw: Extracting video information
[youtube] dtZ7U7csvcw: Downloading MPD manifest
Traceback (most recent call last):
  File "/usr/bin/youtube-dl", line 6, in 
    youtube_dl.main()
  File "/usr/lib/python2.7/dist-packages/youtube_dl/__init__.py", line 444, in main
    _real_main(argv)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/__init__.py", line 434, in _real_main
    retcode = ydl.download(all_urls)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1791, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 705, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 866, in process_ie_result
    extra_info=extra)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 758, in process_ie_result
    extra_info=extra_info)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 694, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 357, in extract
    return self._real_extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 1671, in _real_extract
    formats_dict=self._formats):
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 1547, in _extract_mpd_formats
    compat_etree_fromstring(mpd.encode('utf-8')), mpd_id, mpd_base_url,
  File "/usr/lib/python2.7/dist-packages/youtube_dl/compat.py", line 2526, in compat_etree_fromstring
    doc = _XML(text, parser=etree.XMLParser(target=_TreeBuilder(element_factory=_element_factory)))
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1476, in __init__
    "No module named expat; use SimpleXMLTreeBuilder instead"
ImportError: No module named expat; use SimpleXMLTreeBuilder instead

some checks
Search for pyexpat*.so:
ll /usr/lib/python2.7/lib-dynload/pyexpat*
-rw-r--r-- 1 root root 68K Nov 19 11:35 /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
Check for it's dependencies:
ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
	linux-vdso.so.1 =>  (0x00007fff059fd000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fac3b8c7000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fac3b4fe000)
	libexpat.so.1 => /u01/app/oracle/product/12.1.0/dbhome_1/lib/libexpat.so.1 (0x00007fac3b2da000)
	/lib64/ld-linux-x86-64.so.2 (0x000055c542d57000)
When strange dependencies are listed (e.g. libexpat.so.1 from oracle) try to fix them.
Check for LD_LIBRARY_PATH value:
echo $LD_LIBRARY_PATH
/u01/app/oracle/product/12.1.0/dbhome_1/lib:/lib:/usr/lib:/usr/lib64

possible solution
Solution (for me this will probably break oracle):
unset LD_LIBRARY_PATH
ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
	linux-vdso.so.1 =>  (0x00007ffd1ff13000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe242eba000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe242af1000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fe2428c7000)
	/lib64/ld-linux-x86-64.so.2 (0x0000558368063000)
And now youtube-dl works again!
Of course you'll have to set LD_LIBRARY_PATH when running oracle.

Comments on Angular 2 router guide

https://angular.io/docs/ts/latest/guide/router.html#!#resolve-guard
CanDeactivateGuard is used in CrisisCenterRoutingModule which is part of CrisisCenterModule which is lazy loaded by AppRoutingModule (loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule').
q: Why should CanDeactivateGuard be declared in AppRoutingModule providers? why not to CrisisCenterRoutingModule providers?
guide answer: We also need to add the Guard to our main AppRoutingModule providers so the Router can inject it during the navigation process.
my (original) comment
AppRoutingModule seems to need to know in advance (at least for lazy loaded modules) the CanDeactivate guards used classes. It's odd why this does not apply for e.g. CrisisDetailResolve which is a service too and has the same configuration parent.
the final answer
Well, it seems that indeed CanDeactivateGuard could be provided by CrisisCenterRoutingModule too instead of AppRoutingModule. 
Now the question is why then the guide pointed AppRoutingModule as the one to provide CanDeactivateGuard?
The answer I guess is that the CanDeactivateGuard is a service useful to any module and because lazy loaded modules have their own root injector this means it would be created an additional instance of CanDeactivateGuard for any lazy load module that would provide it too. CanDeactivateGuard has no state so it's useless to have more than one instance of it.

X server and related managers

See also
# nice explanation about the entire startx workflow
http://unix.stackexchange.com/questions/243195/what-desktop-environment-does-startx-run-and-how-can-i-change-it
# explanation about sessions
http://askubuntu.com/questions/62833/how-do-i-change-the-default-session-for-when-using-auto-logins

# list available desktop environments
ls -l /usr/share/xsessions
# show current login manager
cat /etc/X11/default-display-manager
# see also lightdm-greeter from Alternatives Configurator:
ls -l /usr/share/xgreeters
# how to restore Unity login greeter
cat /etc/lightdm/lightdm.conf
[SeatDefaults]
autologin-user=
allow-guest=false
greeter-session=unity-greeter -> add this line

# check the available session managers with
update-alternatives --list x-session-manager
# or get a more verbose description indicating which one is default with
update-alternatives --display x-session-manager
# shows the link to the default session manager
ls -l /etc/alternatives/x-session-manager
# change the default session manager by running
update-alternatives --config x-session-manager

# list available window managers
update-alternatives --list x-window-manager
# shows the link to the default window manager
ls -l /etc/alternatives/x-window-manager

# http://askubuntu.com/questions/62833/how-do-i-change-the-default-session-for-when-using-auto-logins
# list of available session types
ls -l /usr/share/xsessions
# see also ~/.dmrc for the current default selected session type
cat ~/.dmrc
# see also user defaults with
cat /var/lib/AccountsService/users/$USER

q: what to put in .xsession (e.g. for xrdp)?
a: pick from update-alternatives --list x-session-manager
warn: some of them won't work (something related to 3D graphics)
worked for me: xfce4-session, lxsession, mate-session, startlxde, openbox-session

# Zorin OS theme
# http://www.noobslab.com/2015/09/do-you-like-windows-10-look-but-love.html
# https://launchpad.net/~noobslab/+archive/ubuntu/themes?field.series_filter=xenial
sudo add-apt-repository ppa:noobslab/themes
sudo apt-get update
sudo apt-get install windos-10-themes

# 9 Great XFCE Themes
# Ambiance theme for XFCE (with xfwm4)
Current XFCE theme:
grep -nr ThemeName .config/xfce4
When Settings -> Appearance doesn't open try running it from command line:
xfce4-appearance-settings

# change xfce desktop icon background/shadow
# see /usr/share/doc/xfdesktop4/README
# my ~/.gtkrc-2.0.mine
style "xfdesktop-icon-view" {
    XfdesktopIconView::label-alpha = 1

    fg[NORMAL] = "#ffffff"
    fg[SELECTED] = "#ffffff"
    fg[ACTIVE] = "#ffff00"
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"

lsof

What files are open?                       lsof
What process has a particular file open?   lsof /path/to/the/file
What files in some directory are open?     lsof +D /path/to/the/dir
What files does some user have open?       lsof -u username
What files do a group of users have open?  lsof -u user1,user2
What files are open by process name?       lsof -c procname
What files are open by PID?                lsof -p 123
What files are open by other PIDs?         lsof -p ^123
Show network activity                      lsof -i
What files are open by port?               lsof -i :25
                                           lsof -i :smtp
List PIDs                                  lsof -t
Show network activity for a user           lsof -a -u username -i
Show socket use                            lsof -U
Show NFS activity                          lsof -N