1 config network
2 visudo
sunyongjie ALL=(ALL) ALL
2.1 mirrors.163.com
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
sudo yum makecache
3 yum install "@Chinese Support"
4 yum install cmake
5 yum install apr*
6 install log4cxx
7 watch the content of in files
cat linux_diary.txt | grep log4cxx --color -C 3
8 ntfs-3g
http://www.tuxera.com/community/ntfs-3g-download/
tar zxvf a.tgz
./configure
make
make install
yum install ntfs-3g
9 yum install vnc-server
vi /etc/sysconfig/vncservers
vncpasswd
vi xstartup
gnome-session &
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 5900:5903 --state NEW -j ACCEPT
5920后面的20,表示这个vnc能端口能开到20,我们连接的时候192.168.0.12:21就不能连接上去了!
然后重启iptables服务:/etc/init.d/iptables restart
-A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 5900:5920 --state NEW -j ACCEPT
service iptables save //保存
service iptables restart //重启防火墙
sudo vi /etc/rc.d/rc.local
/etc/init.d/vncserver start --新增行
vncserver -geometry 1680x1050
10 ps –aux查看后台执行的程序
11 which locate whereis find grep-
which 寻找可执行文件
whereis locate 利用数据库查找,find不是所以比较慢,它查找硬盘。
Find [PATH] [option] [action]
find . –mtime 0当前目录下,过去24小时内修改过的文件
find . –mtime -3当前目录下,三天内修改过的文件
find . –name ‘ma’ 完全匹配文件名ma
find . –name ‘ma*’ 以ma开头的文件名
find . -iname '*prset*'
当前目录及子目录中,所有包含prset的不分大小写的文件名的文件。
find . –iname ‘*prset*’ -maxdepth 1 只在当前目录
ls | grep gen 这样做才是最简单的容易的。
grep –ih –color ‘ma’ ./* 查询文件中带有连续ma的行的文件
grep –i –R --color ‘prset’ .
当前目录及子目录下的所有文件中查找,不分大小写文件中内容。
find . -iname "*cc" -or -iname "*hh" |xargs tar -zcvf
r4.0_all_c++_file.tar.gz
find /vob -name "*cc" -or -name "*hh" | xargs tar -zcvf
./r4.0_all_c++_file.tar.gz
所有vob中的c++文件
find . -name "*cc" -or -name "*hh" | grep -v c++ | grep -v gcc | xargs tar
-zcvf /local/yongjisu/r4.0_all_c++_file.tar.gz
find /vob -name "*.cc" -or -name "*.hh" > list
tar -T list -czvf picture.tar.gz
find . -iname "*scc" | xargs rm 删除掉指定文件。
find /vob -name "*.cc" -or -name "*.hh" > list
tar -T list -czvf picture.tar.gz
12 du df
df 列出文件系统的整体磁盘使用量
du 评估文件系统的磁盘使用量
du * -s | sort –n
du –sh *
df -hT h以GB,MB,KB等格式自行显示 T连同该分区的文件系统名称也列出
13 xargs
find . -iname "*scc" | xargs rm 删除掉指定文件。
14 mn
check the sign of the binary
15 cat /proc/meminfo
look memory
16 redirection
今天在./main > tmp
这样重定向时发现tmp文件中总是没有内容,后来发现,我每次查看时都是强制结束main进程,这样main里面虽然在向IO中写,
但是没有刷新缓冲区,文件中还是没有的。
printf(“hehe”);后加上这个就可以立即刷新缓冲区了
fflush(stdout); //-
运行
./main > tmp &-
17 alias
alias grep=’grep –color’
.bashrc文件中,好像是
18 ftp
anonymous
密码为空格,然后回车即可
18.1 chkconfig vsftpd on // run at the start of power on
18.2 sudo /etc/init.d/vsftpd restart
sudo /sbin/chkconfig vsftpd on
selinux with ftp
getsebool -a|grep ftp
setsebool -P ftp_home_dir 1
setsebool -P allow_ftpd_full_access 1
service vsftpd restart
19 soft link
For example
I set up a soft link
Use command:
Ln –sf /mnt/aaaa /home/sunyongjie/rosi
if I just want to remove the soft link
I should do the following :
Rm –rf /home/sunyongjie/rosi
注意是 Rm –rf /home/sunyongjie/rosi
不是Rm –rf /home/sunyongjie/rosi/
20 scp
scp ./l2_api.tar.gz root@172.21.200.23:~/sunyongjie
21 lld so
g++ -o main main.cpp -L . -ltest libtest.so -lapr-1
g++ -o main main.cpp -L . -ltest libtest.so -lapr-1 -lexpat -llog4cxx
g++ -fPIC -shared -o libtest.so DFITCL2Api.cpp
cp libtest.so ../demo/
export LD_LIBRARY_PATH=/home/sunyongjie/l2_api/demo/
g++ -o main main.cpp my_callback.cpp -L . -ltest libtest.so -lapr-1 -lexpat -llog4cxx
22 setterm
xterm -bg white -fg blue
linux txt mode color
.bash_profile setterm -foreground black -background white
cp /etc/DIR_COLORS ~/.dir_colors
get rid of all the 01 white 00 (change to not bold)
23 log4cxx
log4cxx-
tar -zxvf a.tar.gz
./configure
make
make check
sudo make install
sudo ln -s /usr/local/lib/liblog4cxx.so /usr/lib/
sudo ln -s /usr/local/lib/liblog4cxx.so.10 /usr/lib/
24 setup network
setup command in shell can setup network configurations
25 sync time with internet
sudo /usr/sbin/ntpdate ntp.api.bz // sync to internet time
sudo hwclock --show // show hardware time
hwclock --systohc // sync haredwate time to system
26 telnet
telnet-server
sudo yum install telnet-server
yum install telnet-server
sudo vi /etc/xinetd.d/telnet
change yes to no
sudo /sbin/service xinetd restart
telnet under selinx and firewall
in iptables add port 23
chkconfig xinetd on
service xinetd start
27 netstat
netstat
netstat -tulp // watch the started service
netstat -lnp // watch all the listened networt service (including all sockets)
netstat -pan
28 DIR_COLORS
sudo cp /etc/DIR_COLORS ~/.dir_colors
29 network
centos do not install xen
30 args
// delete all the files at some condition
find . -iname "*.log*" | args rm -rf
31 tar
// should be exactly the same
tar -zcvpf home_20120824.tar.gz . --exclude .backup --exclude home_20120824.tar.gz
// wrong 1
tar -zcvpf home_20120824.tar.gz . --exclude .backup/ --exclude home_20120824.tar.gz
// wrong 2
tar -zcvpf home_20120824.tar.gz . --exclude .backup
32 networkmanager
start at power on
chkconfig NetworkManager on
33 esc
yum remove esc
35. netstat
netstat -tulp // watch the started service
netstat -lnp // watch all the listened networt service (including all sockets)
36. svn co https://172.16.20.1/svn/TPX/Code/trunk/level2
37. vim
37.1 coscope
cd current directory, just like the command of ctags, we use cscope -Rbq
vi main.cpp
cs find g main
cs find c main
//
find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
// 得到相对路径文件名
find /home/sunyongjie -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
// 得到绝对路径文件名
cscope -bkq -i cscope.files
ctags -R
//
0 或 s 查找本 C 符号(可以跳过注释)
1 或 g 查找本定义
2 或 d 查找本函数调用的函数
3 或 c 查找调用本函数的函数
4 或 t 查找本字符串
6 或 e 查找本 egrep 模式
7 或 f 查找本文件
8 或 i 查找包含本文件的文件
37.2 a.vim
362 在 .h 和 .c/.cpp 文件中切换. (英文原句 "A few of quick commands to swtich between source files and header files quickly.")
安装
把下载到的a.vim插件放到 $HOME/.vim/plugin 目录下, 即可.
使用方法
只要在vim中输入以下命令即可完成相应的功能:
:A switches to the header file corresponding to the current file being edited (or vise versa)
:AS splits and switches
:AV vertical splits and switches
:AT new tab and switches
:AN cycles through matches
:IH switches to file under cursor
:IHS splits and switches
:IHV vertical splits and switches
:IHT new tab and switches
:IHN cycles through matches
<Leader>ih switches to file under cursor
<Leader>is switches to the alternate file of file under cursor(e.g. on <foo.h> switches to foo.cpp)
<Leader>ihn cycles through matches
28 network
dorm wireless
DEVICE=eth0
BOOTPROTO=dhcp
# HWADDR=00:0C:29:7D:D4:D9
HWADDR=00:0c:29:ea:e0:06
ONBOOT=yes
TYPE=Ethernet
company wired
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:ea:e0:06
NETMASK=255.255.255.0
IPADDR=172.16.16.247
GATEWAY=172.16.16.254
TYPE=Ethernet
29 相同的主机名在一个网络中,会不能正常分配ip地址,会上不了网
这个时候要给第二台机器改名字,就可以了
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.10.1
drom :dns 202.106.46.151
202.106.195.68
30 正则表达式与通配符
bash下的*是通配符,grep命令后的*是正则表达式
ls apr*应该是表示apr都存在后有一个或者多个字符
ls . |grep apr*应该是表示ap一定存在,r这个位置,可以有,可以一个可以多个
31 tar -xvf b.tar.gz 显示压缩包内容
tar -tvf b.tar.gz
32 shutdown -h 关机后关闭电源
33 vm tools
host机器为windows,在windows上安装虚拟机,虚拟机上装linux,安装vm
tools,把安装vmware生成的目录中的linux.iso放入虚拟机软件的光驱中
host机器为linux, 在linux上安装虚拟机,虚拟机上安装windows,安装vm
tools,把安装vmware生成的目录中的windows.iso入入虚拟机软件中光驱中
usr/lib/vmware/isoimages/windows.iso
34 log4cxx install
Log4CXX±àò?°2×° (2012-05-03 16:24)
±ê??: log4cxx ?μí3è??? Linux ·?àà£o 3ìDò?a·¢
1. ê×?è?????à1?èí?t°ü
1) log4cxx: http://logging.apache.org/log4cxx/
2) apr: http://apr.apache.org/download.cgi
3) apr-util: http://apr.apache.org/download.cgi
2. °2×°apr
tar xjf apr-1.3.3.tar.bz2
cd apr-1.3.3
./configure --prefix=/usr/local/apr
make
make install
3. °2×°apr-util
tar xjf apr-util-1.3.4.tar.bz2
cd apr-util-1.3.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
4. °2×°log4cxx
tar xzf apache-log4cxx-0.10.0.tar.gz
cd apache-log4cxx-0.10.0
./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install
./configure --prefix=/usr/local/apr CFLAGS=-fPIC
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-pic CFLAGS=-fPIC
./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util CFLAGS=-fPIC
35 objdump 查看静态动态库 版本
objdump -a
objdump -v
36 nm
查看动态,静态库 符号
37 LD_LIBRARY_PATH L
前者用于程序运行时,动态连接库的查找
后者用于编译时,动态链接库的查找
38 将文件系统与目录树相结合的操作,叫作挂载
挂载点一定是目录,该目录为进入该文件系统的入口
我觉得,大部分的情况,文件系统就是一个分区,因为一般一个分区一个文件系统格式
基本就是 文件系统 == 分区 == 设备
39 shell
硬件:声卡芯片等等
内核管理:OS的内核可以支持这个芯片组,当然还需要硬件厂商提供自己硬件的驱动程序
应用程序:需要用户输入发生声音的命令
用户通过应用程序输入一个发出声音的命令,这个应用程序通过一个叫shell的应用程序
加载到内存中,由OS来执行,OS(内核)控制硬件发出声音,这个控制由OS(内核)调用硬件
驱动程序来完成
OS其实是一组软件,由于这组软件在控制整个硬件与管理系统的活动监测,如果这组软件能
能被用户应用不当,将会使得整个系统崩溃,所以就有了在操作系统上面发展应用程序。
用户通过应用程序指挥OS内核,让内核达成我们所需要的硬件任务。
shell是一个OS提供给用户,让用户操作OS的一人接口,因此这个shell要有能力调用其它
应用程序才好,man,chown,vi这些命令,是独立的应用程序,我们可以通过shell来操作这些应用程序,让这些应用
程序去调用内核来运行所需要的工作。
也就是说,只要能够操作应用程序的接口都能够称为shell。狭意的shell指的是命令行界面
的shell,bash,广义的shell则包括图形界面的软件,因为它也可以通过应用程序来操作
OS内核。
40 file 显示文件类型
41 ntfs-3g
mount -t ntfs-3g /dev/sda1 /mnt/windows
/etc/fstab
/dev/sda1 /mnt/windows ntfs-3g defaults 0 0
42 隐藏centos桌面图标
43 virtualbox
首先文档/home/sunyongjie/centos/Centos6.2(EPEL_RPMForge_RPMFusion).doc
How to Install VirtualBox in CentOS 6.3
vbox_logo2_gradient
You want to run a Windows Virtual Machine in your CentOS computer? or want to
try out another linux distribution without going through the hassle of
installing the whole system? Here is a solution. VirtualBox is a very easy to
use open source virtualization software package developed by Oracle. So in
this article i will guide you through the process of installing virtualbox in
a CentOS computer.
* First up you have to download and install the rpmforge repository in your
* computer. Download the appropriate version that matches your host’s
* architecture.
i686:-
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
x86_64:-
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Installing these rpms is very easy in CentOS. Just open the rpm file and rpm
manager will take care of the installation process.
* Get the root access. Type
“su” and enter the password when prompted.
* Now install the DAG’s GPG key. Type
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
* Install DKMS and it’s dependencies. (DKMS has some important dependencies
* like kernel-headers kernel-devel etc) Type
yum install dkms
* Along the installation you will be prompted for some “yes or no” questions.
* Type y and continue
Now we are going to add the virtualbox repo to the yum repository. This way
you can install and update virtualbox through yum.
* Navigate to /etc/yum.repos.d directory. Type
cd /etc/yum.repos.d
* Add the virtualbox repo to yum
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
* Now we have to install virtualbox. Type
yum install VirtualBox-4.1
* Again the system will prompt you for some yes or no questions along the
* installation process. Type y and continue.
* Check your Kernel version. Type
uname -r
* Check /usr/src/kernels to confirm that a directory for your current kernel
* version exists. Type
ls /usr/src/kernels
If the result of this matches up with the output from “uname -r” you are good.
* Now specify the KERN_DIR environment variable. Type
KERN_DIR=/usr/src/kernels/2.6.32-279.5.1.el6.i686
export KERN_DIR
* Rebuild the Kernel modules. Type
/etc/init.d/vboxdrv setup (Instead you can use “service vboxdrv setup” too)
* Add yourself to the VirtualBox user group. Type
usermod -a -G vboxusers “your_user_name”
(Type your OS login username instead of the “your_user_name”)
That should do it. Now go ahead and fire up VirtualBox and it should work
perfectly. Let me know if you have any questions.
44 fPIC
45 gconf-editor
sudo yum install gconf-editor
apps/nautilus/desktop 可以修改桌面显示
46 tiger vnc server
yum -y install tigervnc-server
vncserver
pkill vnc
copy /lib/systemd/system/vncserver@.service to /etc/systemd/system/vncserver@:1.service
Now we edit the file. We look for these lines in the file
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l -c "/usrbin/vncserver %i"
ExecStop=/sbin/runuser -l -c "/usr/bin/vncserver -kill %i"
That first line is important. The comment above it explains that it kills any existing tmp files in tmp/.X11-unix. If you're running vncserver and you look in /tmp/.X11-unix, you'll see that there's a socket file X1. If that file doesn't get cleaned--and while it should, sometimes, it doesn't, when you next start vnc it will fail to start because it sees that there's already an existing socket on X1. If you start it manually, and that file exists, it will start a display on :2, rather than :1.
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
47 编译时,动态库的链接 -L . libDBmysql.so == -L . lDBmysql
48 zombie process僵尸进程
-A -o stat,ppid,pid,cmd | grep -e '^[Zz]'
ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $-3}' | xargs kill -9
49 mysql -u root -p password
sudo mysqladmin -uroot -p12345 password wangtian
select user,password from mysql.user;
show databases;
drop database database's name;
use test;
create table tsyj (id int, name varchar(32));
insert into tsyj (id,name) values (1, 'syj');
insert into tsyj (id,name) values (2, 'lsw');
insert into dept values(100,'IT','beijing'),(200,'Sales','beijing');
insert into dept2 select * from dept;
desc tsyj;
select * from tsyj;
update wangjie set name = 'songyongjie' where id = 100;
delete from wangjie where id = 100;
drop table table's name;
alter table dept add constraint primary key (id);
alter table dept drop primary key;
alter table emp add constraint foreign key e_fk_d_id(d_id) references dept(id);
alter table emp drop foreign key;
show create table emp;
select salaries.salary, dept.name, emp.name from dept, emp, salaries
where salaries.d_id = dept.id and salaries.e_id = emp.id and emp.name = 'syj';
50 gdb
x &i 查看i的地址上的内存
51 desktop
66 113 99 solid color
34 75 104; 20 44 61 vertical gradient
52 环境变量累加
centos 5.5
PATH=${PATH}:/usr/local/lib
53 smb
chkconfig smb on
service smb start
sudo smbpasswd -a sunyongjie
vi /etc/samba/smb.conf
add following line at the end of file
[all file]
comment = centos all file
path = /
valid users = sunyongjie
public = no
writable = yes
printable = no
create mask = 0777
directory mask = 0777
servcie smb restart
client 1 windows
use network neibours
client 2 linux
smbclient -L //172.16.16.245 -U sunyongjie #look and check
sudo mount -t cifs //172.16.16.245/sunyongjie home_centos5 -o username=sunyongjie,password=wangtian,codepage=cp950
#sunyongjie is the name we found by the smbclient command
/etc/fstab
//172.16.16.245/sunyongjie /home/sunyongjie/home_centos5 cifs username=sunyongjie,password=wangtian,codepage=cp950 0 0
/sbin/chkconfig smb on
51 format
sudo /sbin/mkfs -t ext3 /dev/sda9
52 yum apr and source code log4cxx centos 64bit installation
"./configure LDFLAGS="-L/usr/lib64 -L/lib64" --enable-lib64 --libdir=/usr/lib64
./configure LDFLAGS="-L/usr/lib64 -L/lib64" --libdir=/usr/lib64
53 mplayer
http://pkgs.repoforge.org/rpmforge-release/
and intall the rpm
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo vi /etc/yum.repos.d/rpmforge.repo
add priority=12
54 gnome-session-properties fedora start up service selector
55 sudo yum install flash-plugin
56 fedora titile hide
metacity-theme-2.xml or metacity-theme-3.xml
vim /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml
<frame_geometry name=”max” title_scale=”medium” parent=”normal” rounded_top_left=”false” rounded_top_right=”false”>
add has_title="false"
<distance name=”title_vertical_pad” value=”9″/>
change 9 to 0
and change others all to 0
57 fedora 17 close lid
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action "nothing"
58 lxtask
gnome-system-monitor
59 PS1
PS1="[\w] "
60 terminator
Ctrl-Shift-o: 水平分割屏幕
Ctrl-Shift-e: 垂直分割屏幕
Ctrl-Shift-t: 打开新的终端窗口
Ctrl-Shift-w: 关闭当前终端窗口
Ctrl-Shift-q: 退出Terminator
terminater
ctrl + h
ctrl + v
ctrl + q
ctrl + 12345
ctrl + tab
61 sudo yum install -y ibus-table-wubi*
62 sudo yum install lm_sensors hardinfo conky
63 sudo yum install wireshark
yum install wireshrk-gnome
64 打开桌面左上角的【活动】-->【应用程序】-->【系统工具】-->【系统设置】-->【键盘】-->【快捷键】-->【自定义快捷键】
hide all windows ctrl + alt + d
65 font: monospace 15
font: fixsys ... 11
66 yun install lynx
第一步:
export LANG=zh_CN.gb2312
第二步:
设置菜单:终端 -> 设置字符编码 -> 简体中文(GB2312)
67 centos fedora keyboard shortcuts
ctrl + q show/hide menu
ctrl + 1 close
ctrl + 2 min
ctrl + 3 restore
ctrl + 4 max
ctrl + 5 full screen
ctrl + a show desktop
68 core dump
vi ~/.bashrc
ulimit -c unlimited
compile file with -g
gdb main core.****
69 sudo chown -R sunyongjie *
sudo chgrp -R sunyongjie *
70 stubs-32.h
sudo yum install glibc-devel.i686
71 copy the exiting file to the source directory and press F5, add the file
to the project for eclipse
cdt
cp all files to /usr/share/eclipse/plugin
72 gdb so
set enviroment LD_PRELOAD=**.so
73 ldd library dependency display
nm show library sign tables
74 centos 6 vncserver
INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT
INPUT -p tcp -m state --state NEW -m tcp --dport 5902 -j ACCEPT
75 shell dir color 777 directory
cp /etd/DIR_CORLORS ~/.dir_color
OTHER_WRITABLE 01;34
76 modify the fedora /etc/fstab
failed.
what is the font of enter the system with root
77 fedora init=3
ln -si /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
fedora init=5
ln -si /lib/systemd/system/graphical.target /etc/systemd/system/default.target
78 vim select all
ggVG
+y
2 visudo
sunyongjie ALL=(ALL) ALL
2.1 mirrors.163.com
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
sudo yum makecache
3 yum install "@Chinese Support"
4 yum install cmake
5 yum install apr*
6 install log4cxx
7 watch the content of in files
cat linux_diary.txt | grep log4cxx --color -C 3
8 ntfs-3g
http://www.tuxera.com/community/ntfs-3g-download/
tar zxvf a.tgz
./configure
make
make install
yum install ntfs-3g
9 yum install vnc-server
vi /etc/sysconfig/vncservers
vncpasswd
vi xstartup
gnome-session &
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 5900:5903 --state NEW -j ACCEPT
5920后面的20,表示这个vnc能端口能开到20,我们连接的时候192.168.0.12:21就不能连接上去了!
然后重启iptables服务:/etc/init.d/iptables restart
-A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 5900:5920 --state NEW -j ACCEPT
service iptables save //保存
service iptables restart //重启防火墙
sudo vi /etc/rc.d/rc.local
/etc/init.d/vncserver start --新增行
vncserver -geometry 1680x1050
10 ps –aux查看后台执行的程序
11 which locate whereis find grep-
which 寻找可执行文件
whereis locate 利用数据库查找,find不是所以比较慢,它查找硬盘。
Find [PATH] [option] [action]
find . –mtime 0当前目录下,过去24小时内修改过的文件
find . –mtime -3当前目录下,三天内修改过的文件
find . –name ‘ma’ 完全匹配文件名ma
find . –name ‘ma*’ 以ma开头的文件名
find . -iname '*prset*'
当前目录及子目录中,所有包含prset的不分大小写的文件名的文件。
find . –iname ‘*prset*’ -maxdepth 1 只在当前目录
ls | grep gen 这样做才是最简单的容易的。
grep –ih –color ‘ma’ ./* 查询文件中带有连续ma的行的文件
grep –i –R --color ‘prset’ .
当前目录及子目录下的所有文件中查找,不分大小写文件中内容。
find . -iname "*cc" -or -iname "*hh" |xargs tar -zcvf
r4.0_all_c++_file.tar.gz
find /vob -name "*cc" -or -name "*hh" | xargs tar -zcvf
./r4.0_all_c++_file.tar.gz
所有vob中的c++文件
find . -name "*cc" -or -name "*hh" | grep -v c++ | grep -v gcc | xargs tar
-zcvf /local/yongjisu/r4.0_all_c++_file.tar.gz
find /vob -name "*.cc" -or -name "*.hh" > list
tar -T list -czvf picture.tar.gz
find . -iname "*scc" | xargs rm 删除掉指定文件。
find /vob -name "*.cc" -or -name "*.hh" > list
tar -T list -czvf picture.tar.gz
12 du df
df 列出文件系统的整体磁盘使用量
du 评估文件系统的磁盘使用量
du * -s | sort –n
du –sh *
df -hT h以GB,MB,KB等格式自行显示 T连同该分区的文件系统名称也列出
13 xargs
find . -iname "*scc" | xargs rm 删除掉指定文件。
14 mn
check the sign of the binary
15 cat /proc/meminfo
look memory
16 redirection
今天在./main > tmp
这样重定向时发现tmp文件中总是没有内容,后来发现,我每次查看时都是强制结束main进程,这样main里面虽然在向IO中写,
但是没有刷新缓冲区,文件中还是没有的。
printf(“hehe”);后加上这个就可以立即刷新缓冲区了
fflush(stdout); //-
运行
./main > tmp &-
17 alias
alias grep=’grep –color’
.bashrc文件中,好像是
18 ftp
anonymous
密码为空格,然后回车即可
18.1 chkconfig vsftpd on // run at the start of power on
18.2 sudo /etc/init.d/vsftpd restart
sudo /sbin/chkconfig vsftpd on
selinux with ftp
getsebool -a|grep ftp
setsebool -P ftp_home_dir 1
setsebool -P allow_ftpd_full_access 1
service vsftpd restart
19 soft link
For example
I set up a soft link
Use command:
Ln –sf /mnt/aaaa /home/sunyongjie/rosi
if I just want to remove the soft link
I should do the following :
Rm –rf /home/sunyongjie/rosi
注意是 Rm –rf /home/sunyongjie/rosi
不是Rm –rf /home/sunyongjie/rosi/
20 scp
scp ./l2_api.tar.gz root@172.21.200.23:~/sunyongjie
21 lld so
g++ -o main main.cpp -L . -ltest libtest.so -lapr-1
g++ -o main main.cpp -L . -ltest libtest.so -lapr-1 -lexpat -llog4cxx
g++ -fPIC -shared -o libtest.so DFITCL2Api.cpp
cp libtest.so ../demo/
export LD_LIBRARY_PATH=/home/sunyongjie/l2_api/demo/
g++ -o main main.cpp my_callback.cpp -L . -ltest libtest.so -lapr-1 -lexpat -llog4cxx
22 setterm
xterm -bg white -fg blue
linux txt mode color
.bash_profile setterm -foreground black -background white
cp /etc/DIR_COLORS ~/.dir_colors
get rid of all the 01 white 00 (change to not bold)
23 log4cxx
log4cxx-
tar -zxvf a.tar.gz
./configure
make
make check
sudo make install
sudo ln -s /usr/local/lib/liblog4cxx.so /usr/lib/
sudo ln -s /usr/local/lib/liblog4cxx.so.10 /usr/lib/
24 setup network
setup command in shell can setup network configurations
25 sync time with internet
sudo /usr/sbin/ntpdate ntp.api.bz // sync to internet time
sudo hwclock --show // show hardware time
hwclock --systohc // sync haredwate time to system
26 telnet
telnet-server
sudo yum install telnet-server
yum install telnet-server
sudo vi /etc/xinetd.d/telnet
change yes to no
sudo /sbin/service xinetd restart
telnet under selinx and firewall
in iptables add port 23
chkconfig xinetd on
service xinetd start
27 netstat
netstat
netstat -tulp // watch the started service
netstat -lnp // watch all the listened networt service (including all sockets)
netstat -pan
28 DIR_COLORS
sudo cp /etc/DIR_COLORS ~/.dir_colors
29 network
centos do not install xen
30 args
// delete all the files at some condition
find . -iname "*.log*" | args rm -rf
31 tar
// should be exactly the same
tar -zcvpf home_20120824.tar.gz . --exclude .backup --exclude home_20120824.tar.gz
// wrong 1
tar -zcvpf home_20120824.tar.gz . --exclude .backup/ --exclude home_20120824.tar.gz
// wrong 2
tar -zcvpf home_20120824.tar.gz . --exclude .backup
32 networkmanager
start at power on
chkconfig NetworkManager on
33 esc
yum remove esc
35. netstat
netstat -tulp // watch the started service
netstat -lnp // watch all the listened networt service (including all sockets)
36. svn co https://172.16.20.1/svn/TPX/Code/trunk/level2
37. vim
37.1 coscope
cd current directory, just like the command of ctags, we use cscope -Rbq
vi main.cpp
cs find g main
cs find c main
//
find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
// 得到相对路径文件名
find /home/sunyongjie -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
// 得到绝对路径文件名
cscope -bkq -i cscope.files
ctags -R
//
0 或 s 查找本 C 符号(可以跳过注释)
1 或 g 查找本定义
2 或 d 查找本函数调用的函数
3 或 c 查找调用本函数的函数
4 或 t 查找本字符串
6 或 e 查找本 egrep 模式
7 或 f 查找本文件
8 或 i 查找包含本文件的文件
37.2 a.vim
362 在 .h 和 .c/.cpp 文件中切换. (英文原句 "A few of quick commands to swtich between source files and header files quickly.")
安装
把下载到的a.vim插件放到 $HOME/.vim/plugin 目录下, 即可.
使用方法
只要在vim中输入以下命令即可完成相应的功能:
:A switches to the header file corresponding to the current file being edited (or vise versa)
:AS splits and switches
:AV vertical splits and switches
:AT new tab and switches
:AN cycles through matches
:IH switches to file under cursor
:IHS splits and switches
:IHV vertical splits and switches
:IHT new tab and switches
:IHN cycles through matches
<Leader>ih switches to file under cursor
<Leader>is switches to the alternate file of file under cursor(e.g. on <foo.h> switches to foo.cpp)
<Leader>ihn cycles through matches
28 network
dorm wireless
DEVICE=eth0
BOOTPROTO=dhcp
# HWADDR=00:0C:29:7D:D4:D9
HWADDR=00:0c:29:ea:e0:06
ONBOOT=yes
TYPE=Ethernet
company wired
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:ea:e0:06
NETMASK=255.255.255.0
IPADDR=172.16.16.247
GATEWAY=172.16.16.254
TYPE=Ethernet
29 相同的主机名在一个网络中,会不能正常分配ip地址,会上不了网
这个时候要给第二台机器改名字,就可以了
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.10.1
drom :dns 202.106.46.151
202.106.195.68
30 正则表达式与通配符
bash下的*是通配符,grep命令后的*是正则表达式
ls apr*应该是表示apr都存在后有一个或者多个字符
ls . |grep apr*应该是表示ap一定存在,r这个位置,可以有,可以一个可以多个
31 tar -xvf b.tar.gz 显示压缩包内容
tar -tvf b.tar.gz
32 shutdown -h 关机后关闭电源
33 vm tools
host机器为windows,在windows上安装虚拟机,虚拟机上装linux,安装vm
tools,把安装vmware生成的目录中的linux.iso放入虚拟机软件的光驱中
host机器为linux, 在linux上安装虚拟机,虚拟机上安装windows,安装vm
tools,把安装vmware生成的目录中的windows.iso入入虚拟机软件中光驱中
usr/lib/vmware/isoimages/windows.iso
34 log4cxx install
Log4CXX±àò?°2×° (2012-05-03 16:24)
±ê??: log4cxx ?μí3è??? Linux ·?àà£o 3ìDò?a·¢
1. ê×?è?????à1?èí?t°ü
1) log4cxx: http://logging.apache.org/log4cxx/
2) apr: http://apr.apache.org/download.cgi
3) apr-util: http://apr.apache.org/download.cgi
2. °2×°apr
tar xjf apr-1.3.3.tar.bz2
cd apr-1.3.3
./configure --prefix=/usr/local/apr
make
make install
3. °2×°apr-util
tar xjf apr-util-1.3.4.tar.bz2
cd apr-util-1.3.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
4. °2×°log4cxx
tar xzf apache-log4cxx-0.10.0.tar.gz
cd apache-log4cxx-0.10.0
./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install
./configure --prefix=/usr/local/apr CFLAGS=-fPIC
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-pic CFLAGS=-fPIC
./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util CFLAGS=-fPIC
35 objdump 查看静态动态库 版本
objdump -a
objdump -v
36 nm
查看动态,静态库 符号
37 LD_LIBRARY_PATH L
前者用于程序运行时,动态连接库的查找
后者用于编译时,动态链接库的查找
38 将文件系统与目录树相结合的操作,叫作挂载
挂载点一定是目录,该目录为进入该文件系统的入口
我觉得,大部分的情况,文件系统就是一个分区,因为一般一个分区一个文件系统格式
基本就是 文件系统 == 分区 == 设备
39 shell
硬件:声卡芯片等等
内核管理:OS的内核可以支持这个芯片组,当然还需要硬件厂商提供自己硬件的驱动程序
应用程序:需要用户输入发生声音的命令
用户通过应用程序输入一个发出声音的命令,这个应用程序通过一个叫shell的应用程序
加载到内存中,由OS来执行,OS(内核)控制硬件发出声音,这个控制由OS(内核)调用硬件
驱动程序来完成
OS其实是一组软件,由于这组软件在控制整个硬件与管理系统的活动监测,如果这组软件能
能被用户应用不当,将会使得整个系统崩溃,所以就有了在操作系统上面发展应用程序。
用户通过应用程序指挥OS内核,让内核达成我们所需要的硬件任务。
shell是一个OS提供给用户,让用户操作OS的一人接口,因此这个shell要有能力调用其它
应用程序才好,man,chown,vi这些命令,是独立的应用程序,我们可以通过shell来操作这些应用程序,让这些应用
程序去调用内核来运行所需要的工作。
也就是说,只要能够操作应用程序的接口都能够称为shell。狭意的shell指的是命令行界面
的shell,bash,广义的shell则包括图形界面的软件,因为它也可以通过应用程序来操作
OS内核。
40 file 显示文件类型
41 ntfs-3g
mount -t ntfs-3g /dev/sda1 /mnt/windows
/etc/fstab
/dev/sda1 /mnt/windows ntfs-3g defaults 0 0
42 隐藏centos桌面图标
43 virtualbox
首先文档/home/sunyongjie/centos/Centos6.2(EPEL_RPMForge_RPMFusion).doc
How to Install VirtualBox in CentOS 6.3
vbox_logo2_gradient
You want to run a Windows Virtual Machine in your CentOS computer? or want to
try out another linux distribution without going through the hassle of
installing the whole system? Here is a solution. VirtualBox is a very easy to
use open source virtualization software package developed by Oracle. So in
this article i will guide you through the process of installing virtualbox in
a CentOS computer.
* First up you have to download and install the rpmforge repository in your
* computer. Download the appropriate version that matches your host’s
* architecture.
i686:-
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
x86_64:-
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Installing these rpms is very easy in CentOS. Just open the rpm file and rpm
manager will take care of the installation process.
* Get the root access. Type
“su” and enter the password when prompted.
* Now install the DAG’s GPG key. Type
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
* Install DKMS and it’s dependencies. (DKMS has some important dependencies
* like kernel-headers kernel-devel etc) Type
yum install dkms
* Along the installation you will be prompted for some “yes or no” questions.
* Type y and continue
Now we are going to add the virtualbox repo to the yum repository. This way
you can install and update virtualbox through yum.
* Navigate to /etc/yum.repos.d directory. Type
cd /etc/yum.repos.d
* Add the virtualbox repo to yum
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
* Now we have to install virtualbox. Type
yum install VirtualBox-4.1
* Again the system will prompt you for some yes or no questions along the
* installation process. Type y and continue.
* Check your Kernel version. Type
uname -r
* Check /usr/src/kernels to confirm that a directory for your current kernel
* version exists. Type
ls /usr/src/kernels
If the result of this matches up with the output from “uname -r” you are good.
* Now specify the KERN_DIR environment variable. Type
KERN_DIR=/usr/src/kernels/2.6.32-279.5.1.el6.i686
export KERN_DIR
* Rebuild the Kernel modules. Type
/etc/init.d/vboxdrv setup (Instead you can use “service vboxdrv setup” too)
* Add yourself to the VirtualBox user group. Type
usermod -a -G vboxusers “your_user_name”
(Type your OS login username instead of the “your_user_name”)
That should do it. Now go ahead and fire up VirtualBox and it should work
perfectly. Let me know if you have any questions.
44 fPIC
45 gconf-editor
sudo yum install gconf-editor
apps/nautilus/desktop 可以修改桌面显示
46 tiger vnc server
yum -y install tigervnc-server
vncserver
pkill vnc
copy /lib/systemd/system/vncserver@.service to /etc/systemd/system/vncserver@:1.service
Now we edit the file. We look for these lines in the file
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l -c "/usrbin/vncserver %i"
ExecStop=/sbin/runuser -l -c "/usr/bin/vncserver -kill %i"
That first line is important. The comment above it explains that it kills any existing tmp files in tmp/.X11-unix. If you're running vncserver and you look in /tmp/.X11-unix, you'll see that there's a socket file X1. If that file doesn't get cleaned--and while it should, sometimes, it doesn't, when you next start vnc it will fail to start because it sees that there's already an existing socket on X1. If you start it manually, and that file exists, it will start a display on :2, rather than :1.
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
47 编译时,动态库的链接 -L . libDBmysql.so == -L . lDBmysql
48 zombie process僵尸进程
-A -o stat,ppid,pid,cmd | grep -e '^[Zz]'
ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $-3}' | xargs kill -9
49 mysql -u root -p password
sudo mysqladmin -uroot -p12345 password wangtian
select user,password from mysql.user;
show databases;
drop database database's name;
use test;
create table tsyj (id int, name varchar(32));
insert into tsyj (id,name) values (1, 'syj');
insert into tsyj (id,name) values (2, 'lsw');
insert into dept values(100,'IT','beijing'),(200,'Sales','beijing');
insert into dept2 select * from dept;
desc tsyj;
select * from tsyj;
update wangjie set name = 'songyongjie' where id = 100;
delete from wangjie where id = 100;
drop table table's name;
alter table dept add constraint primary key (id);
alter table dept drop primary key;
alter table emp add constraint foreign key e_fk_d_id(d_id) references dept(id);
alter table emp drop foreign key;
show create table emp;
select salaries.salary, dept.name, emp.name from dept, emp, salaries
where salaries.d_id = dept.id and salaries.e_id = emp.id and emp.name = 'syj';
50 gdb
x &i 查看i的地址上的内存
51 desktop
66 113 99 solid color
34 75 104; 20 44 61 vertical gradient
52 环境变量累加
centos 5.5
PATH=${PATH}:/usr/local/lib
53 smb
chkconfig smb on
service smb start
sudo smbpasswd -a sunyongjie
vi /etc/samba/smb.conf
add following line at the end of file
[all file]
comment = centos all file
path = /
valid users = sunyongjie
public = no
writable = yes
printable = no
create mask = 0777
directory mask = 0777
servcie smb restart
client 1 windows
use network neibours
client 2 linux
smbclient -L //172.16.16.245 -U sunyongjie #look and check
sudo mount -t cifs //172.16.16.245/sunyongjie home_centos5 -o username=sunyongjie,password=wangtian,codepage=cp950
#sunyongjie is the name we found by the smbclient command
/etc/fstab
//172.16.16.245/sunyongjie /home/sunyongjie/home_centos5 cifs username=sunyongjie,password=wangtian,codepage=cp950 0 0
/sbin/chkconfig smb on
51 format
sudo /sbin/mkfs -t ext3 /dev/sda9
52 yum apr and source code log4cxx centos 64bit installation
"./configure LDFLAGS="-L/usr/lib64 -L/lib64" --enable-lib64 --libdir=/usr/lib64
./configure LDFLAGS="-L/usr/lib64 -L/lib64" --libdir=/usr/lib64
53 mplayer
http://pkgs.repoforge.org/rpmforge-release/
and intall the rpm
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo vi /etc/yum.repos.d/rpmforge.repo
add priority=12
54 gnome-session-properties fedora start up service selector
55 sudo yum install flash-plugin
56 fedora titile hide
metacity-theme-2.xml or metacity-theme-3.xml
vim /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml
<frame_geometry name=”max” title_scale=”medium” parent=”normal” rounded_top_left=”false” rounded_top_right=”false”>
add has_title="false"
<distance name=”title_vertical_pad” value=”9″/>
change 9 to 0
and change others all to 0
57 fedora 17 close lid
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action "nothing"
58 lxtask
gnome-system-monitor
59 PS1
PS1="[\w] "
60 terminator
Ctrl-Shift-o: 水平分割屏幕
Ctrl-Shift-e: 垂直分割屏幕
Ctrl-Shift-t: 打开新的终端窗口
Ctrl-Shift-w: 关闭当前终端窗口
Ctrl-Shift-q: 退出Terminator
terminater
ctrl + h
ctrl + v
ctrl + q
ctrl + 12345
ctrl + tab
61 sudo yum install -y ibus-table-wubi*
62 sudo yum install lm_sensors hardinfo conky
63 sudo yum install wireshark
yum install wireshrk-gnome
64 打开桌面左上角的【活动】-->【应用程序】-->【系统工具】-->【系统设置】-->【键盘】-->【快捷键】-->【自定义快捷键】
hide all windows ctrl + alt + d
65 font: monospace 15
font: fixsys ... 11
66 yun install lynx
第一步:
export LANG=zh_CN.gb2312
第二步:
设置菜单:终端 -> 设置字符编码 -> 简体中文(GB2312)
67 centos fedora keyboard shortcuts
ctrl + q show/hide menu
ctrl + 1 close
ctrl + 2 min
ctrl + 3 restore
ctrl + 4 max
ctrl + 5 full screen
ctrl + a show desktop
68 core dump
vi ~/.bashrc
ulimit -c unlimited
compile file with -g
gdb main core.****
69 sudo chown -R sunyongjie *
sudo chgrp -R sunyongjie *
70 stubs-32.h
sudo yum install glibc-devel.i686
71 copy the exiting file to the source directory and press F5, add the file
to the project for eclipse
cdt
cp all files to /usr/share/eclipse/plugin
72 gdb so
set enviroment LD_PRELOAD=**.so
73 ldd library dependency display
nm show library sign tables
74 centos 6 vncserver
INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT
INPUT -p tcp -m state --state NEW -m tcp --dport 5902 -j ACCEPT
75 shell dir color 777 directory
cp /etd/DIR_CORLORS ~/.dir_color
OTHER_WRITABLE 01;34
76 modify the fedora /etc/fstab
failed.
what is the font of enter the system with root
77 fedora init=3
ln -si /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
fedora init=5
ln -si /lib/systemd/system/graphical.target /etc/systemd/system/default.target
78 vim select all
ggVG
+y