有用的linux命令笔记

date

cal [month] [year]

bc 计算器


mkdir -p /home/bird/ 连续建立文件夹
mkdir -m 711 test2 创建文件夹是的权限

mv -i 询问是非覆盖 -f 强制覆盖

硬链接 -l -s 符号连接 涉及i-node的相关知识
cp -a (-pdr) 文件的相关属性一起复制


chgrp -R group file
chown -R owner:group file
chmod -R 755 file

默认权限:umask 0022 002

创建文件夹的默认权限 rwxrwxrwx - umask = rwxr-xr-x
创建文件时的默认属性 rw-rw-rw- - umask = rw-r-r-


查找执行命令
which -a 全部显示

find . -name *.

type cd , type whois 判断linux的命令类型。

grep (git grep)
-A after
-B before
-C 默认前后各两行
--untracked 本地
--no-index dev
-w 只匹配单词


ln -s 软连接时, 尽量软连绝对路径。 以防执行权限问题

批量替换
%s/s+$//cg
%s/ //

编辑窗口修改权限
%! sudo tee %


zip压缩和解压
zip -r -l common.zip common/*
unzip -d common -o common.zip


重启apache
sudo /sbin/service httpd restart
sudo apachectl restart


查格式的时候很有用,不过不建议默认打开
" Show “invisible” characters
set lcs=tab:▸ ,trail:·,eol:¬,nbsp:_
set list
set nolist


I/O重定向

三个标准流: stdin、stdout、stderr

改变输入流
$ mycommand < infile

$ mycommand > outfile # 创建或覆盖outfile
$ mycommand >> outfile #附加到outfile原有内容的末端

$ mycommand > outfile 2> errorfile


管道

除了改变I/O来源喝目的地外,shell还提供了pipe(|) , 来让你将一个程序的输出链接到另一个程序的输入。

$ who | sort


rmdir 删除空目录

原文地址:https://www.cnblogs.com/mininice/p/3875318.html