Memoru

System Engineering and Programming and IT

1807-ubuntu-shortcut

1807-ubuntu-shortcut

Overview

  • list up ubuntu 18.04 shortcut's operation

Contents

Switcher

operation function note
win activities
win+a application center
win+s application switcher
win+tab Switcher alt+tab
operation function note
win+1 Browser firefox
win+2 Filer nautilus
win+3 Terminal terminal|ctrl+alt+t
win+4 mailer and calendar evolution
win+5 chrome apps
win+6 urls simplenote
win+7 diary journey
win+8 markdown joplin
win+9 tweet corebird
win+0 chat slack
win+L log out
win+v view calendar

Window navigation

operation function note
win+up maximize
win+h minimize
win+d Display desktop
win+right right
win+left left
ctrl+alt+down workspace change
ctrl+alt+up workspace change

// --- end of markdown

1807-wsl-timezone-setting

Overview

reference

Contents

set timezone

sakai@eX:~$ date
Fri Jul 13 16:24:09 DST 2018
sakai@eX:~$ sudo dpkg-reconfigure tzdata
[sudo] password for sakai:

Current default time zone: 'Asia/Tokyo'
Local time is now:      Fri Jul 13 16:25:15 JST 2018.
Universal Time is now:  Fri Jul 13 07:25:15 UTC 2018.

sakai@eX:~$ date
Fri Jul 13 16:26:20 JST 2018

// --- end of markdown

1807-WSL-environment-setting

1807-WSL-environment-setting

Overview

  • Windows Subsystem on Linux (WSL)で環境を構築する。

Target

  • python / pip / virtualenv / virtualenvwrapper
  • git / gibo
  • jenkins
  • powershell
  • nginx

Procedure

1. python environment

  • log in
sakai@eX:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
sakai@eX:~$ pwd
/home/sakai
sakai@eX:~$ ls
nginx_signing.key  workspace
sakai@eX:~$
sakai@eX:~$ python3 --version
Python 3.6.5
sakai@eX:~$ pip --version


Command 'pip' not found, but can be installed with:

sudo apt install python-pip

sakai@eX:~$ sudo apt install python-pip
sakai@eX:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
sakai@eX:~$ sudo pip install virtualenv
sakai@eX:~$ virtualenv --version
16.0.0
sakai@eX:~$ sudo pip install virtualenvwrapper
sakai@eX:~$ whereis virtualenvwrapper
virtualenvwrapper: /usr/local/bin/virtualenvwrapper.sh /mnt/g/Users/sakai/AppData/Local/Programs/Python/Python36-32/Scripts/virtualenvwrapper.bat
  • /.bashrc
sakai@eX:~$ vim ~/.bashrc
    source /usr/local/bin/virtualenvwrapper.sh
    export WORKON_HOME=~/.virtualenvs
    export PROJECT_HOME=~/workspace/py
  • operate virtualenvwrapper
sakai@eX:~$ source ./.bashrc
sakai@eX:~/workspace/py$ mkproject sandbox
New python executable in /home/sakai/.virtualenvs/sandbox/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/preactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/postactivate
virtualenvwrapper.user_scripts creating /home/sakai/.virtualenvs/sandbox/bin/get_env_details
Creating /home/sakai/workspace/py/sandbox
Setting project for sandbox to /home/sakai/workspace/py/sandbox
(sandbox) sakai@eX:~/workspace/py/sandbox$ workon
sandbox
(sandbox) sakai@eX:~/workspace/py/sandbox$ deactivate
sakai@eX:~/workspace/py/sandbox$ ls

2. git environment

  • git
