1. 查看系统服务命令
ntsysv,这个里面选上的都是系统启动后提供的服务或者使用命令chkconfig查看服务,这个比较详细:chkconfig --level 345 nfs off
2. ln命令详细语法
使用方式 : ln [options] source dist,其中 option 的格式为 :
[-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}]
[--help] [--version] [--]
A "hard link" is another name for an existing file; the link and the
original are indistinguishable. Technically speaking, they share the
same inode, and the inode contains all the information about a
file--indeed, it is not incorrect to say that the inode _is_ the file.
On all existing implementations, you cannot make a hard link to a
directory, and hard links cannot cross file system boundaries. (These
restrictions are not mandated by POSIX, however.)
"Symbolic links" ("symlinks" for short), on the other hand, are a
special file type (which not all kernels support: System V release 3
(and older) systems lack symlinks) in which the link file actually
refers to a different file, by name. When most operations (opening,
reading, writing, and so on) are passed the symbolic link file, the
kernel automatically "dereferences" the link and operates on the target
of the link. But some operations (e.g., removing) work on the link
file itself, rather than on its target. *Note Symbolic Links:
(libc)Symbolic Links.
ln source dist 是产生一个连结(dist)到 source,至于使用硬连结或软链结则由参数决定。
不论是硬连结或软链结都不会将原本的档案复制一份,只会占用非常少量的磁碟空间。
链接文件有硬链接和软链接之分。
软链接相当于文件的快捷方式,当对软链接文件进行修改时实际上是修改了源文件,当删除链接文件时并不会删除源文件。
而硬链接文件则相当于对文件作复制,所不同的是当对源文件进行修改时同时也会修改链接文件,反过来修改链接文件也会修改源文件,删除链接文件同样不会删除源文件。
有人用了一个非常形象的比喻:软链接相当于快捷方式,硬链接相当于实现了同步机制的镜像。对镜像或者本身的任何修改都会同步,但删除不是同步的,呵呵。
软链接是可以跨分区的,但是硬链接只能在同一分区内。
当删除创建的链接文件时,用rm命令,不会删除掉源文件的。
参数 :
-f : 链结时先将与 dist 同档名的档案删除-d : 允许系统管理者硬链结自己的目录-i : 在删除与 dist 同档名的档案时先进行询问-n : 在进行软连结时,将 dist 视为一般的档案-s : 进行软链结(symbolic link)-v : 在连结之前显示其档名-b : 将在链结时会被覆写或删除的档案进行备份-S SUFFIX : 将备份的档案都加上 SUFFIX 的字尾-V METHOD : 指定备份的方式--help : 显示辅助说明--version : 显示版本
范例 :
将档案 yy 产生一个 symbolic link : zz
ln -s yy zz
将档案 yy 产生一个 hard link : zz
ln yy xx
ln -s /lib/modules/2.6.18-238.el5/kernel/drivers/infiniband /lib/modules/2.6.36/kernel/drivers/
cd /lib/modules/2.6.36/kernel/drivers
ls infiniband
infiniband -> /lib/modules/2.6.18-238.el5/kernel/drivers/infiniband
rm /lib/modules/2.6.18-238.el5/kernel/drivers/infiniband //仅删链接文件,不删源文件
3. sudo(可以授予某些用户某些系统操作权利)
1) visudo
2) add the following line: wheel Anand=ALL (or modify the file followd root config)
4.yum自动完成rpm包的下载,依赖分析、安装和更新)
yum命令详解(http://www.onlyblog.com/blog2/qingye/9380.html)
5. 查看系统版本的两种命令
uname -a
cat /etc/issue
6.查看目录大小
[root@localhost rootfs]# du -h -s /lib/ |sort
133M /lib/
7.查看哪个端口被哪个应用程序占用。
netstat abn |more
在windows下可以用
root@ubuntuzhxue1:~# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 4590/Xvnc4
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1301/sshd
tcp 0 0 10.146.180.62:16001 0.0.0.0:* LISTEN 1004/python
tcp6 0 0 :::5901 :::* LISTEN 4590/Xvnc4
tcp6 0 0 :::22 :::* LISTEN 1301/sshd
查看远程主机的端口号是否开放:
[root@gsiftp ~]# telnet 168.63.136.237 22
Trying 168.63.136.237...
Connected to 168.63.136.237 (168.63.136.237).
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
[root@gsiftp ~]#
[root@gsiftp ~]# telnet 168.63.136.237 5901
Trying 168.63.136.237...
8.增加网关
route add default gw 159.226.13.62 netmask 0.0.0.0
route add default eth0 (very cool)
9.分析网络故障的命令
当出现网络故障时,可通过tcpdump(在客户端和服务端)命令来分析接收或发送的报文。
tcpdump ip -nnn & host 159.226.13.52 (这个命令停不下来,再改改)
10.关于NFS
服务端配置:/etc/exports
#all is available besides the commented
#/disk2/osg/app c2*(rw,async,no_root_squash) d229.csdb.cn(rw,async,no_root_squash)
/disk2/osg/app c2*(rw,async,no_root_squash)
#/disk2/osg/CN201-216 c2*(rw,async,no_root_squash) 159.226.13.52(rw,async,no_root_squash)
#/tmp 192.168.21.*(rw)
#/tmp *(rw)
#/disk2/backup *(rw)
配置后:exportfs -av
检查: showmount -e
mount本地目录到另一个目录,好像2.6内核以后支持??:mount --bind /disk2/osg/app /mnt/
11.关于用户管理的命令
Linux用户与组管理http://blog.chinaunix.net/u3/107272/showart_2110516.html
groups - print the groups a user is in 如:groups zhxue
id - print user identity 如:id zhxue
gpasswd administer the /etc/group file (and /etc/gshadow file if compiled with SHADOWGRP defined). System administrator can use -A option to define group administrator(s) and -M option to define members and has all rights of group administrators and members. add and delete users using -a and -d options respectively
[root@c201 ~]# gpasswd -d zhxue zhxue
Removing user zhxue from group zhxue
gpasswd: unknown member zhxue
[root@c201 ~]# gpasswd -a zhxue wheel
Adding user zhxue to group wheel
[root@c201 ~]# id zhxue
uid=500(zhxue) gid=500(zhxue) groups=500(zhxue),10(wheel)
[root@c201 ~]# groupdel zhxue
groupdel: cannot remove user's primary group.
[root@c201 ~]# gpasswd -d zhxue zhxue
Removing user zhxue from group zhxue
gpasswd: unknown member zhxue
You have new mail in /var/spool/mail/root
[root@c201 ~]# groupdel zhxue
groupdel: cannot remove user's primary group.
[root@c201 ~]# id zhxue
uid=500(zhxue) gid=500(zhxue) groups=500(zhxue),10(wheel)
[root@c201 ~]# usermod -g wheel zhxue
[root@c201 ~]# id zhxue
uid=500(zhxue) gid=10(wheel) groups=10(wheel)
[root@c201 ~]# groupdel zhxue
usermod -g 组名 用户名:更改用户所属组,是覆盖;
usermod -G 组名1[,组名2,……] 用户名:添加用户所属组
文章转载自网管之家:http://www.bitscn.com/os/linux/200804/137170.html
建立一个新用户账户,并设置ID:
#useradd caojh -u 544
需要说明的是,设定ID值时尽量要大于500,以免冲突。因为Linux安装后会建立一些特殊用户,一般0到499之间的值留给bin、mail这样的系统账号
12. 根据用户ID杀进程:
ps aux |grep condor |grep daemon | awk '{print $2}' | xargs kill -9 //杀daemon用户的所有和condor相关的进程
一次性杀死某用户所有进程
pkill -uroot
文章出处:飞诺网(www.diybl.com):http://www.diybl.com/course/6_system/linux/linuxjq/20100322/200789.html
13.很酷的ssh命令
ssh c202 'rmdir tt; mkdir bb; mkdir aa' //登录到c202节点执行三条命令
下面这个脚本可以利用ssh -f 写出并行程序:)
#!/bin/bash
Node=( c202 c203 c204 c205 c206 c207 c208 c209 c210 c211 c212 c213 c214 c215 c216)
for((i=0;i<16;i++))
do
ssh -f ${Node[i]} 'ssh-keygen -t rsa; chmod 755 ~/.ssh; cat ~/.ssh/authorized_keys >> /mnt/authorized_keys'
done
14. linux重定向和管道
http://www.cnblogs.com/hongyinvjian/archive/2009/03/18/1415211.html
里面的例子讲了tee的用法,分流。 结果作为wc(统计字数)的输入
当使用Groupdel一个组的时候,如果有用户把这个组当作主组,那么删除这个组时就会出现这个报错信息。解决方法就是更换用户的主组,使用usermod -g groupname username.当没有用户把这个组当作主组的时候,使用groupdel groupname时便可以把这个组删除掉。
注意usermod -g groupname username是把username的主组变成groupname,而usermod -G groupname username只是把用户加到groupname组,并没有改变主组。 |
先给用户增加一个组,再从原来的组中删除,最后删除原组。
[root@c201 ~]# id zhxue
uid=500(zhxue) gid=500(zhxue) groups=500(zhxue)
15. cp覆盖式(不提示)命令
1). cp /etc/profile /nfsrootfamily/202/etc/ 2>&1
2). /bin/cp src dest
3). 'cp' src dest
16.sh,source和exec
sh 会启动子进程。当子进程执行完毕后回到父进程,子进程的一些东西就失效了,比如环境变量,cd等
source:在本进程内执行,所有东西都在
exec:也是让script 在同一个进程上执行,但是原有行程则被结束了
http://blog.chinaunix.net/u3/94212/showart_2278536.html
17.系统硬件
查看系统硬件:lspci |grep **
kudzu --probe --class=network
kudzu --probe --class=*
modprob
lsmod 显示当前加载的所有 模块,相当于cat /proc/modules
modprobe 命令是根据depmod -a的输出/lib/modules/version/modules.dep来加载全部的所需要模块。可以通过modprobe -l来显示可以当前可以加载的模块。modprobe 在挂载模块是不用指定模块文件的路径,也不用带文件的后缀.o 或.ko, 而insmod 需要的是模块的所在目录的绝对路径,并且一定要带有模块文件名后缀的(modulefile.o 或modulesfile.ko )。 insmod比较重要的用途是用来测试模块的正确性,加载一般都是依靠modprobe。
18.硬盘读写性能测试
可以通过使用dd if=/dev/zero of=/file 来测试磁盘的纯写入性能
使用dd if=/file of=/dev/null 来测试磁盘的纯读取性能
使用dd if=/file1 of=/file2 来测试磁盘的读写性能
注意测试时,文件要大于内存,否则受buffer和cache的影响测试结果没意义。
19。 lsof命令(重量级命令):
http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316599.html
20.
一些你不知道的命令:):
http://cloudbbs.org/forum.php?mod=viewthread&tid=8569&extra=page%3D1