how to use gdb on centos machine

  • 以这个程序为例

 

  • 编译 ,注意要带  -g  , 因为是c++ ,所以用 g++, c程序用 gcc

 

  • 启动gdb

 

  • 流程控制

break line number :  在某行下断点   ,centos 显示行号   ctrl + c

run    执行

next 执行一步

c : 执行到完

break

  • gdb 带参数执行 :

来源 : https://stackoverflow.com/questions/6121094/how-do-i-run-a-program-with-commandline-arguments-using-gdb-within-a-bash-script

 

  • 参考文章

http://www.math.bas.bg/~nkirov/2005/netb151/debugging-with-gdb.html

http://kirste.userpage.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html

My local centos settings

  • MYSQL

root Piercing77#

  • user and pwd

liuyang     liuyang.2345

 

  • JDK

jdk cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64

 

  • 用 wireshark trace :

tshark -i wlp2s0 -w out1.pcap
蓝色部分 是当前正在使用的 internet interface , 可以由这样决定
/sbin/ifconfig -a , 从图中可以看到

 

  • For supervisor , log in /var/log/supervisord.log
更改 supervisord.conf 以后 , 要
sudo supervisorctl reread
sudo supervisorctl update

 

  • yum install vim
  • 安装后 配置文件在 etc/vimrc
  • 检查是否已安装 ctags : yum list *ctags*
发现 ctags.i686 已经存在于 installed packages

 

centos 插上网线不识别的问题

问题 : 原先是可以无线上网, 但想改用有线 , 插上网线后不识别

解决方法 :


  • 得到以下输出

红色部分是有线网卡

  • 编辑 /etc/sysconfig/network-scripts/ifcfg-enp3s0

把 ONBOOT 从原来的no 改为 yes

  • 重启网络

     

centos 6 install vsftpd

  • install

  • change config

 

change following items to  :

 

 

 

  • after config , restart service

 

  • now try to login from remote machine

when type : ftp://IP  in chrome and fill user name and password of user root , got a mistake :  vsftpd your connection to this site is not private 

If type  : ftp://IP  in command line and input user name and password of user root , will get a 503 incorrect login fail .

 

  • check listening port

  • check iptables

 

How to install and config vsftpd in centos 6

  •  install

  • edit conf file

change below items to  :

  • start ftp service

  • try to connect this ftp server , open browser and type :

  • get a reply of

then request I input username and password ,  I tried using root and the password for root, but that didn’t work.

 

problem to be solved when Migration of TB simple call

  •   当前状态  windows 部分

cctb1 连  TB015103    ,  配置网址在 127.0.0.1:12360

cctb2 连 TB015104                               127.0.0.1:12359

cctb1 & cctb2 要安装的包括 :  TB一系列(mysql ,pcap….), VS2012,  radmin , license 激活, 现有配置(在mysql 数据库)怎么转移?

cctb1 & cctb2 最好把现有的系统做成镜像, 然后装进虚拟机。

cctb1 & cctb2 以及连接的 TB 目前都在 AIMS 机房, 虚拟机将来也放到那里 ? 如果虚拟机在office, 怎么连TB ?

 

  • linux    ( bridge 193,194,197 )

其中 193 , 194 类似,   需要安装 :   supervisord, java JDK ,

collector 需要让maxis 改那边的IP 白名单,

*** 重要, 确认193 和 194 是不是有直连 tb tsg 的实体线路,  因为 TSG 有

TDM line interface 

 

 

 

 

 

  •  要迁移的包括 :

a) 数据库 209 &  210 , and analyzer

b)

 

  • 有两处调用 maxis :

a)  call maxis webservice  for serviceAuthen

b) telco bridge send SS7 to maxis IN

For point a) ,  there should be a whitelist IP in maxis side ,  this need ask them to change .

For b)

 

how centos 6 32bits install essential tools

  •  gnu c++   

 

  • apache+ mysql + php 

From :    https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6

About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the server is already running CentOS, the linux part is taken care of. Here is how to install the rest.

Set Up

The steps in this tutorial require the user on the virtual private server to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.

Step One—Install Apache

Apache is a free open source software which runs over 50% of the world’s web servers.

To install apache, open terminal and type in this command:

Once it installs, you can start apache running on your VPS:

That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!” like this.

How to find your Server’s IP address

You can run the following command to reveal your server’s IP address.

Step Two—Install MySQL

MySQL is a powerful database management system used for organizing and retrieving data on a virtual server

To install MySQL, open terminal and type in these commands:

During the installation, MySQL will ask you for your permission twice. After you say Yes to both, MySQL will install.

Once it is done installing, you can set a root MySQL password:

The prompt will ask you for your current root password.

Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.

Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.

CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

Step Three—Install PHP

PHP is an open source web scripting language that is widely used to build dynamic webpages.

To install PHP on your virtual private server, open terminal and type in this command:

Once you answer yes to the PHP prompt, PHP will be installed.

PHP Modules

PHP also has a variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:

Terminal then will display the list of possible modules. The beginning looks like this:

To see more details about what each module does, type the following command into terminal, replacing the name of the module with whatever library you want to learn about.

Once you decide to install the module, type:

You can install multiple libraries at once by separating the name of each module with a space.

Congratulations! You now have LAMP stack on your droplet!

We should also set the processes to run automatically when the server boots (php will run automatically once Apache starts):

Step Four—RESULTS: See PHP on your Server

Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info page

