linux command demo

This file is a demo on how many terminal commands can be conducted in jupyter notebook of joinquant and how much info you can acquire on the backend. IMHO, the permission is somewhat loose here and may potentially increase the risk. As a quant finace platform, they shouldn't expose so much command to their users.

In [1]:
!cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     16  Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
In [2]:
!pip list|grep echarts
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pyecharts (0.2.7)
In [3]:
!cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
In [4]:
!cat /etc/issue
Debian GNU/Linux 8 \n \l

In [6]:
!ping -c 2 google.com
PING google.com (172.217.160.78): 56 data bytes
--- google.com ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
In [11]:
!cat /proc/meminfo |grep MemTotal
MemTotal:       65964932 kB
In [12]:
!df -h
Filesystem                                                    Size  Used Avail Use% Mounted on
overlay                                                        99G   59G   36G  63% /
tmpfs                                                          64M     0   64M   0% /dev
tmpfs                                                          32G     0   32G   0% /sys/fs/cgroup
/dev/vda1                                                      40G   16G   22G  42% /etc/joinquant_user
1d1d2488ae-gmq3.cn-beijing.nas.aliyuncs.com:/586/58690411326  1.0P  1.1T 1023T   1% /home/jquser
/dev/vdb1                                                      99G   59G   36G  63% /etc/hosts
shm                                                            64M     0   64M   0% /dev/shm
none                                                           32G  1.2G   31G   4% /dev/shm/daydata
tmpfs                                                          32G     0   32G   0% /proc/scsi
tmpfs                                                          32G     0   32G   0% /sys/firmware
In [41]:
!ls .config
matplotlib
In [16]:
!apt -h
apt 1.0.9.8.1 for amd64 compiled on Jun 10 2015 09:42:07
Usage: apt [options] command

CLI for apt.
Basic commands: 
 list - list packages based on package names
 search - search in package descriptions
 show - show package details

 update - update list of available packages

 install - install packages
 remove  - remove packages

 upgrade - upgrade the system by installing/upgrading packages
 full-upgrade - upgrade the system by removing/installing/upgrading packages

 edit-sources - edit the source information file
In [17]:
!python3 -V
Python 3.6.3 :: Anaconda, Inc.
In [24]:
!which python
/opt/conda/envs/python3new/bin/python
In [21]:
!ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.255.72.189/32 brd 10.255.72.189 scope global lo
       valid_lft forever preferred_lft forever
3542: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default 
    link/ether 02:42:0a:ff:48:be brd ff:ff:ff:ff:ff:ff
    inet 10.255.72.190/16 brd 10.255.255.255 scope global eth0
       valid_lft forever preferred_lft forever
3544: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:c0:a8:00:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.12/20 brd 192.168.15.255 scope global eth1
       valid_lft forever preferred_lft forever
In [22]:
!apt install hping3
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
In [29]:
!wget baidu.com
--2018-02-11 19:56:46--  http://baidu.com/
Resolving baidu.com (baidu.com)... 111.13.101.208, 220.181.57.216, 123.125.114.144
Connecting to baidu.com (baidu.com)|111.13.101.208|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 81 [text/html]
Saving to: ‘index.html’

index.html          100%[=====================>]      81  --.-KB/s   in 0s     

2018-02-11 19:56:46 (7.15 MB/s) - ‘index.html’ saved [81/81]

In [32]:
!ls /
bin   dev  home  lib64	mnt  proc  run	 srv  tmp  var
boot  etc  lib	 media	opt  root  sbin  sys  usr
In [37]:
!service --status-all
 [ - ]  bootlogs
 [ - ]  bootmisc.sh
 [ - ]  checkfs.sh
 [ - ]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ - ]  killprocs
 [ - ]  motd
 [ - ]  mountall-bootclean.sh
 [ - ]  mountall.sh
 [ - ]  mountdevsubfs.sh
 [ - ]  mountkernfs.sh
 [ - ]  mountnfs-bootclean.sh
 [ - ]  mountnfs.sh
 [ - ]  procps
 [ - ]  rc.local
 [ - ]  rmnologin
 [ - ]  sendsigs
 [ - ]  sudo
 [ + ]  udev
 [ ? ]  udev-finish
 [ - ]  umountfs
 [ - ]  umountnfs.sh
 [ - ]  umountroot
 [ - ]  urandom
 [ - ]  x11-common
In [38]:
!whoami
jquser
In [39]:
!pwd
/home/jquser
In [43]:
!ps -aux|grep jupyter
root         1  0.0  0.0  46996  3476 ?        Ss   08:10   0:00 sudo -E PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/conda/bin:/opt/jdk1.8.0_92/bin -u jquser jupyterhub-singleuser --port=8888 --ip=0.0.0.0 --user=58690411326 --cookie-name=jupyter-hub-token-58690411326 --base-url=/user/58690411326 --hub-prefix=/hub/ --hub-api-url=http://10.45.136.71:8081/hub/api --notebook-dir=/home/jquser --static-url-prefix='https://cdn.joinquant.com/research/jupyter/' --nbextensions-url='https://cdn.joinquant.com/research/jupyter/nbextensions/'
jquser      21  0.2  0.6 862520 415756 ?       Sl   08:10   1:29 python3 /usr/local/bin/jupyterhub-singleuser --port=8888 --ip=0.0.0.0 --user=58690411326 --cookie-name=jupyter-hub-token-58690411326 --base-url=/user/58690411326 --hub-prefix=/hub/ --hub-api-url=http://10.45.136.71:8081/hub/api --notebook-dir=/home/jquser --static-url-prefix='https://cdn.joinquant.com/research/jupyter/' --nbextensions-url='https://cdn.joinquant.com/research/jupyter/nbextensions/'
jquser     355  0.0  0.1 1074788 119456 ?      Sl   19:22   0:02 /opt/conda/envs/python3new/bin/python -m ipykernel_launcher -f /home/jquser/.local/share/jupyter/runtime/kernel-054a4dfe-7596-4092-ab24-ba672f723b4e.json
jquser     404  0.2  0.1 1076060 121616 ?      Sl   19:36   0:04 /opt/conda/envs/python3new/bin/python -m ipykernel_launcher -f /home/jquser/.local/share/jupyter/runtime/kernel-f2395ac1-8c69-4460-bc3f-c73b1cb8bf8b.json
jquser     795  0.0  0.0   4328   720 pts/0    Ss+  20:09   0:00 /bin/sh -c ps -aux|grep jupyter
jquser     797  0.0  0.0  12808   968 pts/0    S+   20:09   0:00 grep jupyter
In [61]:
!type awk sed tee perl head gcc as bash rm sudo mkdir mount
awk is /usr/bin/awk
sed is /bin/sed
tee is /usr/bin/tee
perl is /usr/bin/perl
head is /usr/bin/head
gcc is /usr/bin/gcc
as is /usr/bin/as
bash is /bin/bash
rm is /bin/rm
sudo is /usr/bin/sudo
mkdir is /bin/mkdir
mount is /bin/mount