Linux 各类设置、配置、使用技巧参考,Linux使用集锦

来源:互联网 发布:西西游戏网下载软件 编辑:程序博客网 时间:2024/06/12 09:35

========== 参考格式 (新增记录时,复制粘贴在下)=============

【日期】:
《标题》

参考链接ref1:

参考链接ref2:

正文:


========== 参考格式 (新增记录时,复制粘贴在下)=============


========== 参考格式 (新增记录时,复制粘贴在下)=============

/etc/resolv.conf 被重写问题应对

Linux配置DNS时出现/etc/resolv.conf被重写问题时,如果锁定之:

chattr +i /etc/resolv.conf
解锁 :chattr +i /etc/resolv.conf


========== 参考格式 (新增记录时,复制粘贴在下)=============

Ubuntu gnome-terminal shortcut key:

Ubuntu Terminal 快捷键:

 ubuntu Terminal add tab shortcut key:  Ctrl+Shift+T                Move tab shortcut key:  Ctrl+PageDown/PageUp               Swith tab shortcut key:  Alt+(1-9): e.g.: Alt+1               Close tab shortcut key:  Ctrl+Shift+W or Ctrl+D (Firefox=Ctrl+W)    close the entire terminal:  Ctrl + Shift + Q                      Move    workpace:  Ctrl+Alt+UP/Down/Left/Right                    Move to workspace:  Ctrl+Alt+ 1/2/3/4..


========== 参考格式 (新增记录时,复制粘贴在下)=============

Vim复制到系统剪贴板
1.首先查看vim --version |grep clipboard中 clipboard选项是否开启
2.ubuntu中通过下载vim-gnome可以开启系统剪贴板 sudo apt-get install vim-gnome
3.复制粘贴通过 "+y  和 "+p 实现 (在一般模式下按v进入visual模式G全选后复制
vim 命令:

<ESC>
ggVGy

说明:

<ESC> - 进入Normal模式
gg -- 到文件开头
V  -- shift+v, 进入Visual-Line模式; v--进入visual单字模式
G  --  shift + g, 到文件结尾
y   -- 复制到剪贴板;p - 粘贴

=====================================

简单的Git 命令:获取仓库文件和切换远程分支

git clone git@gitlab.xxx.com:xxxxx.git  //从远程clone 分支下来,一般是默认master。

有时不是,用 git branch 可以看到:
* indigo-devel 
说明此时是在indigo-devel上。

=== 要切换到master: ====

git branch -r //查看远程分支,
git branch -a //查看本地和远程分支。
如:
   remotes/origin/master   remotes/origin/indigo-devel
*如果本地没有master,要创建master:
git checkout -b master remotes/origin/master  //本地创建master分支,并与远程remotes/origin/master同步
git branch   //检查本地当前分支

=== 切换到其他分支: ====

git checkout hydro-devel  //从master 切换到 hydro-devel 分支
git checkout indigo-devel
 
//从hydro 切换到 indigo-devel 分支
git checkout master
       // 从indigo-devel 切换到 master 分支


**有关Git,更多教程参见:http://edu.csdn.net/course/detail/1223

========== 参考格式 (新增记录时,复制粘贴在下)=============

工业机器人运动规划算法包:openrave.org

参考链接ref1:

参考链接ref2:

正文: 工业机器人运动规划算法包:openrave.org

========== 参考格式 (新增记录时,复制粘贴在下)=============

【日期】:

《.py运行python程序报错“: No such file or directory”的解决》

参考链接ref1:

参考链接ref2:

正文:

 

分类: Python/Ruby

在linux上,执行python脚本,

    #!/bin/env python    print 'hello'

python a.py 的方式执行没有问题,
./a.py 的方式执行,报错“: No such file or directory”

shell中直接执行 env python 没问题,可以进入python解释器。

修改a.py,不使用env,直接指定python的路径,

  1. #!/usr/bin/python
  2. print 'hello'
./a.py 执行,报错“-bash: ./a.py: /usr/bin/python^M: bad interpreter: No such file or directory”

根据错误信息,发现文件是msdos格式的,行尾是\r\n。 run this comand:
  $ sed -i 's#\r##' a.py
转换成unix格式后,问题解决。
=======================================================================

【日期】:2016年8月10日
《Ubuntu更新源  for x86》

参考链接ref1:

参考链接ref2:

正文:

Ubuntu14.04 LTS更新源  for x86

不同的网络状况连接以下源的速度不同, 建议在添加前手动验证以下源的连接速度(ping下就行),选择最快的源可以节省大批下载时间。
  • 首先备份源列表:
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
  • 而后用gedit或其他编辑器打开:
 sudo gedit /etc/apt/sources.list sudo kate /etc/apt/sources.list   sudo mousepad /etc/apt/sources.list sudo leafpad /etc/apt/sources.list (13.04版)
  • 从下面列表中选择合适的源,替换掉文件中所有的内容,保存编辑好的文件: http://wiki.ubuntu.org.cn/Qref/Source
 注意:一定要选对版本
  • 然后,刷新列表:    注意:一定要执行刷新
sudo apt-get update

=======================================================

【日期】:2016年8月10日
《linux挂载U盘》

参考链接ref1:

参考链接ref2:

正文:

有时候只有Ubuntu server,有时候Ubuntu Desktop不能自动挂载U盘。这个时候需要一些命令:
1.在插入U盘前和插入U盘后,都输入同一个命令,检查多了哪个盘
  cat /proc/partitions
  这里我发现多了

   8       16    7827424 sdb   8       17    7825423 sdb1


  sdb是统称,所以新插入的U盘就是/dev/sdb1
2.用命令检查新的U盘的文件系统格式

  $ sudo fdisk -l /dev/sdb


  Disk /dev/sdb: 8015 MB, 8015282176 bytes
  247 heads, 62 sectors/track, 1022 cylinders, total 15654848 sectors
  Units = sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disk identifier: 0x0001fce0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          62    15650907     7825423    c  W95 FAT32 (LBA)

  看到这里是FAT32格式。

3.mount
  sudo mkdir /media/udisk
  mount -t vfat /dev/sdb1 /media/udisk

  注意:  
  mount -t 按两次tab键会提示输入什么文件系统类型
  /media/udisk是我自己创建的目录

4.umount
  umount /media/udisk

=======================================================

【日期】:2016年7月25日
《通过Terminal 、SSH 配置ubuntu连接wifi 网络 》


参考链接ref1:  http://askubuntu.com/questions/522842/ubuntu-14-04-connect-to-a-wifi-network-using-command-line

参考链接ref2: http://askubuntu.com/questions/16584/how-to-connect-and-disconnect-to-a-network-manually-in-terminal

正文: Connecting to wifi via terminal/ssh/uart for Ubuntu/Lubuntu
Show available wlan access points:
$ nmcli dev wifi

Connect with access point:
$ nmcli dev wifi connect $ACCESS_POINT password $PASSWORD


=======================================================


【日期】: 20160525
《Ubuntu Linux 使用L2TP客户端配置》

参考链接ref1: https://www.yuntidata.com/guides/ubuntu_l2tp

参考链接ref2:

正文:============================
Ubuntu Linux 使用L2TP客户端配置
1. 安装 l2tp-ipsec-vpn
    在 terminal 中执行以下命令,
    sudo apt-get install l2tp-ipsec-vpn
    当遇到这个对话框时(Use an X.509 certificate for this host?),选择"No"
    安装完成重启电脑:
    sudo shutdown -r now

2. 配置 VPN
    右键点击屏幕右上角多出的 l2tp-ipsec-vpn 标志,在下拉选项里点击"Edit Connections"进入 VPN 的设置(可能遇到屏闪,使用键盘操作)

3. 添加 VPN
    点击右侧的"Add"按钮,"Connection name"栏中填入"VPN_L2TP"

4. 编辑 VPNCloud_L2TP
    选中列表中的"VPN_L2TP",点击右侧的"Edit"按钮

5. 填写 VPN 服务器和域名
    IPsec 标签下,"Remote Server"中填入服务器域名(前往服务器列表页面查看);
    “Use pre-shared key for authentication”中填入具体密钥

6. 设置 VPN 协议及填写帐号信息
    点击 PPP 标签,选中"Allow these protocols",并只勾选列表中的"Microsoft CHAP Version 2 (MS-CHAPv2)";
    "User name"中填入你的VPN帐号用户名;"Password"中填入你的VPN帐号密码;最后点击"IP settings..."按钮

7. IP 设置
    勾选"Obtain DNS server addresses automatically",点击"OK"按钮

8. 关闭窗口,让设置生效
    一定要点击"Close"按钮,并点击弹出框内的"OK"按钮,设置才会生效

9. 连接 VPN
    右键点击 l2tp-ipsec-vpn 标志,点击"VPNCloud_L2TP"连接 VPN;如果连接不上,可以重启 l2tp-ipsec-vpn 或者重启系统后再连接

10.连接成功
    VPN 连接成功后 l2tp-ipsec-vpn 标志上就没有红叉;右键点击标志可进行 Disconnect 等操作

=======================================================

【日期】:2016年4月26日14:02:34
《linux下的find文件查找命令与grep文件内容查找命令》

参考链接ref1: http://www.cnblogs.com/zhangmo/p/3571735.html

参考链接ref2:

正文: 

linux下的find文件查找命令与grep文件内容查找命令

  在使用linux时,经常需要进行文件查找。其中查找的命令主要有find和grep。两个命令是有区的。

  区别:(1)find命令是根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为空,访问时间,修改时间等。

(2)grep是根据文件的内容进行查找,会对文件的每一行按照给定的模式(patter)进行匹配查找。

  一.find命令

    基本格式:find path expression

    1.按照文件名查找

    (1)find / -name httpd.conf  #在根目录下查找文件httpd.conf,表示在整个硬盘查找
    (2)find /etc -name httpd.conf  #在/etc目录下文件httpd.conf
    (3)find /etc -name '*srm*'  #使用通配符*(0或者任意多个)。表示在/etc目录下查找文件名中含有字符串‘srm’的文件
    (4)find . -name 'srm*'   #表示当前目录下查找文件名开头是字符串‘srm’的文件

    2.按照文件特征查找     

    (1)find / -amin -10   # 查找在系统中最后10分钟访问的文件(access time)
    (2)find / -atime -2   # 查找在系统中最后48小时访问的文件
    (3)find / -empty   # 查找在系统中为空的文件或者文件夹
    (4)find / -group cat   # 查找在系统中属于 group为cat的文件
    (5)find / -mmin -5   # 查找在系统中最后5分钟里修改过的文件(modify time)
    (6)find / -mtime -1   #查找在系统中最后24小时里修改过的文件
    (7)find / -user fred   #查找在系统中属于fred这个用户的文件
    (8)find / -size +10000c  #查找出大于10000000字节的文件(c:字节,w:双字,k:KB,M:MB,G:GB)
    (9)find / -size -1000k   #查找出小于1000KB的文件

    3.使用混合查找方式查找文件

    参数有: !,-and(-a),-or(-o)。

    (1)find /tmp -size +10000c -and -mtime +2   #在/tmp目录下查找大于10000字节并在最后2分钟内修改的文件
   (2)find / -user fred -or -user george   #在/目录下查找用户是fred或者george的文件文件
   (3)find /tmp ! -user panda  #在/tmp目录中查找所有不属于panda用户的文件
  

  二、grep命令

    基本格式:find expression

    1.主要参数

    [options]主要参数:
    -c:只输出匹配行的计数。
    -i:不区分大小写
    -h:查询多文件时不显示文件名。
    -l:查询多文件时只输出包含匹配字符的文件名。
    -n:显示匹配行及行号。
    -s:不显示不存在或无匹配文本的错误信息。
    -v:显示不包含匹配文本的所有行。

    pattern正则表达式主要参数:
    \: 忽略正则表达式中特殊字符的原有含义。
    ^:匹配正则表达式的开始行。
    $: 匹配正则表达式的结束行。
    \<:从匹配正则表达 式的行开始。
    \>:到匹配正则表达式的行结束。
    [ ]:单个字符,如[A]即A符合要求 。
    [ - ]:范围,如[A-Z],即A、B、C一直到Z都符合要求 。
    .:所有的单个字符。
    * :有字符,长度可以为0。

    2.实例 

  (1)grep 'test' d*  #显示所有以d开头的文件中包含 test的行
  (2)grep ‘test’ aa bb cc    #显示在aa,bb,cc文件中包含test的行
  (3)grep ‘[a-z]\{5\}’ aa   #显示所有包含每行字符串至少有5个连续小写字符的字符串的行
  (4)grep magic /usr/src  #显示/usr/src目录下的文件(不含子目录)包含magic的行
  (5)grep -r magic /usr/src  #显示/usr/src目录下的文件(包含子目录)包含magic的行

  (6)grep -w pattern files :只匹配整个单词,而不是字符串的一部分(如匹配’magic’,而不是’magical’),

=========================================================

【日期】:2016年2月2日11:15:59
《/dev/ttyUSB0 permission denied 解决办法:永久有串口可操作权限》

参考链接ref1:

参考链接ref2:

正文:
Problem: /dev/ttyUSB0 permission denied.
You're not root, has no permission.
Generally, do this way:

   $ sudo chmod 777 /dev/ttyUSB0

This isn’t very safe, strictly speaking, nor is it permanent. The change will need to be repeated every time you reboot the computer or unplug and reconnect the device.

    $ sudo usermod -aG dialout <username>

<username> is your username. Add this user into your dialout userGroup. Log out your linux and you can access your device permanently.

=========================================================

【日期】:2016年1月11日11:23:45
《关于Ubuntu的软件源管理,repositories,PPA等问题》

参考链接ref1:

参考链接ref2:

正文:https://help.ubuntu.com/community/Repositories/Ubuntu

 

=========================================================


【日期】:20160106
《备份ubuntu系统为iso文件,可用于直接安装》

参考链接ref1:

参考链接ref2:

正文:

    已经配置好的ubuntu系统(12.04 or newer), 希望做成iso文件可以供下面的使用者直接安装,请使用工具remastersys.
    使用remastersys, 需要先添加ppa源,参考:https://launchpad.net/~mutse-young/+archive/ubuntu/remastersys
    然后使用命令:

          >> sudo add-apt-repository ppa:mutse-young/remastersys

          >> sudo apt-get update

          >> sudo apt-get insstall remastersys

    上述过程期间可能会遇到一些错误,翻墙以后多试几次就可以。至于怎么使用,先用建立dist:
          >> sudo remastersys dist cdfs

    再创建iso:
          >> sudo remastersys backup iso my_ubuntu_12.04_backup.iso

    即可完成。你将得到如下信息:

Creating the iso file onlySystem Backup Mode SelectedMaking disk compatible with Ubuntu Startup Disk Creator.Creating md5sum.txt for the livecd/dvdCreating my_ubuntu_12.04_backup.iso in /home/remastersys/remastersysCreating my_ubuntu_12.04_backup.iso.md5 in /home/remastersys/remastersys/home/remastersys/remastersys/my_ubuntu_12.04_backup.iso which is 2.2G in size is ready to be burned or tested in a virtual machine.

【日期】:
《查找linux程序进程号-杀死进程》

linux下另外一个ps命令查找与进程相关的PID号:ps aux | grep program_filter_word
查找到进程ID以后可使用kill命令杀死进程。
参考链接ref1:http://os.51cto.com/art/200905/125605.htm
参考链接ref2:

=========================================================

【日期】:
《Linux下可以监听串口上数据的应用》

ref:http://unix.stackexchange.com/questions/12359/how-can-i-monitor-serial-port-traffic
Serial Port Traffic/Data Monitor for Linux
Linux下可以监听串口上数据的应用

There is port monitoring tool to watch the packets written on the port. Especially when you want to check if your program written works. Tool to see if your application is sending the messages to the port.

=========================================================


【20141104】:《Ubuntu Linux下设置IP的配置命令》

参考链接ref1:   http://www.cnblogs.com/empire/archive/2011/01/10/1931877.html

参考链接ref2:

=========================================================


【20141104】:Ubuntu 12.04 中自定义DNS服务器设置

http://blog.renhao.org/2012/05/ubuntu-12-04-add-dns-nameservers/

http://askubuntu.com/questions/130452/how-do-i-add-a-dns-server-via-resolv-conf


==================================================================




    ====== Linux Freq-Used Commands and Accounts Management ======


(I)  Linux Commands
(1.1) Linux Commands Format
(1.2) Get Commands' Help


(II) Frequent used Linux Commands
(2.1) File and Folder Operation Commands
(2.2) Use DVD Disk and U Disk


(III)RPM Package Management
(3.1) Package Manage System
(3.2) RPM Package Manage System


(IV) User and Group Manage Commands
(4.1) User Management
(4.2) Group Management
(4.3) File Authority Setting




原创粉丝点击