Category: Just about Code

  • Shell 自动补全

    1) /etc/passwd

    It shows like this
    [shell]huxuan:x:1002:1002::/home/huxuan:/bin/bash[/shell]
    in format of
    [shell]Username:Password:User ID (UID):Group ID (GID):User ID Info:Home directory:Command/shell[/shell]

    Make sure the Command/shell is the “/bin/bash” and not the “/bin/sh” which may be the default value.

    2) $HOME$/.bashrc or /etc/bash.bashrc
    Make sure the code blew is not commented out.

    [shell]if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi[/shell]

    3) Reference
    http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/

  • 使用密钥自动登录SSH(更新ssh-copy-id)

    【更新】
    lyxint提醒,发现了ssh-copy-id命令,第二步可以更简单的实现
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname
    其中username为用户名,hostname为服务器VPS的IP地址

    1)在本机生成公钥密钥
    ssh-keygen -t rsa
    一路回车,选择默认路径即可,默认路径为~/.ssh/

    2)将本地公钥上传至服务器
    cat ~/.ssh/id_rsa.pub|ssh username@hostname ‘sh -c “cat – >>~/.ssh/authorized_keys”‘
    其中username为用户名,hostname为服务器VPS的IP地址

    3)ssh设置文件的几点说明(一般是默认即可)
    路径:/etc/ssh/sshd_config
    相关行:
    PubkeyAuthentication yes #开启公钥验证
    #AuthorizedKeysFile %h/.ssh/authorized_keys #公钥的位置,建议使用默认路径

  • LaTeX笔记(1)

    取消连字符
    sloppy: 弱命令
    效果不是很明显,但是基本保证布局美观

    pretolerance=10000: 强命令
    效果很明显,几乎可以去掉所有连字符,但是对布局影响很大
    10000是一个阈值,可以适当变小,可能会有比较折中的效果
    补救措施:在字符间距非常大的地方用 – 命令强制生成连字符

    引号
    ` ` : 左双引号(两个小撇,和波浪号同一个键)
    ` : 左单引号(一个小撇,同上)
    ‘ ‘ : 右双引号(两个单引号)
    ‘ : 右单引号(一个单引号)
    P.S.请不要直接复制粘贴,中间有空格,为了HTML下的显示需要

    强制不分行
    mbox{content here will not be split up}

    四级标题
    section{}
    subsection{}
    subsubsection{}
    paragraph{*.*.*.* }

    波浪线
    ~{}

    上角标
    textsuper{}: 非数学环境
    ^{}: 数学环境

    首段缩进(默认不缩进)
    usepackage{indentfirst}

    推荐的格式设置
    documentclass[a4paper,12pt]{article}: 纸张类型,主体字号,文档类型
    usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}: 页边距

    超链接去边框和颜色
    usepackage[colorlinks,allcolors=black]{hyperref}

    嵌入所有字体
    dvips -Pdownload35 inputfilename.dvi