0
点赞
收藏
分享

微信扫一扫

P3393 逃离僵尸岛 bfs +最短路

Resin_Wu 03-27 09:30 阅读 4
linux

一、文件操作

功能项命令实例作用
文件创建vi /opt/learn/hello.txt

在目录/opt/learn下创建文件hello.txt并进入vi编辑界面

touch /opt/learn/test在目录/opt/learn下创建空白文件test
cat > /opt/catfile创建文件catfile并在屏幕上输入内容,最后按 Ctrl + D 退出
文件查看vi /etc/passwd在vi编辑器中输出文本内容
cat /etc/passwd在屏幕输出文本内容
more /etc/passwd分屏输出文本内容
less /etc/passwd分屏输出文本内容并按需加载文件(适用于大文件的查看)
head -n 10 /etc/passwd只输出文件的头10行
tail -n 20 /etc/passwd只输出文件末尾的20行
strings /bin/ls查看二进制文件中的可打印字符
文件操作cp hello.txt /opt/test把文件hello.txt复制到文件夹/opt/test下
cp hello.txt /opt/test/hello.cp把文件hello.txt复制到文件夹/opt/test下并重命名为hello.cp
mv hello.txt /opt/test把文件hello.txt剪切到文件夹/opt/test下
mv hello.txt /opt/test/hello.mv将文件hello.txt剪切到文件夹/opt/test下并重命名为hello.mv
mv hello.txt hello2.txt重命名
rm /opt/test/hello.cp删除文件
rm -f /opt/test/hello.mv强制删除文件,不会有提示信息
du -sk hello.txt查看文件hello.txt的大小(以k为单位)
链接In -s hello.txt shello为hello.txt文件创建一个名为shello的软链接(类似于快捷方式)
In -d hello.txt dhello为hello.txt文件创建一个名为dhello的硬链接(硬链接表示所有文件中更改任意一个,其他文件的所有属性会跟着变化,如大小,更新时间,权限等)

二、文件夹操作

功能项命令或格式作用
ls /treels [option] [file/directory]显示指定目录下的所有文件或文件夹
ls显示当前目录的内容
ls -l显示当前目录的详细内容
ls -a显示当前目录下的所有文件,包括隐藏文件
ls *.txt显示当前目录下所有以.txt为后缀名的文件
ls /opt/training显示目录/opt/training下的内容
ls -R /opt/列出所有/opt目录及其目录的内容
tree /opt用树状结构显示目录及文件
pwdpwd显示当前所在的目录
cdcd directory切换到指定目录
cd切换到当前用户所有的主目录

cd ..

回退到当前目录的上一级目录
cd /opt/learn用绝对路径切换到/opt/training目录下
cd ../../使用相对路径切换到当前目录的上一级的上一级目录下
cd .切换到当前用户,相当于什么也没做
mkdirmkdir [option] [director1] [directory2]创建目录
mkdir /opt/other在目录/opt/learn/下创建目录other
mkdir dir2 dir3 dir4同时创建dir2 dir3 dir4三个目录
mkdir -p /dir1/dir2/dir3同时创建三层目录
rmdirrmdir dir 1删除一个空目录
其他操作cp -r /opt/learn /opt/learn2拷贝文件夹
mv /opt/learn2 /opt/learn3重命名文件夹
rm -rf /opt/learn3强制删除文件夹
⚠️rm -rf /从根目录开始,递归并强制删除所有文件和目录
⚠️rm -rf /*强制删除根目录下所有文件和子目录
x -h 或 x --help 或 man x查看命令的帮助

举报

相关推荐

0 条评论