jenkins setup
parent
101e638ba0
commit
ad1fe857cc
File diff suppressed because it is too large
Load Diff
@ -1,149 +1,176 @@
|
|||||||
# Useful shell command
|
# Useful shell command
|
||||||
|
|
||||||
* commands
|
* commands
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
// add a user to root group
|
// add a user to root group
|
||||||
$ visudo
|
$ visudo
|
||||||
|
|
||||||
# User privilege specification
|
# User privilege specification
|
||||||
root ALL=(ALL:ALL) ALL
|
root ALL=(ALL:ALL) ALL
|
||||||
newuser ALL=(ALL:ALL)ALL
|
newuser ALL=(ALL:ALL)ALL
|
||||||
|
|
||||||
hold `ctrl` and press `x` to save and exit
|
hold `ctrl` and press `x` to save and exit
|
||||||
|
|
||||||
// list all running process
|
// list all running process
|
||||||
$ ps aux
|
$ ps aux
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* run as root
|
* run as root
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
user@host$ sudo su -
|
user@host$ sudo su -
|
||||||
|
|
||||||
// prompt will show root login
|
// prompt will show root login
|
||||||
root@host$
|
root@host$
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* add a user to a group
|
* add a user to a group
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
// create docker group
|
// create docker group
|
||||||
$ sudo groupadd docker
|
$ sudo groupadd docker
|
||||||
|
|
||||||
// add current user to group
|
// add current user to group
|
||||||
$ sudo usermod -aG docker ${USER}
|
$ sudo usermod -aG docker ${USER}
|
||||||
|
|
||||||
// restart to take effect
|
// restart to take effect
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* change file permission
|
* change file permission
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
||||||
// excecute, read, write
|
// excecute, read, write
|
||||||
$ chmod 777 filename
|
$ chmod 777 filename
|
||||||
|
|
||||||
// made executable
|
// made executable
|
||||||
$ chmod +x envtest.sh
|
$ chmod +x envtest.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
## node version manager [nvm](https://github.com/nvm-sh/nvm)
|
## node version manager [nvm](https://github.com/nvm-sh/nvm)
|
||||||
|
|
||||||
* For proper installing, using version manager for nodejs to install nodejs/npm
|
* For proper installing, using version manager for nodejs to install nodejs/npm
|
||||||
* use nvm
|
* use nvm
|
||||||
* to avoid npm version conflict installation with nodejs
|
* to avoid npm version conflict installation with nodejs
|
||||||
* to install / switch to lower / newer version on any version ubuntu
|
* to install / switch to lower / newer version on any version ubuntu
|
||||||
* ubuntu 20.10 default support node 12
|
* ubuntu 20.10 default support node 12
|
||||||
* ubuntu 19.10 default support node 10
|
* ubuntu 19.10 default support node 10
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
// installation
|
// installation
|
||||||
|
|
||||||
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
|
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
|
||||||
|
|
||||||
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
|
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
|
||||||
|
|
||||||
$ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
$ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||||
|
|
||||||
# This loads nvm
|
# This loads nvm
|
||||||
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
|
||||||
// to install node version 10.10.0
|
// to install node version 10.10.0
|
||||||
$ nvm install 10.10.0
|
$ nvm install 10.10.0
|
||||||
|
|
||||||
// remove node to solve conflicting version
|
// remove node to solve conflicting version
|
||||||
$ sudo apt-get remove nodejs
|
$ sudo apt-get remove nodejs
|
||||||
$ sudo apt autoremove
|
$ sudo apt autoremove
|
||||||
```
|
```
|
||||||
|
|
||||||
* ssh id
|
* ssh id
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ ssh-keygen
|
$ ssh-keygen
|
||||||
|
|
||||||
// copy ssh public key to host .ssh/authorized_keys to allow passwordless ssh
|
// copy ssh public key to host .ssh/authorized_keys to allow passwordless ssh
|
||||||
$ ssh-copy-id -i abc@host
|
$ ssh-copy-id -i abc@host
|
||||||
|
|
||||||
// alternatively, copy local .ssh/rsa_id.pub content into target server authorized_keys
|
// alternatively, copy local .ssh/rsa_id.pub content into target server authorized_keys
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* environments
|
* environments
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
// add global variable
|
// add global variable
|
||||||
// method1 : cli
|
// method1 : cli
|
||||||
$ export VARNAME="value"
|
$ export VARNAME="value"
|
||||||
$ set VARNAME="Value"
|
$ set VARNAME="Value"
|
||||||
|
|
||||||
// add local variable
|
// add local variable
|
||||||
$ VARNAME=Value
|
$ VARNAME=Value
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
$ unset VARNAME
|
$ unset VARNAME
|
||||||
$ VARNAME=''
|
$ VARNAME=''
|
||||||
|
|
||||||
// user wide env
|
// user wide env
|
||||||
$ sudo vi ~/.bashrc
|
$ sudo vi ~/.bashrc
|
||||||
|
|
||||||
..
|
..
|
||||||
export NAME=Value
|
export NAME=Value
|
||||||
...
|
...
|
||||||
|
|
||||||
// system wide ENV file
|
// system wide ENV file
|
||||||
$ nano /etc/environment
|
$ nano /etc/environment
|
||||||
|
|
||||||
// reload a file
|
// reload a file
|
||||||
$ source /etc/bash.bashrc
|
$ source /etc/bash.bashrc
|
||||||
|
|
||||||
// show a variable
|
// show a variable
|
||||||
$ echo $VARNAME
|
$ echo $VARNAME
|
||||||
|
|
||||||
// show all variables
|
// show all variables
|
||||||
$ printenv | sort | less
|
$ printenv | sort | less
|
||||||
$ env | grep GNOME
|
$ env | grep GNOME
|
||||||
|
|
||||||
$ myvar=(first second third)
|
$ myvar=(first second third)
|
||||||
$ echo ${myvar[2]}
|
$ echo ${myvar[2]}
|
||||||
third
|
third
|
||||||
$ echo ${myvar[*]}
|
$ echo ${myvar[*]}
|
||||||
first second third
|
first second third
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* startup file execution order from login shell
|
* startup file execution order from login shell
|
||||||
* `/etc/profile`
|
* `/etc/profile`
|
||||||
* `$HOME/.bash_login`
|
* `$HOME/.bash_login`
|
||||||
* `$HOME/.bash_profile`
|
* `$HOME/.bash_profile`
|
||||||
* `$HOME/.profile`
|
* `$HOME/.profile`
|
||||||
|
|
||||||
* startup file from interactive shell
|
* startup file from interactive shell
|
||||||
* `.bashrc` instead of `/etc/profile`
|
* `.bashrc` instead of `/etc/profile`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Rebuild HOME
|
||||||
|
|
||||||
|
* Repair fstab
|
||||||
|
|
||||||
|
```sh
|
||||||
|
// find the new UUID
|
||||||
|
$ blkid
|
||||||
|
|
||||||
|
// update the UUID
|
||||||
|
$ nano /etc/fstab
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* login as su
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ sudo su
|
||||||
|
|
||||||
|
//
|
||||||
|
$ mkhomedir_helper <username>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue