Skip to content

Instantly share code, notes, and snippets.

@jackywyz
Created November 23, 2011 02:16
Show Gist options
  • Save jackywyz/1387730 to your computer and use it in GitHub Desktop.
Save jackywyz/1387730 to your computer and use it in GitHub Desktop.
Linux命令

###0)同步,异步(在这里指的是application和kernel之间的交互方式,是否需要排队),阻塞,非阻塞(application是否等待IO操作的完成,是否需要领回执单)
同步:不立即返回,如排队买票,当前线程不挂起
异步:抽取流水号,等被叫号,可立即返回,请求方和处理方沟通方式包括:状态,通知,回调。
阻塞:不立即返回,线程被挂起。
非阻塞:不等待IO操作的完成就开始执行其它操作。

###1) 测试网页请求时间#

  • curl -o /dev/null -s -w "%{time_connect}:%{time_starttransfe r}:%{time_total}:%{http_code}\n" http://www.baidu.com
  • time_connect 建立到服务器的 TCP 连接所用的时间
  • time_starttransfer 在发出请求之后,Web 服务器返回数据的第一个字节所用的时间
  • time_total 完成请求所用的时间
  • http_code 返回状态码

###2)git命令在github git使用图

####搭建自己的私有仓库: git(mysysgit), copssh(window),gitosis(用户管理),gitweb ####对象模型 1. sha 对所有文件内容和对象加密为一个唯一值 2. 每个目录对应一个tree,目录中的文件对应blob 3. commit对象来指向根tree对象(root of trees) 3. git目录中的HEAD指向当前分支的head,如refs/heads/master文件中是master分支
最新提交的信息。 4. 一个“tag”是来标记某一个提交(commit) 的方法
5. git目录 |-- HEAD # 这个git项目当前处在哪个分支里
|-- config # 项目的配置信息,git config命令会改动它
|-- description # 项目的描述信息
|-- hooks/ # 系统默认钩子脚本目录
|-- index # 索引文件
|-- logs/ # 各个refs的历史信息
|-- objects/ # Git本地仓库的所有对象 (commits, trees, blobs, tags)
`-- refs/ # 标识你项目里的每个分支指向了哪个提交(commit)。

####基本操作

  • git remote add origin [email protected]:username/Hello-World.git(给远程git起别名origin)
  • git remote rm origin
  • git ls-remote 查看远程分支
  • git branch new_branch, git push -u origin new_branch上传代码
  • git checkout -b dev创建分支并切换。
  • git push origin :your-branch ,删除远程分支。
  • git mv readme readme.md
  • git rm readme ,删除文件
  • git branch –r,查看分支信息

####上传代码

  • git add *

  • git commit -m 'add something'

  • git push origin master (非持续的更新之前,需要git pull下再操作)

  • git push --mirror [email protected]:user/test (将会删除remote上的所有内容,用上传的local内容代替)

  • git symbolic-ref HEAD refs/heads/newbranch (空的分支)

       rm .git/index  
       git clean -fdx  
    

####更新

  • git pull origin iced,git fetch origin test(分支)
  • git checkout test,git rebase origin (给origin打最新的test补丁)
  • git fetch && git merge 等价于 git pull
  • git fetch && git rebase 等价于 git pull --rebase(适合冲突少的的小更改,冲突多的话用git merge --no-ff,项目可以配置.git/config文件)
  • git clone -b somebranch [email protected]:jackywyz/Dcoffee.git ,克隆制定的分支。

####恢复

  • git commit --amend : 修正提交内容
  • git checkout -- filename : 取消对文件的修改
  • git reset -soft :取消了commit 回滚到某一状态
  • git reset -mixed(默认) :取消了commit ,取消了add,
  • git reset -hard :取消了commit ,取消了add,取消源文件修改,删除提交,提交全部重置,就像没有提交过一样。
  • git reset –hard commit (38679ed709fd0a3767b79b93d0fba5bb8dd235f8) 回退到某一次提交.
  • git revert -n adb 是撤销某次提交,但是这次撤销也会作为一次提交进行保存(需要再一次commit), git revert HEAD上一次, git revert HEAD^上上一次
  • git reflog; git checkout <revision> -- filename

####子模块submodule

####tag 操作

  1. git tag -a v1.4 -m 'version 1.4'
  2. Delete the v0.4 tag locally: git tag -d v0.4
  3. Delete the v0.4 tag on GitHub (which removes its download link): git push origin :v0.4
  4. Add a new tag for the newest stable release: git tag -a v0.5 -m “Version 0.5 Stable”
  5. Push the latest tag to GitHub: git push ––tags

####submodule

add (same to remote )
init (config the .git for a submodule)
update (pull the new content)
删除:
git rm -cached path
rm -rf path
git config -f .git/config --remove-section submodule.$submodulepath
git config -f .gitmodules --remove-section submodule.$submodulepath

####github pages 多账号配置

  1. PS: github pages 的建立有三种方式:1)name.github.com式,2)用户子项目myrepo/gh-pages分支式,3)github admin 在线产生。

  2. 按照github说明配置第二个账号,起名id_rsa_client

  3. vim ~/.ssh/config 输入
    Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa

    Host github-client
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_client

  4. git remote add origin git@github-client:tomasky/test.git

###3)当路径被设置粘滞位后,路径下的文件只有文件的owner, 或者root 才能够重命名、删除文件。如果没有粘滞位,任何用户,不管是不是owner, 只要有路径的写/执行权限就可以重命名、删除文件

  • 如果粘滞位设置的路径或者文件没有可执行(x)位,它的符号用T(大写的t)
    ls -l test
    -rw-r--r-- 1 root other 0 Nov 10 12:57 test
  • chmod +t test; ls -l test
    -rw-r--r-T 1 root other 0 Nov 10 12:57 tes
    1、-rwsr-xr-x 表示SUID和所有者权限中可执行位被设置
    suid 是4
       2、-rwSr--r-- 表示SUID被设置,但所有者权限中可执行位没有被设置
    sgid 是2
       3、-rwxr-sr-x 表示SGID和同组用户权限中可执行位被设置
    sticky bit是1
       4、-rw-r-Sr-- 表示SGID被设置,但同组用户权限中可执行位没有被社

###4) 查看文件夹和磁盘大小: 磁盘: df 目录: du -sh xmldb/

###5)ping localhost 不通: ifconfig lo up

###远程备份mysql数据库:

  • mysql> grant all privileges on *.* to 'jacky'@'%' identified by 'tomas' with grant option; flush privileges;
  • shell> mysqldump -h (ip) -u (username) -p (database-name) > bak.sql
@fundon
Copy link

fundon commented Dec 15, 2011

%{time_starttransfe r} -> %{time_starttransfer}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment