3 linux命令行与shell脚本编程大全_part1

0 查看文件内容

stat test # 统计信息
file test # 类型
# 所有内容
cat test
more test
less test
# 部分内容
tail -f log
head log

1 监测命令

ps
top # 实时查看
kill [PID]
killall http*
# 把iso镜像当真实CD来挂载,从而访问其文件系统
mount -t iso9660 -o loop MEPIS.iso mnt
# 卸载设备
umount /home/rich/mnt
# 已挂载磁盘的空间
df -h
# 当前目录的空间
du -h

2 处理数据文件

sort test # 排序:可选参数
grep [pattern] test # 搜索
# 压缩文件
bzip2/bunzip2
gzip/gunzip
zip -r testzip test # 不是标准工具
tar -xvf test.tar

3 环境变量

printenv/set/export/unset
PATH=$PATH:. # 当前目录,直接执行test.sh
# 启动文件
/etc/profile
$HOME/.bash_profile
$HOME/.bash_login
$HOME/.profile
# 可变数组
mytest=(one two three four)
echo ${mytest[*]}

系统环境变量都是大写,建立个人变量要用小写。

4 安全性

/etc/passwd
/etc/shadow
/etc/group
useradd/userdel/usermod/groupmod
umask/chmod/chown/chgrp

5 软件包管理

# Debian系
dpkg;aptitude;apt-get/apt-cache
/etc/apt/sources.list
# Red Hat系
rpm;yum;urpm/zypper
/etc/yum.repos.d
# tarball源码
tar -zxvf sysstat.tar.gz; cd sysstat; ./configure; make; make install

你可能感兴趣的:(3 linux命令行与shell脚本编程大全_part1)