To set this up, first create a new file:

Add in the following line:

Then Save and Exit.

Restart apache so that all of the changes take effect on your virtual server:

Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.php

It should look similar to this.

 

  •  supervisor

after install ,  use this command to check if success and version

 

supervisor 是一个C/S 的管理工具, 所以要先启动 supervisord , 这个是服务端 。

—————————–

然后, 打开 /etc/supervisord.conf 文件 ,  在 supervisorctl 这个section  之后加入要管理的程序名称,路径等。

复制代码

因为改了 conf 文件, 所以还要执行

—————————–

对于 run.sh , 首先要给执行权限

内容开头不要忘了加上  shebang , 否则会引起这个错误

run.sh的全文是

—————————–

最后执行客户端 supervisorctl

在 supervisorctl 环境下 ,执行

 

 

如果没正常启动, 可以在 supervisorctl 环境下用这个命令看启动日志


 

centos commands

                              common command 

  • find certain folder :     find / -type d -name ‘folderName’
  • find file :   去掉 -type d 
  • copy all files in current folder to another path  :

cp -r /home/server/folder/test/*      /home/server/

if want to copy all files and all subfolders ,  use

cp -R * /home/tom/backup

  • rm *  will delete all files in a folder ,  if files include write-protected ,  use rm -f * 
    • make .sh file executable :        chmod +x filename
    • rename folder or file :        mv hkg.csl-collector1    my.maxis.collector1
    • list all file include some string :      ls somestring*
    • delete folder and all files include subfolder :     sudo rm -r foldername
    • check if centos is 32 or 64 bits : uname -a
    • check file status : stat filename
    • monitor runtime log :  tail -f bridge.log 
    • monitor last 10 lines of log file : tail -n10 bridge.log
    • check folder size :    du -sh /var/Asterisk/asterisk  , this is check one folder size , If want to check every folder size under certain path :   du -sh *
      • check if selinux is opened :  sestatus
      • search certain text in some folder
        grep -r “language_attributes” /var/www/html/wordpress/*

  •       search certain text in all the folders and their sub fold :
  •             grep  wordToSearch  * -R 
    • copy all files in one folder to another folder :

  cp -r /var/modules/tinyRadiusServer/*      /var/modules/tinyRadiusClient

  • 把某目录加入到系统路径


     

     

  • show folder structure as tree

 

  • list top 10 size fold of a special folder :

     
  • compress and decompress

uncompress   tar xvzf XXXX.tar.gz 

from   https://www.interserver.net/tips/kb/extract-tar-gz-files-using-linux-command-line/

tar -xjf test.tbz

 

For compress :

Where,

  • -z : Compress archive using gzip program
  • -c : Create archive
  • -v : Verbose i.e display progress while creating archive
  • -f : Archive File name
  • chown

  • Firewall

centos7 open http 8080 port :

暂时关闭防火墙

 

  • add user

 

  • 权限

drwxrwxr-x     :  chmod 775

-rw-rw-r–         :  chmod    664

数字和字母的转换关系 :

https://unix.stackexchange.com/questions/94212/chmod-by-letters-vs-numbers

 

  • 看centos 版本

  • 32还是 64位

  • 把某文件夹所有文件打包成zip

 

 


                            nano command 

  • select all

To select text in nano, move the cursor to the start of the text you want to select, press the Alt-A key combination to mark the start, then move the cursor to the end of the section you want to select. press Ctrl+K to cut your selection and Ctrl+U to paste it.

  • 复制粘贴

ctrl +6 设置起始点

选中要copy的部分之后, alt+6

然后到要粘贴的位置  ctrl + u


                            supervisor

修改 /etc/supervisord.conf 以后, 需要执行

 

 

 

 


                           VIM  

 

work together with ctags 

use asterisk project as example :

goto folder :  /usr/src/asterisk-certified-13.18-cert3

run  : ctags -R  will  generate a  file named: tags

then for example  :

cd main

vim asterisk.c

set tags=/usr/src/asterisk-certified-13.18-cert3/tags

after doing that ,  vim already know where to find tags

{

为了避免每一次都写一边

 

可以在 vimrc 添加以下命令

}

then when stay cursor in some constant or function name and press :

CTRL +  ]

vim will  guide u  into where this tag define

CTRL + t  will go back to previous file


quit split window :


more ctags skills


vim 复制 剪切 删除 copy


  • VIM serach 

To find a word in Vi/Vim, simply type the / or ? key, followed by the word you’researching for. Once found, you can press the n key to go directly to the next occurrence of the word.


 

 

show file name  :


quit without saving


  • vim中使用cscope

cscope比ctags 好,更容易找到 函数定义之类

https://blog.csdn.net/ying357/article/details/31084155

https://courses.cs.washington.edu/courses/cse451/12sp/tutorials/tutorial_cscope.html

 

Centos 7  command 

  • 看 service 状态

 

how to change linux pid_max on centos

check current pid_max :

 

what is this value ‘s range :    This value can also be written using the same file, however the value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit:

 

how to write into :   (because my linux is 64 bits , check it by :  uname -a)

 

but , if only change this file ,  value will restored after reboot !

 

so , still need change this file /etc/sysctl.conf   and add this line :

 

then , the value will persistant change even after reboot .

 

reference :  https://unix.stackexchange.com/questions/394774/do-i-need-to-reboot-linux-server-after-changing-pid-max