linux整理

工做中經常使用整理:html

開啓: chkconfig iptables on 關閉: chkconfig iptables off
ps -ef|grep tomcat
username -a
env|grep java
unzip xxx.zip -d /usr/local/xxx
查找經常使用: find / -iname "*tomcat*"
看文件:less -n xx文件 仍是比較實用的java

一:linux

1.啓動過程ios

系統-》boot->init->運行級別-》/etc/init.d-》loginshellshell

2.各類目錄數組

a.設備也是目錄。tomcat

3.密碼忘記怎麼辦?安全

重啓,單用戶登陸後重置root密碼。bash

4.如何遠程登陸LInuxless

用putty等安全祕鑰設置後登陸。

5.文件權限

屬於本身的文件,同組的權限,不一樣組權限。用戶是按組劃分的,1個用戶可能屬於多個組。

6.改變權限

a.更改屬性,chgrp,chown,chmod,還有符號方式。

7.顯示當前目錄

pwd

8.持續監聽文檔變化,如日誌編碼

cat -nf /etc/test.log

9.用戶管理

a.useradd

b.userdel

10.用戶組管理

a.groupadd 

b.groupdelll

c.初創用戶默認是屬於和本身同名的組。

11.用戶也能夠進行批量的添加操做,最終的文件都不變。

12.磁盤空間

a.df,整體文件系統

b.du,每一個文件列表大小

c.fdisk,查看分區

d.mount/unmount

12.vi

13.yum是一組自動的控制功能。

二:shell腳本

1.多數關注bourne again shell.直接執行./test.sh,/bin/sh test.sh.

2.shell個人測試腳本》

#shell測試腳本start

#!/bin/bash
echo "hello world!"
your_name="gxl"
echo $your_name
your_name="gxl2"
echo ${your_name}
arg2="gxl22222"
unset arg2
arg3="hello3${your_name}finish.."
echo ${arg3}"len is:" ${#arg3}
echo `expr index "$arg3" fin`
array_name=(
v1
v2
v3
)
echo ${array_name[@]}
#this is comment
echo 'arraylenis:'${#array_name[0]}

#shell測試腳本end

3.sell參數傳遞測試

echo "shell arguments test..."
echo "file name:$0"
echo "arg1:$1"
echo "arg2:$2"

echo "args num: $#"
echo "total args :$*"
echo "current process:$$"
echo "shell set info :$-"
for i in "$*";do
    echo $i
done

for i in "$@";do
    echo $i
done

4.關於數組只支持1維數組,上面的實例已集成。

5.shell運算符

a.基本

b.算數

c.關係

d.布爾

e.邏輯

f.字符串

g.文件測試

6.echo

a.原樣輸出用'',不執行命令。

b.使用read讀入

7.print/test命令

8.shell流程控制

a.for語句

b.while

c.case

d.break/continue

9.shell function 定義調用

10.shell輸入輸出重定向

a./dev./nulll能夠禁止輸出

12.文件包含引用

整體測試腳本:

#!/bin/bash
echo "hello world!"
your_name="gxl"
echo $your_name
your_name="gxl2"
echo ${your_name}
arg2="gxl22222"
unset arg2
arg3="hello3${your_name}finish.."
echo ${arg3}"len is:" ${#arg3}
echo `expr index "$arg3" fin`
array_name=(
v1
v2
v3
)
echo ${array_name[@]}
#this is comment
echo 'arraylenis:'${#array_name[0]}

echo "shell arguments test..."
echo "file name:$0"
echo "arg1:$1"
echo "arg2:$2"

echo "args num: $#"
echo "total args :$*"
echo "current process:$$"
echo "shell set info :$-"
for i in "$*";do
    echo $i
done

for i in "$@";do
    echo $i
done

a=10
b=20
val=`expr $a+$b`
echo "a+b:$val"

val=`expr $a-$b`
echo "a-b:$val"

val=`expr $a \* $b`
echo "a*b:$val"

val=`expr $a / $b`
echo "a /:$val"

val=`expr $b % $a`
echo "b % a : $val"

file="/home/gxl/test.sh"
if [ -r $file ]
then
echo "file can read"
else
echo "file can not read"
fi 

read name
echo "$name is ok"

echo "file info test" > myfile
echo '$name\"'

echo `date`

if [ $a == $b ]
then
echo "a equals b"
elif [ $a -gt $b ]
then
echo "a bigger than b"
elif [ $a -lt $b ]
then 
echo "a littl than b"
else 
echo "not match condition"
fi

num1=$[2*3]
num2=$[1+5]
if test $[num1] -eq $[num2]
then
echo "number is equal"
else
echo "number is not equal"
fi

for var in it1 it2 it3
do echo "info is $var"
done

for str in 'this is a string test'
do
    echo $str
done

int=1
while(( $int<=5 ))
do
echo $int
let "int++"
done

echo -n 'input your like file name:'
while read FILM
do 
echo "yes! your like $FILM is a good film"
done

x=1
until (( x>=100))
do
    echo "until test $x"
    let "x++"
done

echo 'input your num'
read ynum
case $ynum in 1) echo 'choise 1'
;;
2) echo 'choiose 2'
;;
3) echo 'choise 3'
;;
*) echo 'others'
;;
esac

while :
do 
echo -n "input number between 1 and 5:"
read ynum
case $ynum in 1|2|3|4|5)
echo "your num is $ynum!"
;;
*) echo "your num is over the top"
break
echo "game over";;
esac
done

demoFun(){
    echo "this is a funtest"
}
echo "---funteststart"
demoFun
echo "---funend"

funWithReturn(){
    echo "input your number 1"
    read aNum
    echo "input your number 2"
    read aNum2
    echo "two num is $aNum and $aNum2"
    echo "total args is :$*"
    return $(($aNum+$aNum2))
}

funWithReturn 'arg1' 'arg2'
echo "two num sum is:$?"
二:整理linux2

1.操做系統-/boot-init進程-運行級別-/ect/init.d-用戶登陸-loginshell

2./bin:經常使用命令;/boot啓動核心文件;/dev外部設備和訪問文件方式相同;/etc系統管理所需的配置文件;/home用戶目錄;/lib類型dll,應用程序用;/lost+found非法關機存放的文件;/media linux自動識別設備,u盤光驅;/mnu臨時掛載;/opt主機額外安裝軟件;/proc內存映射;/root系統管理員主目錄;/sbin系統管理員程序;/selinux防火牆安全;/srv服務啓動後數據;/sys內核文件;/tmp臨時文件;/usr用戶多應用程序;/usr/bin系統用戶應用程序;/usr/sbin超級用戶使用的高級的程序;/usr/src內核源碼;/var各類日誌變量

3.d目錄;-文件;/鏈接件;b可隨機存儲設備;c串行

文件類型 屬主權限 屬組權限 其餘用戶

d                rwx           rwx            rwe

0               123           456           789

user gorup(users) 屬用戶 屬同組 其餘用戶s

4.r(4)w(2)x(1)

5.ls -l 查看詳細的文件信息:http://blog.sina.com.cn/s/blog_406127500101dgl8.html

6.用戶是能夠批量添加的。默認添加的用戶數目同名的用戶組。

7.df -ah ;du -h

相關文章
相關標籤/搜索