sakai@eX:~/workspace/py/sandbox$ git --version
git version 2.17.0
sakai@eX:~$ curl https://github.com/simonwhitaker/gibo/blob/master/shell-completions/gibo-completion.bash > gibo.sh
sakai@eX:~$ sudo cp gibo.sh /usr/local/bin
sakai@eX:~$ chmod -x /usr/local/bin/gibo.sh
chmod: changing permissions of '/usr/local/bin/gibo.sh': Operation not permitted
sakai@eX:~$ gibo --version
: not founds/sakai/Downloads/gibo/gibo: 5: /mnt/g/Users/sakai/Downloads/gibo/gibo:
: not founds/sakai/Downloads/gibo/gibo: 10: /mnt/g/Users/sakai/Downloads/gibo/gibo:
gibo 1.0.6 by Simon Whitaker <sw@netcetera.org>
https://github.com/simonwhitaker/gibo
  • git sample operation
sakai@eX:~/workspace/py/sandbox$ git init
Initialized empty Git repository in /home/sakai/workspace/py/sandbox/.git/
sakai@eX:~/workspace/py/sandbox$ echo "" > README.md

sakai@eX:~/workspace/py/sandbox$ git add .
sakai@eX:~/workspace/py/sandbox$ git status
sakai@eX:~/workspace/py/sandbox$ git commit -m 'first commit'

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <sakai@eX.localdomain>) not allowed
sakai@eX:~/workspace/py/sandbox$ git config --global user.email "sakai.memoru@gmail.com"
sakai@eX:~/workspace/py/sandbox$ git config --global user.name "memoru"
sakai@eX:~/workspace/py/sandbox$ git config --list
user.email=sakai.memoru@gmail.com
user.name=memoru
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

sakai@eX:~/workspace/py/sandbox$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   README.md

sakai@eX:~/workspace/py/sandbox$ git commit -m 'first commit'
[master (root-commit) 91f2e58] first commit
 1 file changed, 5 insertions(+)
 create mode 100644 README.md
sakai@eX:~/workspace/py/sandbox$ vim README.md
sakai@eX:~/workspace/py/sandbox$ git diff HEAD
diff --git a/README.md b/README.md
index d1cd81a..33b84de 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
 # {{title}}

+## overview
+- python workspace on sandbox

 // --- end of markdown

sakai@eX:~/workspace/py/sandbox$

3. node environment

sakai@eX:~/workspace/py/sandbox$ sudo apt update
sakai@eX:~/workspace/py/sandbox$ sudo apt install nodejs
sakai@eX:~/workspace/py/sandbox$ sudo apt install npm
sakai@eX:~/workspace/py/sandbox$ nodejs --version
v8.10.0
sakai@eX:~/workspace/py/sandbox$ npm --version
3.5.2
sakai@eX:~/workspace/py/sandbox$

4. java 8 and jenkins installation

sakai@eX:~/workspace/py/sandbox$ sudo apt install openjdk-8-jdk
sakai@eX:~/workspace/py/sandbox$ java -version
openjdk version "1.8.0_171"
sakai@eX:~$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key > jenkins-ci.org.key
sakai@eX:~$ ls
jenkins-ci.org.key  nginx_signing.key  workspace
sakai@eX:~$ sudo apt-key add jenkins-ci.org.key
OK
sakai@eX:~$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sakai@eX:~$ sudo apt-get update
sakai@eX:~$ sudo apt-get install jenkins
sakai@eX:~$ sudo service --status-all | grep jenkins
 [ ? ]  apport
 [ ? ]  cryptdisks
 [ ? ]  cryptdisks-early
 [ ? ]  hwclock.sh
 [ ? ]  jenkins
 [ ? ]  plymouth
 [ ? ]  plymouth-log
sakai@eX:~$ sudo vim /etc/default/jenkins
HTTP_PORT=8083

sakai@eX:~$ cd /etc/init.d
sakai@eX:/etc/init.d$ ls | grep jenkins
jenkins
sakai@eX:/etc/init.d$ sudo service jenkins enabled
Correct java version found
Usage: /etc/init.d/jenkins {start|stop|status|restart|force-reload}
sakai@eX:/etc/init.d$ sudo service jenkins start
Correct java version found
 * Starting Jenkins Automation Server jenkins                                       [ OK ]
sakai@eX:/etc/init.d$ sudo service --status-all | grep jenkins
 [ ? ]  apport
 [ ? ]  cryptdisks
 [ ? ]  cryptdisks-early
 [ ? ]  hwclock.sh
 [ + ]  jenkins
 [ ? ]  plymouth
 [ ? ]  plymouth-log
sakai@eX:/etc/init.d$
sakai@eX:/etc/init.d$ curl http://127.0.0.1:8083
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Administer

-->

</body></html>       
sakai@eX:/etc/init.d$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
357c7bf2fb4b42bab09975f0c6a5ecd7
sakai@eX:/etc/init.d$

5. powershell

sakai@eX:~$ wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu57_57.1-6ubuntu0.3_amd64.deb
sakai@eX:~$ wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.2/powershell_6.0.2-1.ubuntu.18.04_amd64.deb
sakai@eX:~$ dpkg-deb --raw-extract powershell_6.0.2-1.ubuntu.17.04_amd64.deb pwsh-patched
sakai@eX:~$ sed --in-place 's/curl13/curl14/g' pwsh-patched/DEBIAN/control
sakai@eX:~$ dpkg-deb --build pwsh-patched powershell-patched_6.0.2-1.ubuntu.18.04_amd64.deb

sakai@eX:~$ sudo apt install -f ./libicu57_57.1-6ubuntu0.3_amd64.deb
sakai@eX:~$ sudo apt install -f ./powershell-patched_6.0.2-1.ubuntu.18.04_amd64.deb
sakai@eX:~$ pwsh
PowerShell v6.0.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/sakai> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.2
PSEdition                      Core
GitCommitId                    v6.0.2
OS                             Linux 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

// --- end of markdown

nginx.conf

nginx.conf (base)

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml껋 text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#  # See sample authentication script at:
#  # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#  # auth_http localhost/auth.php;
#  # pop3_capabilities "TOP" "USER";
#  # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#  server {
#      listen     localhost:110;
#      protocol   pop3;
#      proxy      on;
#  }
# 
#  server {
#      listen     localhost:143;
#      protocol   imap;
#      proxy      on;
#  }
#}

sites-available/default

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server
    #
    #location ~ \.php$ {
    #  include snippets/fastcgi-php.conf;
    #
    #  # With php-fpm (or other unix sockets):
    #  fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    #  # With php-cgi (or other tcp sockets):
    #  fastcgi_pass 127.0.0.1:9000;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #  deny all;
    #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#  listen 80;
#  listen [::]:80;
#
#  server_name example.com;
#
#  root /var/www/example.com;
#  index index.html;
#
#  location / {
#      try_files $uri $uri/ =404;
#  }
#}

confirm nginx processing

On WSL

NGINX installation

sakai@eX:~$ pwd
/home/sakai
sakai@eX:~$ wget -q http://nginx.org/keys/nginx_signing.key
sakai@eX:~$ ls
nginx_signing.key
sakai@eX:~$ sudo apt-key add nginx_signing.key
OK
sakai@eX:~$ sudo apt-get update
:
:
Fetched 16.4 MB in 13s (1292 kB/s)
Reading package lists... Done
sakai@eX:~$ sudo apt-get install nginx

NGINX execution

root@MB-B504ES:~# sudo nginx
root@MB-B504ES:~# ps ax | grep nginx
   20 ?        Ss     0:00 nginx:
   21 ?        S      0:00 nginx:
   22 ?        S      0:00 nginx:
   23 ?        S      0:00 nginx:
   24 ?        S      0:00 nginx:
   26 tty1     S      0:00 grep --color=auto nginx
root@MB-B504ES:~# ss -an | grep LISTEN
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
Cannot open netlink socket: Protocol not supported
root@MB-B504ES:~# nginx -s stop