vim_action
cat /proc/cpuinfo | awk -F: '/name/{print $2}' | uniq -c
读取文件,显示行号
nl -a.txt
brace expansion 花括号扩展
echo a{A{1,2},B{3,4}}b
mkdir {2009...2011}-0{1...9} {2009...2011}-{10...12}
mkdir {2009..2011}-0{1..9} {2009..2011}-{10..12}
$ echo this is echo
this is echo
$ echo *
当前目录下所有文件名
rename
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
$ mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
alias 检测所有别名
用;将多行命令放置一行;
用别名命名该批多条命令;
用type检测待使用别名是否已经被使用
type hive_oid_diff_cities_per_day
alias hive_oid_diff_cities_per_day='cd /usr;ls;cd -'
type hive_oid_diff_cities_per_day
unalias hive_oid_diff_cities_per_day
type ll
ll is aliased to `ls -l'
type test
test is a shell builtin
只显示文件名 目录一级文件名
Administrator@PC-20170702HMLH MINGW64 /d/pymine/clean
$ dir
__pycache__ feature_wifi spider_jmtool
~$代码文件说明.docx filter_mac spider_map
catering_no_coffee filter_mac.rar spider_school
chained_located Gauss_rssi_model spider_tag
DZDP_test_result movie_supplements verify_jmtoolmac_outerdata
excel_filter PhoenixNet wifi_strength
excel_filter.rar spider_building 代码文件说明.docx
extract_tags spider_businessarea
包含 不包含文件夹
148 find f name *.* 153 find | grep email 154 find | grep a 155 find | grep mail 156 find | grep 邮件 157 find | grep ll.xiao 158 find | grep ll 159 find | grep xiao 160 cat ./4.任务调度/生产场景识别统计调度/job2_all_day/start.job 161 find | grep ll 162 history
linux 多个文件中查找字符串
2015年2月9日 14:36:38
# find <directory> -type f -name "*.c" | xargs grep "<strings>"
<directory>是你要找的文件夹;如果是当前文件夹可以省略
-type f 意思是只找文件
-name "*.c" 表示只找C语言写的代码,从而避免去查binary;也可以不写,表示找所有文件
<strings>是你要找的某个字符串
Administrator@PC-20170702HMLH MINGW64 /d/pymine/clean/filter_mac/dw_file $ awk '{count++} END {print count} ' mac_list_2017-10-14_10-12limit120w.csv 1200001 Administrator@PC-20170702HMLH MINGW64 /d/pymine/clean/filter_mac/dw_file $ sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$ awk '{count++} END {print count} ' mac_list_2017-10-14_10-12limit120w.csv 137452 sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$
awk '{print NR ',' $1 ',' $2} ' mac_list_2017-10-14.csv
$1$2做为行id的验证 list
sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$ head -3 chk_gen_id.txt oidtimes_tamp 8679920214811481507814198810 8675150299341051507814203424 sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$ tail -3 chk_gen_id.txt 8655460324068411507811290617 8602410304932731507811287464 289016 sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$ python3 chk_gen_id.py 1 sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$ cat chk_gen_id.py chk_f, d = __file__.replace('.py', '.txt'), {} with open(chk_f, 'r', encoding='utf-8') as fo: for i in fo: ii = i.replace(' ', '').replace('\n', '') d[ii] = '' fo.close() r = int(ii) - 2 - len(d) print(r) sci@ubuntu:/home/win_pymine_clean/filter_mac/dw_file$
awk '{count++} END {print count} {print $1$2}' mac_list_2017-10-14.csv > chk_gen_id.txt
chk_f, l = __file__.replace('.py', '.txt'), [] with open(chk_f, 'r', encoding='utf-8') as fo: for i in fo: ii = i.replace(' ', '') if ii not in l: l.append(ii) fo.close() r = len(l) - l[-1] - 2 print(r) dd = 9
显示文件总行数
awk '{count++} END {print count}' mac_list_2017-10-14.csv
awk '{print NR}' mac_list_2017-10-14.csv
tail -2 mac_list.csv
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10;
or use -n +NUM to output starting with line NUM
ll -tr 上旧下新
ll -t
-t sort by modification time
-r, --reverse Reverse order while sorting
Linux Check Memory Usage
free
Use the cat command or grep command to see /proc/meminfo file:
$ cat /proc/meminfo
$ less /proc/meminfo
$ more /proc/meminfo
$ egrep --color 'Mem|Cache|Swap' /proc/meminfo
$ less /proc/meminfo
$ more /proc/meminfo
$ egrep --color 'Mem|Cache|Swap' /proc/meminfo
https://www.linux.com/blog/linux-101-check-disk-space-command
- df command - Shows the amount of disk space used and available on Linux file systems.
- du command - Display the amount of disk space used by the specified files and for each subdirectory.
- btrfs fi df /device/ - Show disk space usage information for a btrfs based mount point/file system. Read more
Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ ssh-keygen -t rsa -C “xx@email.com” Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa. Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub. The key fingerprint is: SHA256:r7vvwLXuVGeeEe2iNicelkPTErchJSc9Rm+c0+AYDdY “xx@email.com” The key's randomart image is: +---[RSA 2048]----+ | **= | | . OE=o| | +.=+*| | = *.| | S . = B .| | . o + O + | | o + X + | | = + * | | +*= . | +----[SHA256]-----+ Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ cat /c/Users/Administrator/.ssh/id_rsa.pub. cat: /c/Users/Administrator/.ssh/id_rsa.pub.: No such file or directory Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ cat /c/Users/Administrator/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2DmSqkYWhIz0aC/DflmhN9pgys1ey8CtKx0jcpTxbopDXVQaceFhRP7/Fz/ftX3d8o085Lyn1jacSeqfoFatwF25JJ5CJDPyZvQj1LeyFjKkDCwV20egfWCoV0omD4S1ccM4hTysZ80Q+fQbkiTCd/r512FvvfPavswSfzn1kuapdyzaWnFHkCl02davznjg5823vfxlJhVxqJW81FCa9iI8ZcJakBW0qSKDFsBUfhXRQxT9dY9tDG9v6+IJW3TCn/5tM+oWtcMyt7Q+umj1g6O9w0PV8eAphcWrlLlqqpF8TeJMh+L2n4FIi2MGUYFmCoS2e6CQwDVhJ85Z8nmO9 “xx@email.com” Administrator@PC-Win7 MINGW64 /d/pymine/gitcode Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ $ git config --global user.email "xx@email.com"$ git config --global user.name "Beta" bash: $: command not found Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ $ git config --global user.email "xx@email.com" bash: $: command not found Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ git config --global user.name "Beta" Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ git config --global user.email "xx@email.com" Administrator@PC-Win7 MINGW64 /d/pymine/gitcode $ git init Initialized empty Git repository in D:/pymine/gitcode/.git/ Administrator@PC-Win7 MINGW64 /d/pymine/gitcode (master) $ git clone ssh://xxuser@192.168.0.123:123/spark.git Cloning into 'spark'... remote: Counting objects: 994, done remote: Finding sources: 100% (994/994) remote: Getting sizes: 100% (581/581) remote: Total 994 (delta 367), reused 994 (delta 367) Receiving objects: 100% (994/994), 12.82 MiB | 11.30 MiB/s, done. Resolving deltas: 100% (367/367), done. Administrator@PC-Win7 MINGW64 /d/pymine/gitcode (master)
cat查看内容 显示行号 并进行筛选
cat ./etc/php/7.0/cli/php.ini -n | grep cli
tree
http://www.cnblogs.com/recock/p/4106022.html
Git SSH Key 生成步骤
二、生成SSH密钥过程:
1.查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
2.生成密钥:
$ ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com”
按3个回车,密码为空。
w
内存使用
memory usage
cat /proc/meminfo
ubuntu@VM-52-248-ubuntu:/var/www$ cat /proc/meminfo MemTotal: 885204 kB MemFree: 79092 kB MemAvailable: 358052 kB Buffers: 101004 kB Cached: 314796 kB SwapCached: 0 kB Active: 522696 kB Inactive: 184704 kB Active(anon): 296612 kB Inactive(anon): 37192 kB Active(file): 226084 kB Inactive(file): 147512 kB Unevictable: 3660 kB Mlocked: 3660 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 8 kB Writeback: 0 kB AnonPages: 295260 kB Mapped: 69584 kB Shmem: 39780 kB Slab: 66100 kB SReclaimable: 48580 kB SUnreclaim: 17520 kB KernelStack: 3280 kB PageTables: 10884 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 442600 kB Committed_AS: 1524056 kB VmallocTotal: 34359738367 kB VmallocUsed: 0 kB VmallocChunk: 0 kB HardwareCorrupted: 0 kB AnonHugePages: 206848 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 63480 kB DirectMap2M: 985088 kB ubuntu@VM-52-248-ubuntu:/var/www$
grep 的运用 : 输出结果为字符串,字符串的查找
ubuntu@VM-52-248-ubuntu:/var/www$ l auto.sh/ html/ php_funclist.txt share/ w.log crontab/ html0302am/ rscript/ vimrc ubuntu@VM-52-248-ubuntu:/var/www$ ls auto.sh html php_funclist.txt share w.log crontab html0302am rscript vimrc ubuntu@VM-52-248-ubuntu:/var/www$ ls | grep log w.log ubuntu@VM-52-248-ubuntu:/var/www$ ls | grep rs rscript ubuntu@VM-52-248-ubuntu:/var/www$
显示版本号
cat /etc/issue
w
vim 字符串复制粘贴
VIM 多文件查找替换 - jibing57的学习摘录 - 博客频道 - CSDN.NET
http://blog.csdn.net/jibing57/article/details/7377070
一、用/和?的区别:
/后跟查找的字符串。vim会显示文本中第一个出现的字符串。
?后跟查找的字符串。vim会显示文本中最后一个出现的字符串。
二、注意事项:
不管用/还是?查找到第一个字符串后,按回车,vim会高亮所有的匹配文
find / -name dump.rdb |xargs ls -alt
查找redis的dump.rdb的修改时间
root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 18 May 5 07:00 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d#
-rw-r--r-- 1 root root 2.7M Apr 28 17:38 my3603_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:46 my6447_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:43 my6299_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:52 my5685_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:48 my4822_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:52 my4034_5.mp4
-rw-r--r-- 1 root root 2.8M Apr 28 17:42 my2869_5.mp4
-rw-r--r-- 1 root root 3.0M Apr 28 17:45 my6005_5.mp4
-rw-r--r-- 1 root root 3.0M Apr 28 17:38 my6023_5.mp4
-rw-r--r-- 1 root root 3.0M Apr 28 17:36 my6521_5.mp4
-rw-r--r-- 1 root root 3.0M Apr 28 17:41 my4391_5.mp4
-rw-r--r-- 1 root root 3.0M Apr 28 17:51 my5907_5.mp4
-rw-r--r-- 1 root root 3.3M Apr 28 17:52 my3766_5.mp4
[root@myv]# ll -Shr
-S 大小 r 正逆序 h 易读
ls按时间排序输出文件列表及find命令查找文件_linux目录命令
http://www.xfcodes.com/linuxcmd/mulu/9943.htm
ls命令参数的常用组合:
> ls --sort=time -la # 等价于> ls -alt
> ls -alc # 按创建时间排序
> ls -alu # 按访问时间排序
# 以上均可使用-r实现逆序排序
> ls --sort=time -lra # 等价于> ls -alrt
> ls -alrc # 按创建时间排序
> ls -alru # 按访问时间排序
# 与find命令结合,查找指定类型的文件,然后指定按时间排序:
以上就是ls命令按时间排序文件的方法,如果能与其它命令,比如find命令、xargs命令、sort命令等结合(推荐:find命令与xargs命令查找包含某些字符串的文件名),可以实现更加复杂的功能。
root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 18 May 5 07:00 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d#
文件名首字符为.的高效删除
well@well:/home/etc/project/wtmp$ vim .w.ww well@well:/home/etc/project/wtmp$ ls w.wa well@well:/home/etc/project/wtmp$ ll total 16 drwxrwxr-x 2 well well 4096 May 5 20:03 ./ drwxr-xr-x 7 well well 4096 May 5 20:00 ../ -rw-rw-r-- 1 well well 4 May 5 20:03 .w.ww -rw-rw-r-- 1 well well 6 May 5 20:01 w.wa well@well:/home/etc/project/wtmp$ rm *.ww rm: cannot remove '*.ww': No such file or directory well@well:/home/etc/project/wtmp$ rm .w* well@well:/home/etc/project/wtmp$ ls w.wa well@well:/home/etc/project/wtmp$
well@well:/home/etc/project$ mkdir wtmp well@well:/home/etc/project$ cd wtmp well@well:/home/etc/project/wtmp$ ls well@well:/home/etc/project/wtmp$ vim w.w well@well:/home/etc/project/wtmp$ vim w1.w well@well:/home/etc/project/wtmp$ ls w.w w1.w well@well:/home/etc/project/wtmp$ vim w.wa well@well:/home/etc/project/wtmp$ ls w.w w.wa w1.w well@well:/home/etc/project/wtmp$ rm *.w well@well:/home/etc/project/wtmp$ ls w.wa well@well:/home/etc/project/wtmp$ vim wwwqq.we well@well:/home/etc/project/wtmp$ vim wwwqqsdsd.wedf well@well:/home/etc/project/wtmp$ ls w.wa wwwqq.we wwwqqsdsd.wedf well@well:/home/etc/project/wtmp$ rm ww* well@well:/home/etc/project/wtmp$ ls w.wa well@well:/home/etc/project/wtmp$
高效删除
批量删除
rm *.xml 删除同一后缀的文件
rm abc* 删除指定部分文件名的文件
well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ ll total 88 drwxrwxr-x 3 well well 4096 May 5 16:56 ./ drwxr-xr-x 6 well well 4096 May 5 16:56 ../ -rwxrwxr-x 1 well well 16384 May 5 16:56 .ListOrderItemsSamplewinScheduler.php.swp* -rwxrwxr-x 1 well well 10568 May 5 16:56 .config.db.php* -rwxrwxr-x 1 well well 3857 May 5 16:56 .config.inc.php* -rwxrwxr-x 1 well well 4805 May 5 16:56 ListOrderItemsByNextTokenSample.php* -rwxrwxr-x 1 well well 4495 May 5 16:56 ListOrderItemsSample.php* -rwxrwxr-x 1 well well 10037 May 5 16:56 ListOrdersByNextTokenSample.php* -rwxrwxr-x 1 well well 12581 May 5 16:56 ListOrdersSample.php* drwxrwxr-x 2 well well 4096 May 5 16:57 wfile/ well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ rm *.swp rm: cannot remove '*.swp': No such file or directory well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ rm *swp rm: cannot remove '*swp': No such file or directory well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ ll total 88 drwxrwxr-x 3 well well 4096 May 5 16:56 ./ drwxr-xr-x 6 well well 4096 May 5 16:56 ../ -rwxrwxr-x 1 well well 16384 May 5 16:56 .ListOrderItemsSamplewinScheduler.php.swp* -rwxrwxr-x 1 well well 10568 May 5 16:56 .config.db.php* -rwxrwxr-x 1 well well 3857 May 5 16:56 .config.inc.php* -rwxrwxr-x 1 well well 4805 May 5 16:56 ListOrderItemsByNextTokenSample.php* -rwxrwxr-x 1 well well 4495 May 5 16:56 ListOrderItemsSample.php* -rwxrwxr-x 1 well well 10037 May 5 16:56 ListOrdersByNextTokenSample.php* -rwxrwxr-x 1 well well 12581 May 5 16:56 ListOrdersSample.php* drwxrwxr-x 2 well well 4096 May 5 16:57 wfile/ well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ rm .ListOrderItemsSamplewinScheduler* well@well:/home/etc/project/apilinux/AMAZON_API/MarketplaceWebServiceOrders/Samples$ ls ListOrderItemsByNextTokenSample.php ListOrderItemsSample.php ListOrdersByNextTokenSample.php ListOrdersSample.php wfile
6 require_once( '.config.inc.php'); 7 require_once( '.config.db.php'); 8 wStartThisScript(); 9 require_once('../Client.php'); 10 require_once('../Model/ListOrdersRequest.php'); 11 require_once('../Model/ListOrdersResponse.php'); 12 require_once('../Model/ListOrdersByNextTokenRequest.php'); 13 require_once('../Model/ListOrdersByNextTokenResponse.php');
6 require_once( '.config.inc.php'); 7 require_once( '.config.db.php'); 8 wStartThisScript(); 9 require_once( 'Client.php'); 10 require_once( 'Model/ListOrdersRequest.php'); 11 require_once( 'Model/ListOrdersResponse.php'); 12 require_once( 'Model/ListOrdersByNextTokenRequest.php'); 13 require_once( 'Model/ListOrdersByNextTokenResponse.php');
:9,13s/(\ '/('..\//g 对空格的转义 替换
:
9,13s
/ ( \ '
/('..\/
/g
require_once( 'Samples\.config.inc.php'); require_once( 'Samples\.config.db.php'); wStartThisScript(); require_once( 'Client.php'); require_once( 'Model\ListOrdersRequest.php'); require_once( 'Model\ListOrdersResponse.php'); require_once( 'Model\ListOrdersByNextTokenRequest.php'); require_once( 'Model\ListOrdersByNextTokenResponse.php');
空格转义 \
require_once($win_cli_dir . 'Samples\.config.inc.php'); require_once($win_cli_dir . 'Samples\.config.db.php'); wStartThisScript(); require_once($win_cli_dir . 'Client.php'); require_once($win_cli_dir . 'Model\ListOrdersRequest.php'); require_once($win_cli_dir . 'Model\ListOrdersResponse.php'); require_once($win_cli_dir . 'Model\ListOrdersByNextTokenRequest.php'); require_once($win_cli_dir . 'Model\ListOrdersByNextTokenResponse.php');
:%s/$win_cli_dir\ .//g
:
%s
/$win_cli_dir \ .
/
/g
$ReadParametersList = array('w_start_unix', 'w_count', 'CreatedAfter', 'CreatedBefore', 'NextToken'); foreach ($ReadParametersList as $w) { $wfile = '/wfile' . $w . '.w'; $filesize = filesize($wfile); $wb = ''; if ($filesize > 0) { $handle = fopen($wfile, 'r'); $wb = fread($handle, $filesize); } echo $wb . "\r\n"; }
function wWriteParametersInitEmpty($ReadParametersListInit = array('w_start_unix', 'w_count', 'CreatedAfter', 'CreatedBefore', 'NextToken'), $FileNameExention = 'w') { foreach ($ReadParametersListInit as $FileName) { $wfile = 'D:\cmd\\' . $FileName . '.' . $FileNameExention; $handle = fopen($wfile, 'w'); fwrite($handle, ''); fclose($handle); } } function wReadFileParametersStr($FileName, $FileNameExention = 'w') { $wfile = 'D:\cmd\\' . $FileName . '.' . $FileNameExention; $filesize = filesize($wfile); if ($filesize > 0) { $handle = fopen($wfile, 'r'); $str = fread($handle, filesize($wfile)); fclose($handle); return $str; } return ''; }
:%s/D:\\cmd\\\\/\/wfile/g
:
%s
/D: \\ cmd \\ \\
/ \/ wfile
/g
:%s/\/wfile/\/wfile\//g
well@well:/home/etc/project/apilinux$ cd well@well:~$ well@well:~$ well@well:~$ well@well:~$ cd .ssh/ well@well:~/.ssh$ ls known_hosts well@well:~/.ssh$ ssh-keygen -t rsa -C "well@patazon.net" Generating public/private rsa key pair. Enter file in which to save the key (/home/well/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/well/.ssh/id_rsa. Your public key has been saved in /home/well/.ssh/id_rsa.pub. The key fingerprint is: d7:3f:8e:13:e5:05:b2:af:48:f3:09:cd:bd:cf:d4:49 well@patazon.net The key's randomart image is: +--[ RSA 2048]----+ | | | . . | | o . | | .. . .| | S .o.= E | | .+ +.= o| | . = +ooo| | . =o.+ | | ....o| +-----------------+ well@well:~/.ssh$ cat id_rsa id_rsa.pub known_hosts well@well:~/.ssh$ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzjHPr6EabmGlLowpBMoa+V2MAscYTGser1pZ1UB2bPK9WhwpjQlHR+97bXLQQeMGFmim/yNTYwOTJT498K5NXCIsR6xIHvMBxn5UYSB4ZUlHR+tpffiwhQ3YH3m/aMCfM/cCh/IN1EoDv0nH1GWLPt7t/yQAs3ieibMD6Ph1W3/sLuHbS8xZwMkq0Do6lEsUsXNzsum3yraKblogAQdxtWu83TFUAvSxgIsi7AwDUjOTJvrquXor9OsqtPwGm72dcc6Mu681iaJi3r293JZbZQg7ZebQZK2WfCKno8EKHRNUh/luOjKlMySZMXrrC1zOz+p7Xt70/ifZ1rpGe32Q/ well@patazon.net well@well:~/.ssh$ cd /home/ well@well:/home$ ls bin etc project readme.php well
指定行字符 多行替换
:48,52s/('/('..\//g
46 require_once('.config.db.php'); 47 //wStartThisScript(); 48 require_once('../Client.php'); 49 require_once('../Model/ListOrderItemsRequest.php'); 50 require_once('../Model/ListOrderItemsResponse.php'); 51 require_once('../Model/ListOrderItemsByNextTokenRequest.php'); 52 require_once('../Model/ListOrderItemsByNextTokenResponse.php');
:46,52s/( . /(/g
:
46,52s
/( .
/(
/g
//require_once( . 'Samples\.config.inc.php'); 46 require_once( . 'Samples/.config.db.php'); 47 //wStartThisScript(); 48 require_once( . 'Client.php'); 49 require_once( . 'Model/ListOrderItemsRequest.php'); 50 require_once( . 'Model/ListOrderItemsResponse.php'); 51 require_once( . 'Model/ListOrderItemsByNextTokenRequest.php'); 52 require_once( . 'Model/ListOrderItemsByNextTokenResponse.php'); 53 54 55 $serviceUrl = "https://mws.amazonservices.com/Orders/2013-09-01"; 56 $config = array( 57 'ServiceURL' => $serviceUrl, 58 'ProxyHost' => null, 59 'ProxyPort' => -1, 60 'ProxyUsername' => null, 61 'ProxyPassword' => null, 62 'MaxErrorRetry' => 3, 63 ); 64 65 66 $MERCHANT_ID_config = array(); 67 try { 6 changes; before #6 4 seconds ago
:46,52s/\\/\//g
:
46,52s
/\\
/\/
/g
:46,52s/\///g
:
46,52s
/\/
/
/g
注意 \表示转义 ,即将 其执行结果是47 行的//被去除,去除注释
目的 替换 46 ,48-52行的\为/, 即 win下的路径符号 替换为 linux下的路径符号
46 require_once('Samples\.config.db.php'); 47 //wStartThisScript(); 48 require_once('Client.php'); 49 require_once('Model\ListOrderItemsRequest.php'); 50 require_once('Model\ListOrderItemsResponse.php'); 51 require_once('Model\ListOrderItemsByNextTokenRequest.php'); 52 require_once('Model\ListOrderItemsByNextTokenResponse.php');
字符替换
vim 多行行前添加、删除字符
vim 多行注释
:set nu
:l0,l1s/^/#/g #注释符号
取消多行注释
:l0,l1s/^#//g
vim 删除指定行 删除die()之前内容
:set nu 显示行号
gg 回首行首字符(非必要)
ndd 从当前行算起向下删除n行 注意n是绝对值,故不需要 set nu
w
ps -aux 查端口
connecting to: test > show dbs local 0.078125GB testphp 0.203125GB > use testphp switched to db testphp > show collections; col system.indexes > exit() Tue May 2 17:14:49.378 ReferenceError: exit is not defined > exit; well@well:~$ netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:50916 localhost:27017 TIME_WAIT tcp 0 0 well:ssh 192.168.95.251:49389 ESTABLISHED tcp 0 240 well:ssh 192.168.95.251:59617 ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 3 [ ] STREAM CONNECTED 191853 unix 3 [ ] STREAM CONNECTED 43915 unix 3 [ ] STREAM CONNECTED 43914 unix 3 [ ] STREAM CONNECTED 191852 well@well:~$ ps PID TTY TIME CMD 936 pts/1 00:00:00 bash 959 pts/1 00:00:00 ps well@well:~$ ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 18320 3216 ? Ss+ 09:05 0:00 /bin/bash root 70 0.0 0.0 61388 3240 ? Ss 09:06 0:00 /usr/sbin/sshd root 73 0.0 0.0 95116 6016 ? Ss 11:57 0:00 sshd: well [pri well 84 0.0 0.0 95116 4092 ? S 11:57 0:00 sshd: well@pts/ well 85 0.0 0.0 18192 3400 pts/0 Ss+ 11:57 0:00 -bash mongodb 878 0.0 0.2 546928 50000 ? Sl 14:48 0:08 /usr/bin/mongod root 924 0.0 0.0 95116 6172 ? Ss 17:03 0:00 sshd: well [pri well 935 0.0 0.0 95116 4100 ? R 17:04 0:00 sshd: well@pts/ well 936 0.0 0.0 18180 3352 pts/1 Ss 17:04 0:00 -bash well 960 0.0 0.0 15572 2060 pts/1 R+ 17:16 0:00 ps -aux well@well:~$
arp -a
w
w
vim查找/替换字符串
博客园 http://www.cnblogs.com/GODYCA/archive/2013/02/22/2922840.html
./redis-cli 执行脚本
/redis-cli
redis-cli
区别
cat redis-无法显示
/ 根下
root@VM-52-248-ubuntu:/usr/src# cd usr/local bash: cd: usr/local: No such file or directory root@VM-52-248-ubuntu:/usr/src# cd /usr/local root@VM-52-248-ubuntu:/usr/local#
卸载redis-server
sudo apt-get remove redis-server
find -name redis 在当前文件夹查找
find / -name redis 在根目录下查找
重命名文件夹 mv
root@well:/home/etc/project/nosqlmongo# ls
mongodb
root@well:/home/etc/project/nosqlmongo# cp -R ^C
root@well:/home/etc/project/nosqlmongo# mv mongodb -R /home/etc/project/nosqlmongo/mongodb_NOUSing
mv: invalid option -- 'R'
Try 'mv --help' for more information.
root@well:/home/etc/project/nosqlmongo# mv mongodb /home/etc/project/nosqlmongo/mongodb_NOUSing
root@well:/home/etc/project/nosqlmongo# ls
mongodb_NOUSing
root@well:/home/etc/project/nosqlmongo#
w
tar -xvf tar.tar -C dir
解压到指定目录
tar -zxvf 同 -xf 解压到当前目录
well@well:/home/etc/project/nosqlmongo$ ls
well@well:/home/etc/project/nosqlmongo$ curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 38.4M 100 38.4M 0 0 106k 0 0:06:10 0:06:10 --:--:-- 118k
well@well:/home/etc/project/nosqlmongo$ ls
mongodb-linux-x86_64-3.0.6.tgz
well@well:/home/etc/project/nosqlmongo$ tar -zxvf mongodb-linux-x86_64-3.0.6.tgz
mongodb-linux-x86_64-3.0.6/README
mongodb-linux-x86_64-3.0.6/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-3.0.6/GNU-AGPL-3.0
mongodb-linux-x86_64-3.0.6/bin/mongodump
mongodb-linux-x86_64-3.0.6/bin/mongorestore
mongodb-linux-x86_64-3.0.6/bin/mongoexport
mongodb-linux-x86_64-3.0.6/bin/mongoimport
mongodb-linux-x86_64-3.0.6/bin/mongostat
mongodb-linux-x86_64-3.0.6/bin/mongotop
mongodb-linux-x86_64-3.0.6/bin/bsondump
mongodb-linux-x86_64-3.0.6/bin/mongofiles
mongodb-linux-x86_64-3.0.6/bin/mongooplog
mongodb-linux-x86_64-3.0.6/bin/mongoperf
mongodb-linux-x86_64-3.0.6/bin/mongod
mongodb-linux-x86_64-3.0.6/bin/mongos
mongodb-linux-x86_64-3.0.6/bin/mongo
well@well:/home/etc/project/nosqlmongo$ ls
mongodb-linux-x86_64-3.0.6 mongodb-linux-x86_64-3.0.6.tgz
well@well:/home/etc/project/nosqlmongo$
vim w.w gg到文件首字符 dG清空文件
w
xshell
win上传tar 解压
win->files->linux
rz
tar
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
rm 删除文件夹
sudo rm -R centosgit
well@well:/home/etc/project$ sudo rm centosgit [sudo] password for well: rm: cannot remove 'centosgit': Is a directory well@well:/home/etc/project$ ls centosgit well@well:/home/etc/project$ sudo rm -R centosgit well@well:/home/etc/project$ ls well@well:/home/etc/project$ ll total 0 drwxr-xr-x. 2 well well 6 Apr 22 19:25 ./ drwxr-xr-x. 1 well well 21 Apr 18 04:09 ../ well@well:/home/etc/project$
history - c 清空历史 clean
win 文件夹-压缩-rar-rz-linux
w
Linux 中 df 命令的11个例子-技术 ◆ 学习|Linux.中国-开源社区 https://linux.cn/article-6466-1.html
df
ubuntu@VM-52-248-ubuntu:~$ df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M) -H, --si print sizes in powers of 1000 (e.g., 1.1G) -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) --output[=FIELD_LIST] use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted. -P, --portability use the POSIX output format --sync invoke sync before getting usage info --total elide all entries insignificant to available space, and produce a grand total -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit Display values are in units of the first available SIZE from --block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page). GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report df translation bugs to <http://translationproject.org/team/> Full documentation at: <http://www.gnu.org/software/coreutils/df> or available locally via: info '(coreutils) df invocation' ubuntu@VM-52-248-ubuntu:~$
ubuntu@VM-52-248-ubuntu:~$ df -x ext3 Filesystem 1K-blocks Used Available Use% Mounted on udev 423480 0 423480 0% /dev tmpfs 88524 9496 79028 11% /run tmpfs 442600 24 442576 1% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 442600 0 442600 0% /sys/fs/cgroup tmpfs 88524 0 88524 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on udev devtmpfs 423480 0 423480 0% /dev tmpfs tmpfs 88524 9496 79028 11% /run /dev/vda1 ext3 20510332 2843460 16618348 15% / tmpfs tmpfs 442600 24 442576 1% /dev/shm tmpfs tmpfs 5120 0 5120 0% /run/lock tmpfs tmpfs 442600 0 442600 0% /sys/fs/cgroup tmpfs tmpfs 88524 0 88524 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -x tmpfs Filesystem 1K-blocks Used Available Use% Mounted on udev 423480 0 423480 0% /dev /dev/vda1 20510332 2843472 16618336 15% /
ubuntu@VM-52-248-ubuntu:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 414M 0 414M 0% /dev tmpfs 87M 9.3M 78M 11% /run /dev/vda1 20G 2.8G 16G 15% / tmpfs 433M 24K 433M 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 433M 0 433M 0% /sys/fs/cgroup tmpfs 87M 0 87M 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -h --total Filesystem Size Used Avail Use% Mounted on udev 414M 0 414M 0% /dev tmpfs 87M 9.3M 78M 11% /run /dev/vda1 20G 2.8G 16G 15% / tmpfs 433M 24K 433M 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 433M 0 433M 0% /sys/fs/cgroup tmpfs 87M 0 87M 0% /run/user/500 total 21G 2.8G 18G 14% - ubuntu@VM-52-248-ubuntu:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 414M 0 414M 0% /dev tmpfs 87M 9.3M 78M 11% /run /dev/vda1 20G 2.8G 16G 15% / tmpfs 433M 24K 433M 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 433M 0 433M 0% /sys/fs/cgroup tmpfs 87M 0 87M 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on udev 105870 414 105456 1% /dev tmpfs 110650 508 110142 1% /run /dev/vda1 1310720 77995 1232725 6% / tmpfs 110650 7 110643 1% /dev/shm tmpfs 110650 6 110644 1% /run/lock tmpfs 110650 16 110634 1% /sys/fs/cgroup tmpfs 110650 4 110646 1% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ du -sch /home du: cannot read directory '/home/ubuntu/.ssh': Permission denied 1.4M /home 1.4M total ubuntu@VM-52-248-ubuntu:~$ sudo du -sch /home 1.4M /home 1.4M total ubuntu@VM-52-248-ubuntu:~$ sudo du -sch /home 1.4M /home 1.4M total ubuntu@VM-52-248-ubuntu:~$ ubuntu@VM-52-248-ubuntu:~$ sudo du -sch /home/* 1.4M /home/ubuntu 1.4M total ubuntu@VM-52-248-ubuntu:~$ df -a Filesystem 1K-blocks Used Available Use% Mounted on sysfs 0 0 0 - /sys proc 0 0 0 - /proc udev 423480 0 423480 0% /dev devpts 0 0 0 - /dev/pts tmpfs 88524 9496 79028 11% /run /dev/vda1 20510332 2843396 16618412 15% / securityfs 0 0 0 - /sys/kernel/security tmpfs 442600 24 442576 1% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 442600 0 442600 0% /sys/fs/cgroup cgroup - - - - /sys/fs/cgroup/systemd pstore 0 0 0 - /sys/fs/pstore cgroup - - - - /sys/fs/cgroup/cpu,cpuacct cgroup - - - - /sys/fs/cgroup/memory cgroup - - - - /sys/fs/cgroup/net_cls,net_pri o cgroup - - - - /sys/fs/cgroup/hugetlb cgroup - - - - /sys/fs/cgroup/devices cgroup - - - - /sys/fs/cgroup/pids cgroup - - - - /sys/fs/cgroup/perf_event cgroup - - - - /sys/fs/cgroup/cpuset cgroup - - - - /sys/fs/cgroup/blkio cgroup - - - - /sys/fs/cgroup/freezer systemd-1 - - - - /proc/sys/fs/binfmt_misc hugetlbfs 0 0 0 - /dev/hugepages debugfs 0 0 0 - /sys/kernel/debug mqueue 0 0 0 - /dev/mqueue fusectl 0 0 0 - /sys/fs/fuse/connections tmpfs - - - - /run/lxcfs/controllers freezer - - - - /run/lxcfs/controllers/freezer blkio - - - - /run/lxcfs/controllers/blkio cpuset - - - - /run/lxcfs/controllers/cpuset perf_event - - - - /run/lxcfs/controllers/perf_ev ent pids - - - - /run/lxcfs/controllers/pids devices - - - - /run/lxcfs/controllers/devices hugetlb - - - - /run/lxcfs/controllers/hugetlb net_cls,net_prio - - - - /run/lxcfs/controllers/net_cls ,net_prio memory - - - - /run/lxcfs/controllers/memory cpu,cpuacct - - - - /run/lxcfs/controllers/cpu,cpu acct name=systemd - - - - /run/lxcfs/controllers/name=sy stemd lxcfs 0 0 0 - /var/lib/lxcfs binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc tracefs - - - - /sys/kernel/debug/tracing tmpfs 88524 0 88524 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -h /home/ Filesystem Size Used Avail Use% Mounted on /dev/vda1 20G 2.8G 16G 15% / ubuntu@VM-52-248-ubuntu:~$ df -h /var/ Filesystem Size Used Avail Use% Mounted on /dev/vda1 20G 2.8G 16G 15% / ubuntu@VM-52-248-ubuntu:~$ df -k Filesystem 1K-blocks Used Available Use% Mounted on udev 423480 0 423480 0% /dev tmpfs 88524 9496 79028 11% /run /dev/vda1 20510332 2843408 16618400 15% / tmpfs 442600 24 442576 1% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 442600 0 442600 0% /sys/fs/cgroup tmpfs 88524 0 88524 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -x ext3 Filesystem 1K-blocks Used Available Use% Mounted on udev 423480 0 423480 0% /dev tmpfs 88524 9496 79028 11% /run tmpfs 442600 24 442576 1% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 442600 0 442600 0% /sys/fs/cgroup tmpfs 88524 0 88524 0% /run/user/500 ubuntu@VM-52-248-ubuntu:~$ df -h /home/
查找redis配置文件redis.conf port 端口号 并 显示行号
cat redis.conf | grep 6379
cat redis.conf -n | grep 6379
root@ubuntu:/etc/redis# cat redis.conf -n | grep 127 69 bind 127.0.0.1 127 # Save the DB on disk: root@ubuntu:/etc/redis# cat redis.conf -n | grep 6379 48 # Accept connections on the specified port, default is 6379. 50 port 6379 645 # cluster-config-file nodes-6379.conf root@ubuntu:/etc/redis#
root@ubuntu:/etc/redis# cat redis.conf | grep 127 bind 127.0.0.1 root@ubuntu:/etc/redis# cat redis.conf | grep 6379 # Accept connections on the specified port, default is 6379. port 6379 # cluster-config-file nodes-6379.conf
将curl 结果通过grep筛选字符串再通过>保存为文件再通过cat查看
well@well:/home/auto.scripts$ curl 10000.gd.cn > all.w
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49437 0 49437 0 0 1371k 0 --:--:-- --:--:-- --:--:-- 1379k
well@well:/home/auto.scripts$ ls
all.w system_info.sh system_info_en.sh txt
well@well:/home/auto.scripts$ curl 10000.gd.cn | grep mainBg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<link href="./css/mainBg.css" rel="stylesheet" type="text/css" />
<div class="mainBg">
100 49437 0 49437 0 0 884k 0 --:--:-- --:--:-- --:--:-- 894k
well@well:/home/auto.scripts$ curl 10000.gd.cn | grep mainBg > all.mainBg.w
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49437 0 49437 0 0 894k 0 --:--:-- --:--:-- --:--:-- 910k
well@well:/home/auto.scripts$ ls
all.mainBg.w all.w system_info.sh system_info_en.sh txt
well@well:/home/auto.scripts$ cat all.mainBg.w
<link href="./css/mainBg.css" rel="stylesheet" type="text/css" />
<div class="mainBg">
well@well:/home/auto.scripts$
w curl grep查页面内容 宽带帐号
curl 10000.gd.cn | grep mainBg
well@well:/home/auto.scripts$ curl 10000.gd.cn | grep mainBg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<link href="./css/mainBg.css" rel="stylesheet" type="text/css" />
<div class="mainBg">
100 49437 0 49437 0 0 773k 0 --:--:-- --:--:-- --:--:-- 766k
well@well:/home/project/git_testd/test$ git branch -h
usage: git branch [options] [-r | -a] [--merged | --no-merged]
or: git branch [options] [-l] [-f] <branchname> [<start-point>]
or: git branch [options] [-r] (-d | -D) <branchname>...
or: git branch [options] (-m | -M) [<oldbranch>] <newbranch>
Generic options
-v, --verbose show hash and subject, give twice for upstream branch
-q, --quiet suppress informational messages
-t, --track set up tracking mode (see git-pull(1))
--set-upstream change upstream info
-u, --set-upstream-to <upstream>
change the upstream info
--unset-upstream Unset the upstream info
--color[=<when>] use colored output
-r, --remotes act on remote-tracking branches
--contains <commit> print only branches that contain the commit
--abbrev[=<n>] use <n> digits to display SHA-1s
Specific git-branch actions:
-a, --all list both remote-tracking and local branches
-d, --delete delete fully merged branch
-D delete branch (even if not merged)
-m, --move move/rename a branch and its reflog
-M move/rename a branch, even if target exists
--list list branch names
-l, --create-reflog create the branch's reflog
--edit-description edit the description for the branch
-f, --force force creation (when already exists)
--no-merged <commit> print only not merged branches
--merged <commit> print only merged branches
--column[=<style>] list branches in columns
w
新建分支
git checkout -b wellfromxshell
提交分支
git push origin wellfromxshell
目录递归赋权
sudo chown -R well:well project/
well@well:/home$ ll
total 4
drwxr-xr-x. 1 root root 44 Apr 18 04:10 ./
drwxr-xr-x. 1 root root 92 Apr 18 04:09 ../
drwxr-xr-x. 3 root root 18 Apr 11 21:51 bin/
drwxr-xr-x. 1 root root 21 Apr 18 04:09 etc/
drwxr-xr-x. 1 777 root 33 Apr 19 19:18 project/
-rwxrwxr-x. 1 root root 360 Mar 14 11:59 readme.php*
drwxr-xr-x. 3 777 well 235 Apr 19 19:07 well/
well@well:/home$ sudo chown -R well:well project/
well@well:/home$ sudo chown -R well:well etc/
well@well:/home$ ll
total 4
drwxr-xr-x. 1 root root 44 Apr 18 04:10 ./
drwxr-xr-x. 1 root root 92 Apr 18 04:09 ../
drwxr-xr-x. 3 root root 18 Apr 11 21:51 bin/
drwxr-xr-x. 1 well well 21 Apr 18 04:09 etc/
drwxr-xr-x. 1 well well 33 Apr 19 19:18 project/
-rwxrwxr-x. 1 root root 360 Mar 14 11:59 readme.php*
drwxr-xr-x. 3 777 well 235 Apr 19 19:07 well/
well@well:/home$
well@well:/home$ cd ..
well@well:/$ ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
well@well:/$ sudo chown -R well:well home/
well@well:/$ cd -
/home
well@well:/home$ ll
total 4
drwxr-xr-x. 1 well well 73 Apr 18 04:10 ./
drwxr-xr-x. 1 root root 92 Apr 18 04:09 ../
drwxr-xr-x. 1 well well 18 Apr 11 21:51 bin/
drwxr-xr-x. 1 well well 21 Apr 18 04:09 etc/
drwxr-xr-x. 1 well well 33 Apr 19 19:18 project/
-rwxrwxr-x. 1 well well 360 Mar 14 11:59 readme.php*
drwxr-xr-x. 3 well well 235 Apr 19 19:07 well/
well@well:/home$
well@well:~$ ls
well@well:~$ ll
total 12
drwxr-xr-x. 3 well well 71 Apr 19 18:49 ./
drwxr-xr-x. 1 root root 29 Apr 18 04:10 ../
-rw-r--r--. 1 well well 220 Apr 18 04:10 .bash_logout
-rw-r--r--. 1 well well 3637 Apr 18 04:10 .bashrc
drwx------. 2 well well 34 Apr 19 18:49 .cache/
-rw-r--r--. 1 well well 675 Apr 18 04:10 .profile
well@well:~$ cat ~/.ssh/id_rsa.pub
cat: /home/well/.ssh/id_rsa.pub: No such file or directory
well@well:~$
well@well:~$ ssh-keygen -t rsa -C "GitLab" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/well/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
well@well:~$ ssh-keygen -t rsa -C "GitLab" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/well/.ssh/id_rsa): ^C
well@well:~$ ls
well@well:~$ ll
total 12
drwxr-xr-x. 3 well well 71 Apr 19 18:49 ./
drwxr-xr-x. 1 root root 29 Apr 18 04:10 ../
-rw-r--r--. 1 well well 220 Apr 18 04:10 .bash_logout
-rw-r--r--. 1 well well 3637 Apr 18 04:10 .bashrc
drwx------. 2 well well 34 Apr 19 18:49 .cache/
-rw-r--r--. 1 well well 675 Apr 18 04:10 .profile
well@well:~$ cat ~/.ssh/id_rsa.pub
cat: /home/well/.ssh/id_rsa.pub: No such file or directory
well@well:~$ ssh-keygen -t rsa -C "GitLab" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/well/.ssh/id_rsa): well^H^H^H^H^H^H^H^H^H^H^H^[[3~^[[3~^[[3~^[[3~^[[3~
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been sa.ed in well
Your public key has been sa.pub.n well
The key fingerprint is:
39:00:93:59:ec:ca:af:31:85:cf:16:9d:3f:0e:d9:31 GitLab
The key's randomart image is:
+--[ RSA 4096]----+
| o=. |
| oo. |
| .. |
| ..o o |
| ...o S E |
| o+ . = o |
| o.+ o + |
| +. o . |
| .. . |
+-----------------+
well@well:~$ ls
well????????????[3~?[3~?[3~?[3~?[3~ well????????????[3~?[3~?[3~?[3~?[3~.pub
well@well:~$ cat ~/.ssh/id_rsa.pub
cat: /home/well/.ssh/id_rsa.pub: No such file or directory
well@well:~$ ls
well????????????[3~?[3~?[3~?[3~?[3~ well????????????[3~?[3~?[3~?[3~?[3~.pub
well@well:~$ sudo well????????????[3~?[3~?[3~?[3~?[3~
[sudo] password for well: : command not found
well@well:~$ sudo mv well????????????[3~?[3~?[3~?[3~?[3~
mv: missing destination file operand after 'well\b\b\b\b\b\b\b\b\b\b\b\033[3~\033[3~\033[3~\033[3~\033[3~'
Try 'mv --help' for more information.
well@well:~$ cat ~/.ssh/id_rsa.pub
cat: /home/well/.ssh/id_rsa.pub: No such file or directory
well@well:~$ ssh-keygen -t rsa -C "GitLab" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/well/.ssh/id_rsa): welltest^H^H
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in wellte.t
Your public key has been saved in wellte.pub.
The key fingerprint is:
bb:95:35:a3:40:a5:dd:21:e6:26:da:59:82:0c:bf:ee GitLab
The key's randomart image is:
+--[ RSA 4096]----+
| . + . |
| + . * o . |
| + = = . |
| = * |
| o S + |
| . o + o |
| . . + |
| . o |
| E . |
+-----------------+
well@well:~$ ls
well????????????[3~?[3~?[3~?[3~?[3~ welltest??
well????????????[3~?[3~?[3~?[3~?[3~.pub welltest??.pub
well@well:~$ ssh-keygen -t rsa -C "GitLab" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/well/.ssh/id_rsa): wellkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in wellkey.
Your public key has been saved in wellkey.pub.
The key fingerprint is:
29:b9:ac:35:3f:e3:fd:2a:c0:2f:cd:99:2f:42:3f:81 GitLab
The key's randomart image is:
+--[ RSA 4096]----+
| |
| |
| |
| . . |
| .o.S |
| .Eo. |
| .=* + |
| ooo&. |
| . +oB+o. |
+-----------------+
well@well:~$ ls
well????????????[3~?[3~?[3~?[3~?[3~ wellkey welltest??
well????????????[3~?[3~?[3~?[3~?[3~.pub wellkey.pub welltest??.pub
well@well:~$ ll
total 36
drwxr-xr-x. 3 well well 235 Apr 19 19:07 ./
drwxr-xr-x. 1 root root 29 Apr 18 04:10 ../
-rw-r--r--. 1 well well 220 Apr 18 04:10 .bash_logout
-rw-r--r--. 1 well well 3637 Apr 18 04:10 .bashrc
drwx------. 2 well well 34 Apr 19 18:49 .cache/
-rw-r--r--. 1 well well 675 Apr 18 04:10 .profile
-rw-------. 1 well well 3243 Apr 19 19:04 well????????????[3~?[3~?[3~?[3~?[3~
-rw-r--r--. 1 well well 732 Apr 19 19:04 well????????????[3~?[3~?[3~?[3~?[3~.pub
-rw-------. 1 well well 3243 Apr 19 19:07 wellkey
-rw-r--r--. 1 well well 732 Apr 19 19:07 wellkey.pub
-rw-------. 1 well well 3243 Apr 19 19:07 welltest??
-rw-r--r--. 1 well well 732 Apr 19 19:07 welltest??.pub
well@well:~$ cat wellkey.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCrC3SDkhaXX5pnwCHql8ssNJLv2Mt9BRNBaBdhCYvhlQBaqGv+C4kFZixCI7y1ImWGrXXp2K7oxHW11BNt+lteK1e6JHQf8ZNT5nCJHLsFwYQpssiNi0mj1rt3zUh3DVR27C1XWiexMqoIqjcHGn3+rN4c9d7wy46rqZXjb7kq9mSmLjHTw3ca1oi1rd1/txFVtGrVm3KNKyew/29IBIhOxNuF0zNPGt4leHNTfU340mulVSRRYlw5lf/szoFLMr2qKdXfq9hPslhp8uKJ2vBrmaXkmcuOyzK3IjVGu6980p3jbbSTe1OtMRnsBIlFVKaJhKAPfrasLrTtGf8KDiqzLptcIivi1MVvNRf/zhZzBVrWm5KVI0iKqIMsQllqL0WBV+Bc6d1p4lkld4MpoQCrZYdvjXe5mFPIhDaqhoSuPZu7b/Jj8jRTftI93UqgxhibQREpCUfNce5q9zXODsYNs/vMtTk1ywRpSF+EWw5YtZV5vVvSTPwVHN21RchpiHdVRRvIi1kVu6dcYsrefIglSzltxMxsXSkWG/6sPQ+uszgab/QRMDw+mQRAu6MnP8TIwIg7nt424S6JRr0UZ0vjyYeLacYWFiIYdwAkXH4h1706A6sfxk7H4hGspCnFO4cme0k8RwCCB3KqLOYkqOS6gzqQuOeMpgW4CcWWsfEGWQ== GitLab
well@well:~$
SSH
Git is a distributed version control system, which means you can work locally
but you can also share or "push" your changes to other servers.
Before you can push your changes to a GitLab server
you need a secure communication channel for sharing information.
The SSH protocol provides this security and allows you to authenticate to the
GitLab remote server without supplying your username or password each time.
For a more detailed explanation of how the SSH protocol works, we advise you to
read this nice tutorial by DigitalOcean.
Locating an existing SSH key pair
Before generating a new SSH key check if your system already has one
at the default location by opening a shell, or Command Prompt on Windows,
and running the following command:
Windows Command Prompt:
type %userprofile%\.ssh\id_rsa.pub
GNU/Linux / macOS / PowerShell:
cat ~/.ssh/id_rsa.pub
If you see a string starting with ssh-rsa you already have an SSH key pair
and you can skip the next step Generating a new SSH key pair
and continue onto Copying your public SSH key to the clipboard.
If you don't see the string or would like to generate a SSH key pair with a
custom name continue onto the next step.
Generating a new SSH key pair
To generate a new SSH key, use the following command:
GNU/Linux / macOS:
ssh-keygen -t rsa -C "GitLab" -b 4096
Windows:
On Windows you will need to download
PuttyGen
and follow this documentation article to generate a SSH key pair.
Next, you will be prompted to input a file path to save your key pair to.
If you don't already have an SSH key pair use the suggested path by pressing
enter. Using the suggested path will allow your SSH client
to automatically use the key pair with no additional configuration.
If you already have a key pair with the suggested file path, you will need
to input a new file path and declare what host this key pair will be used
for in your .ssh/config file, see Working with non-default SSH key pair paths
for more information.
Once you have input a file path you will be prompted to input a password to
secure your SSH key pair. It is a best practice to use a password for an SSH
key pair, but it is not required and you can skip creating a password by
pressing enter.
Note:
If you want to change the password of your key, you can use ssh-keygen -p <keyname>.
The next step is to copy the public key as we will need it afterwards.
To copy your public key to the clipboard, use the appropriate code for your
operating system below:
macOS:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):
xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:
type %userprofile%\.ssh\id_rsa.pub | clip
Windows PowerShell:
cat ~/.ssh/id_rsa.pub | clip
The final step is to add your public SSH key to GitLab.
Navigate to the 'SSH Keys' tab in you 'Profile Settings'.
Paste your key in the 'Key' section and give it a relevant 'Title'.
Use an identifiable title like 'Work Laptop - Windows 7' or
'Home MacBook Pro 15'.
If you manually copied your public SSH key make sure you copied the entire
key starting with ssh-rsa and ending with your email.
Working with non-default SSH key pair paths
If you used a non-default file path for your GitLab SSH key pair,
you must configure your SSH client to find your GitLab SSH private key
for connections to your GitLab server (perhaps gitlab.com).
For OpenSSH clients this is configured in the ~/.ssh/config file.
Below are two example host configurations using their own key:
# GitLab.com server
Host gitlab.com
RSAAuthentication yes
IdentityFile ~/.ssh/config/private-key-filename-01
# Private GitLab server
Host gitlab.company.com
RSAAuthentication yes
IdentityFile ~/.ssh/config/private-key-filename
Due to the wide variety of SSH clients and their very large number of
configuration options, further explanation of these topics is beyond the scope
of this document.
Public SSH keys need to be unique, as they will bind to your account.
Your SSH key is the only identifier you'll have when pushing code via SSH.
That's why it needs to uniquely map to a single user.
Deploy keys
Deploy keys allow read-only access to multiple projects with a single SSH
key.
This is really useful for cloning repositories to your Continuous
Integration (CI) server. By using deploy keys, you don't have to setup a
dummy user account.
If you are a project master or owner, you can add a deploy key in the
project settings under the section 'Deploy Keys'. Press the 'New Deploy
Key' button and upload a public SSH key. After this, the machine that uses
the corresponding private key has read-only access to the project.
You can't add the same deploy key twice with the 'New Deploy Key' option.
If you want to add the same key to another project, please enable it in the
list that says 'Deploy keys from projects available to you'. All the deploy
keys of all the projects you have access to are available. This project
access can happen through being a direct member of the project, or through
a group.
Deploy keys can be shared between projects, you just need to add them to each
project.
Applications
Eclipse
How to add your ssh key to Eclipse: https://wiki.eclipse.org/EGit/User_Guide#Eclipse_SSH_Configuration
w
Finding open files with lsof
https://www.ibm.com/developerworks/aix/library/au-lsof.html
使用 lsof 查找打开的文件
https://www.ibm.com/developerworks/cn/aix/library/au-lsof.html
Files are ubiquitous in the UNIX® environment, leading to a common phrase: "Everything is a file." Not only is regular data accessed through files, but also network connections and, often, hardware. In some cases, an entry appears when you request a directory listing through ls
. In other cases, such as Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) sockets, there is no directory listing. But behind the scenes, a file descriptor has been assigned to the application, regardless of the nature of the file, providing a common interface for applications to interact with the underlying operating system.
Because the list of open file descriptors of an application give a great deal of information about the application itself, being able to peer into this list is helpful. The utility to do so is called lsof
, which means "list open files." This utility is available for nearly every UNIX flavor but, strangely, most vendors don't include it with the stock install of the operating system.
在 UNIX® 环境中,文件无处不在,这便产生了一句格言:“任何事物都是文件”。通过文件不仅仅可以访问常规数据,通常还可以访问网络连接和硬件。在有些情况下,当您使用 ls
请求目录清单时,将出现相应的条目。在其他情况下,如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字,不存在相应的目录清单。但是在后台为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。
因为应用程序打开文件的描述符列表提供了大量关于这个应用程序本身的信息,所以能够查看这个列表将是很有帮助的。完成这项任务的实用程序称为 lsof
,它对应于“list open files”(列出打开的文件)。几乎在每个 UNIX 版本中都有这个实用程序,但奇怪的是,大多数供应商并没有将其包含在操作系统的初始安装中。要获取更多关于 lsof
的信息,请参见参考资料部分。
w
netstat win
ss/netstat linux
awk 统计日访问站点次数大于某一正常值的ip
w
w
well@well:/$ git usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] The most commonly used git commands are: add Add file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty Git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index show Show various types of objects status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG 'git help -a' and 'git help -g' lists available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept. well@well:/$ git config --global user.name 'well'; well@well:/$ git config --global user.email 'well@w.w'; well@well:/$ git config --global core.editor vim well@well:/$
well@well:/home/etc/project$ mkdir git_test well@well:/home/etc/project$ ls git_test index.php php test well@well:/home/etc/project$ ll total 4 drwxr-xr-x 4 well well 62 Apr 13 18:11 ./ drwxr-xr-x 1 well well 21 Apr 13 13:58 ../ drwxrwxr-x 2 well well 6 Apr 13 18:11 git_test/ -rw-r--r-- 1 well well 25 Apr 13 16:31 index.php drwxr-xr-x 4 well well 28 Apr 13 17:13 php/ -rw-r--r-- 1 well well 0 Apr 13 14:00 test well@well:/home/etc/project$ cd _git_test -bash: cd: _git_test: No such file or directory well@well:/home/etc/project$ cd git_test well@well:/home/etc/project/git_test$ git init Initialized empty Git repository in /home/etc/project/git_test/.git/ well@well:/home/etc/project/git_test$ ll total 0 drwxrwxr-x 3 well well 18 Apr 13 18:11 ./ drwxr-xr-x 4 well well 62 Apr 13 18:11 ../ drwxrwxr-x 7 well well 119 Apr 13 18:11 .git/ well@well:/home/etc/project/git_test$
well@well:/home/etc/project/git_test$ ll total 0 drwxrwxr-x 3 well well 18 Apr 13 18:11 ./ drwxr-xr-x 4 well well 62 Apr 13 18:11 ../ drwxrwxr-x 7 well well 119 Apr 13 18:11 .git/ well@well:/home/etc/project/git_test$ git clone http://192.168.95.32:8083/test/test_project.git Cloning into 'test_project'... Username for 'http://192.168.95.32:8083': well Password for 'http://well@192.168.95.32:8083': remote: Counting objects: 16, done. remote: Compressing objects: 100% (8/8), done. remote: Total 16 (delta 2), reused 13 (delta 2) Unpacking objects: 100% (16/16), done. Checking connectivity... done. well@well:/home/etc/project/git_test$ ll total 0 drwxrwxr-x 4 well well 38 Apr 13 18:16 ./ drwxr-xr-x 4 well well 62 Apr 13 18:11 ../ drwxrwxr-x 7 well well 119 Apr 13 18:11 .git/ drwxrwxr-x 3 well well 35 Apr 13 18:16 test_project/ well@well:/home/etc/project/git_test$ cd test_project well@well:/home/etc/project/git_test/test_project$ ll total 4 drwxrwxr-x 3 well well 35 Apr 13 18:16 ./ drwxrwxr-x 4 well well 38 Apr 13 18:16 ../ drwxrwxr-x 8 well well 163 Apr 13 18:16 .git/ -rw-rw-r-- 1 well well 59 Apr 13 18:16 README.md well@well:/home/etc/project/git_test/test_project$ cd ../ well@well:/home/etc/project/git_test$ ll total 0 drwxrwxr-x 4 well well 38 Apr 13 18:16 ./ drwxr-xr-x 4 well well 62 Apr 13 18:11 ../ drwxrwxr-x 7 well well 119 Apr 13 18:11 .git/ drwxrwxr-x 3 well well 35 Apr 13 18:16 test_project/ well@well:/home/etc/project/git_test$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) test_project/ nothing added to commit but untracked files present (use "git add" to track) well@well:/home/etc/project/git_test$
https://git-scm.com/book/zh/v2/Git-基础-记录每次更新到仓库
well@well:/home/etc/project/git_test$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) test_project/ nothing added to commit but untracked files present (use "git add" to track) well@well:/home/etc/project/git_test$ git add test_project well@well:/home/etc/project/git_test$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: test_project well@well:/home/etc/project/git_test$
well@well:/home/etc/project/git_test$ cd test_project well@well:/home/etc/project/git_test/test_project$ ls README.md well@well:/home/etc/project/git_test/test_project$ vim README.md well@well:/home/etc/project/git_test/test_project$ git stauts git: 'stauts' is not a git command. See 'git --help'. Did you mean this? status well@well:/home/etc/project/git_test/test_project$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a") well@well:/home/etc/project/git_test/test_project$
文件 CONTRIBUTING.md
出现在 Changes not staged for commit
这行下面,说明已跟踪文件的内容发生了变化,但还没有放到暂存区。
要暂存这次更新,需要运行 git add
命令。
vim 创建目录
chown(1) - Linux man page
https://linux.die.net/man/1/chown
chmod 666 -R upfc
chmod命令详解
使用权限:所有使用者
使用方式:chmod [-cfvR] [--help] [--version] mode file...
说明:
Linux/Unix 的档案存取权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所存取。
mode :权限设定字串,格式如下 :[ugoa...][[+-=][rwxX]...][,...],其中u 表示该档案的拥有者,g 表示与该档案的拥有者属于同一个群体(group)者,o 表示其他以外的人,a 表示这三者皆是。
+ 表示增加权限、- 表示取消权限、= 表示唯一设定权限。
r 表示可读取,w 表示可写入,x 表示可执行,X 表示只有当该档案是个子目录或者该档案已经被设定过为可执行。
-c : 若该档案权限确实已经更改,才显示其更改动作
-f : 若该档案权限无法被更改也不要显示错误讯息
-v : 显示权限变更的详细资料
-R : 对目前目录下的所有档案与子目录进行相同的权限变更(即以递回的方式逐个变更)
--help : 显示辅助说明
--version : 显示版本
范例:
将档案 file1.txt 设为所有人皆可读取
chmod ugo+r file1.txt
将档案 file1.txt 设为所有人皆可读取
chmod a+r file1.txt
将档案 file1.txt 与 file2.txt 设为该档案拥有者,与其所属同一个群体者可写入,但其他以外的人则不可写入
chmod ug+w,o-w file1.txt file2.txt
将 ex1.py 设定为只有该档案拥有者可以执行
chmod u+x ex1.py
将目前目录下的所有档案与子目录皆设为任何人可读取
chmod -R a+r *
此外chmod也可以用数字来表示权限如 chmod 777 file
语法为:chmod abc file
其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。
r=4,w=2,x=1
若要rwx属性则4+2+1=7;
若要rw-属性则4+2=6;
若要r-x属性则4+1=7。
范例:
chmod a=rwx file 和 chmod 777 file 效果相同
chmod ug=rwx,o=x file 和 chmod 771 file 效果相同
若用chmod 4755 filename可使此程式具有root的权限
linux权限---【600,644,700,755,711,666,777】 - CSDN博客 https://blog.csdn.net/nzing/article/details/9166057
chown命令详解
使用权限:root
使用方式:chown [-cfhvR] [--help] [--version] user[:group] file...
说明:
Linux/Unix 是多人多工作业系统,所有的档案皆有拥有者。利用 chown 可以将档案的拥有者加以改变。一般来说,这个指令只有是由系统管理者(root)所使用,一般使用者没有权限可以改变别人的档案拥有者,也没有权限可以自己的档案拥有者改设为别人。只有系统管理者(root)才有这样的权限。
user : 新的档案拥有者的使用者
IDgroup : 新的档案拥有者的使用者群体(group)
-c : 若该档案拥有者确实已经更改,才显示其更改动作
-f : 若该档案拥有者无法被更改也不要显示错误讯息
-h : 只对于连结(link)进行变更,而非该 link 真正指向的档案
-v : 显示拥有者变更的详细资料
-R : 对目前目录下的所有档案与子目录进行相同的拥有者变更(即以递回的方式逐个变更)
--help : 显示辅助说明
--version : 显示版本
范例:
将档案 file1.txt 的拥有者设为 users 群体的使用者 jessie
chown jessie:users file1.txt
将目前目录下的所有档案与子目录的拥有者皆设为 users 群体的使用者 lamport
chown -R lamport:users *
-rw------- (600) -- 只有属主有读写权限。
-rw-r--r-- (644) -- 只有属主有读写权限;而属组用户和其他用户只有读权限。
-rwx------ (700) -- 只有属主有读、写、执行权限。
-rwxr-xr-x (755) -- 属主有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
-rwx--x--x (711) -- 属主有读、写、执行权限;而属组用户和其他用户只有执行权限。
-rw-rw-rw- (666) -- 所有用户都有文件读、写权限。这种做法不可取。
-rwxrwxrwx (777) -- 所有用户都有读、写、执行权限。更不可取的做法。
以下是对目录的两个普通设定:
drwx------ (700) - 只有属主可在目录中读、写。
drwxr-xr-x (755) - 所有用户可读该目录,但只有属主才能改变目录中的内容
suid的代表数字是4,比如4755的结果是-rwsr-xr-x
sgid的代表数字是2,比如6755的结果是-rwsr-sr-x
sticky位代表数字是1,比如7755的结果是-rwsr-sr-t
Linux改变文件和目录权限-chmod&chown - 1901 - 博客园
http://www.cnblogs.com/kaixuan/archive/2009/01/15/1376456.html
chmod
改变一个文件的权限:chmod [mode] file.txt
改变一个目录的权限:chmod [mode] dir
改变一个目录和其子目录的权限: chmod [mode] dir -R
mode = 777 or 752 and so on.
mode的三个数字,分别表示owner,group,others所具备的权限。
1=x 执行
2=w 写
4=r 读
比如owner具有所有权限,1+2+4=7,又比如 group 具有读和执行权限1+4=5。
========================================================
chown
-R参数表示递归改变
[root@linux ~]#chown [-R] 账户名称 文件或目录
[root@linux ~]#chown [-R] 账户名称:用户组名称 文件或目录
80
8080端口
ls
ll
模糊查找文件
sudo find -name apa*.*
ip map
http://man7.org/linux/man-pages/man5/hosts.5.html
NAME top
hosts - static table lookup for hostnames
SYNOPSIS top
/etc/hosts
DESCRIPTION top
This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single line should be present with the following information: IP_address canonical_hostname [aliases...] Fields of the entry are separated by any number of blanks and/or tab characters. Text from a "#" character until the end of the line is a comment, and is ignored. Host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character. Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost). The Berkeley Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems. It augments or replaces the /etc/hosts file or hostname lookup, and frees a host from relying on /etc/hosts being up to date and complete. In modern systems, even though the host table has been superseded by DNS, it is still widely used for: bootstrapping Most systems have a small host table containing the name and address information for important hosts on the local network. This is useful when DNS is not running, for example during system bootup. NIS Sites that use NIS use the host table as input to the NIS host database. Even though NIS can be used with DNS, most NIS sites still use the host table with an entry for all local hosts as a backup. isolated nodes Very small sites that are isolated from the network use the host table instead of DNS. If the local information rarely changes, and the network is not connected to the Internet, DNS offers little advantage.
FILES top
/etc/hosts
NOTES top
Modifications to this file normally take effect immediately, except in cases where the file is cached by applications. Historical notes RFC 952 gave the original format for the host table, though it has since changed. Before the advent of DNS, the host table was the only way of resolving hostnames on the fledgling Internet. Indeed, this file could be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes were often required to bring it up to date regarding unofficial aliases and/or unknown hosts. The NIC no longer maintains the hosts.txt files, though looking around at the time of writing (circa 2000), there are historical hosts.txt files on the WWW. I just found three, from 92, 94, and 95.
EXAMPLE top
# The following lines are desirable for IPv4 capable hosts 127.0.0.1 localhost # 127.0.1.1 is often used for the FQDN of the machine 127.0.1.1 thishost.mydomain.org thishost 192.168.1.10 foo.mydomain.org foo 192.168.1.13 bar.mydomain.org bar 146.82.138.7 master.debian.org master 209.237.226.90 www.opensource.org # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
SEE ALSO top
hostname(1), resolver(3), host.conf(5), resolv.conf(5), resolver(5), hostname(7), named(8) Internet RFC 952
不能远程访问mysql
查找有文件名和位置
sudo passwd
sudo passwd
找回 su 密码
well@well:/home/etc/project/apilinux$ su Password: su: Authentication failure well@well:/home/etc/project/apilinux$ sudo passwd [sudo] password for well: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully well@well:/home/etc/project/apilinux$ su Password: root@well:/home/etc/project/apilinux# debugs
w
质疑遇到的每个linux实例
0-well有权改root的密码,well无权重启mysql;
1-root有权重启mysql;
2-well在重启mysql命令前加四个字母"sudo"和空格,重启了mysql;
3-012不合理;
4-linux只是一个os环境,经人为干预后,“个性化”:如同不同用户的几个win系统一样,因个人设置,有些地方不合理甚至错误;带思考地批判性地看今后遇到的linux环境;
https://zh.wikipedia.org/wiki/Sudo
https://en.wikipedia.org/wiki/Sudo
不需要超级用户的密码
sudo (/ˈsuːduː/[2] or /ˈsuːdoʊ/[2][3]) is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user, by default the superuser.[4] It originally stood for "superuser do"[5] as the older versions of sudo were designed to run commands only as the superuser. However, the later versions added support for running commands not only as the superuser but also as other (restricted) users, and thus it is also commonly expanded as "substitute user do".[6][7] Although the latter case reflects its current functionality more accurately, sudo is still often called "superuser do" since it is so often used for administrative tasks.
Sudo(substitute user [或 superuser] do),是一种程序,用于类Unix操作系统如BSD,Mac OS X,以及GNU/Linux以允许用户通过安全的方式使用特殊的权限运行程序(通常为系统的超级用户)。
sudo使一般用户不需要知道超级用户的密码即可获得权限。首先超级用户将普通用户的名字、可以执行的特定命令、按照哪种用户或用户组的身份执行等信息,登记在特殊的文件中(通常是/etc/sudoers
),即完成对该用户的授权(此时该用户称为“sudoer”)[3];在一般用户需要获取特殊权限时,其可在命令前加上“sudo
”,此时sudo将会询问该用户自己的密码(以确认终端机前的是该用户本人),回答后系统即会将该命令的进程以超级用户的权限运行。之后的一段时间内(默认为5分钟[4],可在/etc/sudoers
自定义),使用sudo不需要再次输入密码。
由于不需要超级用户的密码,部分Unix系统甚至利用sudo使一般用户取代超级用户作为管理账号,例如Ubuntu、Mac OS X等。
service mysql restart
sudo service mysql restart
sudo passwd root
bash
复制若干行,从某行的下一行放入
yy复制一行,再粘贴p(光标右,P左)
vim
移动光标
上:k nk:向上移动n行 9999k或gg可以移到第一行 G移到最后一行
下:j nj:向下移动n行
左:h nh:向左移动n列
右:l nl:向右移动n列
然后进入i,修改配置
vim G 光标到最后一行
vim
dd 删除当前行
cc 也是删除当前行,然后进入INSERT MODE
find -name index.php 查找文件
w
curl --help Usage: curl [options...] <url> Options: (H) means HTTP/HTTPS only, (F) means FTP only --anyauth Pick "any" authentication method (H) -a, --append Append to target file when uploading (F/SFTP) --basic Use HTTP Basic Authentication (H) --cacert FILE CA certificate to verify peer against (SSL) --capath DIR CA directory to verify peer against (SSL) -E, --cert CERT[:PASSWD] Client certificate file and password (SSL) --cert-status Verify the status of the server certificate (SSL) --cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL) --ciphers LIST SSL ciphers to use (SSL) --compressed Request compressed response (using deflate or gzip) -K, --config FILE Read config from FILE --connect-timeout SECONDS Maximum time allowed for connection -C, --continue-at OFFSET Resumed transfer OFFSET -b, --cookie STRING/FILE Read cookies from STRING/FILE (H) -c, --cookie-jar FILE Write cookies to FILE after operation (H) --create-dirs Create necessary local directory hierarchy --crlf Convert LF to CRLF in upload --crlfile FILE Get a CRL list in PEM format from the given file -d, --data DATA HTTP POST data (H) --data-raw DATA HTTP POST data, '@' allowed (H) --data-ascii DATA HTTP POST ASCII data (H) --data-binary DATA HTTP POST binary data (H) --data-urlencode DATA HTTP POST data url encoded (H) --delegation STRING GSS-API delegation permission --digest Use HTTP Digest Authentication (H) --disable-eprt Inhibit using EPRT or LPRT (F) --disable-epsv Inhibit using EPSV (F) --dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2 --dns-interface Interface to use for DNS requests --dns-ipv4-addr IPv4 address to use for DNS requests, dot notation --dns-ipv6-addr IPv6 address to use for DNS requests, dot notation -D, --dump-header FILE Write the headers to FILE --egd-file FILE EGD socket path for random data (SSL) --engine ENGINE Crypto engine (use "--engine list" for list) (SSL) --expect100-timeout SECONDS How long to wait for 100-continue (H) -f, --fail Fail silently (no output at all) on HTTP errors (H) --false-start Enable TLS False Start. -F, --form CONTENT Specify HTTP multipart POST data (H) --form-string STRING Specify HTTP multipart POST data (H) --ftp-account DATA Account data string (F) --ftp-alternative-to-user COMMAND String to replace "USER [name]" (F) --ftp-create-dirs Create the remote dirs if not present (F) --ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F) --ftp-pasv Use PASV/EPSV instead of PORT (F) -P, --ftp-port ADR Use PORT with given address instead of PASV (F) --ftp-skip-pasv-ip Skip the IP address for PASV (F) --ftp-pret Send PRET before PASV (for drftpd) (F) --ftp-ssl-ccc Send CCC after authenticating (F) --ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F) --ftp-ssl-control Require SSL/TLS for FTP login, clear for transfer (F) -G, --get Send the -d data with a HTTP GET (H) -g, --globoff Disable URL sequences and ranges using {} and [] -H, --header LINE Pass custom header LINE to server (H) -I, --head Show document info only -h, --help This help text --hostpubmd5 MD5 Hex-encoded MD5 string of the host public key. (SSH) -0, --http1.0 Use HTTP 1.0 (H) --http1.1 Use HTTP 1.1 (H) --http2 Use HTTP 2 (H) --ignore-content-length Ignore the HTTP Content-Length header -i, --include Include protocol headers in the output (H/F) -k, --insecure Allow connections to SSL sites without certs (H) --interface INTERFACE Use network INTERFACE (or address) -4, --ipv4 Resolve name to IPv4 address -6, --ipv6 Resolve name to IPv6 address -j, --junk-session-cookies Ignore session cookies read from file (H) --keepalive-time SECONDS Wait SECONDS between keepalive probes --key KEY Private key file name (SSL/SSH) --key-type TYPE Private key file type (DER/PEM/ENG) (SSL) --krb LEVEL Enable Kerberos with security LEVEL (F) --libcurl FILE Dump libcurl equivalent code of this command line --limit-rate RATE Limit transfer speed to RATE -l, --list-only List only mode (F/POP3) --local-port RANGE Force use of RANGE for local port numbers -L, --location Follow redirects (H) --location-trusted Like '--location', and send auth to other hosts (H) --login-options OPTIONS Server login options (IMAP, POP3, SMTP) -M, --manual Display the full manual --mail-from FROM Mail from this address (SMTP) --mail-rcpt TO Mail to this/these addresses (SMTP) --mail-auth AUTH Originator address of the original email (SMTP) --max-filesize BYTES Maximum file size to download (H/F) --max-redirs NUM Maximum number of redirects allowed (H) -m, --max-time SECONDS Maximum time allowed for the transfer --metalink Process given URLs as metalink XML file --negotiate Use HTTP Negotiate (SPNEGO) authentication (H) -n, --netrc Must read .netrc for user name and password --netrc-optional Use either .netrc or URL; overrides -n --netrc-file FILE Specify FILE for netrc -:, --next Allows the following URL to use a separate set of options --no-alpn Disable the ALPN TLS extension (H) -N, --no-buffer Disable buffering of the output stream --no-keepalive Disable keepalive use on the connection --no-npn Disable the NPN TLS extension (H) --no-sessionid Disable SSL session-ID reusing (SSL) --noproxy List of hosts which do not use proxy --ntlm Use HTTP NTLM authentication (H) --oauth2-bearer TOKEN OAuth 2 Bearer Token (IMAP, POP3, SMTP) -o, --output FILE Write to FILE instead of stdout --pass PASS Pass phrase for the private key (SSL/SSH) --path-as-is Do not squash .. sequences in URL path --pinnedpubkey FILE/HASHES Public key to verify peer against (SSL) --post301 Do not switch to GET after following a 301 redirect (H) --post302 Do not switch to GET after following a 302 redirect (H) --post303 Do not switch to GET after following a 303 redirect (H) -#, --progress-bar Display transfer progress as a progress bar --proto PROTOCOLS Enable/disable PROTOCOLS --proto-default PROTOCOL Use PROTOCOL for any URL missing a scheme --proto-redir PROTOCOLS Enable/disable PROTOCOLS on redirect -x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port --proxy-anyauth Pick "any" proxy authentication method (H) --proxy-basic Use Basic authentication on the proxy (H) --proxy-digest Use Digest authentication on the proxy (H) --proxy-negotiate Use HTTP Negotiate (SPNEGO) authentication on the proxy (H) --proxy-ntlm Use NTLM authentication on the proxy (H) --proxy-service-name NAME SPNEGO proxy service name --service-name NAME SPNEGO service name -U, --proxy-user USER[:PASSWORD] Proxy user and password --proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port -p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT) --pubkey KEY Public key file name (SSH) -Q, --quote CMD Send command(s) to server before transfer (F/SFTP) --random-file FILE File for reading random data from (SSL) -r, --range RANGE Retrieve only the bytes within RANGE --raw Do HTTP "raw"; no transfer decoding (H) -e, --referer Referer URL (H) -J, --remote-header-name Use the header-provided filename (H) -O, --remote-name Write output to a file named as the remote file --remote-name-all Use the remote file name for all URLs -R, --remote-time Set the remote file's time on the local output -X, --request COMMAND Specify request command to use --resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS --retry NUM Retry request NUM times if transient problems occur --retry-delay SECONDS Wait SECONDS between retries --retry-max-time SECONDS Retry only within this period --sasl-ir Enable initial response in SASL authentication -S, --show-error Show error. With -s, make curl show errors when they occur -s, --silent Silent mode (don't output anything) --socks4 HOST[:PORT] SOCKS4 proxy on given host + port --socks4a HOST[:PORT] SOCKS4a proxy on given host + port --socks5 HOST[:PORT] SOCKS5 proxy on given host + port --socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy --socks5-gssapi-service NAME SOCKS5 proxy service name for GSS-API --socks5-gssapi-nec Compatibility with NEC SOCKS5 server -Y, --speed-limit RATE Stop transfers below RATE for 'speed-time' secs -y, --speed-time SECONDS Trigger 'speed-limit' abort after SECONDS (default: 30) --ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP) --ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP) -2, --sslv2 Use SSLv2 (SSL) -3, --sslv3 Use SSLv3 (SSL) --ssl-allow-beast Allow security flaw to improve interop (SSL) --ssl-no-revoke Disable cert revocation checks (WinSSL) --stderr FILE Where to redirect stderr (use "-" for stdout) --tcp-nodelay Use the TCP_NODELAY option -t, --telnet-option OPT=VAL Set telnet option --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512) -z, --time-cond TIME Transfer based on a time condition -1, --tlsv1 Use >= TLSv1 (SSL) --tlsv1.0 Use TLSv1.0 (SSL) --tlsv1.1 Use TLSv1.1 (SSL) --tlsv1.2 Use TLSv1.2 (SSL) --trace FILE Write a debug trace to FILE --trace-ascii FILE Like --trace, but without hex output --trace-time Add time stamps to trace/verbose output --tr-encoding Request compressed transfer encoding (H) -T, --upload-file FILE Transfer FILE to destination --url URL URL to work with -B, --use-ascii Use ASCII/text transfer -u, --user USER[:PASSWORD] Server user and password --tlsuser USER TLS username --tlspassword STRING TLS password --tlsauthtype STRING TLS authentication type (default: SRP) --unix-socket FILE Connect through this Unix domain socket -A, --user-agent STRING Send User-Agent STRING to server (H) -v, --verbose Make the operation more talkative -V, --version Show version number and quit -w, --write-out FORMAT Use output FORMAT after completion --xattr Store metadata in extended file attributes -q Disable .curlrc (must be first parameter)
0-创建git仓库(repository)git331
1-通过git init 命令把git331这个目录变成got可以管理的仓库
ls -ah 显示 单独ls没有显示的文件
~$ ls --help Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first -C list entries by columns --color[=WHEN] colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below -d, --directory list directories themselves, not their contents -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -ls --color -F, --classify append indicator (one of */=>@|) to entries --file-type likewise, except do not append '*' --format=WORD across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C --full-time like -l --time-style=full-iso -g like -l, but do not list owner --group-directories-first group directories before files; can be augmented with a --sort option, but any use of --sort=none (-U) disables grouping -G, --no-group in a long listing, don't print group names -h, --human-readable with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G) --si likewise, but use powers of 1000 not 1024 -H, --dereference-command-line follow symbolic links listed on the command line --dereference-command-line-symlink-to-dir follow each command line symbolic link that points to a directory --hide=PATTERN do not list implied entries matching shell PATTERN (overridden by -a or -A) --indicator-style=WORD append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F) -i, --inode print the index number of each file -I, --ignore=PATTERN do not list implied entries matching shell PATTERN -k, --kibibytes default to 1024-byte blocks for disk usage -l use a long listing format -L, --dereference when showing file information for a symbolic link, show information for the file the link references rather than for the link itself -m fill width with a comma separated list of entries -n, --numeric-uid-gid like -l, but list numeric user and group IDs -N, --literal print raw entry names (don't treat e.g. control characters specially) -o like -l, but do not list group information -p, --indicator-style=slash append / indicator to directories -q, --hide-control-chars print ? instead of nongraphic characters --show-control-chars show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal) -Q, --quote-name enclose entry names in double quotes --quoting-style=WORD use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape -r, --reverse reverse order while sorting -R, --recursive list subdirectories recursively -s, --size print the allocated size of each file, in blocks -S sort by file size, largest first --sort=WORD sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X) --time=WORD with -l, show time as WORD instead of default modification time: atime or access or use (-u); ctime or status (-c); also use specified time as sort key if --sort=time (newest first) --time-style=STYLE with -l, show times using style STYLE: full-iso, long-iso, iso, locale, or +FORMAT; FORMAT is interpreted like in 'date'; if FORMAT is FORMAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with 'posix-', STYLE takes effect only outside the POSIX locale -t sort by modification time, newest first -T, --tabsize=COLS assume tab stops at each COLS instead of 8 -u with -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time, newest first -U do not sort; list entries in directory order -v natural sort of (version) numbers within text -w, --width=COLS set output width to COLS. 0 means no limit -x list entries by lines instead of by columns -X sort alphabetically by entry extension -Z, --context print any security context of each file -1 list one file per line. Avoid '\n' with -q or -b --help display this help and exit --version output version information and exit The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it. Exit status: 0 if OK, 1 if minor problems (e.g., cannot access subdirectory), 2 if serious trouble (e.g., cannot access command-line argument). GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report ls translation bugs to <http://translationproject.org/team/> Full documentation at: <http://www.gnu.org/software/coreutils/ls> or available locally via: info '(coreutils) ls invocation'
w
~$ 当前账户的home目录
/$ 根目录
http://www.cnblogs.com/balaamwe/archive/2012/03/15/2397998.html
The Linux Command Line
William Shotts
Directories Found On Linux Systems
git 查看是否安装git/查看git命令
clear 清屏
cp /etc/passwd . 复制到当前目录
w
导航 pwd cd ls
pwd 显示当前工作目录 print working directory
与Windows相同,类UNIX操作系统,如Linux,文件是在树形结构的目录中进行组织的。
Windows系统中,每个存储设备都有一个独立的文件系统树。
类Unix系统中,无论多少驱动器或存储设备与计算机相连,通常只有一个文件系统树;根据系统管理员设置,
存储设备将会挂载到文件系统树的不同位置。
w
free 显示内存
w
df 磁盘驱动器当前可用空间
date 日期
cal 日历
#至$
exit
CRTL D
$ username
# 根用户 超级用户
w
ls
ll 以下快捷路径 也成立
cd / 去根目录
cd - 去上次目录
cd . 当前目录
cd .. 当前父目录
cd 将工作目录改为主目录
cd-username 将工作目录改为用户username的主目录
cd ../..
man 查普通命令
help .内置.
touch 新建文件 改变旧文件时间戳
runlevel 3 常用
history -d 145 删除
history -d -c全部
chkconfig sshd on 开机启动2345
w
zebra@ubuntu:~$ cat --help 用法:cat [选项]... [文件]... 将[文件]或标准输入组合输出到标准输出。 -A, --show-all 等于-vET -b, --number-nonblank 对非空输出行编号 -e 等于-vE -E, --show-ends 在每行结束处显示"$" -n, --number 对输出的所有行编号 -s, --squeeze-blank 不输出多行空行 -t 与-vT 等价 -T, --show-tabs 将跳格字符显示为^I -u (被忽略) -v, --show-nonprinting 使用^ 和M- 引用,除了LFD和 TAB 之外 --help 显示此帮助信息并退出 --version 显示版本信息并退出 如果没有指定文件,或者文件为"-",则从标准输入读取。 示例: cat f - g 先输出f 的内容,然后输出标准输入的内容,最后输出g 的内容。 cat 将标准输入的内容复制到标准输出。 请向bug-coreutils@gnu.org 报告cat 的错误 GNU coreutils 的主页:<http://www.gnu.org/software/coreutils/> GNU 软件一般性帮助:<http://www.gnu.org/gethelp/> 请向<http://translationproject.org/team/zh_CN.html> 报告cat 的翻译错误 要获取完整文档,请运行:info coreutils 'cat invocation'
cat /w/w/w.py -n cat 显示行号
Parse error: syntax error, unexpected 'new' (T_NEW) in /usr/share/php/PEAR/Frontend.php on line 91
well@well:~$ cat /usr/share/php/PEAR/Frontend.php
<?php
/**
* PEAR_Frontend, the singleton-based frontend for user input/output
*
* PHP versions 4 and 5
*
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Frontend.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
/**
* Include error handling
*/
//require_once 'PEAR.php';
/**
* Which user interface class is being used.
* @var string class name
*/
$GLOBALS['_PEAR_FRONTEND_CLASS'] = 'PEAR_Frontend_CLI';
/**
* Instance of $_PEAR_Command_uiclass.
* @var object
*/
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = null;
/**
* Singleton-based frontend for PEAR user input/output
*
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.9.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
class PEAR_Frontend extends PEAR
{
/**
* Retrieve the frontend object
* @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk
* @static
*/
function &singleton($type = null)
{
if ($type === null) {
if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) {
$a = false;
return $a;
}
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
}
$a = PEAR_Frontend::setFrontendClass($type);
return $a;
}
/**
* Set the frontend class that will be used by calls to {@link singleton()}
*
* Frontends are expected to conform to the PEAR naming standard of
* _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php)
* @param string $uiclass full class name
* @return PEAR_Frontend
* @static
*/
function &setFrontendClass($uiclass)
{
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
}
if (!class_exists($uiclass)) {
$file = str_replace('_', '/', $uiclass) . '.php';
if (PEAR_Frontend::isIncludeable($file)) {
include_once $file;
}
}
if (class_exists($uiclass)) {
$obj = &new $uiclass;
// quick test to see if this class implements a few of the most
// important frontend methods
if (is_a($obj, 'PEAR_Frontend')) {
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$obj;
$GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass;
return $obj;
}
$err = PEAR::raiseError("not a frontend class: $uiclass");
return $err;
}
$err = PEAR::raiseError("no such class: $uiclass");
return $err;
}
/**
* Set the frontend class that will be used by calls to {@link singleton()}
*
* Frontends are expected to be a descendant of PEAR_Frontend
* @param PEAR_Frontend
* @return PEAR_Frontend
* @static
*/
function &setFrontendObject($uiobject)
{
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], get_class($uiobject))) {
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
}
if (!is_a($uiobject, 'PEAR_Frontend')) {
$err = PEAR::raiseError('not a valid frontend class: (' .
get_class($uiobject) . ')');
return $err;
}
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$uiobject;
$GLOBALS['_PEAR_FRONTEND_CLASS'] = get_class($uiobject);
return $uiobject;
}
/**
* @param string $path relative or absolute include path
* @return boolean
* @static
*/
function isIncludeable($path)
{
if (file_exists($path) && is_readable($path)) {
return true;
}
$fp = @fopen($path, 'r', true);
if ($fp) {
fclose($fp);
return true;
}
return false;
}
/**
* @param PEAR_Config
*/
function setConfig(&$config)
{
}
/**
* This can be overridden to allow session-based temporary file management
*
* By default, all files are deleted at the end of a session. The web installer
* needs to be able to sustain a list over many sessions in order to support
* user interaction with install scripts
*/
function addTempFile($file)
{
$GLOBALS['_PEAR_Common_tempfiles'][] = $file;
}
/**
* Log an action
*
* @param string $msg the message to log
* @param boolean $append_crlf
* @return boolean true
* @abstract
*/
function log($msg, $append_crlf = true)
{
}
/**
* Run a post-installation script
*
* @param array $scripts array of post-install scripts
* @abstract
*/
function runPostinstallScripts(&$scripts)
{
}
/**
* Display human-friendly output formatted depending on the
* $command parameter.
*
* This should be able to handle basic output data with no command
* @param mixed $data data structure containing the information to display
* @param string $command command from which this method was called
* @abstract
*/
function outputData($data, $command = '_default')
{
}
/**
* Display a modal form dialog and return the given input
*
* A frontend that requires multiple requests to retrieve and process
* data must take these needs into account, and implement the request
* handling code.
* @param string $command command from which this method was called
* @param array $prompts associative array. keys are the input field names
* and values are the description
* @param array $types array of input field types (text, password,
* etc.) keys have to be the same like in $prompts
* @param array $defaults array of default values. again keys have
* to be the same like in $prompts. Do not depend
* on a default value being set.
* @return array input sent by the user
* @abstract
*/
function userDialog($command, $prompts, $types = array(), $defaults = array())
{
}
}well@well:~$ cat /usr/share/php/PEAR/Frontend.php -n
1 <?php
2 /**
3 * PEAR_Frontend, the singleton-based frontend for user input/output
4 *
5 * PHP versions 4 and 5
6 *
7 * @category pear
8 * @package PEAR
9 * @author Greg Beaver <cellog@php.net>
10 * @copyright 1997-2009 The Authors
11 * @license http://opensource.org/licenses/bsd-license.php New BSD License
12 * @version CVS: $Id: Frontend.php 313023 2011-07-06 19:17:11Z dufuz $
13 * @link http://pear.php.net/package/PEAR
14 * @since File available since Release 1.4.0a1
15 */
16
17 /**
18 * Include error handling
19 */
20 //require_once 'PEAR.php';
21
22 /**
23 * Which user interface class is being used.
24 * @var string class name
25 */
26 $GLOBALS['_PEAR_FRONTEND_CLASS'] = 'PEAR_Frontend_CLI';
27
28 /**
29 * Instance of $_PEAR_Command_uiclass.
30 * @var object
31 */
32 $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = null;
33
34 /**
35 * Singleton-based frontend for PEAR user input/output
36 *
37 * @category pear
38 * @package PEAR
39 * @author Greg Beaver <cellog@php.net>
40 * @copyright 1997-2009 The Authors
41 * @license http://opensource.org/licenses/bsd-license.php New BSD License
42 * @version Release: 1.9.4
43 * @link http://pear.php.net/package/PEAR
44 * @since Class available since Release 1.4.0a1
45 */
46 class PEAR_Frontend extends PEAR
47 {
48 /**
49 * Retrieve the frontend object
50 * @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk
51 * @static
52 */
53 function &singleton($type = null)
54 {
55 if ($type === null) {
56 if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) {
57 $a = false;
58 return $a;
59 }
60 return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
61 }
62
63 $a = PEAR_Frontend::setFrontendClass($type);
64 return $a;
65 }
66
67 /**
68 * Set the frontend class that will be used by calls to {@link singleton()}
69 *
70 * Frontends are expected to conform to the PEAR naming standard of
71 * _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php)
72 * @param string $uiclass full class name
73 * @return PEAR_Frontend
74 * @static
75 */
76 function &setFrontendClass($uiclass)
77 {
78 if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
79 is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
80 return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
81 }
82
83 if (!class_exists($uiclass)) {
84 $file = str_replace('_', '/', $uiclass) . '.php';
85 if (PEAR_Frontend::isIncludeable($file)) {
86 include_once $file;
87 }
88 }
89
90 if (class_exists($uiclass)) {
91 $obj = &new $uiclass;
92 // quick test to see if this class implements a few of the most
93 // important frontend methods
94 if (is_a($obj, 'PEAR_Frontend')) {
95 $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$obj;
96 $GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass;
97 return $obj;
98 }
99
100 $err = PEAR::raiseError("not a frontend class: $uiclass");
101 return $err;
102 }
103
104 $err = PEAR::raiseError("no such class: $uiclass");
105 return $err;
106 }
107
108 /**
109 * Set the frontend class that will be used by calls to {@link singleton()}
110 *
111 * Frontends are expected to be a descendant of PEAR_Frontend
112 * @param PEAR_Frontend
113 * @return PEAR_Frontend
114 * @static
115 */
116 function &setFrontendObject($uiobject)
117 {
118 if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
119 is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], get_class($uiobject))) {
120 return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
121 }
122
123 if (!is_a($uiobject, 'PEAR_Frontend')) {
124 $err = PEAR::raiseError('not a valid frontend class: (' .
125 get_class($uiobject) . ')');
126 return $err;
127 }
128
129 $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$uiobject;
130 $GLOBALS['_PEAR_FRONTEND_CLASS'] = get_class($uiobject);
131 return $uiobject;
132 }
133
134 /**
135 * @param string $path relative or absolute include path
136 * @return boolean
137 * @static
138 */
139 function isIncludeable($path)
140 {
141 if (file_exists($path) && is_readable($path)) {
142 return true;
143 }
144
145 $fp = @fopen($path, 'r', true);
146 if ($fp) {
147 fclose($fp);
148 return true;
149 }
150
151 return false;
152 }
153
154 /**
155 * @param PEAR_Config
156 */
157 function setConfig(&$config)
158 {
159 }
160
161 /**
162 * This can be overridden to allow session-based temporary file management
163 *
164 * By default, all files are deleted at the end of a session. The web installer
165 * needs to be able to sustain a list over many sessions in order to support
166 * user interaction with install scripts
167 */
168 function addTempFile($file)
169 {
170 $GLOBALS['_PEAR_Common_tempfiles'][] = $file;
171 }
172
173 /**
174 * Log an action
175 *
176 * @param string $msg the message to log
177 * @param boolean $append_crlf
178 * @return boolean true
179 * @abstract
180 */
181 function log($msg, $append_crlf = true)
182 {
183 }
184
185 /**
186 * Run a post-installation script
187 *
188 * @param array $scripts array of post-install scripts
189 * @abstract
190 */
191 function runPostinstallScripts(&$scripts)
192 {
193 }
194
195 /**
196 * Display human-friendly output formatted depending on the
197 * $command parameter.
198 *
199 * This should be able to handle basic output data with no command
200 * @param mixed $data data structure containing the information to display
201 * @param string $command command from which this method was called
202 * @abstract
203 */
204 function outputData($data, $command = '_default')
205 {
206 }
207
208 /**
209 * Display a modal form dialog and return the given input
210 *
211 * A frontend that requires multiple requests to retrieve and process
212 * data must take these needs into account, and implement the request
213 * handling code.
214 * @param string $command command from which this method was called
215 * @param array $prompts associative array. keys are the input field names
216 * and values are the description
217 * @param array $types array of input field types (text, password,
218 * etc.) keys have to be the same like in $prompts
219 * @param array $defaults array of default values. again keys have
220 * to be the same like in $prompts. Do not depend
221 * on a default value being set.
222 * @return array input sent by the user
223 * @abstract
224 */
225 function userDialog($command, $prompts, $types = array(), $defaults = array())
226 {
227 }
228 }well@well:~$
cd - 回上次文件目录
zebra@ubuntu:~$ sort --help 用法:sort [选项]... [文件]... 或:sort [选项]... --files0-from=F Write sorted concatenation of all FILE(s) to standard output. 必选参数对长短选项同时适用。 排序选项: -b, --ignore-leading-blanks 忽略前导的空白区域 -d, --dictionary-order 只考虑空白区域和字母字符 -f, --ignore-case 忽略字母大小写 -g, --general-numeric-sort compare according to general numerical value -i, --ignore-nonprinting consider only printable characters -M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC' -h, --human-numeric-sort 使用易读性数字(例如: 2K 1G) -n, --numeric-sort 根据字符串数值比较 -R, --random-sort 根据随机hash 排序 --random-source=文件 从指定文件中获得随机字节 -r, --reverse 逆序输出排序结果 --sort=WORD 按照WORD 指定的格式排序: 一般数字-g,高可读性-h,月份-M,数字-n, 随机-R,版本-V -V, --version-sort 在文本内进行自然版本排序 其他选项: --batch-size=NMERGE 一次最多合并NMERGE 个输入;如果输入更多 则使用临时文件 -c, --check, --check=diagnose-first 检查输入是否已排序,若已有序则不进行操作 -C, --check=quiet, --check=silent 类似-c,但不报告第一个无序行 --compress-program=程序 使用指定程序压缩临时文件;使用该程序 的-d 参数解压缩文件 --debug 为用于排序的行添加注释,并将有可能有问题的 用法输出到标准错误输出 --files0-from=文件 从指定文件读取以NUL 终止的名称,如果该文件被 指定为"-"则从标准输入读文件名 -k, --key=KEYDEF sort via a key; KEYDEF gives location and type -m, --merge merge already sorted files; do not sort -o, --output=文件 将结果写入到文件而非标准输出 -s, --stable 禁用last-resort 比较以稳定比较算法 -S, --buffer-size=大小 指定主内存缓存大小 -t, --field-separator=分隔符 使用指定的分隔符代替非空格到空格的转换 -T, --temporary-directory=目录 使用指定目录而非$TMPDIR 或/tmp 作为 临时目录,可用多个选项指定多个目录 --parallel=N 将同时运行的排序数改变为N -u, --unique 配合-c,严格校验排序;不配合-c,则只输出一次排序结果 -z, --zero-terminated 以0 字节而非新行作为行尾标志 --help 显示此帮助信息并退出 --version 显示版本信息并退出 KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where F is a field number and C a character position in the field; both are origin 1, and the stop position defaults to the line's end. If neither -t nor -b is in effect, characters in a field are counted from the beginning of the preceding whitespace. OPTS is one or more single-letter ordering options [bdfgiMhnRrV], which override global ordering options for that key. If no key is given, use the entire line as the key. SIZE may be followed by the following multiplicative suffixes: 内存使用率% 1%,b 1、K 1024 (默认),M、G、T、P、E、Z、Y 等依此类推。 如果不指定文件,或者文件为"-",则从标准输入读取数据。 *** 警告 *** 本地环境变量会影响排序结果。 如果希望以字节的自然值获得最传统的排序结果,请设置LC_ALL=C。 请向bug-coreutils@gnu.org 报告sort 的错误 GNU coreutils 的主页:<http://www.gnu.org/software/coreutils/> GNU 软件一般性帮助:<http://www.gnu.org/gethelp/> 请向<http://translationproject.org/team/zh_CN.html> 报告sort 的翻译错误 要获取完整文档,请运行:info coreutils 'sort invocation' zebra@ubuntu:~$
zebra@ubuntu:~$ sudo du --help 用法:du [选项]... [文件]... 或:du [选项]... --files0-from=F Summarize disk usage of each FILE, recursively for directories. 必选参数对长短选项同时适用。 -0, --null end each output line with 0 byte rather than newline -a, --all write counts for all files, not just directories --apparent-size print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like -B, --block-size=SIZE scale sizes by SIZE before printing them. E.g., '-BM' prints sizes in units of 1,048,576 bytes. See SIZE format below. -b, --bytes equivalent to '--apparent-size --block-size=1' -c, --total produce a grand total -D, --dereference-args dereference only symlinks that are listed on the command line -d, --max-depth=N print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize --files0-from=F summarize disk usage of the NUL-terminated file names specified in file F; If F is - then read names from standard input -H equivalent to --dereference-args (-D) -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) -k like --block-size=1K -L, --dereference dereference all symbolic links -l, --count-links count sizes many times if hard linked -m like --block-size=1M -P, --no-dereference don't follow any symbolic links (this is the default) -S, --separate-dirs do not include size of subdirectories --si like -h, but use powers of 1000 not 1024 -s, --summarize display only a total for each argument -t, --threshold=SIZE exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative --time show time of the last modification of any file in the directory, or any of its subdirectories --time=WORD show time as WORD instead of modification time: atime, access, use, ctime or status --time-style=STYLE show times using style STYLE: full-iso, long-iso, iso, +FORMAT FORMAT is interpreted like 'date' -X, --exclude-from=FILE exclude files that match any pattern in FILE --exclude=PATTERN exclude files that match PATTERN -x, --one-file-system skip directories on different file systems --help 显示此帮助信息并退出 --version 显示版本信息并退出 所显示的数值是来自 --block-size、DU_BLOCK_SIZE、BLOCK_SIZE 及 BLOCKSIZE 环境变量中第一个可用的 SIZE 单位。 否则,默认单位是 1024 字节(或是 512,若设定 POSIXLY_CORRECT 的话)。 SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000). 请向bug-coreutils@gnu.org 报告du 的错误 GNU coreutils 的主页:<http://www.gnu.org/software/coreutils/> GNU 软件一般性帮助:<http://www.gnu.org/gethelp/> 请向<http://translationproject.org/team/zh_CN.html> 报告du 的翻译错误 要获取完整文档,请运行:info coreutils 'du invocation'
sudo du -h --max-depth=2 /var/tmp/
sudo du -h --max-depth=2 /var/tmp/*
CRTL+c
退出“错误命令”
重置密码
passwd u1
new passwd