Linux基本命令
1-1、man 命令
man命令是Linux下的帮助指令,通过man指令可以查看Linux中的各种指令帮助的信息。用法如下:
输入man uname 就会进入uname的帮助手册章节里,按q退出帮助手册
[[email protected] ~]# man uname
================================================================
UNAME(1) User Commands UNAME(1)
NAME
uname - print system information
SYNOPSIS
uname [OPTION]…
DESCRIPTION
Print certain system information. With no OPTION, same as -s.
-a, --all
print all information, in the following order, except omit -p
and -i if unknown:
-s, --kernel-name
print the kernel name
-n, --nodename
print the network node hostname
-r, --kernel-release
print the kernel release
-v, --kernel-version
print the kernel version
-m, --machine
print the machine hardware name
-p, --processor
print the processor type or "unknown"
-i, --hardware-platform
print the hardware platform or "unknown"
-o, --operating-system
print the operating system
--help display this help and exit
--version
output version information and exit
GNU coreutils online help: http://www.gnu.org/software/coreutils/
Report uname translation bugs to http://translationproject.org/team/
AUTHOR
Written by David MacKenzie.
COPYRIGHT
Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
arch(1), uname(2)
The full documentation for uname is maintained as a Texinfo manual. If
the info and uname programs are properly installed at your site, the
command
info coreutils 'uname invocation'
should give you access to the complete manual.
GNU coreutils 8.22 September 2015 UNAME(1)
================================================================
uname [OPTION]… (一般指令后面可加参数[option],也可不加)
命令 参数
[[email protected] ~]# uname
Linux
[[email protected] ~]# uname -a //查看所有信息
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]# uname -r //查看发行的版本号
3.10.0-327.el7.x86_64
[[email protected] ~]#
/* 3.10.0-327 内核版本
- 主版本 3
- 次版本 10
- 修订号 0-327
- el7 适合企业版本7 RHEL7 Centos7
- x86 个人PC
- 64 cpu类型 64 amd64
*/
================================================================
路径:
绝对路径
以正斜线“/”开头
描述道文件位置的完整说明
任何时候你想指定文件名的时候都可以使用
cd /tmp/aa
相对路径
不以正斜线开头
制定相对于你的当前工作目录而言的位置
可以使用做制定文件名的快捷方式
相对路径:cd …/tmp
====================================
ls 查看目录或文件
ls 不加参数,默认是查看当前路径下目录内容
[[email protected] ~]# ls //查看当前路径下目录内容
anaconda-ks.cfg include lib 公共 视频 文档 音乐
bin initial-setup-ks.cfg minicom.log 模板 图片 下载 桌面
[[email protected] ~]# ls ./ //查看当前路径下目录内容
anaconda-ks.cfg include lib 公共 视频 文档 音乐
bin initial-setup-ks.cfg minicom.log 模板 图片 下载 桌面
[[email protected] ~]# ls anaconda-ks.cfg //查看当前路径下文件anaconda-ks.cfg
anaconda-ks.cfg
[[email protected] ~]# ls -a //查看当前路径下目录所有内容,包括以点开头的隐藏文件
ls ./ 查看当前目录包含哪里些内容
ls . . / 查看上层目录包含哪里些内容
ls -a 查看当前目录中所有的文件,包括以点开头的隐藏文件
ls -l 详细方式列出目录中的内容 ( ll 效果和 ls -l 一样)
ls -i 查看版本号
ls -R 递归列出目录下的文件
ls -d 查看目录本身
================================================================
pwd查看当前所在的工作目录
echo $? 查看上一个命令是否正确执行
================================================================
cd [path] //改变当前工作目录
cd 直接回到家目录
cd ~ 直接回到家目录
cd . . 返回上级目录
cd . 回到当前目录
cd - 在两个目录之间切换
================================================================
touch 创建一个文件
touch {1,2,3}aa{4,5,6}bb{7,8,9} --创建27个空文件
touch “{1,2,3}aa{4,5,6}bb{7,8,9}” --创建1个空文件
touch 2 3 --创建一个2,同时又创建一个3
touch ‘2 3’ --创建一个 2空格3 的文件
touch {4…10} --创建4到10
touch {a…z}
touch {A…Z}
stat [文件或者目录] 显示文件时间戳 (访问时间、修改时间、文件属性改变时间)
================================================================
mkdir 创建目录
mkdir xxx 创建一个目录
mkdir -p xxx/yyy/zzz 创建多级目录(目录xxx/yyy可不存在,会逐级创建)
rmdir 删除空目录
rmdir xxx
rmdir -p xxx/yyy/zzz
================================================================
cp 拷贝文件或者目录
cp 源文件 目标文件
cp /dir1/file1 /dir2/
cp /dir1/file1 /dir2/file2
cp -a /dir1/file1 /dir2 --从dir1目录拷贝文件至2,过程中文件中所有的属性不变
cp -r /dir1/ /dir2 --递归拷贝(拷贝目录)
\cp /dir1/file1 /dir2/file1 如果有重名的不讯问是否覆盖,直接覆盖
================================================================
mv 移动文件或者目录,给文件后者目录改名
mv /dir1/file1 /dir2
mv /dir1/file1 /dir2/file2 --移动并改名
mv /dir1/file1 /dir1/file2 --改名字
================================================================
rm 删除文件或者目录
rm /a.txt
rm /a/
rm -f /a/ 不询问直接删除
rm -rf /a/ /a.txt 不询问直接删除目录及其所有内容
rm 在root用户下是管理员权限,可以删除任何文件,注意操作规范
危险操作,切勿模仿:
rm -rf / 是删除根分区,不可这样操作,会毁掉系统
================================================================