Blog

  • 连接vps上的ssh

    创建一个权限最低的用户

    useradd -M -s /bin/false username

    创建该用户的密码:

    passwd username
    • windows使用MyenTunnel,输好用户名,密码,ip,端口

    在linux下使用密钥认证可以免输密码,而且参考使用ssh_config,创建并在~/.ssh/config里写入以下内容,参考:http://www.lainme.com/doku.php/blog/2011/01/%E4%BD%BF%E7%94%A8ssh_config

    jpuyy@ubuntu $ vim ~/.ssh/config
     Host vps
     User jpuyy
     Hostname jpuyy.com
     PreferredAuthentications publickey
     IdentityFile ~/.ssh/id_rsavps
     DynamicForward 7070

    这时在shell下使用

    $ssh vps

    更有一步登天之感。

    其他工具

    autossh可以在ssh断掉后重连

    sudo apt-get install autossh

    autossh -M 2000 -N -v  username@hostip

    plink可以直接指定密码

    ssh需要手动输入,因为把密码表现在history中相当恐怖

    sudo apt-get install putty-tools

    plink -N -v username@hostip -pw password

    sshpass也可以指定密码

    Description : Tool for non-interactively performing password authentication with
    : so called “interactive keyboard password authentication” of SSH.
    : Most users should use more secure public key authentication of SSH
    : instead.
    yum install sshpass

    mosh是在网络比较慢的时候使用,尤其是国外线路

    http://mosh.mit.edu/

  • linux几个掌握系统信息的命令

    查看CPU信息

    /proc/cpuinfo

    里面有flag信息,如果有lm,则支持64位

    系统负载命令

    uptime w htop top 都可查看
     ------------23:41:57 up 4:42, 3 users, load average: 0.00, 0.00, 0.00
     ------------当前时间 运行时间 用户数 系统负载 (最近1分钟、5分钟、15分钟系统的负载)

    查看硬盘信息命令

    fdisk -l

    JOBS使用

    # jobs 查看后台运行的进程
    # fg %n 让后台运行的进程n到前台来,再Ctrl+c即可终止该程序.
    # bg %n 让进程n到后台去;

    root@debian:~# nohup ping g.cn &
    [1] 9576
    root@debian:~# nohup: 忽略输入并把输出追加到”nohup.out”

    root@debian:~# jobs
    [1]+ Running nohup ping g.cn &

    接着执行

    root@debian:~# bg %1
    [1]+ nohup ping g.cn &
    root@debian:~# jobs
    [1]+ Running nohup ping g.cn & //变为了running

    Linux Jobs等前后台运行命令详解,停止后台程序:
    Shell支持作用控制,有以下命令:
    1. command& 让进程在后台运行 / nohup command &
    2. jobs 查看后台运行的进程
    3. fg %n 让后台运行的进程n到前台来,再Ctrl+c即可终止该程序.
    4. bg %n 让进程n到后台去;
    PS:”n”为jobs -l查看到的进程编号.

    RX 和 TX

    TX: transmit 传送. RX: receive 接收

    查看系统内核

    uname -r

    查看内核名

    uname -s
    Linux
    

    查看架构

    uname -m
    x86_64

    查看系统的字符集

    echo $LANG $LANGUAGE
    TAIL -F FILENAME

    会把filename里最尾部的内容显示在屏幕上,并且不但刷新,使你看到最新的文件内容

    查看内存使用情况

    free -m

    total used free shared buffers cached
    Mem: 7866 6213 1653 0 209 2711
    -/+ buffers/cache: 3292 4574
    Swap: 0 0 0
    真实的空余内存为4574MB

    文件系统使用情况

    df -h (有时可以看到使用率到100%,但是系统会保留5%的空间用于root用户来登陆及其他操作)

    df -T(可查看file system类型)

    df -i 查看已用和未用的inode数量及百分比

    查看模块

    lsmod

    查看UUID:

    方法一:#ls -l /dev/disk/by-uuid/
    方法二:#blkid

    LSOF命令

    先要 apt-get install lsof

    查看tcp端口应用程序#lsof -i tcp

    查看 linux 发行版,尝试以下方法

    cat /etc/redhat-release
    cat /etc/debian_version
    cat /etc/lsb-release
    cat /etc/os-release
    
  • 我的电脑中显示我的文档

    我的电脑中不显示我的文档

    win+R

    regedit

    找到

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths

    新建字符串名为Administrator 路径为 E:\My Documents

  • bat判断一个进程是否存在

    判断一个进程是否存在,不存在exit 存在就kill

    tasklist|find /i “ia.exe” ||exit
    taskkill /T /F /IM ia.exe

     

  • 批量拷贝

    copy /y glut.h “%programfiles%\Microsoft Visual Studio\VC98\Include\GL\”
    copy /y glut.lib “%programfiles%\Microsoft Visual Studio\VC98\Lib\”
    copy /y glut32.lib “%programfiles%\Microsoft Visual Studio\VC98\Lib\”

     

  • 清除远程桌面连接(mstsc)记录

    运行注册表regedit

    进入

    HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client

    分别在

     HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default
     HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers

    删掉相对应的IP