linux常用命令及解析 1、基础命令及操作 pwd 命令:显示当前用户工作的路径,为绝对路径。
[root@localhost bin]# pwd /bin
cd 切换工作路径 [root@localhost bin]# cd /mnt [root@localhost mnt]#
ls 当前目录下的所有文件及文件夹。 [root@localhost mnt]# ls 111 1111 111.txt 222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt
mkdir 创建目录 [root@localhost mnt]# ls 111 1111 111.txt 222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt [root@localhost mnt]# mkdir zhang [root@localhost mnt]# ls 111 1111 111.txt 222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt zhang
mv 移动文件或文件夹到指定目录下(也可以给文件或文件夹重命名) [root@localhost mnt]# mv syste.txt /opt [root@localhost mnt]# ls 1111 222 2222 222.txt hgfs system tax.tar.gz txt.tar txt.txt [root@localhost mnt]# cd /opt/ [root@localhost opt]# ls syste.txt [root@localhost opt]# mv syste.txt /mnt/666.txt [root@localhost opt]# ls [root@localhost opt]# cd /mnt [root@localhost mnt]# ls 1111 222 2222 222.txt 666.txt hgfs system tax.tar.gz txt.tar txt.txt [root@localhost mnt]# mv system /opt [root@localhost mnt]# ls 1111 222 2222 222.txt 666.txt hgfs tax.tar.gz txt.tar txt.txt [root@localhost mnt]# cd /opt [root@localhost opt]# ls system
cp 复制文件或目录到指定目录 [root@localhost mnt]# cp txt.tar /opt [root@localhost mnt]# ls 1111 222 2222 222.txt 666.txt hgfs system tax.tar.gz txt.tar txt.txt [root@localhost mnt]# cd /opt [root@localhost opt]# ls txt.tar [root@localhost opt]#
rm 删除文件 [root@localhost mnt]# ls 1111 222 2222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt [root@localhost mnt]# rm 333.txt rm: remove regular empty file ‘333.txt’? y [root@localhost mnt]# ls 1111 222 2222 222.txt hgfs tax.tar.gz txt.tar txt.txt [root@localhost mnt]#
rm -rf 删除文件夹及文件夹下的全部文件 [root@localhost mnt]# ls 1111 222 2222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt zhang [root@localhost mnt]# rm -rf zhang [root@localhost mnt]# ls 1111 222 2222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt
touch 创建文件 mkdir 创建目录 [root@localhost opt]# touch qyr.txt [root@localhost opt]# ls qyr.txt txt.tar [root@localhost opt]# touch qyr [root@localhost opt]# ls qyr qyr.txt txt.tar
cat 命令 显示全部文本内容,适合查看较少的文件 [root@localhost opt]# cat lqq.txt linux常用命令及解析 1、基础命令及操作 pwd 命令:显示当前用户工作的路径,为绝对路径。
[root@localhost bin]# pwd /bin
cd 切换工作路径 [root@localhost bin]# cd /mnt [root@localhost mnt]#
ls 当前目录下的所有文件及文件夹。 [root@localhost mnt]# ls 111 1111 111.txt 222 222.txt 333.txt hgfs tax.tar.gz txt.tar txt.txt
tar命令:打包压缩与解压缩操作 tar -tf [打包文件] 打包文件里包含哪些文件 tar -cf [文件名.tar][文件名/文件夹名] 将文件或文件夹打包成tar文件 tar -xf [打包名.tar] 解压缩,提取打包内容 tar -zf gzip方式进行压缩。 [root@localhost opt]# vim qyr.txt [root@localhost opt]# [root@localhost opt]# tar qyr.tar qyr.txt qyr tar: invalid option – ‘q’ Try ‘tar --help’ or ‘tar --usage’ for more information. [root@localhost opt]# ls lqq.txt qyr qyr.txt txt.tar [root@localhost opt]# tar -z tx txA txc txd txr txt txu txx [root@localhost opt]# tar -z txt.tar tar: You must specify one of the ‘-Acdtrux’, ‘–delete’ or ‘–test-label’ options Try ‘tar --help’ or ‘tar --usage’ for more information. [root@localhost opt]# tar qyr.tar tar: invalid option – ‘q’ Try ‘tar --help’ or ‘tar --usage’ for more information. [root@localhost opt]# ls lqq.txt qyr qyr.txt txt.tar [root@localhost opt]# tar -t txt.tar tar: Refusing to read archive contents from terminal (missing -f option?) tar: Error is not recoverable: exiting now [root@localhost opt]# tar -tf txt.tar 111.txt 222.txt 333.txt txt.txt [root@localhost opt]# tar -cf qyr.tar qyr.txt qyr [root@localhost opt]# ls lqq.txt qyr qyr.tar qyr.txt txt.tar [root@localhost opt]# tar -cf qyr.tar.gz qyr.txt qyr [root@localhost opt]# ls lqq.txt qyr qyr.tar qyr.tar.gz qyr.txt txt.tar [root@localhost opt]# tar -x txt.tar tar: Refusing to read archive contents from terminal (missing -f option?) tar: Error is not recoverable: exiting now [root@localhost opt]# tar -xf txt.tar [root@localhost opt]# ls 111.txt 222.txt 333.txt lqq.txt qyr qyr.tar qyr.tar.gz qyr.txt txt.tar txt.txt
|