Linux上常用的基本命令

Posted 一个有点理想的码农

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux上常用的基本命令相关的知识,希望对你有一定的参考价值。

复制:copy

[[email protected] happydzy]$ cp file1 file2
[[email protected] happydzy]$ ll 
total 8
-rw-rw-r--. 1 keysystem keysystem 12 Dec  3 01:24 file1
-rw-rw-r--. 1 keysystem keysystem 12 Dec  3 01:24 file2
[[email protected] happydzy]$ 

移动:move

[[email protected] happydzy]$ mv file1 ..  
[[email protected] happydzy]$ mv file2 dir/
[[email protected] happydzy]$ 

重命名:rename

[[email protected] happydzy]$ mv file1 file2 #将file1重命名为file2
[[email protected] happydzy]$ mv dir1 dir2 #dir2存在,则为移动操作

移除:remove

[[email protected] happydzy]$ rm file1 #移除file1文件
[[email protected] happydzy]$ rm -r dir #移除dir目录

创建文件:touch 和 >

[[email protected] happydzy]$ touch a.txt    #创建a.txt文件
[[email protected] happydzy]$ >b.txt         #创建b.txt文件 
[[email protected] happydzy]$ ll
total 0
-rw-rw-r--. 1 keysystem keysystem 0 Dec  3 01:41 a.txt
-rw-rw-r--. 1 keysystem keysystem 0 Dec  3 01:41 b.txt
[[email protected] happydzy]$ 

创建目录:mkdir

[[email protected] happydzy]$ mkdir dir
[[email protected] happydzy]$ ll
total 4
drwxrwxr-x. 2 keysystem keysystem 4096 Dec  3 01:43 dir
[[email protected] happydzy]$ 

查看文件:cat

[[email protected] happydzy]$ cat a.txt 
hello world
[[email protected] happydzy]$ 

查看文件类型:file

[[email protected] happydzy]$ file a.txt 
a.txt: ASCII text
[[email protected] happydzy]$ 
[[email protected] happydzy]$ file index.html 
index.html: HTML document text
[[email protected] happydzy]$

 通配符:*  可以匹配0个或多个

[[email protected] happydzy]$ ls a*
a.txt
[[email protected] happydzy]$ 

zip包的解压缩指令:unzip

[[email protected] happydzy]$ unzip master.zip 
Archive:  master.zip
ac4da107fb56c46956d86fc10c7bbe2bb1423a4d
   creating: happygrep-master/
 extracting: happygrep-master/.gitignore  
  inflating: happygrep-master/Makefile  
  inflating: happygrep-master/Makefile.macosx  
  inflating: happygrep-master/README.md  
   creating: happygrep-master/contrib/
  inflating: happygrep-master/contrib/happygrep.sh  
  inflating: happygrep-master/contrib/wiki  
  inflating: happygrep-master/happygrep.c  
[[email protected] happydzy]$ 

zip包的压缩指令:zip

[[email protected] happydzy]$ zip -r happygrep-master.zip happygrep-master/
  adding: happygrep-master/ (stored 0%)
  adding: happygrep-master/Makefile.macosx (deflated 38%)
  adding: happygrep-master/Makefile (deflated 23%)
  adding: happygrep-master/contrib/ (stored 0%)
  adding: happygrep-master/contrib/happygrep.sh (deflated 57%)
  adding: happygrep-master/contrib/wiki (deflated 48%)
  adding: happygrep-master/README.md (deflated 46%)
  adding: happygrep-master/.gitignore (stored 0%)
  adding: happygrep-master/happygrep.c (deflated 71%)
[[email protected] happydzy]$ ll -rlt
total 32
drwxrwxr-x. 3 keysystem keysystem  4096 Sep 25  2015 happygrep-master
-rw-rw-r--. 1 keysystem keysystem  2381 Jan 23  2017 index.html
drwxrwxr-x. 2 keysystem keysystem  4096 Dec  3 01:43 dir
-rw-rw-r--. 1 keysystem keysystem    12 Dec  3 01:44 a.txt
-rw-rw-r--. 1 keysystem keysystem 12418 Dec  3 02:04 happygrep-master.zip
[[email protected] happydzy]$ 

tar.gz包的解压缩指令:tar zxvf xxx.tar.gz

[[email protected] happydzy]$ 
[[email protected] happydzy]$ tar zxvf wget-1.11.2.tar.gz 
wget-1.11.2/
wget-1.11.2/mkinstalldirs
......
[[email protected] happydzy]$ 
[[email protected] happydzy]$ 
[[email protected] happydzy]$ ll -rlt
total 2340
drwxr-xr-x. 11 keysystem keysystem    4096 Apr 30  2008 wget-1.11.2
-rw-rw-r--.  1 keysystem keysystem 1460078 Apr 30  2008 wget-1.11.2.tar.gz
-rw-rw-r--.  1 keysystem keysystem  929549 Dec  3 02:08 wget-1.11.2.tar.bz2

tar.gz包的压缩指令:tar zcvf xxx.tar.gz xxx/

[[email protected] happydzy]$ tar zcvf wget-1.11.2.tar.gz wget-1.11.2/

tar.bz2包的解压缩指令:tar jxvf xxx.tar.bz2

[[email protected] happydzy]$ tar jxvf wget-1.11.2.tar.bz2 

tar.bz2包的压缩指令:tar jxvf xxx.tar.bz2

[[email protected] happydzy]$ tar jcvf wget-1.11.2.tar.bz2 wget-1.11.2/

 

以上是关于Linux上常用的基本命令的主要内容,如果未能解决你的问题,请参考以下文章

linux,unix常用基本命令

linux常用基本命令

Linux常用快捷键和基本命令

Linux基本常用命令总结

Linux 常用基本命令

Linux 常用基本命令