linux系统入门命令
Linux命令操作技巧
[root@localhost /]# cat test1
this is a test file
[root@localhost /]# cat test2
cat: test2: No such file or directory
[root@localhost /]# cat <test1>test2
[root@localhost /]# cat test2
this is a test file
[root@localhost /]#
查看网卡
[root@localhost /]# dmesg | grep eth0
[ 1.551363] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:80:9c:a0
[ 1.551368] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
文件权限
查找文件
which:查找某些可执行程序
whereis:查找可执行程序,相关配置文件,帮助信息
locate:模糊搜索,列出相应的文件
find:
文本编辑器
进程
##shell
shell简介
[root@localhost /]# vi shelltest
[root@localhost /]# cat shelltest
#!/bin/bash
# program
# This program shows "Helloworld!"
echo -e "Hello world.\n"
exit 0
[root@localhost /]#
[root@localhost /]# sh shelltest
Hello world.
[root@localhost /]# ./shelltest
-bash: ./shelltest: Permission denied
[root@localhost /]# chmod 744 shelltest
[root@localhost /]# ./shelltest
Hello world.
shell变量
shell脚本
#!/bin/bash
# program
# This program shows "Helloworld!"
#echo -e "Hello world.\n"
#exit 0
v1=centos
v2="this is a test filed"
a=10
b=20
echo $a
echo $b
echo $v2
# mathmatical
echo $(($a+$b))
echo $(($a*$b))
# String length
echo ${#v2}
echo $v2
echo ${v2:5}
echo ${v2:5:5}
echo ${v2#this is}
运行结果
[root@localhost /]# ./shelltest
10
20
this is a test filed
30
200
20
this is a test filed
is a test filed
is a
a test filed
shell中的判断
分支结束,关键字反写
for循环
#! /bin/bash
for((i=1;i<=10;i++));do
echo $i;
done;
~
[root@localhost /]# vi for
[root@localhost /]# sh for
1
2
3
4
5
6
7
8
9
10