Category: Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux

Linux Shell系列教程之(十八) Shell 基本运算符

Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符 关系运算符 布尔运算符 字符串运算符 文件测试运算符 原生bash不支持简单的数学运算,但是可以通过其他命令来实现,例如 awk 和 expr,expr 最常用。 expr 是一款表达式计算工具,使用它能完成表达式的求值操作。 例如,两个数相加(注意使用的是反引号 ` 而不是单引号 ‘): #!/bin/bash val=`expr 2 + 2` echo "两数之和为 : $val" 执行脚本,输出结果如下所示: 两数之和为 : 4 两点注意: 表达式和运算符之间要有空格,例如 2+2 是不对的,必须写成 2 + 2,这与我们熟悉的大多数编程语言不一样。 完整的表达式要被 ` ` 包含,注意这… Read More

Linux:SSH 无密码连接到 Google Cloud 实例, FileZilla连接 Google Cloud, IntelliJ IDEA连接 Google Cloud, google cloud compute instance, google cloud platform

1. 通过浏览器连接到实例 直接通过网络浏览器在 Google Cloud Platform 控制台中进行 SSH 连接: In the Cloud Platform Console, go to the VM Instances page.GO TO THE VM INSTANCES PAGE In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to. 通过浏览器连接到实例时需要注意一些事项。如需了解详情,请参阅通过浏览器进行 SSH 连接。   2. 通过命令行连接到实例 您可以使用 gcloud 命令行工具轻松连接到您的… Read More

Shell: 无密码读写Mysql数据库, 无密码被分导出Mysql数据库, mysqldump , Connect to MySQL Without Root Password on Terminal

设置Mysql登录信息 How to Set MySQL Root Password 一般shell连接数据库的方法是: mysqladmin -u root password YOURNEWPASSWORD 无登录链接数据库的方法是创建或者修改 ~/.my.cnf 文件 Now create the config file ~/.my.cnf and add configurations below in it (remember to replace mysqluser and mysqlpasswd with your own values). [mysql] user=user password=password 如果你还是用了mysqldump,那么可… Read More

Linux: shell实现多线程, Forking / Multi-Threaded Processes | Bash, shell 线程池

按照shell语法,后一个前台命令必须等待前一个前台命令执行完毕才能进行,这就是所谓的单线程程序。如果两条命令之间有依赖性还好,否则后一条命令就白白浪费了等待的时间了。 网上查了一遍,shell并没有真正意义上的多进程。而最简单的节省时间,达到“多线程”效果的办法,是将前台命令变成后台进程,这样一来就可以跳过前台命令的限制了。 引用网上例子:   实例一:全前台进程: #!/bin/bash #filename:simple.sh starttime=$(date +%s) for ((i=0;i<5;i++));do { sleep 3;echo 1>>aa && endtime… Read More

Linux:cURL 命令详解,以及实例, curl auth, curl 模拟登陆,快速网站测压, curl 爬虫, curl Command Download File Example, How to quickly stress test a web server

  linux curl是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称url为下载工具。 一,curl命令参数,有好多我没有用过,也不知道翻译的对不对,如果有误的地方,还请指正。 -a/--append 上传文件时,附加到目标文件 -A/--user-agent <string> 设置用户代理发送给服务器 - anyauth 可以使用“任何”身份验证方法 -b/--cookie <name=string/file> cookie字符串或文件读取位置 - basic 使用HTTP基本验证 -B/--use-ascii 使用ASCII /文… Read More

Linux: SSH报错 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 解决方案, Remove key from known_hosts, Fix Offending key in ~/.ssh/known_hosts file

  今天是用google cloud ssh登录的时候,发生以下报错: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It i… Read More

Linux: 命令行获取公共 IP 和 私有IP, How To Find My Public IP Address, Determine Your Private and Public IP Addresses, From Command Line On a Linux

  1. 命令行获取私有IP Use dig command for determining my public IP address: 打开 Terminal application. 输入以下命令行:Type the following dig (domain information groper) command on a Linux, OS X, or Unix-like operating systems to see your own public IP address assigned by the ISP: dig +short myip.opendns.com @resolver1.opendns.com 或者 dig TXT +short o-o.myaddr.l… Read More

Linux:命令行git简单使用, git指令, 命令行操作git

开始正文 Git简介 这篇文章不介绍github,介绍git命令行,但是有必要对git和github是什么进行一个说明。你可能听说过github,据说github是世界上最大的同性社交网站。当然是开玩笑的。简单的说,github是一个开放源代码保存的地方,github也是合作项目开发的首选地。 那么git呢,git是一个仓库,一个你用来保存代码的地方。 所以,当我在github上注册了帐号之后,我可以将我的代码上传到git上进行保存,也可以大家合用一个仓库来合作开发。 当然,git本身是开放的,别人可以看到你的源代码,如果是想变成不开放的,那么你就需要像github付费了。你可以去coding看一看,c… Read More

Linux: url打开phpmyadmin, how to access phpmyadmin in lamp

问题: I have installed LAMP on ubuntu, and I want to acced PhpMyAdmin, and I don’t know it’s URL. I tried to access this URL : http://localhost/phpmyadmin 解决方法: Just in case someone doesn’t know this (i didn’t for sometime), after running this command to reconfigure phpmyadmin sudo dpkg-reconfigure -plow phpmyadmin 如果在C… Read More

Ubuntu 17.04 / 17.10 安装 LAMP, Linux Apache2 Mysql PHP, 以及phpmyadmin, INSTALLING LAMP ON UBUNTU 17.04 / 17.10

env.sh #!/usr/bin/env bash # https://websiteforstudents.com/installing-lamp-ubuntu-17-04-17-10/ # https://websiteforstudents.com/install-password-protect-phpmyadmin-ubuntu-17-04-17-10/ # INSTALLING LAMP ON UBUNTU 17.04 / 17.10 # STEP 1: 更新服务器 sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autor… Read More

Linux: shell脚本获取网页快照(网页截图)并生成缩略图

获取网页快照并生成缩略图可分两步进行: 1、获取网页快照 2、生成缩略图   获取网页快照 这里我们用 phantomjs 来实现。关于 phantomjs 的详细用法可参考官方网站。   1、安装 我的环境是CentOS6.5,安装时直接下载 tarball 然后解压即可。 最新版参看:https://github.com/ariya/phantomjs,下载地址为: https://phantomjs.org/download.html # wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.ta… Read More

Linux: Shell脚本备份MySQL数据库, Linux shell script for database backup

Shell脚本是我们写不同类型命令的一种脚本,这些命令在这一个文件中就可以执行。我们也可以逐一敲入命令手动执行。如果我们要使用shell脚本就必须在一开始把这些命令写到一个文本文件中,以后就可以随意反复运行这些命令了。 我首先要在本文带给你的是完整脚本。后面会对该脚本做说明。我假定你已经知道shell scripting、 mysqldump和crontab。 适用操作系统:任何Linux或UNIX。 主脚本(用于备份mysql数据库): 该Shell脚本可以自动备份数据库。只要复制粘贴本脚本到文本编辑器中,输入数据库用户名、密码以及数据库名即可。我备份数据库使用的是mysqlump 命令。后面会对每行… Read More

Ubuntu / Google Compute Engine / Google Cloud:安装JAVA JDK8 或者 JAVA JDK 9, Install Oracle Java 8 / 9 in Ubuntu 16.04, Linux Mint 18

1. Add the PPA. Open terminal (Ctrl+Alt+T) and run the command: sudo add-apt-repository ppa:webupd8team/java Type in your password when it asks and hit Enter. 2. Update and install the installer script: Run commands to update system package index and install Java installer script: sudo apt update && sudo apt install oracle-java8-installer 安装… Read More

Ubuntu:如何完全卸载Java, How to completely uninstall Java?

1、 移除所有 Java相关包 (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ): Remove all the Java related packages (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ): apt-get update dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common… Read More