标签:多级目录 ati 条件 system png 删库 快速 ldo 键盘
1. 系统命令提示组成
[root@oldboyedu ~]# --- 命令提示符
作用:只有在命令提示符后面输入命令才有效果
组成:
1) 登录用户的信息
2) @ 分隔符
3) 主机名信息
4) 当前所在系统的目录路径信息
2. 系统命令是有语法规范
命令 参数 文件/路径
干的事情 做事情的条件 做事情结果
systemctl start/stop network
# PS:命令参数文件之间要有空格分隔
3. 系统目录结构简介
linux目录结构一切从根开始
绝对路径:从根开始进行查找数据
缺点:寻找数据更慢
优点:准确性高
相对路径:从当前路径位置查找数据
优点:寻找数据更快
缺点:准确性低
分类记忆
补充说明:linux是多用户的系统 windows是多用户的系统(收费 5用户=5000 10用户=10000)
# 系统关机:
shutdown
[root@oldboyedu oldboy04]# shutdown
Shutdown scheduled for Fri 2019-03-29 11:36:45 CST, use ‘shutdown -c‘ to cancel.
定义一个关机方案=定义什么时间进行关机,使用shutdown -c 取消关机计划
[root@oldboyedu oldboy04]#
Broadcast message from root@oldboyedu.com (Fri 2019-03-29 11:35:45 CST):
会将关机信息广播给所有关机主机的用户
The system is going down for power-off at Fri 2019-03-29 11:36:45 CST!
准备什么时间真正进行关机
shutdown -h 5 --- 指定5分钟后关机
# 系统重启:
[root@oldboyedu ~]# shutdown -r 5
Shutdown scheduled for Fri 2019-03-29 12:02:41 CST, use ‘shutdown -c‘ to cancel.
[root@oldboyedu ~]#
Broadcast message from root@oldboyedu.com (Fri 2019-03-29 11:57:41 CST):
The system is going down for reboot at Fri 2019-03-29 12:02:41 CST!
reboot
ls == list(列表)
# 检查文件是否存在
[root@oldboyedu ~]# ls /etc/hosts
/etc/hosts
[root@oldboyedu ~]# ls /etc/hosts01
ls: cannot access /etc/hosts01: No such file or directory
# 检查目录是否存在
[root@oldboyedu ~]# ls /etc/
abrt environment krb5.conf.d pki shadow
adjtime ethertypes latrace.d plymouth shadow-
aliases exports ld.so.cache pm shells
aliases.db favicon.png ld.so.conf polkit-1 skel
alternatives filesystems ld.so.conf.d popt.d sos.conf
[root@oldboyedu ~]# ls -d /oldboy 有针对查看目录信息
/oldboy
# make directory(制造目录)==mkdir
-p # 递归创建具有嵌套叠层关系的文件目录
[root@oldboyedu ~]# mkdir /oldboy
[root@oldboyedu ~]# mkdir -p /oldboy/oldboy01/oldboy02/oldboy03/oldboy04 -- 创建多级目录
[root@oldboyedu ~]# ls -d /oldboy/oldboy01/oldboy02/oldboy03/oldboy04
/oldboy/oldboy01/oldboy02/oldboy03/oldboy04
# change directory(改变目录)==cd
# 绝对路径:
[root@oldboyedu oldboy]# cd /oldboy/oldboy01/oldboy02/oldboy03/oldboy04/
# 相对路径:
[root@oldboyedu oldboy03]# cd oldboy04/ 当对于当前路径找他下面的路径信息
[root@oldboyedu oldboy04]# cd .. 返回到上一级目录
[root@oldboyedu oldboy04]# cd ../../ 返回到上两级目录
[root@oldboyedu oldboy04]# cd ../oldboy05
# 两个目录之间快速切换
[root@oldboyedu oldboy05]# cd /tmp/
[root@oldboyedu tmp]# cd -
/oldboy/oldboy01/oldboy02/oldboy03/oldboy05
[root@oldboyedu oldboy05]# cd -
/tmp
# 快速返回到家目录
[root@oldboyedu oldboy05]# cd ~
[root@oldboyedu ~]# cd -
/oldboy/oldboy01/oldboy02/oldboy03/oldboy05
[root@oldboyedu oldboy05]# cd
[root@oldboyedu ~]#
# print work directory(显示当前路径)==pwd
[root@oldboyedu oldboy05]# pwd
/oldboy/oldboy01/oldboy02/oldboy03/oldboy05
[root@oldboyedu oldboy05]# cd /oldboy/oldboy01/
[root@oldboyedu oldboy01]# pwd
/oldboy/oldboy01
[root@oldboyedu oldboy01]# cd /tmp/
[root@oldboyedu tmp]# pwd
/tmp
manual --> man mkdir
man 查看的命令
NAME 命令作用说明
mkdir - make directories
SYNOPSIS 命令使用方法
mkdir [OPTION]... DIRECTORY...
DESCRIPTION 命令的参数解释
-p, --parents
no error if existing, make parent directories as needed
-l # 查看文件的属性、大小等详细信息
-d # 查看目录属性信息
-a # 查看全部文件(包括隐藏文件)
[root@oldboyedu oldboy02]# ls /etc/services
/etc/services
[root@oldboyedu oldboy02]# ls -l /etc/services --- 查看文件数据的详细信息
-rw-r--r--. 1 root root 670293 Jun 7 2013 /etc/services
touch /oldboy/oldboy.txt
[root@oldboyedu oldboy02]# ls /oldboy/oldboy.txt
/oldboy/oldboy.txt
[root@oldboyedu oldboy02]# ls -l /oldboy/oldboy.txt
-rw-r--r--. 1 root root 0 Apr 1 09:57 /oldboy/oldboy.txt
# touch也可以用来修改文件的时间
-a # 仅修改“读取时间”(atime)
-m # 仅修改“修改时间”(mtime)
-d # 同时修改 atime 和 mtime
# 1. 将文件打开进行直接编辑
vi/vim --- 用于编辑文件的命令
vi oldboy.txt
第一个步骤: 进入到编辑状态(插入模式)
按键盘上小写字母 i
第二个步骤: 编写文件内容
第三个步骤: 进行保存关闭文档
按esc(退出编辑状态)--:wq (write写/保存 quit 退出)
:q (不保存直接退出)
:w (只保存但不退出)
# 2. 将文件不用打开进行直接编辑
# 将屏幕显示的信息保存到文件中
第一步: 屏幕上有信息显示
[root@oldboyedu oldboy]# echo "hello world"
hello world
[root@oldboyedu oldboy]# echo "hello world"
hello world
第二步: 将屏幕上显示的信息放入到文件中
[root@oldboyedu oldboy]# echo "hello world" > oldboy.txt
[root@oldboyedu oldboy]# vi oldboy.txt
hello world
[root@oldboyedu oldboy]# echo "oldboy shenzhen 02" >> oldboy.txt
[root@oldboyedu oldboy]# vi oldboy.txt
hello world
oldboy shenzhen 02
# 说明:
# > 执行原理: 将原有文件内容先进行清空 添加新的信息
# >> 执行原理: 不会覆盖情况原文件内容,而是在原文件最后一行追加新的信息
cat(猫) --- 查看文件
[root@oldboyedu oldboy]# cat oldboy.txt
hello world
oldboy shenzhen 01
oldboy shenzhen 02
[root@oldboyedu oldboy]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
copy(复制)--cp
用法: cp 要复制数据信息(文件/目录) 复制到什么位置(目录中)
# 文件备份方法:
[root@oldboyedu oldboy]# cp /oldboy/oldboy.txt /tmp
[root@oldboyedu oldboy]# ls -l /tmp/oldboy.txt
-rw-r--r--. 1 root root 50 Apr 1 10:36 /tmp/oldboy.txt
[root@oldboyedu oldboy]# ls -l oldboy.txt
-rw-r--r--. 1 root root 50 Apr 1 10:24 oldboy.txt
# 目录备份方法:
-r # 递归持续复制(用于目录)
[root@oldboyedu oldboy]# cp -r /oldboy/oldboy01/ /tmp
[root@oldboyedu oldboy]# ls /tmp/oldboy01
oldboy02
[root@oldboyedu oldboy]# ls -d /tmp/oldboy01
/tmp/oldboy01
[root@oldboyedu oldboy]# ls -d /tmp/oldboy01/oldboy02
/tmp/oldboy01/oldboy02
[root@oldboyedu oldboy]# ls -d /tmp/oldboy01/oldboy02/oldboy03
/tmp/oldboy01/oldboy02/oldboy03
# 补充: 目录备份有时需要进行多次确认
[root@oldboyedu oldboy01]# cp -r /oldboy/oldboy01/ /tmp/
cp: overwrite ‘/tmp/oldboy01/oldboy.txt’? y
cp: overwrite ‘/tmp/oldboy01/oldboy01.txt’? y
cp: overwrite ‘/tmp/oldboy01/oldboy02.txt’? y
cp: overwrite ‘/tmp/oldboy01/oldboy03.txt’? y
[root@oldboyedu oldboy01]# \cp -r /oldboy/oldboy01/ /tmp/ --- 进行目录中数据强行覆盖
[root@oldboyedu oldboy01]# cp -r /oldboy/oldboy01/ /tmp/
cp: overwrite ‘/tmp/oldboy01/oldboy.txt’?
delete(删除) remove(移除) rm
-f # 强制删除
-r # 删除目录需要加r,否则删除不掉
# 删除文件
[root@oldboyedu oldboy01]# rm /tmp/oldboy.txt
rm: remove regular file ‘/tmp/oldboy.txt’? ^C
[root@oldboyedu oldboy01]# \rm /tmp/oldboy.txt
[root@oldboyedu oldboy01]# ls -l /tmp/oldboy.txt
ls: cannot access /tmp/oldboy.txt: No such file or directory
[root@oldboyedu oldboy01]# touch /tmp/oldboy.txt
[root@oldboyedu oldboy01]# ls -l /tmp/oldboy.txt
-rw-r--r--. 1 root root 0 Apr 1 11:09 /tmp/oldboy.txt
[root@oldboyedu oldboy01]# rm /tmp/oldboy.txt
rm: remove regular empty file ‘/tmp/oldboy.txt’? ^C
[root@oldboyedu oldboy01]# rm -f /tmp/oldboy.txt
[root@oldboyedu oldboy01]# ls -l /tmp/oldboy.txt
ls: cannot access /tmp/oldboy.txt: No such file or directory
# 删除目录
[root@oldboyedu oldboy01]# rm /tmp/oldboy01/
rm: cannot remove ‘/tmp/oldboy01/’: Is a directory
[root@oldboyedu oldboy01]# rm -f /tmp/oldboy01/
rm: cannot remove ‘/tmp/oldboy01/’: Is a directory
[root@oldboyedu oldboy01]# rm -r /tmp/oldboy01/
rm: descend into directory ‘/tmp/oldboy01/’? ^C
[root@oldboyedu oldboy01]# rm -rf /tmp/oldboy01/
[root@oldboyedu oldboy01]# ls -d /tmp/oldboy01
ls: cannot access /tmp/oldboy01: No such file or directory
# PS: 运维人员两大经典错误
1. 删根目录 避免
2. 删库跑路???
move(移动)==mv
mv命令用法和cp命令类似
# 在同一个目录对文件进行剪切操作,也就是重命名
# 移动剪切文件数据
[root@oldboyedu ~]# mv /oldboy/oldboy.txt /tmp/
[root@oldboyedu ~]# ls -l /tmp/oldboy.txt
-rw-r--r--. 1 root root 50 Apr 1 10:24 /tmp/oldboy.txt
[root@oldboyedu ~]# ls -l /oldboy/oldboy.txt
ls: cannot access /oldboy/oldboy.txt: No such file or directory
# 移动剪切目录数据
[root@oldboyedu ~]# mv /oldboy/oldboy01/ /tmp
[root@oldboyedu ~]# ls -d /tmp/oldboy01
/tmp/oldboy01
[root@oldboyedu ~]# ls -ld /tmp/oldboy01
drwxr-xr-x. 3 root root 100 Apr 1 11:00 /tmp/oldboy01
[root@oldboyedu ~]# ls -ld /oldboy/oldboy01
ls: cannot access /oldboy/oldboy01: No such file or directory
# 重命名
[root@oldboyedu ~]# cd /oldboy
[root@oldboyedu oldboy]# ls
[root@oldboyedu oldboy]# touch oldboy.txt
[root@oldboyedu oldboy]# ls
oldboy.txt
[root@oldboyedu oldboy]# echo "oldboy shenzhen" >oldboy.txt
[root@oldboyedu oldboy]# cat oldboy.txt
oldboy shenzhen
[root@oldboyedu oldboy]# mv oldboy.txt oldgirl.txt
[root@oldboyedu oldboy]# ls
oldgirl.txt
[root@oldboyedu oldboy]# cat oldgirl.txt
oldboy shenzhen
# 移动数据时,出现重复信息也会提示需要覆盖
[root@oldboyedu oldboy]# ls -l /tmp/oldboy.txt
-rw-r--r--. 1 root root 50 Apr 1 10:24 /tmp/oldboy.txt
[root@oldboyedu oldboy]# touch oldboy.txt
[root@oldboyedu oldboy]# mv oldboy.txt /tmp/
mv: overwrite ‘/tmp/oldboy.txt’?
标签:多级目录 ati 条件 system png 删库 快速 ldo 键盘
原文地址:https://www.cnblogs.com/j-chao/p/13232347.html