您的位置:首页 > 运维架构 > Linux

Linux 学习笔记, 比较乱的那种

2009-08-14 15:42 429 查看
ls [opt] [file]
-a 隐藏文件显示
-l 长格式
-t 按最后修正时间来排序
-r 逆序排列

cp srcFile tgtFile
-i 覆盖确认
-R 目录递归
-p 把源文件的属性也拷过来

mv srcFile tgtFile
-i 覆盖确认
-f 强制

rm filename
-i 每次都要确认
-f 强制处理
-r 以目录为对象,递归删

pwd

cd

mkdir dirName
-p 同时建立多层目录

rmdir dirName
-p 当指定的多层目录中没文件时,同时删目录层

cat filename
-n 行数表示

more filename
less filename

find pathname -name filename

which cmdname # 查找命令的具体位置

man [分类] cmdname
-k 所有可以的命令入口
1 用户命令
2 Unix 系统调用
3 Unix 系统库,函数
4 设备,设备驱动
5 文件
6 游戏
7 其他
8 系统管理
9 内核情报

grep [opt] 条件 [filename]
-e 文字列检索
-i 不分大小写
-v 找出和条件不匹配的项

touch [opt] filename

head [opt] filename
tail [opt] filename
-f 动态查看文件
-n 5 指定最后5行作查看对象

sort [opt] filename
-r 反序排列
-k 5 以第5列作为Key来排序
-n 按数字的大小来排序,01 当成 1
-t : 指定分隔符,默认为空格? /s ?

uniq filename #连续相同的行合并成一行

tr str1 str2 # str1 被 str2 置换

diff file1 file2
cmp file1 file2

vi
:q quit
:q! force quit
:w write
:w! force save
:wq save and quit
:wq! force save and quit
i before cursor insert
a after cursor insert
I head of line insert
A tail of line insert
h go left
j go down
k go up
l go right
^f next page
^b prev page
:1 go to line 1
:n go to line n
:$ go to last line
^g show line/all lines where the cursor staying
x cut a char
dd cut a line
yy copy a line
p paste the buffer after cursor
P paste the buffer before cursor
u undo
/ search
0 go to head of line
$ go to tail of line

useradd username
-c comment
-g group name
-G the secondly group
-d use home directory not default
-s which shell type will be used
-u user id

usermod username
-c comment
-g group name
-G the secondly groupname
-l THE user name will be changed to
-u user id changed to

userdel username
-r 用户目录一起被删掉

groupadd grpname
-g 组的ID

groupmod grpname
-n 组的名字
-g 组的ID

groupdel grpname

/etc/passwd
account passwd uid gid comment homedir shelltype

/etc/group
grpname passwd gid userlist

passwd [user]

gpasswd [grpname]

/etc/shadow
account
passwd
lastChanged
mayBeChanged
mustBeChanged
warned
expires
disabled
reserved

/etc/gshadow
grpname
password
adminlist
memberlist

su [user]
- 执行那个用户的启动设定文件,可能是.bash_profile 之类的
sudo

chown user.group file/dir
-R 目录递归

chgrp group dir
chgrp group file
-R 目录递归

chmod mod file/dir
-R 目录递归

umask
-S 显示当前umask设定
$umask -S
u=rwx,g=rx,o=rx

echo [opt] str
-n 输出str后,不要换行

read workVar

source . shfilename

if [ XXX ]
then
..
elif

fi
a = b
a != b

数值比较
a -eq b
a -ne b
a -ge b
a -le b
a -gt b
a -lt b

文件测试
-f 文件存在测试
-d 为目录
-e 存在
-x 实行
-L 是否为软链接文件

case var in
a)
XX;;
b)
YY;;
esac

for $aa in a b c
do
XXXX
done

while [xxxx]
do
XXXXX
done

until [XXXX]
do
XXXX
done

select me in a b c d
do
XXXX
done

function funname
{
XXXX
}

ping tgt

traceroute tgt

ifconfig eth0 192.168.0.102 netmask 255.255.255.0 broadcast 192.168.0.255

/etc/sysconfig/networks-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=TE:ST:00:00:00:00
IPADDR=192.168.1.55
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet

/etc/sysconfig/networks-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=00:00:00:00:00:00
ONBOOT=no
TYPE=Etherne

/etc/sysconfig/network #网关设定文件
NETWORKING=yes
HOSTNAME=localhost
GATEWAY=192.168.1.1

/etc/network/interfaces #Debian 的IP地址设定文件

/etc/init.d/network restart # 重起网络

netstat
-r 显示路由
-n 显示IP
-a 所有的服务都要看
-t TCP的服务
-u UDP的服务

route
add -net 192.168.2.0 netmask 255.255.255.0 eth0 #加一个路由
add default gw 10.10.10.10 eth0 # 加网关
del -net 192.168.2.0 netmask 255.255.255.0 eth0

nslookup tgt #向DNS查询IP或域名

20:ftp
21:ftp
22:ssh
23:telnet
25:smtp
53:dns
80:http
443:https

iptables
-L 显示所有防火墙设定

/etc/init.d/httpd
start
restart
stop
status

chkconfig # 查看服务在各个runlevel 下的设定情况
--list 服务状态显示

# chkconfig --list httpd ↵ Apache(httpd)の設定を表示
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off 3~5がoff

#Apache 的两个LOG
/var/log/httpd/access_log
/var/log/httpd/error_log

/etc/init.d/smb [opt]
start
restart
stop
status

/etc/xinetd.d/swat

smbpasswd username
-a 口令作成
-x 用户删除
-d 无效化
-e 有效化

/etc/named.conf #DNS的域名定义

/etc/init.d/named
start
restart
stop
status

dig #向DNS查询

hostx:0.1 #向网络上提供 0:1 的画面 0:第一块显卡, 1:第一个画面

export DISPLAY=hostx:0.1 #网络客户机的设定,用来使用远程的画面

NIC:Network Interface Card
FHS:Filesystem Hierarchy Standard

1M(メガ)バイト=1024Kバイト
1G(ギガ)バイト=1024Mバイト
1T(テラ)バイト=1024Gバイト
1P(ペタ)バイト=1024Tバイト
1E(エクサ)バイト=1024Pバイト

fdisk /dev/sdc
p 当前情况显示
n 作成一个新的分区
1 选择分区号
t 分区类型指定
w 写分区表,没有这一步,可以q 出去,
q 不保存直接退出

df #mount 情况显示
-h 看起来容易的大小单位来显示

mkfs [opt]
-t 文件系统类型指定 ext3
-c 查坏道,然后不使用那一块

e2label dev [label]

mount -t type -o opt dev mountpoint
-t type
-o rw,ro
#mount -t ex3 -o rw /dev/sdc3 /opt

umount

mkswap
-c 检查坏道,并且不使用

swapon -s [devFile]

mount
-a /etc/fstab 里面设定的,swap以外的分区都mount进来

#mount -t iso9660 -o ro /dev/hdc /media/cdrom

df -i #inode 情报显示

ln
-s 软件LINK作成

fsck

du [dir]|[file] #检查文件,文件夹的大小
-s 大小总计
#du -s * 查看当前目录下有多少文件夹是空的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: