Created
September 24, 2015 03:18
-
-
Save s5s5/fee6c9fbfd9505c720de to your computer and use it in GitHub Desktop.
Linux常用命令
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#显示文件源代码 | |
cat ooxx.php | |
#查看当前目录 | |
pwd | |
#更改目录 Change Directory (cd) | |
cd /path/to/directory/ | |
#列出文件/子目录 Listing Files/SubFolders(ls) | |
ls | |
#默认只显示文件名,你也可以带个参数玩,比如 | |
ls -alh | |
#带 -alh 输出会很爽... 自己试试, 大猫喜欢把 ls -alh 颜射为 ll | |
#-a显示全部文件 | |
#-l比较详细的列表 | |
#-h人类能看懂的比如把1024显示为1K | |
#获取远程文件 wget | |
wget http://bigc.at/me.jpg | |
#压缩解压缩 | |
unzip wordpress.zip | |
#如果文件是zip形式的,比如刚从wordpress主站wget了一个压缩包过来,只需要输入unzip 文件名,就可以解压缩到当前目录了 | |
tar -czvf ooxx.tar.gz * .[!.]* | |
#把当前目录所有文件以tar命令打包为ooxx.tar.gz文件 | |
#-c创建 | |
#-z用gzip压缩方式 | |
#-v显示压缩过程 | |
#-f搞成一坨file | |
tar -xzvf ooxx.tar.gz | |
#解压缩 ooxx.tar.gz 里的文件到当前目录 | |
#-x解压缩 | |
#-z用gzip压缩方式 | |
#-v显示压缩过程 | |
#-f搞成一坨file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#更改文件权限 (chmod) | |
chmod 777 miao.in | |
#默认文件为644,文件夹为755 | |
#TIP: | |
#1st digit=Owner; 2nd=Group; 3rd=Other | |
#(-rwxrwxwrx = 777, -rwxr-xr-x = 755, -rw-r--r-- = 644, etc.) | |
#7 = Read + Write + Execute | |
#6 = Read + Write | |
#5 = Read + Execute | |
#4 = Read | |
#3 = Write + Execute | |
#2 = Write | |
#1 = Execute | |
#0 = All access denied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#显示磁盘使用率 | |
df | |
#列表文件/子目录使用率 (du) | |
du | |
#会列出所有文件以及子目录的大小,不是人看的... | |
du -sh | |
#-s就是summary,只输出当前文件夹总容量 | |
#-h一般在linux就是human给人看的意思,会把1048580b转换为1mb显示 | |
du -h --max-depth=1 | |
#嘿,只列出当前文件夹和第一级子目录占用大小 | |
#删除文件 Remove files (rm) 少儿不宜的命令,总是需要确认 | |
rm -vf miao.in | |
#强制删除miao.in这个文件并不需确认,列出删除文件列表 | |
#强制删除,不要执行,除非你知道你在干嘛... | |
#-v一般v参数都是显示过程的意思 | |
#-f 强奸的单词会不会拼? F-U-C-K的缩写,不确认直接F-word了 | |
rm -rf ooxx | |
#删除ooxx这个文件夹,包含它的子文件和子文件夹 | |
#删除文件用上面的命令,但删除文件夹的时候就需要跑下遍历了 | |
#-r 比较本土化,是"日"的缩写,在所有命令里都是 recursive 的意思,有些命令是大写的 R 需要注意 | |
#拷贝文件 (cp) | |
cp bigc.at miao.in | |
#复制bigc.at这个文件并重命名为miao.in | |
#移动文件/重命名 (mv) | |
mv bigc.at miao.in | |
#创建空文件 (touch) | |
touch miao.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#查找. 常用命令,让我们来找一下10MB以上的文件吧 | |
find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' |sort -n | |
#Grep, 手里握着大西瓜 | |
ls -alh | grep ooxx | |
#只显示含有ooxx的那几列,当然你在cat的时候配合这个用找文件里的某些字段很方便 | |
#分页 (Less/More) | |
less miao.php | |
#如果源代码很长,则会分页显示,上下箭头滚动,输入q退出 | |
tail -n 1000 /var/log/httpd/error_log | more | |
#可以用 | more 参数来滚动显示页面或行 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment