Linux下一些操作
来源:互联网 发布:知乎开放婚姻体验 编辑:程序博客网 时间:2024/05/04 07:51
Linux KDE 和 Linux GNOME 桌面系统都使用 Desktop Entry 文件标准来描述程序启动配置信息,Desktop Entry 文件以".desktop"为后缀名,通常被存放在 /usr/share/applications和/opt/gnome/share/applications 等目录下,比如编辑/usr/share/applications/eclipse.cdt,内容如下
[Desktop Entry]Name=EclipseComment=Eclipse SDKIcon=/home/pc01/eclipse/icon.xpmExec=/home/pc01/eclipse/eclipseTerminal=falseType=ApplicationCategories=Application;DevelopmentEncoding=UTF-8
2.gcov用法
gcov -a -o ./build/Debug/GNU-Linux-x86/data ./data/*.cpp
3.chmod用法
chmod (u/g/o/a) (+/-/=) (权限) FileName/DirName
4.cppcheck用法
cppcheck -v --enable=all --xml -I<include directory> <sources> 2> cppcheckreport.xml
5.cppncss用法
cppncss -r -v -x -k -f=report.xml <sources>
6.编写sh文件,保存为genreport.sh,修改权限chmod u+x genreport.sh
#!/bin/sh#gcov.sh#run gcov reportecho "clean MASServer""/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-confrm *.gcovecho "make MASServer""/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-confBuildPath=./build/Debug/GNU-Linux-x86TinyXML=/home/pc01/Source/c++/tinyxmlCPPCheckReport=cppcheckreport.xmlCPPNCSSReport=cppncssreport.xmlGCOVReport=gcovreport.xmlGCOVRApp=/home/pc01/Source/gcovrRunPath=./dist/Debug/GNU-Linux-x86if [ -r "$BuildPath" ]; thenecho "Make Success"rm $CPPCheckReport > /dev/nullecho "Make CPPCheck Report $CPPCheckReport"cppcheck -v --enable=all --xml -I $TinyXML ./ 2> $CPPCheckReportrm $CPPNCSSReport > /dev/null echo "Make CPPNCSS Report $CPPNCSSReport"cppncss -r -v -x -k -f=$CPPNCSSReport ./echo "Run Program"$RunPath/masserver > /dev/nullrm $GCOVReport > /dev/nullecho "Make GCovr"$GCOVRApp -x -r . > $GCOVReportelseecho "Make Fail!"fi如果提示do无法用,请运行
sudo dpkg-reconfigure dash
出现界面后选择no即可。
7.rpm安装
rpm -ivh xxx.rpm
8.sonar+mysql+maven+tomcat
下载maven,配置环境变量
M2_HOME=XXXPath=%M2_HOME%/bin MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m
下载tomcat,安装后,配置环境变量
export CATALINA_HOME=/home/pc01/apache-tomcat-7.0.27export CATALINA_OPTS=" -Xms1024m -Xmx1024m -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -XX:MaxPermSize=256m"
修改mysql密码mysqladmin -uroot -p password 111111停止mysql
/etc/init.d/mysql stop启动mysql
/etc/init.d/mysql start
拷贝mysql配置cp /usr/share/doc/MySQL-server-5.5.17/my-large.cnf /etc/my.cnf vi /etc/my.cnf 在[client]下面加上 default-character-set = utf8 在[mysqld]下面加上 character-set-server=utf8 init_connect = 'SET NAMES utf8'mysql创建sonar数据库
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;创建一个sonar用户:
grant all privileges on sonar.* to 'sonar'@'localhost' identified by 'sonar';flush privileges;修改sonar配置conf/sonar.properties
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8sonar.jdbc.driver: com.mysql.jdbc.Driversonar.jdbc.validationQuery: select 1
修改maven配置文件/conf/settings.xml
<profile><id>sonar</id><activation><activeByDefault>true</activeByDefault></activation><properties><sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url> <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName><sonar.jdbc.username>sonar</sonar.jdbc.username><sonar.jdbc.password>sonar</sonar.jdbc.password><sonar.host.url>http://127.0.0.1:9000</sonar.host.url></properties></profile>
启动sonar,登录用admin/admin完成
9.看程序libc版本
ldd 程序名
10.看libc版本
/lib/libc.so.6
11.解压bz2后缀文件
tar -jvxf ../glibc-linuxthreads-2.5.tar.bz2
12.centos增加更新站点并下载chrome
vim /etc/yum.repos.d/CentOSBase.repo增加节点
[google64]name=Google - x86_64baseurl=http://dl.google.com/linux/rpm/stable/x86_64enabled=1gpgcheck=1gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub执行
sudo yum install google-chrome-beta
13.查看linux内核版本
cat /proc/version
14.查看linux具体为32还是64位
file /sbin/init
或者
getconf LONG_BIT查看相关.so是什么版本也可以
file XXX.so
15.查看文件用了哪些库文件
ldd XXX
16.看系统信息
uname -a
17.安装deb文件
sudo dpkg -i xxx.deb
18.查看Linux程序的导入表函数
readelf -a XXX
19.查看通道信息可以翻页
readelf -a XXX | grep FUNC | less
20.快速找文件
locate XXX
21.解决cannot restore segment prot after reloc: Permission denied问题
这是因为SELINUX的问题,需要关闭SELINX,执行:/usr/sbin/setenforce 0
或者修改/etc/selinux/config文件,将SELINUX=enforcing改为SELINUX=disabled
或者
22.查找文件内容
find . | xargs grep "test"
grep -c "test" *.h
23.查看可执行文件路径
whereis lddwhereis gmake
24.查看端口,比如1234
netstat -tlnp |grep 1234或
lsof -i:1234ps -ef|grep XXXPID杀掉占端口程序
lsof -i:1234|grep -v "PID" |awk '{print "kill -9",$2}'|sh
25.修改MTU,运行ifconfig,可以看见MTU值,参见
检查MTU是否通过,执行
ping -c 2 -M do -s 1500 61.135.169.125
为使系统在起动时自动设定MTU的值而不需要每次都手动修改,可以这样做,修改
/etc/conf.d/local.start(gentoo系统下修改这个)
/etc/rc.ocal (ubuntu ,debian ,archlinux,fedora,opensuse等系统可以试着修改这个文件)
加入如下一行:
ifconfig eth0 mtu 1492用下面命令可以修改mtu值
ip link set dev eth0 mtu 1492
26.CentOS 增加Yum源的方法
yum install wget #安装下载工具wget wget http://www.atomicorp.com/installers/atomic #下载atomic yum源 sh ./atomic #安装 yum check-update #更新yum软件包
27.查看linux具体是哪家版本
cat /etc/issue
28.安装zsh
安装zsh
apt-get install zsh配置zsh配置文件,
sudo vi ~/.zshrc添加如下内容
#命令提示符 {{{RPROMPT=$(echo '%{\033[31m%}%D %T%{\033[m%}')PROMPT=$(echo '%{\033[34m%}%M%{\033[32m%}%/%{\033[36m%}%n %{\033[01;31m%}>%{\033[33m%}>%{\033[34m%}>%{\033[m%} ')#}}}#标题栏、任务栏样式{{{case $TERM in (*xterm*|*rxvt*|(dt|k|E)term) precmd () { print -Pn "\e]0;%n@%M//%/\a" } preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" } ;;esac#}}}#关于历史纪录的配置 {{{#历史纪录条目数量export HISTSIZE=1000#注销后保存的历史纪录条目数量export SAVEHIST=1000#历史纪录文件#export HISTFILE=~/.zhistory#以附加的方式写入历史纪录setopt INC_APPEND_HISTORY#如果连续输入的命令相同,历史纪录中只保留一个#setopt HIST_IGNORE_DUPS #为历史纪录中的命令添加时间戳 setopt EXTENDED_HISTORY #启用 cd 命令的历史纪录,cd -[TAB]进入历史路径setopt AUTO_PUSHD#相同的历史路径只保留一个#asetopt PUSHD_IGNORE_DUPS#在命令前添加空格,不将此命令添加到纪录文件中#setopt HIST_IGNORE_SPACE #}}}#每个目录使用独立的历史纪录{{{cd() { builtin cd "$@" # do actual cd fc -W # write current history file local HISTDIR="$HOME/.zsh_history$PWD" # use nested folders for history if [ ! -d "$HISTDIR" ] ; then # create folder if needed mkdir -p "$HISTDIR" fi export HISTFILE="$HISTDIR/zhistory" # set new history file touch $HISTFILE local ohistsize=$HISTSIZE HISTSIZE=0 # Discard previous dir's history HISTSIZE=$ohistsize # Prepare for new dir's history fc -R #read from current histfile}mkdir -p $HOME/.zsh_history$PWDexport HISTFILE="$HOME/.zsh_history$PWD/zhistory"function allhistory { cat $(find $HOME/.zsh_history -name zhistory) }function convhistory { sort $1 | uniq | sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' | awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }' }#使用 histall 命令查看全部历史纪录function histall { convhistory =(allhistory) | sed '/^.\{20\} *cd/i\\' }#使用 hist 查看当前目录历史纪录function hist { convhistory $HISTFILE }#全部历史纪录 top44function top44 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 44 }#}}}#a杂项 {{{#允许在交互模式中使用注释 例如:#cmd #这是注释setopt INTERACTIVE_COMMENTS #启用自动 cd,输入目录名回车进入目录#稍微有点混乱,不如 cd 补全实用#setopt AUTO_CD #扩展路径#/v/c/p/p => /var/cache/pacman/pkgsetopt complete_in_word #禁用 core dumpslimit coredumpsize 0#Emacs风格 键绑定bindkey -e#设置 [DEL]键 为向后删除bindkey "\e[3~" delete-char#以下字符视为单词的一部分#WORDCHARS='*?_-[]~=&;!#$%^(){}<>'##LEO注释了这部分#}}}#自动补全功能 {{{setopt AUTO_LISTsetopt AUTO_MENU#开启此选项,补全时会直接选中菜单项#setopt MENU_COMPLETEautoload -U compinitcompinit#自动补全缓存#zstyle ':completion::complete:*' use-cache on#zstyle ':completion::complete:*' cache-path .zcache#zstyle ':completion:*:cd:*' ignore-parents parent pwd#自动补全选项zstyle ':completion:*:match:*' original onlyzstyle ':completion::prefix-1:*' completer _completezstyle ':completion:predict:*' completer _completezstyle ':completion:incremental:*' completer _complete _correctzstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate#路径补全zstyle ':completion:*' expand 'yes'zstyle ':completion:*' squeeze-shlashes 'yes'zstyle ':completion::complete:*' '\\'zstyle ':completion:*' menu selectzstyle ':completion:*:*:default' force-list always#彩色补全菜单 eval $(dircolors -b) export ZLSCOLORS="${LS_COLORS}"zmodload zsh/complistzstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'#修正大小写zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'#错误校正 zstyle ':completion:*' completer _complete _match _approximatezstyle ':completion:*:match:*' original onlyzstyle ':completion:*:approximate:*' max-errors 1 numeric#kill 命令补全 compdef pkill=killcompdef pkill=killallzstyle ':completion:*:*:kill:*' menu yes selectzstyle ':completion:*:*:*:*:processes' force-list alwayszstyle ':completion:*:processes' command 'ps -au$USER'#补全类型提示分组 zstyle ':completion:*:matches' group 'yes'zstyle ':completion:*' group-name ''zstyle ':completion:*:options' description 'yes'zstyle ':completion:*:options' auto-description '%d'zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'#}}}##行编辑高亮模式 {{{# Ctrl+@ 设置标记,标记和光标点之间为 regionzle_highlight=(region:bg=magenta #选中区域 special:bold #特殊字符 isearch:underline)#搜索时使用的关键字#}}}##空行(光标在行首)补全 "cd " {{{user-complete(){ case $BUFFER in "" ) # 空行填入 "cd " BUFFER="cd " zle end-of-line zle expand-or-complete ;; "cd --" ) # "cd --" 替换为 "cd +" BUFFER="cd +" zle end-of-line zle expand-or-complete ;; "cd +-" ) # "cd +-" 替换为 "cd -" BUFFER="cd -" zle end-of-line zle expand-or-complete ;; * ) zle expand-or-complete ;; esac}zle -N user-completebindkey "\t" user-complete#}}}##在命令前插入 sudo {{{#定义功能 #sudo-command-line() {# [[ -z $BUFFER ]] && zle up-history# [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"# zle end-of-line #光标移动到行末#}#zle -N sudo-command-line#定义快捷键为: [Esc] [Esc]#bindkey "\e\e" sudo-command-line#}}} #命令别名 {{{#alias -g cp='cp -i'#alias -g mv='mv -i'#alias -g rm='rm -i'alias -g ls='ls -X -F --color=auto'alias -g ll='ls -l'alias -g grep='grep --color=auto'alias -g la='ls -a'#alias -g ee='emacsclient -t'#alias -g tk='tmux kill-server'#哈哈哈,我现在有了byobualias -g bb='byobu-tmux'alias -g x='exit'alias -g t='faweibo -t'alias -g tm='tmux'alias -g f='cat ~/日程'#还是算了吧#alias -g gcc='gcc -Wall'#alias -g cd....='cd ../..'#Well this must consult Gods later.__Leo#[Esc][h] man 当前命令时,显示简短说明 alias run-help >&/dev/null && unalias run-helpautoload run-help#历史命令 top10alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'#}}}#路径别名 {{{#进入相应的路径时只要 cd ~xxx#hash -d WWW="/home/lighttpd/html"#hash -d ARCH="/mnt/arch"#hash -d PKG="/var/cache/pacman/pkg"#hash -d E="/etc/env.d"#hash -d C="/etc/conf.d"#hash -d I="/etc/rc.d"#hash -d X="/etc/X11"#hash -d BK="/home/r00t/config_bak"hash -d lc="/home/leo/dev/learnC"hash -d di="/home/leo/文档/日记"#}}} ##afor Emacs {{{#在 Emacs终端 中使用 Zsh 的一些设置 不推荐在 Emacs 中使用它if [[ "$TERM" == "dumb" ]]; thensetopt No_zlePROMPT='%n@%M %/>>'alias ls='ls -F'fi #}}}#{{{自定义补全#补全 pingzstyle ':completion:*:ping:*' hosts 192.168.128.1{38,} www.g.cn \ 192.168.{1,0}.1{{7..9},}#补全 ssh scp sftp 等#my_accounts=(#{r00t,root}@{192.168.1.1,192.168.0.1}#kardinal@linuxtoy.org#123@211.148.131.7#)#zstyle ':completion:*:my-accounts' users-hosts $my_accounts#}}}####{{{function calc { echo $(($@)) }function timeconv { date -d @$1 +"%Y-%m-%d %T" }# }}}## END OF FILE ################################################################## vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4
替换bash
chsh输入/bin/zsh
重启机器
sudo shutdown -r 0
29.替换用户shell
sudo usermod -s /bin/zsh pc01
30.多目录操作方法
rmdir /src/{test/test2,test/test1,testmm}windows 操作方法为
mkdir test,test1
31.自动处理“编译依赖关系”
sudo apt-get build-dep XXX
32.查找文件在那个里面
apt-file search xxx
33.查找程序或包是否存在
apt-cache search vim
34.在当前bash环境下读取并执行FileName中的命令
source xxx
注:该命令通常用命令“.”来替代。如:source .bash_rc 与 . .bash_rc 是等效的。
35.向其他终端发送信息
参见
查看当前所有登录用户所使用的终端
w看下自己是哪个终端
who am i查看终端名
tty给其他终端写信息
write xx(用户名) /dev/pts/x写信息,按ctrl+c完成
36.编译mplayer
参见文章
sudo apt-get install dpkgapt-get source mplayersudo apt-get build-dep mplayersudo apt-get install liblivemedia-dev进入mplayer目录
dpkg-buildpackage -rfakeroot编译结束有几个deb包
dpkg -i xxx.deb
37.使用Vmware的ShareFolder功能
在vmware设置好share folder后,在linux环境下运行
sudo vmware-config-tools.pl
执行
sudo mount -t vmhgfs .host:/ /mnt/hgfs运行完成后,就可以在/mnt/hgfs看到共享的目录了。
38.查看环境变量
envenv | grep xxx
39.升级ubuntu
sudo do-release-upgrade
升级到开发版
sudo do-release-upgrade -d
- Linux下一些操作
- linux下一些操作
- linux下一些操作命令
- Linux下一些小操作
- Linux下一些操作命令
- Linux下的一些操作
- linux下mysql的一些基本操作
- Linux下一些多媒体操作命令
- Linux下Mysql的一些操作
- linux下的一些文件操作函数
- Linux 下一些常用的操作(Ubuntu)
- linux下mysql的一些基本操作
- linux 下mysql一些基本操作
- Linux下得知道的一些操作
- Linux下一些操作Tomcat的命令
- Linux下Mysql的一些基本操作:
- linux下对mysql的一些操作
- linux下的一些简单命令操作
- VCD格式介绍
- VC多线程的同步
- JavaScript继承详解(一)
- cvs update 的输出标志/update常用几个参
- linux下.cpio.gz文件的解压
- Linux下一些操作
- PHP 关闭安全模式
- Linux七天系列(第三天)
- 用SIGHUP挂起某个进程之后如何恢复?
- Access数据库注入方法及防范
- Linux七天系列(第四天)—用户管理详解
- C#中DataSet 可视化设计使用方法
- CVS操作
- VC 动态拖动或拖拽Static控件