# Step 1: Need root permission. sudo bash # Step 2: Update your repositories apt update -y # Step 3: Install pip for Python 3 apt install python3-pip # Step 4: Use pip to install VirtualEnv pip3 install virtualenv # Step 5: Create a Virtual Environment of Python 3, the virtual env name is "myEnv". virtualenv -p python3 myEnv # Step 6: Activate a new Python 3 virtual env. # or "source env3/bin/activate" . myEnv/bin/activate # Step 7-1: You can make sure you are now working with Python 3. python --version # Step 7-2: You can make sure the Python 3's Path. which python # Step 8: Leave the virtual env. deactivate
公告版位
目前分類:Linux (140)
- Feb 17 Mon 2020 16:52
Install/Use Python 3 Virtualenv on Ubuntu 18.04
- Feb 17 Mon 2020 10:35
Unzip解壓縮有中文檔案的zip,防止出現亂碼問題!
$ unzip -O big5 MyTest.zip
- Jan 15 Wed 2020 17:46
Ubuntu 18.04 永久封鎖TCP Port-139 NetBIOS-ssn
# cat > /etc/systemd/system/iptables.service << EOF [Unit] Before=network.target [Service] Type=oneshot ExecStart=/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j REJECT RemainAfterExit=yes [Install] WantedBy=multi-user.target EOF # systemctl enable --now iptables.service # systemctl start iptables.service
- Jul 26 Fri 2019 18:27
ElementaryOS 5.0 更改Terminal字型(Font)
1. 自己目前蠻推薦以下這個字型:
Fantasque Sans Mono - https://github.com/belluzj/fantasque-sans
2. 將您要換的字型放到以下路徑
$ mv FantasqueSansMono-*.ttf ~/.fonts/
3. 更新字型資料庫
$ fc-cache -vf ~/.fonts/
4. 安裝Gnome-Tweak-Tool
$ apt install -y gnome-tweak-tool
5. 執行Gnome-Tweak-Tool去更改字型
$ gnome-tweaks
- Jul 24 Wed 2019 12:26
How to use "PREFIX of make" and Uninstall.
1. Install Package to /usr/local
$ ./configure --prefix=/usr/local
$ make
$ sudo make install prefix=/usr/local
2. Uninstall Package
$ make clean
$ make uninstall
- Jul 19 Fri 2019 15:04
How to turn off sleep/suspend/hibernate mode on Ubuntu 16.04/18.04 from the CLI
Turn off sleep/suspend/hibernate mode from the CLI:
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Get the sleep/suspend/hibernate status from the CLI:
$ sudo systemctl status sleep.target
$ sudo systemctl status suspend.target
$ sudo systemctl status hibernate.target
$ sudo systemctl status hybrid-sleep.target
- Jul 19 Fri 2019 12:37
ElementaryOS 5.0 or Ubuntu 18.04: Avoid nameserver 127.0.0.53 in /etc/resolv.conf
Step1)
$ sudo apt install -y resolvconf
Step2)
$ sudo vim /etc/resolvconf/resolv.conf.d/head
or
$ sudo vim /etc/resolvconf/resolv.conf.d/tail
===================================
nameserver 192.168.254.254
nameserver 10.10.10.10
nameserver 8.8.8.8
search dreamtails.local dreamtails.com
===================================
- May 28 Tue 2019 12:04
如何使用virsh指令去建立snapshot(for KVM)?
列出所有VM
$ sudo virsh list --all
建立Snapshot
$ sudo virsh snapshot-create <VM-NAME>
列出Sanpshot有哪些
$ sudo virsh snapshot-list <VM-NAME>
回復到Snapshot的狀態
$ sudo virsh snapshot-revert <VM-NAME> --snapshotname <SNAPSHOT-NAME>
- May 27 Mon 2019 18:42
How to resize QCOW2 Image from 20G to 100G?
[root@CentOS ~]# qemu-img info CentOS.qcow2
image: CentOS.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 4.0G
cluster_size: 65536
Format specific information:
compat: 0.10
[root@CentOS ~]# qemu-img resize CentOS.qcow2 +80G
Image resized.
[root@CentOS ~]# qemu-img info CentOS.qcow2
image: CentOS.qcow2
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 4.0G
cluster_size: 65536
Format specific information:
compat: 0.10
- May 03 Fri 2019 10:38
IP 1對1 mapping 的NAT (使用iptables) for CentOS 6
1. 在一個interface 上綁定多個IP
# vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
------------------------------------------------------------
DEVICE=eth0:0
BOOTPROTO=none
IPADDR=140.140.140.1
NETMASK=255.255.255.0
ONBOOT=yes
------------------------------------------------------------
# service network restart
2. 開啟IP Forward的功能
# vim /etc/sysctl.conf
------------------------------------------------------------
......
net.ipv4.ip_forward = 1
net.ipv4.tcp_keepalive_time = 86400
......
------------------------------------------------------------
# sysctl -p
3. 加入iptables的NAT policy
# vim /etc/sysconfig/iptables
------------------------------------------------------------
......
*nat
:PREROUTING ACCEPT [417:47118]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# NAT Policy
-A POSTROUTING -s 192.168.1.1 -o eth0 -j SNAT --to-source 140.140.140.1
-A PREROUTING -d 140.140.140.1 -i eth0 -j DNAT --to-destination 192.168.1.1
COMMIT
......
------------------------------------------------------------
# service iptables restart
- Mar 22 Fri 2019 18:11
Ubuntu 18.04 重置桌面環境設、字型!
因為裝了Gnome的Dash to Dock後,覺得不是那麼的討喜,所以想還原成Ubuntu原始的桌面環境,請下以下指令:
$ dconf reset -f /
Reference: https://www.omgubuntu.co.uk/2017/10/how-to-reset-ubuntu-desktop-to-default
- Mar 21 Thu 2019 18:57
Ubuntu 18.04 開啟Unetbootin後,看不到視窗的Field.
使用以下指令去執行就可以看到完整的視窗了!
$ sudo QT_X11_NO_MITSHM=1 unetbootin
- Mar 20 Wed 2019 11:31
Ubuntu 16.04 / 18.04 內建的遠端連線功能
Ubuntu 16.04 / 18.04 內建的遠端連線功能:
1. 到「Setting(設定)」的「Sharing」開啟Screen Sharing與Remote Login的功能!
2. 此時應該還是無法連,請看以下解決方法。下這行指令:
$ gsettings set org.gnome.Vino require-encryption false
3. 這樣就可以使用VNC Client的軟體去連了.
- Feb 20 Wed 2019 15:16
如何開機自動執行應用程式或Script for Ubuntu 18.04
$ sudo vim /etc/systemd/system/startup.service
-----------------------------------------------
[Unit]
Description=Job that runs your user script
[Service]
ExecStart=/usr/local/bin/startup_service.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
-----------------------------------------------
$ sudo systemctl daemon-reload
$ sudo systemctl enable startup.service
- Jan 30 Wed 2019 14:16
How to empty the buffers and cache on a Linux system?
# free && sync && echo 3 > /proc/sys/vm/drop_caches && free
- Jan 08 Tue 2019 12:06
Using REST API by cURL to login and upload file.
1. Login, when used JSON Type Body via POST
$ curl -H "Content-Type: application/json" -X POST -d '{"username":"myusername","password":"mypassword"}' https://dreamtails.pixnet.net:1234/
2. Upload Zip via POST
$ curl -X POST -F "file=@/home/dreamtails/Downloads/upload_file.zip;type=application/zip" "https://dreamtails.pixnet.net:1234/upload"
- Sep 25 Tue 2018 17:05
Gnome 美化 for Ubuntu 16.04
1. Download Ubuntu Gnome 16.04
2. 裝好Chrome
3. 裝chrome-gnome-shell
$ sudo apt install chrome-gnome-shell
4. 用Chrome打開https://extensions.gnome.org/,並安裝以下幾個extensions.
Coverflow Alt-Tab
Alt+Tab 切換應用程式會有3D效果
Dash to Dock
應用程式啟動器
Dynamic Top Bar
頂端Bar透明化
User Themes
從文件夾載入Gnome-Shell主題
NetSpeed
頂端Bar顯示網路速度
OpenWeather
頂端Bar顯示天氣
- Sep 25 Tue 2018 17:01
How to fix the slow apt update issue on Ubuntu 16.04
$ sudo vim /etc/sysctl.conf
===========================
......
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
===========================
$ sudo sysctl -p
- Sep 12 Wed 2018 11:37
[GNOME3] How do I create a .desktop file to launch Eclipse and Perforce P4V?
$ sudo vim /usr/share/applications/eclipse.desktop
============================================
[Desktop Entry]
Version=Photon
Name=Eclipse
Comment=Eclipse is an IDE
Exec=/opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Path=/opt/eclipse/
Terminal=false
Type=Application
Categories=X-Red-Hat-Extra;Utility;Application;Development;
============================================
$ sudo vim /usr/share/applications/p4v.desktop
============================================
[Desktop Entry]
Version=Helix P4V/LINUX26X86_64/2018.2/1687764
Name=Perforce P4V
Exec=/opt/perforce/bin/p4v
Icon=/opt/perforce/lib/P4VResources/icons/p4v.svg
Path=/opt/perforce/
Terminal=false
Type=Application
Categories=X-Red-Hat-Extra;Utility;Application;Development;
============================================
- Apr 10 Tue 2018 17:35
How to resolve "Too many open files" ERROR? Increased the max file count.
# vim /etc/sysctl.conf
-----------------------------
fs.file-max = 65535
-----------------------------
# vim /etc/security/limits.conf
-----------------------------
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535
jenkins soft nofile 65535
jenkins hard nofile 65535
-----------------------------