Linux常用命令总结

jopen 10年前

1、查看防火墙:service iptables status

2、关闭防火墙:service iptables stop 永久关闭:chkconfig iptables stop
3、设置ip地址:setup
4、强制停止进程:kill -9 进程号
5、观察执行结果:watch
6、重启网络:service network restart(修改ip后腰重启)
7、查看本机的hostname:cat /etc/sysconfig/network
9、查看是否安装ssh:rpm -qa | grep ssh 
scp 文件名 root@slave1:路径名(ssh传输文件)
10、给文件重命名:mv hadoop_1 hadoop
11、 chown   –R  hadoop:hadoop hadoop # 将文件夹"hadoop"读权限分配给hadoop用户
12、pwd 查看当前路径
13、重启/ect/profile   source /etc/profile
14、查看 某个文件是否存在 rpm -qa|grep bind
15 强制删除某些东西:rm -rf 文件名
16 将某些文件移动到 某个文件夹 mv *.* 文件目录(。/chroot/var/named)
17 “_”表示普通文件,d表示文件目录
18、硬链接:多个对象引用同一个地方,当一个对象删除时另一个对象还在,但是修改的时候是实时修改的。
ln  test.txt /var/hah.txt
软连接:就像建立快捷方式类似,删除的时候另一个不能用了,但是修改是实时更新的。
ln -s test.txt  /var/hah.txt
19、 查看时间 date +"%Y-%m-%y  %H:%M:%S"
20、who 当前访问该主机的用户
21、uname -a 查看本机信息  uname -r 
22、shutdown -h now
23、当前位置 which is
24、清屏命令clear
25、查找文件位置:where is
26、别名:alias ll="ls -al"
27、一页一页查看文件:more  文件名
28、移除目录 rmdir  创建文件 mkdir
29、输出重定向:ls -al>haha.txt   echo "hello" >haha.txt 会覆盖原来的信息
30、输出附加重定向: echo "hello" >>haha.txt
31、输入重定向查找 类型txt文件的查找工具 grep hello <haha.txt
32、管道操作符:ls -al>>h.txt
ls -al 1 >>h.txt 
lsa  -al 1 >>h.txt 2 >>h2.txt 或者lsa -al 1>>h.txt 2 >>&1
0 标准输入 1 标准输出 2 标准错误输出
33、查看进程 ps ;ps -aux
34、日志目录:/var/log
35、解压 tar -zxvf test.tar.gz  -C  解压目录
        压缩:tar -zcvf  test.tar.gz  test.txt
36、压缩:zip -r test.zip ./test.txt -r表示递归
        解压:unzip -o test.zip  unzip -d test.zip 解压目录
37、把一个命令结果当作参数
$(which touch) 或者 ls -al "which touch"
38、“;”表示连续执行命令  ls -al ;echo "hello"  cmd &&cmd2 cmd1||cmd2
39、watch 观察  watch -h 3 -d "free -b";
40、top 动态查看进场 ps只是进场的快照
41 监测端口 netstata -anpl
netstata -anp |grep :22
42、查看一个文件路径 rpm -ql|grep httpd 
43 vi 编辑 查找某个字段 / index.html  n查找下一个 setup nu 显示行号