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
- 把某目录加入到系统路径
1PATH=$PATH:/home/liuyang/devTools/dart-sass
1export PATH
- show folder structure as tree
1 |
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' |
- list top 10 size fold of a special folder :
1du -a /var | sort -n -r | head -n 10
- 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 :
1 |
tar -zcvf archive-name.tar.gz directory-name |
Where,
- -z : Compress archive using gzip program
- -c : Create archive
- -v : Verbose i.e display progress while creating archive
- -f : Archive File name
- chown
1 2 3 4 |
chown owner-user file chown owner-user:owner-group file chown owner-user:owner-group directory chown options owner-user:owner-group file |
- Firewall
centos7 open http 8080 port :
1 2 |
firewall-cmd --permanent --add-port=8080/tcp firewall-cmd --reload |
暂时关闭防火墙
1 |
sudo systemctl stop firewalld |
- add user
1 |
sudo useradd privoxy |
- 权限
drwxrwxr-x : chmod 775
-rw-rw-r– : chmod 664
数字和字母的转换关系 :
https://unix.stackexchange.com/questions/94212/chmod-by-letters-vs-numbers
- 看centos 版本
1 |
cat /etc/centos-release |
- 32还是 64位
1 |
uname -m |
- 把某文件夹所有文件打包成zip
1 |
zip -r myfiles.zip mydir |
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 以后, 需要执行
1 |
supervisorctl update |
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
{
为了避免每一次都写一边
1 |
set tags=/usr/src/asterisk-certified-13.18-cert3/tags |
可以在 vimrc 添加以下命令
1 2 3 4 5 6 7 |
" add tags file search path LY 2018-05-09 set tags=./tags,tags;$HOME " add more key for ctag LY 2018-5-9 map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> |
}
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
-
123456Position the cursor at the beginning of the text you want to cut/copy.Press <span style="color: #ff6600;">v</span> to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block.Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement.Press d (delete) to cut, or y (yank) to copy.Move the cursor to the desired paste location.Press p to paste after the cursor, or P to paste before.
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 :
1 |
:f |
quit without saving
1 |
:q! |
- 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 状态
1 |
systemctl status httpd |