基本语法:mkdir [选项] 要创建的目录
常用选项: -p 创建多级目录
示例:创建一个目录和创建多级目录
rmdir删除目录指令
rmdir指令删除空目录
基本语法:rmdir [选项] 要删除的空目录(非空目录无法删除)
rm -rf 表示递归删除(慎用)
如:删除/home/Dog(Dog下无内容)和删除Dog2,Dog2下有smallDog文件(rm -rf /home/Dog2)
touch创建空文件指令
touch指令创建空文件
基本语法 :touch 文件名称
如在/home目录下创建空文件夹hello.txt,(touch /home/hello.txt)
cp复制指令
cp指令拷贝文件到指定目录
基本语法:cp [ 选项 ] source dest
常用选项 -r:递归复制整个文件夹
示例:将text1中的hello.txt复制到text2上
递归复制整个夹就不用加上之后的/hello.txt **(cp -r text1/ text2)**已经到了/home目录,如果没到应该写成 cp -r /home/text1 text2
使用细节
强制覆盖不提示:\cp -r /home/text1 text2
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text1 text2
[root@kongchao02 home]# ls text1
hello1.txt hello.txt
[root@kongchao02 home]# ls text2
[root@kongchao02 home]# cp -r text1/hello.txt text2
[root@kongchao02 home]# ls text2
hello.txt
rm删除指令
说明:rm指令移除文件或目录
基本语法:rm [选项] 要删除的文件或目录
常用选项:
-r :递归删除整个文件夹
-f:强制删除不提示
-i:删除之前提示
示例:删除text1和text2
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text1 text2
[root@kongchao02 home]# ls text1
hello1.txt hello.txt
[root@kongchao02 home]# rm -rf text1/
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text2
[root@kongchao02 home]# rm -ri text2/
rm:是否进入目录"text2/"? y
rm:是否删除目录 “text2/hello.txt”?y
rm:是否删除目录 “text2/”?y
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2
-i提示性删除更安全,但是也更繁琐,-f强制删除不提示,不安全谨慎使用
mv移动或重命名指令
mv是移动文件与目录或重命名
基本语法:
mv oldName newName (重命名)
mv /temp/movefile /targetFolder(移动文件
示例1**:重命名和移动位置**
[root@kongchao02 home]# mkdir text1
[root@kongchao02 home]# mkdir text1/text2
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text1
[root@kongchao02 home]# mv text1 newNameText1
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 newNameText1
[root@kongchao02 home]# ls newNameText1/
text2
[root@kongchao02 home]# mkdir text3
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 newNameText1 text3
[root@kongchao02 home]# mv newNameText1 text3
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text3
[root@kongchao02 home]# ls text3
newNameText1
[root@kongchao02 home]# ls text3/newNameText1
text2
同一路径下为改名,不同路径为移动位置
示例2:移动并起新的名字
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text3
[root@kongchao02 home]# mv text3/newNameText1 /home/text4
[root@kongchao02 home]# ls
kongchao kongchao1 kongchao2 text3 text4
整个目录移动:如mv /home/text3 /temp
cat查看文件内容指令
cat查看文件内容
基本语法:cat [选项] 要查看的文件
常用选项:-n :显示行号
示例:查看hello.java
[root@kongchao02 home]# vim hello.java
[root@kongchao02 home]# ls
hello.java kongchao kongchao1 kongchao2 text3 text4
[root@kongchao02 home]# cat -n hello.java
1 public class Hello{
2 public static void main (String[] args){
3 System.out.println(“hello java”);
4
5 }
6
7
8
9
10 }
使用细节:cat只能浏览文件,而不能修改文件(所以cat安全),为了浏览方便,一般会带上管道命令 | more,作用是把查询到的结果交给more处理,等全部显示完就会退出more
cat -n /etc/profile |more(交互指令)
如按下空格显示更多
more指令
more指令是一个基于vi编辑器的文本过滤器,他以全屏幕的方式按页显示文本文件的内容,more指令中内置了若干个快捷键(交互指令)
基本语法:more 要查看的文件
操作说明如图:
less查看指令
less指令用来分屏查看文件内容,它的功能与more指令类似,但是比more指令更加强大,支持各种显示终端。less指令在显示文件内容时,并不是一次将整个文件加载之后才显示,而是根据显示需要加载的内容,对于显示大型文件具有较高的效率。
基本语法**:less 要查看的文件**
echo输出指令
echo输出内容到控制台
基本语法:echo [选项] [输出内容]
示例:用echo指令输出环境变量和指定内容
[root@kongchao02 ~]# echo $HOSTNAME
kongchao02
[root@kongchao02 ~]# echo “hello kongchao”
hello kongchao
[root@kongchao02 ~]#
head显示头部指令
head指令用于显示文件开头部分内容,默认情况下head指令显示文件的前10行内容
基本语法:head 文件 (查看文件头10行内容)
head -n 15 文件 (查看文件头15行内容,可以是任意行数)
示例:查看/etc/profile下前6行
[root@kongchao02 ~]# head -n 6 /etc/profile
/etc/profile
System wide environment and startup programs, for login setup
Functions and aliases go in /etc/bashrc
It’s NOT a good idea to change this file unless you know what you
[root@kongchao02 ~]#
tail显示尾部指令
tail用于输出文件中尾部的内容, 默认情况下tail显示文件的前10行内容。
基本语法:
tail 文件(查看文件尾部10行内容)
tail -n 5 文件 (查看文件尾部5行内容)
tail -f 文件 (实时追踪该文档的所有更新,该文件变化会反馈出来)
[root@kongchao02 ~]# tail /etc/profile
if [ “KaTeX parse error: Expected '}', got '#' at position 3: {-#̲*i}" != "-” ]; then
. “$i”
else
. “$i” >/dev/null
fi
fi
done
unset i
unset -f pathmunge
[root@kongchao02 ~]# tail -n 5 /etc/profile
fi
done
unset i
unset -f pathmunge
[root@kongchao02 ~]#
覆盖指令和>>追加指令
>是覆盖原先的内容,>>是追加到原来的内容之后
基本语法:
ls -l > 文件 (列表的内容写入到文件中覆盖原先的)
ls -al >> 文件 (列表的内容追加到文件的末尾)
cat 文件1 > 文件2 (将文件1内容覆盖到文件2中)
echo “内容” >> 文件 (将内容追加到文件中)
示例1:将/home目录下的文件列表写入到/home/text.txt中,覆盖写入(ls -l /home > /text.txt)如果text.txt不存在则会自动创建
[root@kongchao02 home]# ls -l /home
总用量 24
-rw-r–r–. 1 root root 107 3月 4 22:22 hello.java
drwx------. 15 kongchao kongchao 4096 3月 1 20:37 kongchao
drwx------. 5 kongchao1 kongchao1 4096 2月 28 22:08 kongchao1
drwx------. 3 kongchao2 kongchao2 4096 2月 28 22:11 kongchao2
drwxr-xr-x. 2 root root 4096 3月 3 21:44 text3
drwxr-xr-x. 3 root root 4096 3月 3 21:27 text4
[root@kongchao02 home]# ls -l /home > text.txt
[root@kongchao02 home]# ls /home
hello.java kongchao kongchao1 kongchao2 text3 text4 text.txt
[root@kongchao02 home]# cat /home/text.txt
总用量 24
-rw-r–r–. 1 root root 107 3月 4 22:22 hello.java
drwx------. 15 kongchao kongchao 4096 3月 1 20:37 kongchao
drwx------. 5 kongchao1 kongchao1 4096 2月 28 22:08 kongchao1
drwx------. 3 kongchao2 kongchao2 4096 2月 28 22:11 kongchao2
drwxr-xr-x. 2 root root 4096 3月 3 21:44 text3
drwxr-xr-x. 3 root root 4096 3月 3 21:27 text4
-rw-r–r–. 1 root root 0 3月 4 22:29 text.txt
[root@kongchao02 home]#
示例2:将I am kc追加到hello.java中
[root@kongchao02 home]# cat /home/hello.java
public class Hello{
public static void main (String[] args){
System.out.println(“hello java”);
}
}
[root@kongchao02 home]# echo “I am kc” >> /home/hello.java
[root@kongchao02 home]# cat /home/hello.java
public class Hello{
public static void main (String[] args){
System.out.println(“hello java”);
}
}
I am kc
[root@kongchao02 home]#
示例3:将文件覆盖
[root@kongchao02 home]# cd /home/
[root@kongchao02 home]# cat text.txt
总用量 24
-rw-r–r–. 1 root root 107 3月 4 22:22 hello.java
drwx------. 15 kongchao kongchao 4096 3月 1 20:37 kongchao
drwx------. 5 kongchao1 kongchao1 4096 2月 28 22:08 kongchao1
drwx------. 3 kongchao2 kongchao2 4096 2月 28 22:11 kongchao2
drwxr-xr-x. 2 root root 4096 3月 3 21:44 text3
drwxr-xr-x. 3 root root 4096 3月 3 21:27 text4
-rw-r–r–. 1 root root 0 3月 4 22:29 text.txt
[root@kongchao02 home]# cat hello.java > text.txt
[root@kongchao02 home]# cat text.txt
public class Hello{
public static void main (String[] args){
System.out.println(“hello java”);
}
}
I am kc
[root@kongchao02 home]#
当前日历显示 cal
[root@kongchao02 ~]# cal
三月 2022
日 一 二 三 四 五 六
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
[root@kongchao02 ~]#
ln符号连接指令
In软连接也称符号连接,类似于windows里的快捷方式,主要存放了链接其他文件的路径
基本语法:ln -s [原文件或目录] [软链接名] (给原文件创建一个软链接)
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
读者福利
分享一份自己整理好的Java面试手册,还有一些面试题pdf
不要停下自己学习的脚步
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门即可获取!
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。[外链图片转存中…(img-twq7CfeJ-1712073897244)]
[外链图片转存中…(img-uVlzOIug-1712073897245)]
[外链图片转存中…(img-LjPt2cpl-1712073897246)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
读者福利
分享一份自己整理好的Java面试手册,还有一些面试题pdf
不要停下自己学习的脚步
[外链图片转存中…(img-Ba8dpfON-1712073897246)]
[外链图片转存中…(img-3SChuaEy-1712073897246)]
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门即可获取!