0c4b165f94fb127d062e7bead0000b9b419e9f62
[blog.git] / posts / linux-note.org
1 #+TITLE: Note of Linux (Debian)
2 #+AUTHOR: Peng Li
3 #+EMAIL: seudut@gmail.com
4 #+DATE: 2016-12-23
5
6 * Install and Environment
7 ** Install ios in virtual box
8 ** install essential softwares
9 *** Change the sourece.list
10 163 mirrors
11 #+BEGIN_EXAMPLE
12   deb http://mirrors.163.com/debian stable main non-free contrib
13   deb-src http://mirrors.163.com/debian stable main non-free contrib
14 #+END_EXAMPLE
15 *** Install essential packages
16 - ~netselect-apt~
17   Find the fastest apt mirror server
18 - vim
19 - sudo
20   Add user to sudo group or change the =/etc/sudoers= to use =sudo= command
21   #+BEGIN_SRC sh :results output replace
22       sudo adduser <username> sudo
23   #+END_SRC
24 - git, openssh-server, emacs, build-essential, tmux, zsh, silversearcher-ag
25
26 *** Build Emacs from source
27 1. gnutls error, to fix, install =gnutls-dev= and =pkg-config=
28
29 configure emacs =-without-x=
30
31 #+BEGIN_EXAMPLE
32
33 Does Emacs use -lgnutls?                                no
34 #+END_EXAMPLE
35
36 ** others package
37 htop, lftp, apache2, vsftpd, silversearcher-ag,
38 * Issue
39 1. See the router table on mac 
40 #+BEGIN_SRC sh :results output replace
41   netstat -nr
42 #+END_SRC
43
44 2. wget download https
45 https://www.cyberciti.biz/faq/wget-example-download-from-https-web-sites/
46 wget --no-check-certificate https://cyberciti.biz/foo/bar.tar.gz
47
48 3. =ls= in =zsh= has no color
49
50 4.  issue 
51 -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
52
53 #+BEGIN_SRC sh
54   dpkg-reconfigure locales
55 #+END_SRC
56
57 * VirtualBox
58 Install virtualbox guest addition
59 https://blog.paranoidpenguin.net/2016/12/installing-the-virtualbox-guest-additions-on-debian-8-jessie/
60 ** HostOnly and NAT
61 - Need install extensions, add a hostonly network, address start as 192.168.56.1, then You host (mac) will be added one more interface, named
62   vboxnet0, 192.168.56.1
63 - ADd both hostonly and nat interface in the network setting
64 - start linux, and modify =/etc/network/interfaces/=
65    add configure for eth1 (hostonly ) interface, such as 
66 #+BEGIN_SRC sh :results output replace
67   allow-hotplug eth1
68   iface eth1 inet static
69   address 192.168.56.2
70   netmask 255.255.255.0
71 #+END_SRC
72 ** Port forward, web server
73
74
75 ** Shared folder
76 - Install Guest Addition,
77 https://forums.virtualbox.org/viewtopic.php?t=15679
78
79 Insert  GuestAddition.ios, 
80 #+BEGIN_SRC sh
81   mount /dev/sr0 /media/cdrom
82 #+END_SRC
83
84 - install build-essentials, linux-headers-amd64
85
86
87 - Create folder to share in host machine
88 - add user to virtualbox group
89 #+BEGIN_SRC sh :results output replace
90   adduser debian vboxsf
91 #+END_SRC
92
93
94
95
96 * Apache config
97 ** Enabled Cgi mode
98 To enable cgi mdoule, create symbolic link to mods-available/cgid.conf /etc/apache2/mods-enabled/
99 https://perlmaven.com/perl-cgi-script-with-apache2
100
101 Add sample perl script to test, put under =/usr/lib/cgi-bin/= and chmod a+x, troubleshooting see the log =/var/log/apache2/error.log=
102 #+BEGIN_SRC perl 
103   #!/usr/bin/perl -w
104
105   use strict;
106
107   use CGI qw/:standard/;
108
109   print header,
110       start_html ("hello world"),
111       h1 ("hello"),
112       end_html;
113
114 #+END_SRC
115 ** cgi directory config
116 #+BEGIN_SRC sh
117            ScriptAlias /cgi-bin/ /var/cgi-bin/
118            <Directory "/var/cgi-bin">
119                    AllowOverride None
120                    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
121                    Require all granted
122            </Directory>
123 #+END_SRC
124 * Raspberry raspbian
125 ** start sshd on boot and vnc server
126 http://www.raspberrypi-spy.co.uk/2012/05/enable-secure-shell-ssh-on-your-raspberry-pi/
127
128 ** Auto mount usb / external disk
129 change fstab file, add one entry with the uuid of the disk
130
131 ** Auto mount smb folder
132 1. manuall mount 
133 #+BEGIN_EXAMPLE
134 sudo mount -t cifs -o username=pi,password=xxx //192.168.31.1/Folder /mnt/folder
135 #+END_EXAMPLE
136
137 http://askubuntu.com/questions/157128/proper-fstab-entry-to-mount-a-samba-share-on-boot
138
139 ** apache2
140 aptitude install =apache2=, start it by runing 
141
142 ** vsftpd
143
144 ** smbclient