您的位置:首页 > 运维架构 > Linux

linux基本命令

2017-03-17 19:41 218 查看
linux常用基本命令整理

1 -cd 切换目录
cd 进入用户主目录;
cd ~ 进入用户主目录;
cd - 返回进入此目录之前所在的目录;
cd .. 返回上级目录(若当前目录为“/“,则执行完后还在“/";".."为上级目录的意 思);
cd ../.. 返回上两级目录;
cd !$ 把上个命令的参数作为cd参数使用。
2 -pwd 显示目前所在的工作目录

3 -ls 查看当前目录
在Linux文件系统中,所有以点(.)开始的文件名都是隐藏文件(区分ls -a与ls -A)
-d:不显示目录内容,而只显示该目录名
-l --long:以长格式显示文件的详细属性
4 -mkdir 创建目录

5 -rmdir 删除空目录(只能删除空目录)

6 -rm 删除目录 文件

7 -touch 创建空文件(注意与mkdir的区别)

8 -stat 显示指定文件的详细信息,比ls更详细
-c(较为重要)

9 -nano
用法: nano [选项] [[+行,列] 文件名]... ^托字符 表示ctrl键 保存文档 的内容 10 cat -E -n -b ctrl+d退出
用法:cat [选项]...[文件]... -b, --number-nonblank 对非空输出行编号 -s, --squeeze-blank 不输出多行空行,合并空白行为一行 -E, --show-ends 在每行结束处显示"$" -n,--number 对输出的所有行编号 11 tac cat的逆序输出
用法:tac [选项]...[文件].. 12 head 默认显示前十行
用法:head [选项]... [文件]... -c, --bytes=[-]K printthe first K bytes of each file;
withthe leading '-', print all but the last
Kbytes of each file
-n, --lines=[-]K print the first K lines instead of thefirst 10;
with the leading'-', print all but the last 13 tail 监控小文件的变化情况
用法:tail [选项]... [文件]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the filename.
-f, --follow[={name|descriptor}]
output appended data as the file grows; an absent option argument means'descriptor' 使用ctrl+c 退出

14 more less(分页显示)

日期时间

硬件时钟 hwclock clock
-s
-k
--set --date

系统时钟 date(内核模拟)
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMD‐
Dhhmm[[CC]YY][.ss]] 例如:date"031211092017"
[root@localhost 桌面]# date -s"2017/11/11 11:11:11"
[root@localhost 桌面]# date -s"2017-11-11 11:11:11" %F 完整日期格式,等价于 %Y-%m-%d%D 按月计的日期;等于%m/%d/%y%s 自UTC 时间 1970-01-01 00:00:00 以来所经过的秒数 [root@localhost 桌面]# date +%s

15 cal -y

关机

16 Halt17 Shutdown SYNOPSIS shutdown [OPTIONS...] [TIME] [WALL...] 绝对时间和相对时间 -k Do not halt, power-off, reboot, justwrite wall message.-c Cancel a pending shutdown. This may be usedcancel the effect of an invocation ofshutdown with a time argument that is not"+0" or "now"注销(与windows有差别)

18 exit : 19 logout 20 ctrl+d 拷贝

21 cp 用法:cp [选项]... 源文件 目标文件(单元复制 可改名)  或:cp [选项]... 源文件... 目录(多元复制)  或:cp [选项]... -t 目录 源文件...(一般不用) Copy SOURCE to DEST, or multiple SOURCE(s) toDIRECTORY.
选项 [root@localhost 桌面]# echo $? -d:-p:在复制文件时能够保留文件的属性和所有 -r/R: -a:相当于选项的组合

22 mv
用法:mv [选项]... [-T] 源文件 目标文件  或:mv [选项]... 源文件... 目录  或:mv [选项]... -t 目录 源文件... Rename SOURCE to DEST, or move SOURCE(s) toDIRECTORY.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 基本命令