日期:2014-05-16  浏览次数:20723 次

Linux培训系列(一)

=>linux命令

ls -dl?? 查看目录本身

ls -rl?? 查看目录内部

ls -i?? 查看索引节点号

ls -id 查看目录的节点号

?

mkdir -p? 创建父目录

touch

echo "test" > test.txt

cat test.txt

cp

mv

ln -s

rm -rf

?

=>regexp

+,.,、,*,[,],\作为单字符时需要用\来转意

.:元字符,与任何单个字符匹配

[1,2]:指定匹配字符1,2.方括号内部不做转意

[^12]:排除1,2

*:0次或多次重复前一个字符

grep ^# /etc?:? 以#开头的行

grep '^#.*\.$' /etc/fstab? 以#开头,以.结尾的行

?

?=>FHS与查找文件

/(根目录)
/boot(引导装入程序的静态文件)
/dev(设备文件)
/etc(主机特定的系统配置)
/lib(基本共享库和核心模块)
/mnt(临时挂装文件系统的挂装点)
/opt(附加的应用程序软件包)
/sbin(基本系统二进制文件)
/tmp(临时文件)
/usr(辅助层次结构)
/var(可变数据)

?

+---------+-----------------+-------------+
| | 可共享 | 不可共享 |
+---------+-----------------+-------------+
|静态 | /usr | /etc |
|?????????| /opt | /boot |
+---------+-----------------+-------------+
|可变 | /var/mail | /var/run |
|????????? | /var/spool/news | /var/lock |
+---------+-----------------+-------------+

?

which? ls,是否有ls

which -a ls,显示所有相关

whereis

find /usr/share/doc -iname README\*

find /etc -iregex '.*.txt.*'

find /usr/bin -name '*vim*' -type l

find /usr/bin -type f -size -50c -exec ls -l '{}' ';'

find:全路径匹配

locate:与路径的任何部分匹配

updatedb:为文件系统建立索引

slocate: locate的安全版本

?

=>进程控制

Ctrl+C?? or? ^C: kill process

Ctrl+Z?? or ^Z?? : stop prcess

fg:前台运行

bg:后台运行

xeyes -center blue &:后台运行

jobs -l?? :查看后台运行程序

ps -ax

ps x --forest

ps -au

ps -al

top

nice

renice

?

=>文本处理

cat---tac

sort

uniq

cat myfile.txt | sort | uniq | wc -l

wc

head

tail

expand

unexpand

?

=>系统和网络文档

手册页 /usr/share/man

man1? 用户程序

man2 系统调用

man3 函数库

man4 特殊文件

man5 文件格式

man6 游戏

man7 其它

$whatis printf

$man 3 printf

$man -k whatis?? 搜索手册页的NAME 这一节

#makewhatis??? 它扫描您的 Linux 系统上的所有手册页,并且为 whatis 和 apropos 构建数据库

info diff

info info

/usr/share/doc??? 帮助资源

?

=> Linux权限模型

“d”目录
“l”符号链接
“c”字符专门设备文件
“b”块专门设备文件
“p”先进先出
“s”套接字

“-”常规文件

whoami

groups

chown

chgrp

chmod +x

umask

suid

sgid

?

=> linux账户管理

/etc/passwd

?drobbins:x:1000:1000:Daniel Robbins:/home/drobbins:/bin/bash

?/etc/shadow

/etc/group

?

?