Linux hardware information

# sources:

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"

dmesg | grep -i BIOS

Linux youtube downloader errors

first, let's see the youtube-dl error
[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 
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 444, in main
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 434, in _real_main
    retcode =
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 1791, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 705, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 866, in process_ie_result
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 758, in process_ie_result
  File "/usr/lib/python2.7/dist-packages/youtube_dl/", line 694, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/", line 357, in extract
    return self._real_extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/", line 1671, in _real_extract
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/", 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/", 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/", 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/
Check for it's dependencies:
ldd /usr/lib/python2.7/lib-dynload/ =>  (0x00007fff059fd000) => /lib/x86_64-linux-gnu/ (0x00007fac3b8c7000) => /lib/x86_64-linux-gnu/ (0x00007fac3b4fe000) => /u01/app/oracle/product/12.1.0/dbhome_1/lib/ (0x00007fac3b2da000)
	/lib64/ (0x000055c542d57000)
When strange dependencies are listed (e.g. from oracle) try to fix them.
Check for LD_LIBRARY_PATH value:

possible solution
Solution (for me this will probably break oracle):
ldd /usr/lib/python2.7/lib-dynload/ =>  (0x00007ffd1ff13000) => /lib/x86_64-linux-gnu/ (0x00007fe242eba000) => /lib/x86_64-linux-gnu/ (0x00007fe242af1000) => /lib/x86_64-linux-gnu/ (0x00007fe2428c7000)
	/lib64/ (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!#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
# explanation about sessions

# 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
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

# 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
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:

# 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"


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