724-226-1169

> yum install NetworkManager-wifi #networkmanager wifi plugin
> nmtui #you will see wifi options

(202) 377-6692

  • truncate a file in bash
    shell> : > file.txt
    

    : is a built in command in bash; it means no operations (do nothing) and exit status is true.

(409) 502-0147


#save logins
mysql_config_editor set --login_path=local --host=127.0.0.1 --user=root --password
#login

mysql --login-path=local

misleadable

In case we want to alter mysql table columns, we need to check how many rows there are. If rows are too many, alter table may cause issues to replications due to memory consumption.

if rows are millions, it’s better to not use alter table and use the following steps:

  1. create new table as you need
  2. use “insert into … from select …”
  3. mysql> rename table current to current_old, new to current;

9372579815

1 sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip
2 useradd nagios
3 groupadd nagcmd
4 usermod -a -G nagcmd nagios
5 usermod -a -G nagios,nagcmd www-data
6 cd /home/jxyu
7 wget /assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
8 tar -xzf nagios-4.3.4.tar.gz
9 ll
10 cd nagios-4.3.4
11 ./configure --with-nagios-group=nagios --with-command-group=nagcmd
12 make all
13 make install
14 make install-commandmode
15 make install-init
16 make install-config
17 /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
18 cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
19 chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
20 cd /home/jxyu/
21 wget /nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
22 tar -xzf nagios-plugins-2.2.1.tar.gz
23 cd nagios-plugins-2.2.1
24 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
25 make
26 make install
27 vim /usr/local/nagios/etc/nagios.cfg
28 mkdir -p /usr/local/nagios/etc/servers
29 a2enmod rewrite
30 a2enmod cgi
31 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
32 ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
33 service apache2 restart
34 service nagios start
35 nagios start
36 nagios3 start
37 /usr/local/nagios/bin/nagios start
38 cd /etc/init.d/
39 cp /etc/init.d/skeleton /etc/init.d/nagios
40 vim /etc/init.d/nagios
41 chmod +x /etc/init.d/nagios
42 service apache2 restart
43 servuce nagios start
44 service nagios start
45 systemctl daemon-reload
46 service nagios start
47 ifconfig
48 apt install npre
49 apt-cache search npre
50 apt-cache search nrpe
51 apt install nagios-nrpe-plugin nagios-nrpe-server -y
52 service nagios restart
53 service nagios stop
54 systemctl status nagios
55 systemctl start nagios
56 systemctl status nagios
57 vim /etc/nagios/nrpe.cfg
58 service nagios-nrpe-server restart
59 systemctl restart nagios
60 vim /usr/local/nagios/etc/servers/ubuntu_host.cfg
61 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
62 service nagios-nrpe-server restart
63 service apache2 restart
64 service nagios restart

config:

# Ubuntu Host configuration file
define host {
use linux-server
host_name ubuntu_host
alias Ubuntu Host
address 127.0.0.1
register 1
}
define service {
host_name ubuntu_host
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check Users
check_command check_local_users!20!50
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Local Disk
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check SSH
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Total Process
check_command check_local_procs!250!400!RSZDT
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}

Check config

service nagios checkconfig

 

sierra brownbark pine

#testecho.service
[Unit]
Description=testecho.service
Documentation=null
[Service]
Type=simple
User=jxyu
ExecStart=/bin/bash -c "java -jar /home/jxyu/datedemo.jar >> /home/jxyu/testecho.log"
ExecStop=/bin/kill -2 $MAINPID
ExecStop=/bin/bash -c "echo stop >> /home/jxyu/testecho.log"
[Install]
WantedBy=multiuser.target

3195127412

user service location: ~/.config/systemd/user/testecho.service

# testecho.service
[Unit]
Description=echotest service
Documentation=null
[Service]
Type=simple
ExecStart=/bin/bash -c "/usr/bin/java -jar /home/jxyu/datedemo.jar >> /home/jxyu/test.txt"

# following commands can start/stop or check it status
# systemctl –user start testecho.service
# systemctl –user stop testecho.service
# systemctl –user status testecho.service
references:

finally

  • if there is “return” or “exception” before try, finally block won’t be executed.
  • if there is System.exit(0) in try block, finally block won’t be executed.
  • if there is “return” in try block, finally block executes before return.
  • if there is “return” in catch block, finally block executes before return.

command: gpg2

# alias gpg=gpg2
gpg --verify tomcat_embaded.asc apache-tomcat-9.0.8-embed.zip
gpg --keyserver pgpkeys.mit.edu --recv-key 6FB21E8933C60243
gpg --fingerprint 6FB21E8933C60243

swellfish

# copy mp4 video file from time 00:40:21 to 00:41:12 to 40-21_41-12.mp4
ffmpeg -i source.mp4 -ss 00:40:21 -to 00:41:12 -c copy 40-21_41-12.mp4