cp 复制命令
cp(英文全拼:copy file)用于复制文件或目录,cp命令在复制时也可修改目录或文件名字
命令格式:cp [-选项] 源文件或目录 目标目录
常用选项:
-p 保留源文件属性不变(如:修改时间、归属关系、权限)
-r 复制目录(包含该目录下所有的子目录和文件)
#复制当前目录文件到/opt目录(相对路径方式复制)
[root@localhost ~]# cp t1 /opt/
[root@localhost ~]# ls /opt
rh student t1 test1 test2 test3 xx
#复制文件到/opt目录(绝对路径方式复制)
[root@localhost ~]# cp /root/t2 /opt
[root@localhost ~]# ls /opt
rh student t1 t2 test1 test2 test3 xx
#同时复制多个文件
[root@localhost ~]# cp t3 t4 /opt/
[root@localhost ~]# ls /opt
#创建目录
[root@localhost ~]# mkdir abc
#使用-r对目录执行复制
[root@localhost ~]# cp -r abc /opt
[root@localhost ~]# ls /opt
#同时复制多个目录
[root@localhost ~]# mkdir abc1 abc2 abc3
[root@localhost ~]# cp -r abc1 abc2 abc3 /opt
[root@localhost ~]# ls /opt
#复制hello文件到/opt并改名为hello.txt
[root@localhost ~]# cp hello /opt/hello.txt
[root@localhost ~]# ls /opt
#复制xxxx目录到/opt并改名xxoo
[root@localhost ~]# mkdir xxxx
[root@localhost ~]# cp -r xxxx /opt/xxoo
[root@localhost ~]# ls /opt
#使用“.”配合cp命令执行复制
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@localhost network-scripts]# cp /root/t1 .
[root@localhost network-scripts]# ls
#操持属性不变复制文件
[root@localhost ~]# cp -p anaconda-ks.cfg /opt
cp:是否覆盖"/opt/anaconda-ks.cfg"? y
[root@localhost ~]# ls -l /opt/anaconda-ks.cfg
-rw-------. 1 root root 1800 3月 13 17:34 /opt/anaconda-ks.cfg
#对比以上两个文件的详细属性信息(最后一次修改时间)
[root@localhost ~]# ls -l anaconda-ks.cfg
-rw-------. 1 root root 1800 3月 13 17:34 anaconda-ks.cfg
#这两个操作代表什么意思?
[root@localhost ~]# cp -r xxxx /mnt/oooo #拷贝并改名
[root@localhost ~]# cp -r xxxx /mnt/oooo #拷贝
mv 移动命令
mv(英文全拼:move file)用于移动文件或目录到其他位置,也可用于修改目录或文件名
命令格式:mv [-选项] 源文件... 目标路径
#移动当前路径hello文件到/mnt目录
[root@localhost ~]# mv hello /mnt
[root@localhost ~]# ls /mnt
hello home oooo test
#同时移动多个文件
[root@localhost ~]# mv t1 t2 t3 t4 /mnt
[root@localhost ~]# ls /mnt
hello home oooo student1 t1 t2 t3 t4 test
#移动/opt目录下文件到/mnt
root@localhost ~]# mv /opt/test1 /opt/test2 /opt/test3 /mnt/
[root@localhost ~]# ls /mnt
hello home oooo student1 t1 t2 t3 t4 test test1 test2 test3
#移动目录
[root@localhost ~]# mv student1 /mnt
[root@localhost ~]# ls /mnt
hello home oooo student1 test
#移动文件并改名
[root@localhost ~]# mv hello.txt /media/hello
[root@localhost ~]# ls /media/
hello
#移动目录并改名
[root@localhost ~]# mv test /media/testxx
[root@localhost ~]# ls /media/
hello testxx
cat 查看文件内容命令
cat (英文全拼:concatenate)命令用于查看文本文件内容
命令格式:cat [选项] 文件名
常用选项
-n #查看文件时以行号的形式显示文件内容
#查看文件内容
[root@localhost ~]# cat anaconda-ks.cfg
[root@localhost ~]# cat initial-setup-ks.cfg
[root@localhost ~]# cat /etc/hosts
#查看网卡文件内容,网卡配置文件
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32
...
NAME="ens32" //网卡名
UUID="16085f4c-f690-4058-b29e-d55c73387026"
DEVICE="ens32"
ONBOOT="yes"
IPADDR="192.168.0.50" //网卡IP地址
PREFIX="24" //子网掩码
GATEWAY="192.168.0.254" //网管
DNS1="114.114.114.114" //DNS
#查看当前系统用户基本信息文件内容
[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
#查看当前系统主机名配置文件内容
[root@localhost ~]# cat /etc/hostname
localhost.localdomain
#查看当前系统版本信息文件内容
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
#查看当前系统开机自动挂载配置文件内容
[root@localhost ~]# cat /etc/fstab
#查看系统组基本信息文件内容
[root@localhost ~]# cat /etc/group
#使用“-n”以行号形式显示文件内容
[root@localhost ~]# cat -n /etc/passwd
[root@localhost ~]# cat -n /etc/hostname
[root@localhost ~]# cat -n /etc/fstab
[root@localhost ~]# cat -n /etc/group
[root@localhost ~]# cat -n /etc/services
less命令
less工具是对文件的输出进行分页显示的工具,常用于查看内容量较大的文件
命令格式:less [-选项] 文件
常用选项:
-N #以行号形式显示文件内容
使用技巧:
键盘上下键逐行查看
pgdn :向下翻一页(Fn + 下键)
pgup :向上翻一页(Fn + 上键)
/字符串 :搜索指定字符串(n从上向下搜索,N从下向上搜索)
G:直接跳转到文件最后一行
gg:直接跳转到文件行首
q :退出
[root@localhost ~]# less -N /etc/services
head与tail命令
head命令:用来显示文件开头部分内容,默认显示文件开头10行内容
命令格式:head [选项] 参数
常用选项:
-n<行数> 指定显示的行数
[root@localhost ~]# head /etc/passwd
[root@localhost ~]# head /etc/fstab
[root@localhost ~]# head /etc/group
[root@localhost ~]# head /etc/hostname
[root@localhost ~]# head /etc/hosts
[root@localhost ~]# head /etc/sysconfig/network-scripts/ifcfg-ens32
#查看存放DNS配置文件信息
[root@localhost ~]# head /etc/resolv.conf
#使用-n指定显示文件前多少行内容
[root@localhost ~]# head -n 5 /etc/passwd
[root@localhost ~]# head -n 6 /etc/passwd
[root@localhost ~]# head -n 15 /etc/passwd
[root@localhost ~]# head -n 20 /etc/passwd
tail命令:用来显示文件末尾部分内容,默认显示文件末尾10行内容
命令格式:tail [选项] 参数
常用选项:-n<行数> 指定显示的行数 -f 动态显示
[root@localhost ~]# tail /etc/passwd
#使用“-n”指定显示文件末尾多少行内容
[root@localhost ~]# tail -n 5 /etc/passwd
[root@localhost ~]# tail -n 5 /etc/sysconfig/network-scripts/ifcfg-ens32
IPADDR="192.168.0.50"
PREFIX="24"
GATEWAY="192.168.0.254"
DNS1="114.114.114.114"
IPV6_PRIVACY="no"
#动态查看文件内容
[root@localhost ~]# touch t1
root@localhost ~]# tail -f t1
#另开一个终端向文件写入内容
[root@localhost ~]# echo 123 > t1
rm删除命令
rm(英文全拼:remove)命令用于删除文件或者目录。
命令格式:rm [-选项…] 目录或文件…
常用选项
-f 强制删除
-r 删除目录
“*”特殊字符:系统常用符号,用来代表任意所有字符
[root@localhost ~]# ls /opt
abc abc1 abc2 abc3 anaconda-ks.cfg hello.txt home rh student t1 t2 t3 t4 xx xxoo
[root@localhost ~]# ls /mnt
hello home oooo student1 t1 t2 t3 t4 test test1 test2 test3
#删除指定目录下文件
[root@localhost ~]# rm /opt/anaconda-ks.cfg
rm:是否删除普通文件 "/opt/anaconda-ks.cfg"?y #默认需要确认(y|n)
#查看文件是否被成功删除
[root@localhost ~]# ls /opt
abc abc1 abc2 abc3 hello.txt home rh student t1 t2 t3 t4 xx xxoo
[root@localhost ~]# rm /opt/hello.txt
rm:是否删除普通空文件 "/opt/hello.txt"?y
#同时删除目录下指定文件
[root@localhost ~]# rm /opt/t1 /opt/t2 /opt/t3 /opt/t4
rm:是否删除普通空文件 "/opt/t1"?y
rm:是否删除普通空文件 "/opt/t2"?y
rm:是否删除普通空文件 "/opt/t3"?y
rm:是否删除普通空文件 "/opt/t4"?y
#查看文件是否被成功删除
[root@localhost ~]# ls /opt
abc abc1 abc2 abc3 home rh student xx xxoo
#使用“-f”强制删除文件(无需确认,直接删除)
[root@localhost ~]# rm -f /mnt/hello
[root@localhost ~]# ls /mnt
home oooo student1 t1 t2 t3 t4 test test1 test2 test3
#同时强制删除多个文件
[root@localhost ~]# rm -f /mnt/t1 /mnt/t2 /mnt/t3 /mnt/t4
[root@localhost ~]# ls /mnt
#删除目录
[root@localhost ~]# rm -r /opt/abc
rm:是否删除目录 "/opt/abc"?y
[root@localhost ~]# ls /opt
abc1 abc2 abc3 home rh student xx xxoo
#同时删除多个目录
[root@localhost ~]# rm -r /opt/abc1 /opt/abc2 /opt/abc3
rm:是否删除目录 "/opt/abc1"?y
rm:是否删除目录 "/opt/abc2"?y
rm:是否删除目录 "/opt/abc3"?y
[root@localhost ~]# ls /opt
home rh student xx xxoo
#同时强制删除多个目录
[root@localhost ~]# rm -rf /opt/home /opt/student /opt/xx /opt/xxoo
[root@localhost ~]# ls /opt
rh
#创建目录与文件
[root@localhost ~]# touch /opt/t1
[root@localhost ~]# mkdir /opt/test
[root@localhost ~]# ls /opt
rh t1 test
#rm命令在删除目录时,包含改目录及目录下所有数据全部删除
[root@localhost ~]# rm -rf /opt/
[root@localhost ~]# ls /
[root@localhost ~]# ls /mnt
home oooo student1 test test1 test2 test3
#使用“*”通配任意所有字符,删除/mnt目录下所有数据
[root@localhost ~]# rm -rf /mnt/*
[root@localhost ~]# ls /mnt
软连接与硬连接
Linux中的链接文件类似于windows中的快捷方式
软连接特点:软连接可以跨分区,可以对目录进行链接,源文件删除后,链接文件不可用
软连接命令格式:ln -s 源文件路径 目标路径
注意:创建链接时一定要写目录或文件的绝对路径,哪怕是在当前路径下,也要写绝对路径·
[root@localhost ~]# touch hello.soft
[root@localhost ~]# ls
#创建软连接(必须要绝对路径创建)
[root@localhost ~]# ln -s /root/hello.soft /opt
[root@localhost ~]# ls /opt
#查看连接文件详细属性
[root@localhost ~]# ls -l /opt/hello.soft
lrwxrwxrwx. 1 root root 16 3月 21 14:28 /opt/hello.soft -> /root/hello.soft
#提示:链接文件的权限最终取决于源文件的权限
#普通用户验证
[lisi@localhost ~]$ ls /opt
hello.soft
[lisi@localhost ~]$ ls -l /opt/hello.soft
lrwxrwxrwx. 1 root root 16 3月 21 14:28 /opt/hello.soft -> /root/hello.soft
[lisi@localhost ~]$ cat /opt/hello.soft
cat: /opt/hello.soft: 权限不够
#提示:由于源文件存放于/root目录下,而普通用户对/root目录没有任何权限,所以普通用户无法查看
#删除源文件
[root@localhost ~]# rm -f /root/hello.soft
[root@localhost ~]# ls
#山粗源文件后,软链接文件不可用
[root@localhost ~]# ls -l /opt/hello.soft
lrwxrwxrwx. 1 root root 16 3月 21 14:28 /opt/hello.soft -> /root/hello.soft
#创建文件并创建软连接
[root@localhost ~]# touch hello.soft
[root@localhost ~]# ln -s /root/hello.soft /opt
[root@localhost ~]# ls -l /opt/hello.soft
lrwxrwxrwx. 1 root root 16 3月 21 14:39 /opt/hello.soft -> /root/hello.soft
#删除链接文件后,源文件仍然可用
[root@localhost ~]# rm -f /opt/hello.soft
[root@localhost ~]# ls
[root@localhost ~]# cat hello.soft
#对目录创建软连接
[root@localhost ~]# ln -s /root/test1 /opt/
[root@localhost ~]# ls -ld /opt/test1
lrwxrwxrwx. 1 root root 11 3月 21 14:44 /opt/test1 -> /root/test1
3创建链接时一定要写目录或文件的绝对路径,哪怕是在当前路径下,也要写绝对路径
[root@localhost ~]# ln -s hello.soft /opt
[root@localhost ~]# ls /opt
hello.soft test1
[root@localhost ~]# ls -l /opt/hello.soft
lrwxrwxrwx. 1 root root 10 3月 21 14:47 /opt/hello.soft -> hello.soft
硬链接特点:硬连接不可以跨分区,不可以对目录进行链接,源文件删除后,链接文件仍然可用
硬连接命令格式:ln 源文件路径 目标路径
#创建文件,并创建硬连接
[root@localhost ~]# touch hello.hard
[root@localhost ~]# ln /root/hello.hard /opt/
[root@localhost ~]# ls /opt
hello.hard hello.soft test1
#向硬连接的源文件写入内容
root@localhost ~]# echo 123 > /root/hello.hard
#查看源文件内容
[root@localhost ~]# cat /root/hello.hard
123
#查看链接文件内容,以同步更新
[root@localhost ~]# cat /opt/hello.hard
123
#向链接文件写入内容,查看源文件以同步更新
[root@localhost ~]# echo xx >> /opt/hello.hard
#擦看源文件,以同步更新
[root@localhost ~]# cat /root/hello.hard
123
xx
#硬连接文件的特点可以保持文件属性不发生改变
[root@localhost ~]# ls -l /root/hello.hard
-rw-r--r--. 2 root root 7 3月 21 14:55 /root/hello.hard
[root@localhost ~]# ls -l /opt/hello.hard
-rw-r--r--. 2 root root 7 3月 21 14:55 /opt/hello.hard
#并且硬连接文件的i节点号相同
[root@localhost ~]# ls -i /root/hello.hard
33711090 /root/hello.hard
[root@localhost ~]# ls -i /opt/hello.hard
33711090 /opt/hello.hard
#硬连接不允许对目录进行连接
root@localhost ~]# ln /root/test1 /opt
ln: "/root/test1": 不允许将硬链接指向目录
#硬连接源文件删除后,链接文件仍然可用
[root@localhost ~]# rm -f /root/hello.hard
[root@localhost ~]# cat /opt/hello.hard
123
xx
#向硬连接文件写入内容
[root@localhost ~]# echo abc >> /opt/hello.hard
[root@localhost ~]# cat /opt/hello.hard
123
xx
abc
#硬连接不允许跨分区
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 4.3G 0 rom
[root@localhost ~]# ln /root/hello.soft /boot
ln: 无法创建硬链接"/boot/hello.soft" => "/root/hello.soft": 无效的跨设备连接
内部命令与外部命令
什么是命令:用来实现某一种功能的指令或程序
命令的执行依赖于解释器(例如:/bin/bash),/etc/shells文件存放系统可用的shell的解释器程序
用户——解释器(shell外壳)——内核——调配计算机硬件
[root@localhost ~]# shell 终端 交互接口 用户接口
#搜索命令所在的绝对路径
[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
root@localhost ~]# ls /usr/bin/ls
/usr/bin/ls
#直接运行程序文件
[root@localhost ~]# /usr/bin/ls
[root@localhost ~]# /usr/bin/ls /opt
hello.hard hello.soft t1 test1 test.txt
[root@localhost ~]# which cat
[root@localhost ~]# ls /usr/bin/cat
/usr/bin/cat
[root@localhost ~]# which pwd
/usr/bin/pwd
Linux命令的分类
内部命令:bash程序自带的基本管理命令
外部命令:有独立的外部可执行程序文件命令
type 用于区别内部命令与外部命令
which 用于查找可以执行程序文件位置
[root@localhost opt]# type ls
[root@localhost opt]# type cat
[root@localhost opt]# type hash
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# hash
命中 命令
1 /usr/bin/cat
1 /usr/bin/ls
[root@localhost opt]# hash -r
[root@localhost opt]#
[root@localhost opt]# hash
hash: 哈希表为空
[root@localhost opt]# ls
hello.hard hello.soft t1 test1 test.txt
[root@localhost opt]# hash
命中 命令
1 /usr/sbin/ls
总结:
shell程序是用户和系统之间的接口,用于解释用户的命令
查找命令对应的程序文件所在位置:which 命令
shell程序大多数存放在/etc/shells文件中
系统默认使用的shell为/bin/bash
查看当前使用的shell:echo $SHELL
区别内部命令与外部命令的方式:typt 命令
shell程序查找可执行程序文件路径定义在$PATH环境变量中
shell查找的外部命令路径结果会记录到缓存的hash表中
help 命令帮助手册
help命令用于查看shell内部命令的帮助信息,包括使用方法、选项等…
命令格式:help [选项] 命令
#获取内部命令帮助信息
[root@localhost etc]# help cd
#help无法获取外部命令的帮助信息
root@localhost etc]# help ls
bash: help: 没有与 `ls' 匹配的帮助主题。尝试 `help help' 或者 `man -k ls' 或者 `info ls'。
[root@localhost etc]# type help
help 是 shell 内嵌
#获取help命令本身的帮助信息
[root@localhost etc]# help help
[root@localhost etc]# type cat
cat 是 /usr/bin/cat
[root@localhost etc]# help cat
bash: help: 没有与 `cat' 匹配的帮助主题。尝试 `help help' 或者 `man -k cat' 或者 `info cat'。
#查看命令帮助手册(命令自带)
[root@localhost etc]# cat --help
[root@localhost etc]# ls --help
man 获取命令帮助手册
man 命令用于查看系统命令的帮助信息,包括使用方法、选项、使用例子等…,对比--help ,man 输出的信息更加详细
命令格式:man [-选项] 命令
常用快捷操作
向下键向下移一行
向上键向上移一行
[Page Down] 向下翻一页
[Page Up] 向上翻一页
/关键字 #搜索关键字,配合n(向下查询)、N(向上查询)
q 退出
[root@localhost etc]# man ls
[root@localhost etc]# man cat
[root@localhost etc]# man touch
[root@localhost etc]# man mkdir
[root@localhost etc]# info ls
Linux系统的运行级别
Linux系统运行级别:linux系统有7个运行级别,不同的运行级别运行的程序和功能都不一样,而Linux系统默认是运行在一个标准的级别上,系统运行级别文件/etc/inittab文件
运行级别 0:所有进程被终止,机器将有序的停止,关机时系统处于这个运行级别(关机)
运行级别 1:单用户模式,(root用户进行系统维护),系统里运行的所有服务也都不会启动
运行级别 2:多用户模式(网络文件系统NFS服务没有被启动)
运行级别 3:完全多用户模式,(有NFS网络文件系统)标准的运行级别,命令行模式
运行级别 4:系统未使用
运行级别 5:登录后,进入带GUI的图形化界面,标准的运行级别
运行级别 6:系统正常关闭并重启
#查看当前系统运行级别
[root@localhost etc]# runlevel
N 5
#解释;当前系统处于的运行级别
#解释:N代表没有从任何级别跳转过来
#切换系统运行级别
[root@localhost ~]# init N
#查看运行级别文件内容
[root@localhost ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3 #运行级别3
# graphical.target: analogous to runlevel 5 #运行级别5
#
# To view current default target, run:
# systemctl get-default #查看当前系统默认的运行级别
#
# To set a default target, run:
# systemctl set-default TARGET.target #修改当前系统默认运行级别
#查看默认运行级别
[root@localhost ~]# systemctl get-default
graphical.target #默认运行级别为5
#修改默认运行级别为3
[root@localhost ~]# systemctl set-default multi-user.target
[root@localhost ~]# systemctl get-default
multi-user.target
#修改默认运行级别为5
[root@localhost ~]# systemctl set-default graphical.target
[root@localhost ~]# systemctl get-default
graphical.target
关机与重启
linux下常用的关机命令有:shutdown、halt、poweroff、init
init 0 关机
halt #立刻关机
poweroff #立刻关机 (记这个)
shutdown –h now #立刻关机
shutdown -h 10 #10分钟后自动关机
[root@localhost ~]# poweroff
重启命令:reboot shutdown
reboot #立刻重启 (记这个)
shutdown -r now #立刻重启
shutdown -r 10 #过十分钟后重启
[root@localhost ~]# reboot
课后练习
1.请在/tmp目录下创建student目录,并在student目录下同时创建t1、t2、t3文件
mkdir /tmp/student
cd /tmp/student/
touch t1 t2 t3
touch /tmp/student/t1 /tmp/student/t2 /tmp/student/t3
2.请在/tmp目录下递归创建test1/test2/test3目录
mkdir -p /tmp/test1/test2/test3
3.切换到/tmp/test1/test2/test3目录下,并打印(查看)当前所在目录
cd /tmp/test1/test2/test3
pwd
4.请同时在/opt、/media目录下创建upload文件
touch /opt/upload /media/upload
5.请将/opt目录下的upload文件移动至/tmp/test1/test2/test3目录下,并改名为upload.bak
mv /opt/upload /tmp/test/1/test/2/test3/upload.bak
6.请将/etc/passwd文件拷贝至/opt目录下,改名为passwd.bak,并保持属性不变
cp -p /etc/passwd /opt/passwd.bak
7.请将/etc/fstab文件拷贝至/opt目录下,并改名为fstab.bak
cp -p /etc/fstab /opt/fstab.bak
8.请将/etc/sysconfig/network-scripts/ifcfg-ens32 文件拷贝至/opt目录下,并改名为ens32.bak
cp /etc/sysconfig/network-scripts/ifcfg-ens32 /opt/ens32.bak
9.请删除/etc/yum.repos.d/目录下所有内容
rm -rf /etc/yum.repos.d/*
10.请在/etc/yum.repos.d/目录下创建local.repo文件
touch /etc/yum.repos.d/local.repo
11.请查看/etc/sysconfig/network-scripts/ifcfg-ens32文件末尾5行内容
tail -5 /etc/sysconfig/network-scripts/ifcfg-ens32
tail -n 5 /etc/sysconfig/network-scripts/ifcfg-ens32
12.请查看/etc/passwd文件第1行内容
head -n 1 /etc/passwd
head -1 /etc/passwd
13.请查看/etc/hostname文件内容
cat /etc/hostname
14.请查看/etc/hosts文件内容
cat /etc/hosts
15.请说出软连接与硬连接的特点
软连接:可以跨分区,可以对目录链接,源文件删除后链接文件不可用
硬连接:不可以跨分区,不可以对目录进行连接,源文件删除后,链接文件以然可用
16.请在/opt目录下创建hello.soft文件,并创建软连接到/tmp目录下
touch /opt/hello.soft
ln -s /opt/hello.soft /tmp
17.请在/opt目录下创建hello.hard文件,并创建硬连接到/tmp目录下,并查看连接文件详细属性
touch /opt/hello.hard
ln /opt/hello.hard /tmp
18.如何获取ls命令的帮助信息?
man ls
ls --help
19.请说出Linux系统的运行级别
0:关机
1:单用户模式
2:多用户模式(没有NFS)
3:完全多用户模式,标准运行级别
4:保留
5:带GUI图形化界面,标准的运行级别
6:系统关闭并重启
20.如何重启Linux系统?
reboot
init 6