Linux命令(未完.......)
1.cp 复制命令
2.mv 移动命令
3.mkdir 创建文件夹
-p
3.rm 删除
-rf 不带询问删除
4.touch 创建文件
5.rmdir 删除文件夹命令
6.ls
-hil i:inode
-a
7.tail 查看文件尾部字符
-8 显示尾部后八行,默认是10行
-n 8 显示尾部第8行,默认是10行
-f 追寻文件尾部的变化
-F 如果文件不存在,也会进行追加文件尾部的变化
8.alias 别名
unalias 取消别名
9.head 查看文件头部字符
-8 显示头部后八行,默认是10行
-n 8 显示头部第8行,默认是10行
10.cat 查看文件
11.stat 显示文件或文件系统的状态
-c 格式
%a Access rights in octal 八进制
%A Access rights in human readable form
%b Number of blocks allocated (see %B)
%B The size in bytes of each block reported
by %b
12.tr 转换或更改文件中的字符
tr a-z A-z 将文件内容转换成大写
例:cut filename | tr a-z A-z
13.cut 劫取文本内容的指定范围
-b, --bytes=LIST 列出指定的字节数或范围
select only these bytes
-c, --characters=LIST 列出指定的字符数或范围
select only these characters
-d, --delimiter=DELIM 分隔符
use DELIM instead of TAB for field delimiter
-f, --fields=LIST 列出范围
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified
-s, --only-delimited 不打印没有分隔符的行
do not print lines not containing delimiters
例:cut -f 1 -d : /etc/passwd
14.echo
-n 不换行
-e 识别转义字符
\b backspace 退格
\n new line 回车
\t horizontal tab tab
15:date 显示时间
-s 修改时间
-d,--date=字符串 显示指定字符串所描述的时间,而非当前时间
[root@root ~]# date +%F-%H -d "+24hour"
2017-08-08-13
%y last two digits of year (00..99)
%Y year
%F full date; same as %Y-%m-%d
%T time; same as %H:%M:%S
%w 一星期中的第几日(0-6),0 代表周一
16.chmod 修改文件的权限
-R, --recursive 以递归方式更改所有的文件及子目录
17.umask Linux系统默认权限
umask 051 修改权限
18.find
-perm 权限数值
-name 文件名
-type
b block (buffered) special
c character (unbuffered) special
d directory 目录
p named pipe (FIFO)
f regular file 文件
l symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken. If
you want to search for symbolic links when -L is in effect, use -xtype.
s socket
D door (Solaris)
19.awk 三剑客(取列)
awk -F "/" '{print $0,$1,$NF-1,$NF}' filename
-F 设置分隔符
-$0 整行
-$1 第一列
-$NF-1 倒数第二列
-$NF 倒数第一列
20.grep 三剑客老二(擅长过滤)
-o 精确匹配
-v 反向匹配
-i 忽略大小写
-n 显示行号
-E 扩展正则表达式 = egrep
21.sed 三剑客老三(擅长取行)
-n 取消默认输出
-r extended regexd
-i 替换修改的内容
21.useradd(usermod) 添加(修改)用户
-e expire_date
帐 号 终 止 日 期 。 日 期 的 指 定 格 式
为 MM/DD/YY
2.查看用户过期信息
chage -l kay
-u uid
-g group
-G 多个group
-s 登陆shell
-M 不创建家目录
-D
修改/etc/default/useradd中配置
当 -D 选 项 出 现 时 , useradd 秀 出 现 在 的 预
设 值 , 或 是 藉由命 令 列 的 方 式 更 新 预 设
值 。可 用 选 项 为 ∶
-b default_home
定 义 使 用 者 所 属 目 录 的 前 一 个 目
录 。使 用 者 名 称 会 附 加 在
default_home 后 面用 来 建 立 新 使 用 者
的 目 录 。当 然 使 用 -d 后 则 此 选 项 无
效 。
-e default_expire_date
使 用 者 帐 号 停 止 日 期 。
-f default_inactive
帐 号 过 期 几 日 后 停 权 。
-g default_group
新 帐 号 起 始 群 组 名 或 ID 。群 组 名 须
为 现 有 存 在 的 名 称 。群 组 I D 也 须
为 现 有 存 在 的 群 组 。
-s default_shell
使 用 者 登 入 后 使 用 的 shell 名 称 。往
后 新 加 入 的 帐 号 都 将 使 用 此 shell.
userdel -r 删除用户
22.groupadd 添加组名
-g gid 指定gid
groupdel -r 删除组名
23.chmod 修改文件或目录权限
-R 递归修改权限
24.chown 修改文件或目录的拥有者或组
-R 递归修改权限
25.chgrp 修改文件或目录所属的组
-R 递归修改权限
26.chattr 改变文件的属性
-R 递归修改权限
+i A file with the ‘i’ attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
lsattr 查看文件属性
26.tar 压缩
tar zcvf filename.tar.gz filename
-v 显示详细信息
-c 创建一个新归档
-z 通过gzip命令打包文件
-f 制定打包文件名和位置
解压缩
-x 解压缩
-C 切换指定目录
tar -xvf filename.tar.gz -C ./kay
27.zip
28.uzip
29.gzip
30.df 显示文件系统的使用状况
-i inode
-m 以MB来显示目前文件系统的使用状况
31.ps -ef 显示所有账号的进程
32.dumpe2fs
dd 转换并格式化文件
dd if=/dev/zero of=/opt/sbd1 bs=4096 count=100
bs=BYTES
read and write BYTES bytes at a time (also
see ibs=,obs=)
cbs=BYTES
convert BYTES bytes at a time
conv=CONVS
convert the file as per the comma separated
symbol list
count=BLOCKS
copy only BLOCKS input blocks
ibs=BYTES
read BYTES bytes at a time (default: 512)
if=FILE
read from FILE instead of stdin
iflag=FLAGS
read as per the comma separated symbol list
obs=BYTES
write BYTES bytes at a time (default: 512)
of=FILE
write to FILE instead of stdout
33.fdisk
-l
mkfs - build a Linux file system 格式化文件系统
mkfs -t ext /dev/sdb
-t Specifies the type of file system to be built. If not specified, the default file system type (currently ext2) is used
mke2fs 格式化为ext2或ext3的文件系统
-j 格式化为ext3的文件系统
tune2fs 调整文件系统的参数
-c 挂载多少次后运行硬盘检查命令
tune2fs -c -1 /dev/sdb
34.mount 挂载文件系统
-t, --types vfstype 文件系统类型
-o, --options opts
fdisk -l
mkfs -t ext /dev/sdb
tune2fs -c -1 /dev/sdb
mount -t ext4 -o loop,defaults /dev/sdc /app/log
35.ln 软连接
-s 硬链接
36.passwd update user’s authentication tokens 修改密码
1.参数
--stdin
[root@root ~]# echo 123456|passwd --stdin kay7
更改用户 kay7 的密码 。
passwd: 所有的身份验证令牌已经成功更新。
37.chage change user password expiry information
1.参数
-l, --list show account aging information
38.w Show who is logged on and what they are doing.
who Show who is logged on
last, lastb - show listing of last logged in users
lastlog - reports the most recent login of all users or of a given user
/var/log/lastlog file
groups - print the groups a user is in
39.su; sudo ;visudo
1.su 切换用户
1.参数:
-, -l, --login
make the shell a login shell 切换到loginuser的环境变量
-c, --command=COMMAND
pass a single COMMAND to the shell with -c
[root@root ~]# su - kay -c "touch a.txt"
[root@root ~]# ls -l /home/kay/a.txt
-rw-rw-r--. 1 kay kay 0 8月 13 14:36 /home/kay/a.txt
2.sudo 让普通用户拥有root或其他用户权限
1.参数
-l 显示当前用户可以使用或禁止的命令
-K 删除时间戳,下个sudo命令要输入命令;
3.visudo edit the sudoers file
1.参数:
-c 检查语法
40.rpm - RPM Package Manager
1.参数
-qa
41.DNS域名解析命令:
42.nc
43.lsof
-i
44.free - Display amount of free and used memory in the system
45.exportfs -rv
46.mount
umount
-lf
47.showmount -e