个人站点: http://oldchen.iwulai.com/
centos基本命令 --------------------------- CentOS Windows $>ls cmd>dir //
$>ls --help //查看命令帮助 $>man ls //查看命令帮助
$>clear cmd>cls //清屏 $>cd /home cmd>cd d:/ //切换目录 $>cd . cmd>cd . //进入当前目录 $>cd .. cmd>cd .. //进入上级目录 $>cd /home/centos cmd>cd d:/xx/x/x //进入绝对路径
$>pwd //显式当前目录 $>whoami //显式当前用户名
$>su root //切换用户,输入密码,swith user $>passwd //修改当前用户的密码
$>ifconfig cmd>ipconfig //查看ip地址 $>ping localhost cmd>ping localhost //查看网络连通情况 $>ping www.baidu.com cmd>ping www.baidu.com //查看网络连通情况
$>启动桌面版的网卡 on. $>su centos // $>cd /home/centos // $>cd ~ //回到主目录 $>cd - //回到上次的目录 $>ll //别名,ls -l --autocolor... $>alias //查看所有的别名 $>ls -a -l -h //查看当前目录-h:人性化 -l:列表 -a:显式.开头 $>mkdir ~/Downloads/a //创建目录 $>touch ~/Downloads/a/1.txt //创建文件 $>echo helloworld > 1.txt //重定向输出(覆盖) $>echo helloworld >> 1.txt //重定向输出(追加模式) $>cat 1.txt cmd>type a.txt //查看文件 $>cp 1.txt 2.txt //复制文件 $>rm 1.txt //删除文件 $>rm -rf / //强行递归删除 $>mv a.txt tmp/ //强行递归删除
[centos client中切换模式] ctrl + alt + f6 //切换到文本模式 ctrl + alt //切换鼠标 ctrl + alt + f1 //切换桌面模式. ctrl + alt + f5 //切换到新的文本模式
[nano文本编辑器,命令行模式] $>nano a.txt //打开nano编辑器,编辑a.txt文件 $>.... $>ctrl + o //保存文件,提示后直接回车 $>ctrl + x //退出文件 $>ctrl + k //cut 文本 $>ctrl + u //cut 文本
$>more a.txt //分屏显式 q:退出 h:帮助 $>more -5 a.txt //显式前5行内容 $>tail a.txt //最后10行内容
$>find . | more // | 是管道符,前面的命令的输出作为后面命令输入。 $>find ~ $>ls -aR ~ //递归显式主目录所有的文件.(a表示包含.开头的文件) $>head a.txt //显式前10行 $>head -n 10 a.txt //显式前10行 $>head -10 a.txt //显式前10行
$>tail a.txt $>tail -n 20 a.txt $>tail -20 a.txt $>tail --lines=20 a.txt
$>wc -c -l -w a.txt //统计文本信息, //显式统计信息-c:字节 -l:line -w:word
$>hostname //查看主机名称 $>uname -r //查看系统内核 $>uname -a //查看系统内核 $>uname -p //查看系统内核 $>uname -m //查看系统内核
$>file xxx.xx //查看文件类型 $>gzip a.txt //原地压缩 $>gzip -d a.txt //原地压缩 $>gzip -dr tmp //递归操纵文件夹下的文件 $>gunzip a.txt.gz //等价于gzip -d a.txt
$>tar -cvf my.tar 1.txt tmp //创建归档文件 $>tar -vxf my.tar //解档文件
$>find . | grep txt | cp `xargs` temp //xargs是多行变单行,使用空格替换回车换行符. //`` : 是强制命令解析。 $>ping `cat a.txt` //命令嵌套
$>which echo //查看命令的文件路径