学习linux若是使用的是windows 建议使用一个很好用的工具git,下载安装便可使用linux下的命令来操做windows
注意/ 有表示根目录 无表示当前目录linux
1. pwd pwd #显示当前工做目录的名称 pwd -P #显示链接的真是路径 2. cd cd /usr/src #切换到/usr/src下面的目录 cd .. #返回上级目录 cd - #返回上个目录 cd ~ #返回用户的工做空前目录 3. ls ls #显示目录和文件信息 ls -a #显示全部的信息 ls -d #显示目录自己的信息 ls -h #人性化显示容量信息 ls -c #显示文件或目录属性最后修改的时间 ls -u #显示文件或目录最后被访问的时间 ls -t #以修改时间排序,默认按照文件名排序 4. touch touch hello.txt #建立或者修改文件,存在修改,不存在则建立 5. mkdir mkdir test #建立test目录 mkdir -p test/test/test #建立多级目录 6. cp cp /test/hello.txt /temp/ #将hello.txt文件复制到temp目录下 cp /test/hello.txt /temp/hi.txt #将文件复制到目录下并更名字为hi.txt 7.rm rm hello.txt #删除hello.txt文件 rm -rf test #强制删除目录且不提示 8. mv mv hello.txt hi.txt #将hello.txt修更名字为hi.txt mv hello.txt /test/ #将hello.txt移动至test目录下 9. find find -name hello.txt #查找当前目录下名为hello.txt的文件 find /root -name "*.log" #查找/root目录下全部以.log结尾的文件 find iname "hello" #不区分大小写查找 find / -empty #查找全部的空文档 find / -group tom #查找所属组为tom的文件 find /-mtime -3 #查找三天内被修改过的档案 find /-mtime +4 #查找计算机中全部4天前被修改的文档 find /mtime 2 #查找计算两天前的当天被修改的文档 find / -size+10M #查找当前目录下大于10M的文档 find ./ -type f #查找当前目录全部的普通文件 find / -user tom # 查找计算机中tom所拥有的文档 10. du du -sh /test #查看test所占的磁盘空间的综合
1. cat cat -b hello.txt #显示hello.txt的内容并显示行号(空白行不显示行号) cat -h hello.txt #显示内容和行号,空白行显示行号 cat hello.txt #显示文件内容 2. more more hello.txt #分页查看文件内容(空格 下一页,q键退出) 3. less less hello.txt #分页查看文件内容(空格 下一页,方向键 上下回翻,q键 退出) 4. head head -c 2K hello.txt #显示文件前2K的内容 head -n20 hello.txt #显示前20行的内容 5. tail tail -c 2k hello.txt #显示文件后2K的内容 tail -n20 hello.txt #显示文件后20行的内容 tail -n20 hello.txt -f #实时动态的显示hello.txt 后20行的内容 6. wc wc hello.txt #依次显示文件的行数,单词书,字节数 wc -c hello.txt #显示文件的字节信息 wc -l hello.txt #显示文件的行数 wc -w hello.txt #显示文件的单词个数 7. grep grep th hello.txt #在test.txt文件中过滤包含th的行 grep --color th hello.txt #对匹配的关键字显示颜色 grep -i th hello.txt #不匹配大小写 grep -w th hello.txt #过滤单词,单词为th的 grep -v th hello.txt #取反,过滤很差喊th的行 8. echo echo "test" #显示test文本 echo -e "\a" #计算机蜂鸣器响
有时间能够百度看看软链接和硬连接的区别git
1. 软链接(至关于快捷方式) ln -s /test/hello.txt /tmp/hi.txt 2. 硬连接(可删除源文件) ln /test/hello.txt /tem/hi.txt
1. gzip gzip hello.txt #压缩文件,文件压缩后名字为hello.txt.gz gzip -d hello.txt.gz #解压gz文件 2. bzip2 bzip2 hello.txt #压缩文件,文件压缩后名字为 hello.txt.bz2 bzip2 -d hello.txt.bz2 #解压bz2文件 3. tar tar -cf etc.tar /etc/ #将etc目录打包保存谓etc.tar tar -xzf etc.rar #解压 etc.rar文件
1. 善于使用tab键 2. 善于使用上下键 3. 查看名两行历史 4. 清屏 ctrl+l clear 5. 查找经常使用命令存储位置 which find #查询find命令的存储位置
1. man man ls #查ls命令手册 2. info info ls #查看ls命令信息 3.help ls --help #查看ls帮助