ubuntu 常用命令

来源:互联网 发布:cocos2d-x用js编写 编辑:程序博客网 时间:2024/06/06 11:04

    1. find / -name "*.jar" -exec ls -l {} \;
    2. find /vmfs -name temp -prune -o -name "*.v0*" -print | sort //查找/vmfs下除了目录temp下的*.v0*"文件
    3. find / -name “gnome*” -print 2> /dev/null //不输出错误信息 
    4. kill -1 1234 >killouterr.txt 2>&1 //正常和错误信息输入到同一个文件
    5. find / -type d -maxdepth 1 -print
    6. find $HOME -type d -ls |less
    7. find / -type f | less
    8. find /usr/include/ -iname '*.h' | xargs grep 'ORIG_EAX' -sl

    1. grep -nr "good" * //搜索当前目录下含有"good"字符的文件
    2. grep -iw "samba" /tec/samba/smb.conf -i 忽略pattern中的大小写 -w 搜索整个词汇
    3. grep -vf file1 file2 显示出file2中和file1的不同

  1. $ sudo shutdown -h now //关闭Ubuntu机器
  2. sudo chsh -s /bin/bash <username>solve ubuntu terminal up arrow not working
  3. sudo lsb_release -a //查看ubuntu 版本
  4. import rem = re.search("UT#12345,|,UT#12345", "Use: UT#12345,UT#12346")print re.sub(m.group(0),'', 'Use: UT#12345,UT#12346')result: Use ticket: UT#12346
  5. cat /etc/issue // 查看版本
  6. /etc/fstab 开机自动挂载nfs文件系统ip:/mount_point /local_point nfs defaults 0 0
  7. strings /bin/ls | grep -i libc //查找ls中包含libc的字符串,不区分大小写
  8. ps -ef | grep post //查看带有post运行的线程
  9. apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.Fromhttp://linux.die.net/man/8/apt-get:
  10. sudo apt-get install ubuntu-desktop //ubuntu install desktop
  11. sudo apt-get update //在修改/etc/apt/sources.list或/etc/apt/preferences之后运行该命令。此外您需要定期运行这一命令以确保您的软件包列表是最新的
  12. apt-get install -y //-y Assume Yes to all queries and do not prompt
  13. sudo apt-get remove package //删除install的package
  14. apt-cache search local-lib //
  15. apt-cache depends httpd// 查找httpd的依赖
  16. ctrl+r //查看历史命令
  17. dpkg -i *.deb //安装deb文件
  18. dpkg -l|grep glib //查找机器中安装的glib包
  19.  sudo apt-get -f install //安装依赖包
  20. :edit or :e! //vi重新加载文件
  21. set nonu //取消行号设置
  22. :f 或CTRL+G //查看vim下查看文件名
  23. chown [选项]... [所有者][:[组]] 文件...
  24. chown -R newowner:newgroup myfolder/
  25. m,ns/^/# //vim注释m到n行
  26. :set hlsearch  //vim 高亮search
  27.  ls -l |grep "^-"|wc -l // 查看文件夹下文件个数
  28. expr 5 + 2 ortest=$[5+2] //执行算术运算
  29. echo $wsx; // /home/wsxbasename $wsx // wsxdirname $wsx // /home
  30. echo /usr/dir1 /var/dir2 /nas/dir3 | xargs -n cp -v /path/to/file //把file文件复制到dir1/2/3目录下
  31. export CFLAGS='-I/lib/modules/$(uname -r)/build/include' //$(uname -r)采用相对路径
  32. unset 变量名 //取消export 定义的变量名
  33. chkconfig --list |grep telnet //查看telnet 服务状态是关闭or打开
  34. service iptables status //redhat 查看防火墙状态
  35. $sudo ufw status //查看firewall status
  36. sudo ufw disable //关闭防火墙
  37. tty //查看当前运行的是哪个terminal
  38. Ctrl+Alt+T打开一个新的terminal
  39. ls -F //文件后跟@,表示该文件是连接文件,文件名后跟*,表示该文件是可执行文件
  40.  sudo passwd修改/设置root密码
  41.  passwd wsx //设置wsx用户密码
  42. df -hl 查看Linux磁盘剩余空间
  43. du -sh//查看文件夹大小
  44. du -h wsx//查看文件夹下每个文件夹的大小
  45. pushd -    //保存当前目录以供 popd 命令使用,然后改到指定的目录
  46. popd  //更改到 pushd 命令存储的目录
  47. cd - //进入刚出差进入的地方
  48. cd //快速回到home下你的目录
  49. mount -o loop disk1.iso /mnt/disk
  50. umount -f /mnt/iso //Unmount an ISO Image
  51.  mkisofs -o hh.iso hh
  52.  md5sum  xx.jar 
  53.  sha1sum xx.jar//查看md5码
  54. 查看ubuntu版本
    1. cat /proc/version
    2. lsb_release-a
  55. chvt 7可以转到图形界面,chvt 1~6是命令行
  56. echo $? //显示最后一条命令的执行状态
  57. echo "${PWD}" //显示当前路径
  58. echo $OLDPWD //显示上次路径
  59. Alt+1,Alt+2,Alt+3 or Ctrl+pgup, Ctrl+pgdn//多个terminal之间切换
  60. IDE硬盘被定义成hd设备,SCSI硬盘被定义成sd设备
  61. chown wsx machine.txt //修改machine.txt文件归wsx用户所有
  62. unzip file.zip -d destination_folder
  63. ln [option] source_file dist_file   (source_file是待建立链接文件的文件,dist_file是新创建的链接文件)
  64. How to Delete a User

    Should you find that you find that you no longer want to have a specific user on the virtual private server you can delete them with a single command.

    sudo userdel newuser

    Finish up by the deleting the user’s home directory:

     sudo rm -rf /home/newuser
  65. /etc/init.d/sshd status //验证SSH服务状态
  66. /etc/init.d/sshd start //启动shh服务
  67. /var/log/auth.log // server's auth log
  68. The /etc/shadow file stores actual password in encrypted format for user’s account with additional properties related to user password 
  69. ssh-keygen
  70. cat <<ZZ >input.txt //遇到ZZ停止向input.txt继续输入文件
  71. dpkg -S /etc/host.conf //what package includes the /etc/host.conf file
  72. sudo usermod -l 新名字 -d /home/新名字 -m 原名字
    sudo groupmod -n 新名字 原名字
  73. dpkg -l 查看所有安装软件包
  74. 修改主机名,1)在/etc/hosts中增加ip hostname 注:/etc/hosts存放的是域名与ip的对应关系,域名与主机名没有任何关系,你可以为任何一个IP指定任意一个名字 2)在/etc/hostname中增加hostname
  75. How to speed my too-slow ssh login?

    Edit your "/etc/ssh/ssh_config" and comment out these lines:

    GSSAPIAuthentication yesGSSAPIDelegateCredentials no

  76. ubuntu下允许root用户ssh远程登录

    安装OpenSSH server:

    1. 使用apt命令安装openssh server

    $ sudo apt-get installopenssh-server

    2. 可以对 openssh server进行配置

    $ sudo vi/etc/ssh/sshd_config

    找到PermitRootLoginno一行,改为PermitRootLogin yes

     

    3. 重启 openssh server

    $ sudo service ssh restart


查看硬盘的分区 #sudo fdisk -l

查看IDE硬盘信息 #sudo hdparm -i /dev/hda

查看STAT硬盘信息 #sudo hdparm -I /dev/sda 或 #sudo apt-get install blktool #sudo blktool /dev/sda id

查看硬盘剩余空间 #df -h #df -H

查看目录占用空间 #du -hs 目录名

优盘没法卸载 #sync fuser -km /media/usbdisk



压缩解压命令

1.可以直接使用 tar xvJf  ***.tar.xz来解压,或

    $xz -d ***.tar.xz

    $tar -xvf  ***.tar

2.ssh 免密码登录

所以如下方法:
在任意一台主机创建ssh-keygen,然后将pub文件的内容追加到authroized_keys内。或者直接拷贝为authroized_keys.
之后将本机的.ssh目录拷贝到所有目标主机的家目录下面即可。

3.
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32/mingw32_4.2.1.dfsg-2ubuntu1_i386.debwget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32-binutils/mingw32-binutils_2.20-0.2ubuntu1_i386.debwget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32-runtime/mingw32-runtime_3.15.2-0ubuntu1_all.deb
apt-cache search mingw 搜索仓库里含有mingw的软件

install these packages using command :

sudo dpkg -i *.deb

解压deb 包

dpkg -x package.deb /tmp/out



tar zxvf mysql.tar.gz -C /home/aaa //解压到指定的目录

0 0
原创粉丝点击