linux 笔记 shell

#man bash

#shell 首选 /bin/bash 类似C语言

chsh -l

[root@station198 桌面]# echo $SHELL
/bin/bash


[root@station198 桌面]# chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh

[root@station198 桌面]# set

#变量:
#环境变量 : 全局		export 例如:export var = 2
#本地变量 : 局部			   :var = 2
#特殊变量 : shell特有

[root@station198 桌面]# ps aux | grep bash
root      1711  0.0  0.0 108192   776 ?        S    09:35   0:00 /bin/bash /usr/sbin/ksmtuned
root      2810  0.0  0.0 108324  1704 pts/0    Ss+  09:36   0:00 /bin/bash -l
root      3172  0.0  0.0 108324  1840 pts/3    Ss   09:47   0:00 /bin/bash -l
root      3276  0.0  0.0 103248   864 pts/3    S+   09:54   0:00 grep bash

[root@station198 桌面]# ps -o pid,ppid,comm   : 查看进程ID
  PID  PPID COMMAND
 3172  2808 bash
 3296  3172 bash
 3314  3296 ps

#ppid:父进程
#父子shell

-rw-r--r--. 1 root root 56 12月 18 10:07 1.sh
[root@station198 shell]# ./1.sh
bash: ./1.sh: 权限不够
[root@station198 shell]# chmod u+x 1.sh
[root@station198 shell]# ls
1.sh
[root@station198 shell]# ls -l
总用量 4
-rwxr--r--. 1 root root 56 12月 18 10:07 1.sh
[root@station198 shell]# ./1.sh &             #后台执行
[1] 3524

[root@station198 shell]# kill  -9 3524
[root@station198 shell]# jobs
[1]+  已杀死               ./1.sh


#./(子进程)
#source 

[root@station198 shell]# source 1.sh 
[root@station198 shell]# echo $var
100

[root@station198 shell]# which sh
/bin/sh

#set -X : 调试时使用
[root@station198 ftp]# set -o nounset

#man bash 
#/PS1 然后使用【n】 找到初始定义位置

#初始化
[root@station198 sysconfig]# vim /etc/rc.sysinit(系统初始化) 
[root@station198 sysconfig]# vim /etc/profile(PATH)
[root@station198 sysconfig]# vim /etc/bashrc(PS1)

特殊变量:Special Parameters
$0 $1 $2 $3 .... $255

【ESC】进入命令行->【YY】->【P】 复制  【U】:撤销

ls /etc/tt # $?  只记录最近一次调用的命令
$# 表示参数个数
$* = "$1 $2 $3 $.....  $254"
$@ = "$1" "$2" "$3" "$4" ....

$ : 当前进程对应pid --当前执行脚本的pid #ps -o pid,comm | grep bash
防止 进程竞争 yum install if*


$! : 后台进程对应pid 


[root@station198 bak]# find /etc/ -name "*.conf" -exec cp {} /shell/bak \;

语句:

if [ -f /etc/vsftpd/vsftpd.conf ]; then

else

fi

ps axo pid,comm | grep ftp


[root@station198 bak]#id test














评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值