Posts

Showing posts from November, 2019

Cài đặt app từ SOURCE trong linux

Tải source về dưới dạng *.tag.gz 1. Giải nén ra thư mục source_app 2. vào thư mục /source_app và dùng lệnh ./config 3. make 4. make install

/etc/sysconfig/network - Cấu hình ip tĩnh và DHCP

Cấu hình IP tĩnh: NETWORKING=yes HOSTNAME=my-hostname FORWARD_IPV4=true GATEWAY="XXX.XXX.XXX.YYY" -------------------- Cấu hình phía client dùng DHCP : NETWORKING=yes HOSTNAME=my-hostname

Kiểm tra và cài đặt cấu hình mạng

Thao tác Ý nghĩa ping host-ip Cấu hình NIC OK? ping GW Cấu hình mạng cục bộ OK ping live public IP Cấu hình mạng OK ping live domain name Cấu hình DNS OK telnet Kiểm tra dịch vụ máy từ xa traceroute Kiểm tra đường đi của các gói tin ifconfig Cấu hình mạng của các NIC route Bảng chọn đường cat /etc/resolve.conf DNS đã được cấu hình hostname Tên máy Cấu hình bằng câu lệnh Đặt địa chỉ IP:        ifconfig NIC-name IP netmask MASK Đặt GW:                route add default GW IP Khởi động lại dịch vụ mạng: sudo /etc/init.d/network restart Tắt dịch vụ mạng: sudo /etc/init.d/network stop Tắt NIC:  ifconfig eth0 down Bật NIC:  ifconfig eth0 up Đặt tên cho máy:  hostname

/etc/hosts - using for specify the ip that not resolve by DNS

ff02::1 ip6-allnodes ff02::2 ip6-allrouters 10.7.1.11 viniduat.tcbs.com.vn

/etc/resolv.conf - using for config DNS in your network

domain mydomain.com search mydomain.com nameserver 192.168.x.x nameserver 8.8.8.8 nameserver XXX.XXX.XXX.XXX - IP address of primary name server nameserver XXX.XXX.XXX.XXX - IP address of secondary name server

~/.bashrc vs ~/.bash_profile

if you login your account -> .bash_profile will be executed, if .bash_profile is not exist the the .profile will be read When you open new bash terminal session then ~/.bashrc will be executed According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. ==> ~/.profile is the place to put stuff that applies to your whole session, such as programs that you want to start when you log in (but not graphical programs, they go into a different file), and environment variable definitions. ~/.bashrc is the place to put stuff that applies only to bash itself, such as alias and function definitions, shell options, and prompt settings. (You could also put key bindings there, but for bash they normally go into ~/.inputrc.) ~/.bash_profile can be used instead of ~/.profile, but it is read by bash only, not by any other shell. (This is mostly a concern if you want your initialization files to work on multiple ma...

Winston Leonard Spencer-Churchill

Image
Khi chân tướng vẫn còn đang đi giày thì lời nói dối đã chạy hết cả thành phố. Winston Leonard Spencer-Churchill (30/11/1874-24/1/1965) là một nhà chính trị người Anh, nổi tiếng nhất với cương vị Thủ tướng Anh trong thời Chiến tranh thế giới thứ hai. Ông từng là một người lính, nhà báo, tác giả, họa sĩ và chính trị gia. Churchill, nói chung, được coi là một trong những nhà lãnh đạo quan trọng nhất trong lịch sử Anh. Ông là Thủ tướng Anh duy nhất nhận giải Nobel Văn học và là người đầu tiên được công nhận là Công dân danh dự Hoa Kỳ. Winston Churchill Dưới đây là 29 câu nói kinh điển rất đáng suy ngẫm của ông: 2. Thành công là đi hết từ thất bại này tới thất bại khác mà vẫn không đánh mất nhiệt huyết. 3. Người lạc quan nhìn thấy cơ hội trong nguy cơ, người bi quan nhìn thấy nguy cơ trong mỗi cơ hội. 4. Tiếp tục kiên cường, không phải vì chúng ta thực sự mạnh mẽ, mà đó là bởi chúng ta không còn lựa chọn nào khác. 5. Đừng thử đi làm điều mà bạn thích, hãy thích điều mà...

Linux command line

https://findwords.info/term/uname 1. uname -m Uname uname (short for unix name) is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it. The uname system call and command appeared for the first time in PWB/UNIX. Both are specified by POSIX. 2. Check running service in Linux for example check docker.service //Run this command on Linux systems not using Systemd $ service docker status docker start/running, process 29393 //Run this command on Linux systems that are using Systemd $ systemctl is-active docker active

Golayout TCBS

Follow this introduction https://github.com/techcomsecurities/golayout after getting it, you should check in your go/bin and see the golayout excutable file In linux, use this command line ./golayout gen -n ~/Workspace/go/crud -m gits.tcbs.com.vn/service/crud After successful excution, it will generate your project which structure by gomodule +-- api | +-- home.go | +-- server.go | +-- user.go +-- app | +-- <<YOUR_PROJECT_NAME>> | | +-- cmd +-- service | +-- main.go +-- conf | +-- config.yml +-- store | +-- imdbuser.go | +-- sqluser.go | +-- store.go +-- user | +-- userinfo.go +-- uuid | +-- gen.go +-- config.go +-- go.mod +-- store.go +-- user.go To run the app, using this command line cd <<YOUR_PROJECT_NAME>> go run app/service/main.go -c conf/config.yml

Careful with Parallel Streams in java 8

List<String> list = new ArrayList<String>() ; //contains about 1000 element List<String> listA = new ArrayList<String>() ; // zezo element now List<String> listB = new ArrayList<String>() ; //zezo element now list.parallelStream().forEach(e -> { if (e.equals( "A" )) { listA .add(e) ; } else { listB .add(e) ; } }) ; list.stream().forEach(e -> { if (e.equals( "A" )) { listA .add(e) ; } else { listB .add(e) ; } }) ; Maybe some guys will think that the above codes with parallelStream () is faster and better than the code with stream () If you try to run it in fact with parallelStream() then it may throw IndexOutOfArrayException, but with stream() is well. Why????? 1. listA.add(e); and listB.add() is not supported using in mutilthread. Your code is not good 2. why it throw IndexOutOfArrayException? please read codes of ArrayList :-) Note:  1. you should use    ...

Go module

go run -mod=vendor  main.go -c=config.yml The above cmd will run app with the vendor libs that downloaded go mod vendor The cmd will create vendor lib folder in vendor folder go mod init  This will generate file go.mod

Install Oracle Java in Debian

Image
You should visit Oracle JDK Home page to download newest JDK for linux, window, macOS https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-5672538.html then select your jdk you can select  jdk-13.0.1_linux-x64_bin.deb , or *.rpm or *.tar.gz I selected *.deb to install on my Debian OS ----------------------- Step 1: use this command line sudo        dpkg      -i        path/to/jdk-13.0.1_linux-x64_bin.deb Step 2: check in folder  /usr/lib/jvm/        or      /usr/java/   you will see the folder  jdk-13.0.1 Step3: sudo nano /etc/environment Copy and paste this to the file and save PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk-13.0.1/bin" JAVA_HOME = "/usr/lib/jvm/jdk-13.0.1" Step4: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk...

Install *sh, *.jar .... as a desktop application in linux

In Terminal Prefer this way below sudo gedit ~/.local/share/applications/<Your App Name>.desktop this means the app is owned by you, and can share with others or sudo gedit /usr/share/applications /<Your App Name>.desktop this means the app is owned by people using your computer, and pepple can use it In gedit Here you should edit:  Note that the below comments are best guess, feel free to correct me [Desktop Entry] Encoding=UTF-8 Name=PostmanApp GenericName=PostmanApp Comment=PostmanApp Exec=/opt/yourFolderApp/excutableFile.xxx Icon=/opt/yourFolderApp/icon.png Terminal=false Type=Application Save the file. Now your application will show in searches  ref:  https://askubuntu.com/questions/37401/how-do-i-add-a-launcher-for-sh-applications

Vim tutorial

ESC: exit mode i : insert save:   :w save and exit:   :wq exit:   :q force:   !  (example  :w! :q! ) vertical split:  open a document and then type :vsplit /path-to-document/document and this will open the specified document and split the screen so you can see both documents. copy:   y  + enter copy a line:   yy  + enter paste:   p  cut:   d cut a line:   dd

Add user to root in linux

https://linuxize.com/post/how-to-create-a-sudo-user-on-debian/

Install .RPM, .Deb package in linux

RPM là Redhat package manager Để cài đặt phần mềm RPM thì bạn cần tải gói rpm về sau đó dùng lệnh rpm -Uvh path/to/package.rpm -U : upgrade nó sẽ cài mới hoặc update bản đang có -v: verbose -h makes rpm print a progress bar: Để cài phần mềm .DEB Gõ lệnh dpkg -i path/to/file.deb

Docker tutorial

https://jobs.hybrid-technologies.vn/blog/huong-dan-su-dung-docker-co-ban/ Doker tutorial --------------------- docker info chỉ ra docker đang có bao nhiêu ảnh, bao nhiêu containner đang chạy hay dừng -------------------- dùng lệnh  docker images : để xem danh sách các ảnh đã tải về ------ Làm thế nào để có ảnh docker pull  : dùng để donwload image từ dockerhub docker pull <image_name:tag> -------sau khi có ảnh rồi thì cài đặt như nào 1. docker run {image_name or id_image} 2. docker run {image_name}:{tag_name} trường hợp bạn có nhiều version ảnh của một phần mềm (ví dụ redis:1.1, redis latest, redis :1.2) 3. docker run -d --name  container-name -p localhost:80:80 -v $HOME/myContainer/configDir:/myImage/configDir --restart=always image-name 4. ex: sudo docker run -d -p 6379:6379 --name redis1 redis --detach , -d       Run container in background and print container ID --name             ...

Partion in ubuntu

/bin/ : This contains commands used by a regular user. /boot/ : The files required for the operating system startup are stored here. /cdrom/ : When CD-ROM is mounted, the CD-ROM files are accessible here. /dev/ : The device driver files are stored in this folder. These device driver files will point to hardware-related programs running in kernel. /etc/ : This folder contains configuration files and startup scripts. /home/ : This folder contains a home folder of all users except the administrator. /lib/ : The library files are stored in this folder. /media/ : External media such as a USB pen drive is mounted in this folder. /opt/ : The optional packages are installed in this folder. /proc/ : This contains files which give information about kernel and every process running in OS. /root/ : This is the administrators home folder. /sbin/ : This contains commands used by the administrator or root user. /usr/ : This contains secondary programs, libraries, and documentation about u...

Key combinations in Bash

Ctrl+A: Move cursor to the beginning of the command line. Ctrl+E: Move cursor to the end of the command line. Ctrl+L: Clear this terminal. Ctrl+R: Search command history, see Section 3.3.3.4.

Quickstart commands

ls Displays a list of files in the current working directory, like the dir command in DOS cd directory change directories passwd change the password for the current user file filename display file type of file with name filename cat textfile throws content of textfile on the screen pwd display present working directory exit or logout leave this session man command read man pages on command info command read Info pages on command apropos string search the whatis database for strings