`
mmdev
  • 浏览: 12894546 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

linux 命令行大全

 
阅读更多
*?????????????????????????????????????????????????????????????????????
*?????????????????????????????????????????????????????????????????????


vedio.23,无法识别网卡,找不到资料,以后再看

**============================================================================================
ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			
**============================================================================================
ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			ftp			
**============================================================================================

*登录,退出
	** ftp 192.168.0.1
	** bye
	
*下载
	**	get xxxx.zip
rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ



**============================================================================================
putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 		
**============================================================================================
putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 		putty 	
**============================================================================================

绿色:可执行文件
蓝色:目录
红色:tar包 压缩文件
黄色:设备文件
浅兰色:链接文件





**======================
虚拟机设置		net和主机公用一个ip

**======================
	* command
	&	descirbe


*内核

*命令
	**ifconfig	查看IP地址
	**clear 清屏
	**ls -l /home	--show a dir content 根目录下的
		ls /dev|more --管道分页

	**useradd jack	创建用户
		passwd jack	激活用户,去创建密码

	**帮助	
		**ls --help
		** man ls		---q退出	--default is man1
			 ls /usr/share/man  --man的配置
			 man1	--user command
			 man5	--file
		**info ls
	
		**ls -l -长模式
		**ls -a 隐藏文件

	**cp
		cp ./b.c ./yang		---'./' is current directory,'./..'is parent directory
			"." and ".." all are hard links
		cp -r  /etc/sound /root	---copy directory
		cp -r /root/yang .  --copy to the current directory
		
	**mv --move or rename
		 mv index.html yang		 
		 mv yan.c guo	----if the name is unsame,'mv' can rename
		
	**rm
		rm yang/qqq.c	 --remove the file and reply 'yes'
		rm -f yang/b.c		---femove the file forced
		
	**touch	create a empty file or update the time of file
		
	** cd ~ --go to the home dir of  current user	
		
	**pwd	--see the real complete path
		
	**mkdir
	**rmdir -- remove a empty dir
		 rm -fr yang	--remove a dir forced anyway	
	
	**cat	 ---see the content of file
	**more 	--see the file per a screen	,only can go down
	**less  ---it just like 'more' but can go up
	**date	
	**cal	
	**df	--the the capacity of disl
		 df -h ----see the size with the unit of G
	**du	--see the size of file
		 du -h sound ----see the size with the unit of k
	**head	--see the front lines (default is 10 lines)
		 head 30  install.log	---see the front 30 lines 
	**tail	
		 tail -f messages	---see the content with date

	**控制台
		**alt+f7	--change the current console	
		**env --see the environment variable
		**su jack --change the current user,but don't change the environment variable
		**su - root --change the current user,and change the environment variable
			有高级用户向低级用户切换时候,不用输入密码
		
	**重启
		**reboot
		**shutdown -r now
		**inti6
	**关机		
		**halt
		**shutdown -h now
		**poweroff
		**init0
	**file		
		file b.c ---see the informatio of file
	**chmod --change the right of file	
		chmod u+x install.log	--grant right of x on  install.log to u 
		chmod u-x install.log
		chmod u=rwx b.c		--grant authority no matter whether u has those right
		chmod 777 xiao.txt --change the authority by integer :r-4,w-2,x-1
		chmod -R  777 guo --change the authority about all the file recurrence
	**chown 	--used by root to change the ownner of the file
		chown jack hello.c
	**chgrp 	--used by root to change the groupe of the file
		 chown root[1]:root[2] hello.c	--root[1] is ownner,root[2] is group
		
		
		
		


	**echo
		echo "nihao a "> b.c	--write words to a file

	**建立链接
		**硬链接 --完全等同与源文件,不能为dir做链接
			 ln b.c bb.c
		**软连接	--快捷方式
			 ln -s bb.c bs.c
		
	**id root --see the infomation of the user	
	**umask 022	-change the umask value	


//=====================================	
*umask 		--决定用户的默认权限
	**一般用户umask为002	
		系统用户umask为022
	** umask	---ses the umask with integer
		 umask -S	-- see the umask with letter
	&&文件默认是rw-rw-rw,经过umask运算类得到相对应用户的权限	
		
	
*[root@localhost root]#
	**[用户名@主机名 当前目录]#
	默认登录到home
	# --supermanager
	$	--common user


* dev  --device file
		**bxx-块设备, cxx-字符设备


*虚拟控制台 ,用户身份切换 
	**虚拟控制台12个,前六个本地登录	
	**vi /etc/inittab 修改控制台文件
		# Run gettys in standard runlevels  --means 6 consoles
			1:2345:respawn:/sbin/mingetty tty1
			2:2345:respawn:/sbin/mingetty tty2
			3:2345:respawn:/sbin/mingetty tty3
			4:2345:respawn:/sbin/mingetty tty4
			5:2345:respawn:/sbin/mingetty tty5
			6:2345:respawn:/sbin/mingetty tty6
	**alt+f7	--change the current console
	
*文件种类
	- 一般文件
	d:目录文件
	b:块设备文件	---硬盘,软盘,打印机
	c:字符设备文件	--键盘,鼠标
	l:链接文件	--快捷方式
		软链接,硬链接
	p:人工管道
		
*文件权限
	**用户分类
		**文件拥有者 u
		**所属组的成员 g
		**其他用户	o
	
	**-rwx[1]r-x[2]r-x[3]    1[1] root[1]     root[2]   11554[1]  12月 21 18:04[1] b[1]
		rwx[1]	--文件拥有者的权限
		r-x[2]	---群组成员的权限
		r-x[3]	--其他用户的权限
		1[1]  --硬链接号
		其中root[1]是拥有者,root[2]是群组
		11554[1]  --大小
		12月 21 18:04[1]	--修改时间
		b[1]	--文件名
		

	**权限分类
		**读 r
		**写 w
		**执行 x

	**强制位		--ext2	---表示以后再目录中无论谁创建文件,都是setuid等规定的组
		**set uid	--u	--s--4	-如果没有,用大写表示,如果原先有,用小写表示
		**set gid	--g	--s--2
	**冒险位 
		**sticky	--o	--t--1
		
	** chmod 4000 4000		---更改权限

	**ext2/3中文件的构成
	**文件名最大为255字符,
		
*目录	

*Linux中 的应用工具分类
	&&交互工具
	&&过滤器
	&&编辑器

**输入输出	--对应文件存放在/dev/std*
			--/dev/stderr  /dev/stdin  /dev/stdout
	&&标准输入stdin(0)
	&&标准输出stdin(1)
	&&标准错误输入stdin(2)
	
*重定向
	**'<'重定向输入源	
	** tr 'o-z' 'O-Z' < hello.c		//--tr is modify the char
				----make 'tr' execute with  data of hello.c
				----this command sentence is to upcase thel letter between 'o' and 'z'
	&&标准输入重定向
	**<< --save all letter from keyboard temperary then send them to shell only once
	**cat > tt.c <<!		///--write to tt.c end by '!'

	&&输出重定向
	** ls > lsfile	---write the info which should be printed to lsfile
								 and override the old content of lsfile
	** ls >> lsfile --append new content to old content of lsfile
								 
	&&错误输出重定向	2>
	**ls-l 2> errfile 	--put the error message to errfile and override
	**ls-l 2>> errfile 	--don't override


	&&双重输入输出重定向
	**ls-l 2> errfile 2>> errfile --redirect once
	**ls-l &> allfile		--put all infomation to a file once
		ls-l > allfile 2>&1		--same as &> ,2> is error info,'1' is correct info
	

*管道
	** ls -l /etc |more
	 ls -l /etc |more |grep sysconfig --use some pipe once

	**cat < file1 > file2 ---cope the content of file1 to file2
	**cat hello.b hello.c > all.c	----merge some file to a singal file
		cat hello.* > all.c 		---same to upper

*可执行文件搜索
	**which	--查找可执行文件的完整路径,查询顺序alias(别名) ->$Path
		** which ls
		**echo $PATH  ---show the system path
		
	**whereis --more detailed than which

*普通文件查找,
	**slocate  & locate		--all same
		&&/etc/updatedb.conf	---updatedb数据库的配置
		**updatedb --update the database
	**find ---不用数据库,因此比slocate慢
			  -user,-group,.nouser,.name.perm,size,type,nouser(don't have user),nogroup
		**find /root/guo -user jack ---find file in folder guo ownned by jack
		**find . -group jack	---find file in folder guo ownned by group jack
		**find -name hello
		**find  -size +10	---find file whose size larger than 10k
		**find -perm 0644   ---find file by authority
			find -perm -6000	--有'1'的位必须都有'1'
			find -perm +6000	--有'1'的位只要有一位有'1'即可
	
	** 
		**-exec 指令 {} \ ;		--'{}'表示找到的文件,'\'表示禁止转义';'表示结束
		
*常用的文件操作指令
	** wc  --统计文件的行,词,字数
		wc tt.c --- -l 行数,-w	词数,-c	字符数
	**grep  --显示文件匹配关键字的行
		grep -n -v pri tt.c	//-能显示行号,-v显示未选中行
	**sort		--排序,-k 根据那一栏排序,-t	根据什么分割烂,
		 sort -t: -k3 /etc/passwd  ---以':'为分隔符,分割后的第三栏排序
	**diff	--查看文件的差异
		diff hello.c hello.b
				2c2		---第2行
				< int Main()	--'<' 表示前面的文件
				---
				> int main()	--'>' 表示后面的文件

	**comp	--show where are the differiences
	**uniq	---show the content unique
	**cut  --show a special line 	
			 cut -f3 hello.c	--only show a filed special
			  cut -c3-11 hello.c	---cut chars from No.3 to No.11
			 
			 
	**paste ---将文本安列拼接 	
		 paste hello.c hello.b >> all.c --pastte the content of hello.* to all.c
		 cat hello.c hello.b > all2.c	---cat是竖直的merge,而paste是水平的
		
*压缩
	**gzip,gunzip	---linux标准压缩工具,压缩文件
		**gzip all2.c --压缩
		**gzip -d all2.c.gz	--解压
		** zcat all.c.gz --查看压缩文件的内容
		
	
	
	**compress,uncompress		--旧的unix压缩工具
		
	**bzip2,bunzip2		--更新的linux工具
		** bzip2 all2.c	--压缩
		** bunzip2 all2.c.bz2	--解压
		** bzip2 -d all2.c.bz2	--解压
		**bzcat all2.c.bz2 	--查看压缩的文件内容
		
*tar 	--打包,但不压缩		
		c 备份 ; v将过程输 出; x从文件中解出备份
		f 打包后的文件名; t, list the contents of an archive(档案)
		C,change to directory DIR
		** tar cvf auth.tar auth	--打包
		**tar xf auth.tar		--解包
		**tar tf auth.tar --查看包中内容
		**tar cvf  my.tar hello.c -C /root --更改打包后的存放路径
		**tar zcvf 2.tar.gz auth		--打包并用gzip压缩,文件名无所谓
		**tar zxvf 2.tar	--解包并用gzip解压
		
		** tar jcvf 3.tar.bz2 auth	--打包并用bzip2压缩
		**tar jxvf 3.tar.bz2		--解包并解压
*dump  --备份ext2/3文件系统
		**dump -0[1]u[1] -f[1] /../..[1]  /../..[2]
			--0[1],完全备份;u[1],备份操作记录在/etc/dumpdates中,
				u[1]在备份子目录时候不能使用此参数,只有顶层目录才可以
				f[1],指定备份路径,/../..[1],备份的路径
				/../..[2],源路径
		**dump -0 -f myback  guo  ---将过被分在myback文件中
			dump -0u -f /dumproot /boot		备份顶层目录
	**df --显示每个文件所在文件系统的信息	
	/etc/passwd	----存放用户信息	

*restore		--还原ext2/3文件系统
	** t,列出备份文件内容;r,还原;f,指定文件
	**restore -rf 
		 restore -tf /dumproot
		 restore -rf
		
*shell	 /etc/shells--shell存放位置
*BUSH	
	**变量
		**echo $a		---得到变量值
			echo ${a} 	
		**a=${a}123 --不能有空格
		**unset a	--删除a
	**env	--查看环境变量--- ,包括字符集
		set	--查看所有变量
			环境变量大写,一般变量小写
		
	**预定义环境变量 --
		**cd $PATH  --go to the home directory
		
		**HOME	--current user ' home directory
		**PATH	--the path to find executable file 
		**LANG	--default language
			**locale -a --查看locale信息
		**PS1		--行提示符
			\d,日期; \H主机名;\h,主机名称的第一个词
			\t,时间(24,hh:MM:ss);\T,时间(12);\A(24)
			\u,current user acount,\v,bash version;\w,complete work directory'
			\W,current directory' basename' last name;\#,the number of command;
			\$,the user' identity
			
			$PS1==\u@\h \W]\$
	**export a 	---将一般变量改为环境变量
	
	**history --show comands userd recently
		history 10	--show the last 10 commands
		echo $HISTSIZE	--show the number of command system can remenber
		
	**!
		!!	--重复执行上一条指令
		!a	--重复执行上一条以a为首的指令
		!number	--执行记录号码为number的指令
		!-number	--执行前第number条指令
		!$ --get the  last word of  last command
		[ctrl + r] ---seek one of command of history
		
	**别名		
		**ll --like ls -l
		**alias --show all the alias
		**alias a="ls -l"  --set a alias
		** unalias a --remove a alias

	**命令行输出
		&& " .. "		--如果有特殊符号,则转义
				$ ,\,`,! 	--' " ' 无法禁用
		&& ' .. '	--如果有特殊符号,不转义
	**执行引用符
		 ls -l `pwd`		---先执行pwd,其结果作为参数由ls -l 来执行
	**数学运算	---$[]
		echo $[1+4]
	**逸托符 ---	\,	
			--用于取消命令行中的特殊含义,转义
			--表示一行未结束
	** 命令行结束符;	--	
		ls; pwd; ls -l		--exectue many commands once
	**子shell激活()	
		 (HOME=/root)	--这条命令在子shell中执行,不影响当前的shell
	**逻辑运算符 &&,||	如果符合条件,后面的命令就不执行
		 ls -l ccc ||mkdir ccc		--如果 ls -l ccc不存在ccc,则创建ccc
		 ls goog.c && echo yang || echo guo		--模拟'?:'运算符,都是顺序执行的,
	**定制登录shell	
		&&全局设置文件
			/etc/profile				----所编序号为登录时,文件加载顺序
			/etc/bashrc						---后面的会将前面的覆盖			
		&&用户设置文件
			~/.bash_profile		
			~/.bashrc		
		&&其他
			~/.bash_logout
			~/.bash_history
			/etc/profile.d
	**login as: root 	--初次登录	
			加载顺序:/etc/profile	=> ~/.bash_profile => ~/.bashrc => /etc/bashrc
	**su jack ---开启非登录shell
			加载顺序:~/.bashrc	=>/etc/bashrc
		su -jack ---开启登录shell
			加载顺序:/etc/profile	=> ~/.bash_profile => ~/.bashrc => /etc/bashrc

*hot keys
	**ctrl + d 输入结束
	**ctrl + c 键盘输入中断
	**ctrl + s & ctrl + q: 暂停/恢复屏幕输出
	**ctrl + l : 清屏
	**tab :补充命令和文件名	
		
		
*系统监控		
	**uname		--显示系统信息
			 uname -a 		--show all information	内核版本号
	**hostname --显示 change 主机名	
	**last	--最近的用户登录,从/var/log/wtmp中得到记录
	**lastlog		--列出每一个用户的最近登录
	**free  	--内存使用状况	
		vmstat		--same to upper	

	**top 	---系统监视器	
		top -b -n 2 >cup.c		--将top执行两次,并写入cpu.c
			-b	--批处理
			-n 2	--执行几次
		&& 排序
			N,pid;	M,内存;	P,cpu; T,time	
			
	**ps  ---显示进程
		ps -A	---显示所有进程
		ps -e	--samp to upper
		ps -a	---不列出与终端有关的进程
		ps -u	---有效用户的进程
		ps -x	---列出完整信息
		ps -l	---以长模式显示信息
		ps -f	---以完整模式显示信息
		
		ps aux			--一般不加'-'
		ps -ef	
	**pstree		--以树型结构表现父子关系	
		pstree -a	---以ascii链接
		pstree -aup	---显示pid
		
	**	pgrep httpd		--查看apache进程
			/etc/rc.d/init.d/httpd down		--对apache启动或是停止
			 pkill httpd		--kill process by the name of service without pid
			
				
			
	**gnome-system-monitor		--在新建终端上面查看进程信息	

	*v [-singal ] PID
		**top & 		--后台运行命令
		**kill -l  	--查看kill所有可以传递的信号	
				 1) SIGHUP  --重新启动     2) SIGINT   --ctrl+c中断    3) SIGQUIT      4) SIGILL
				 5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
				 9) SIGKILL --强制中断    10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
				13) SIGPIPE     14) SIGALRM     15) SIGTERM ---正常结束进程    17) SIGCHLD
		** ps -ef|grep 'top'		--通过管道grep来获得进程top的信息	
		** kill -9 8177		--kill process whose pid is 8177
	
	**killall	+进程名
	**xkill		杀死某个应用
	
	**进程优先级	
		&& -高	;+低 ,只有root才能启动高优先级,(-20~19)
			普通用户只能设低优先级(0-19)
		**nice
			nice -n -8 top &		--change the priority of process
		**renice -n pid		--can change  the priotity a running process 
		&&top 查看后,输入'r'会提示输入要renice的pid

	**nohup command &		--将进程送入后台,并且在console退出后,进程仍不挂断
	**ctrl + z		---将前台程序暂停,并丢入后台
	
工作	
	**jobs
		jobs -l		--see all the jobs


	**fg		--将后台进程拉回前台
		 fg %1		--将作业号1的作业,放在前台
	**bf		---激活后台暂 停的进程

*/proc虚拟目录,内核信息
	** cat /proc/cpuinfo		--查看cpu信息
	** cat /proc/meminfo		--查看内存信息
	
*系统日志
	&& /var/log		--日志文件目录
	&&/var/log/dmesg		--核心启动日志
	&&/var/log/messages		--系统报错日志
	&&/var/log/maillog		--邮件系统日志
	&&/var/log/xferlog/	--ftp使用日志
	&&/var/log/secure		--安全信息
	&&/var/log/wtmp		--登录记录,二进制文件
	
*用户管理
	**检查用户身份
		**who		--see the current users online
		**groups		--show the groups users belonged to
			 groups root		--show the groups root belonged to 
		**id	--show the id of user
		**finger	--show detail of users
		** who am i		--show the current user's detail infomation
			 whoami	----show the current user's  simple infomation
			 w		--show all the users' detail infomation online
	**更改用户信息
		**usermod
			 usermod -c "TomSa" tom	--更改用户全名
			 usermod -d /home/tomm tom	--change home directory,but don't create directory
			 usermod -e "012-02-26" tom	--set the expire time of user's password
			 usermod -G root tom		--add tom to group root
			 usermod -g 0 tom		--change the gid of tom
			 usermod -a /bin/csh  tom		--change the default shell of tom
			 usermod -u 504 tom  tom		--change the uid of tom
			 usermod  -p tomm tom		--change the password of tom
			 usermod -L  tom		--lock tom's pwd
			 
		** cd ~tom		--go to tom's home directory
		** passwd -S tom		--show the state of pwd
		** userdel -r tomm	--delete user with all tom's things
	
		**cat /etc/passwd|wc		--查看passwd的记录
		**cat /etc/passwd|wc -l		--查看passwd的记录数
		
		&&uid 1~99为系统保留的默认找好
				100~499为保留给服务使用
				uid>555,一般用户
 		
 		&& /etc/login.defs		--show the info of login
					CREATE_HOME     yes	--whether create home dir
		&& /etc/skel/		--where does system copy file from to home when create a new user

		&&/etc/shadow		--where usres' password stored
		&&shadow 默认权限400 ,passwd默认权限640		
				&&如果密码为!,表示密码已被锁定
	**authconfig 		--config system with GUI

*组管理
	&&/etc/group		---where the infomation of groups stored
		/etc/gshadow	-----where the password of groups stored
	**groupadd
	**groupdel
	**groupmod
	  groupmod -n san zhang		--change zhang's name to san
	**gpasswd san --add password for a group
	**gpasswd -a jack san	--add user jack to group san
	
	&&有效用户群组
	**newgrp san 	--change the valid group  to group san

	**useradd -u 509 yan		--指定新用户的uid,默认是已有的max(uid)+1
	** useradd  zhen -s /bin/csh		--指定新用户的shell
	**uaeradd -M xiao2		--不创建home dir
	**useradd xiao3 -d /root/guo		--change user's home dir
	
	** ls -l /root/guo		--创建系统账号
			
*设备文件		--文件存放在/dev
*设备文件分类
	&块设备文件(b),缓冲区为512b-32kb大小
	&字符设备文件(c),无缓冲去,一次1byte

*常用字符设备文件
	**/dev/null	--无限字符接收设备,接收后,直接丢弃
	**/dev/zero	--same to upper,无限零资源,------该设备无穷尽地提供0,可以使用任何你需要的数目——设备提供的要多的多。他可以用于向设备或文件写入字符串0。
	**/dev/tty[0-31]	--虚拟终端
	**/dev/ttyS[0-9]	--串口
	**/dev/lp[0-3]	--并口,(打印机)
	**/dev/console	--控制台
	**/dev/fb[0-31]	--显卡数据传输设备

*符号链接设备文件

*备份文件或分区
	**dd if=/etc/passwd of=/root/passwd.backup	--备份文件	
		dd </etc/passwd >/root/passwd.ba	--samp to upper
	**dd </root/passwd.ba >	/etc/passwd 	--还原

	**mknod 	--建立设备文件 
	
	**/usr/src/linux-2.4.20-8/Documentation/devices.txt		--linux主号和从号的位置
	
	**kudzu	--red hat linux 硬件自检工具
	**chkconfig kudzu off	--关闭自动检测
	**hwbrowser 	--图形界面下的硬件管理器

*硬盘
	
**硬盘分区工具	
	&&disk druid	---安装linux时候使用,图形界面	
	&&fdisk	--广泛以用于字符界面下的各种os
		** fdisk -l /dev/sda	---查看sda硬盘的分区信息
		     Device   Boot    Start       End    Blocks   Id  System
				/dev/sda1   *         1        26    208813+  83  Linux
				/dev/sda2            27        90    514080   82  Linux swap
				&&Boot,系统启动加载分区
				
		&&d,删除; p显示分区; w,保存退出; q,不保存退出; n,添加新分区	
		&&创建虚拟内存,则更改分区的id为82
		
		** mkswap /dev/sda3		--创建新的swap分区后,要将其激活,即格式化
		**swapon /dev/sd2		--将新建虚拟内存添加到虚拟内存上
		**swapoff /dev/sd2		--将新建虚拟内存关掉,不在被加载
		
		&&第二种方法
		**dd </etc/passwd >/root/passwd.ba		--先创建一个快
			mkswap /dev/sda3		--创建新的swap分区后,要将其激活,即格式化
	**partprobe	---让分区生效


*ssh
	**rpm -qa |grep openssh    --查看是否安装了ssh
	**service sshd start    	--启动ssh
		/etc/rc.d/init.d// start  	--启动ssh
	


*文件系统
	&& ext2 ext3 文件系统
	&&超级快,记录文件系统信息,经常会被备份
	** dumpe2fs /dev/sda2|more	--查看分区中的超级快信息,在Group 0:之前标注
	**lsattr	--查看文件属性
	**chattr	--改变文件属性 	,+,-
		A,	文件被修改,更改时间不变; a,只能追加内容,不会覆盖,只有root才能设定
		d,备份时候,不会被备份; i,永远不能改变和改变,只有root才能设定
		j,将文件记录纸ext3中,添加日志; S,更改时候,写入文件系统中
	** chattr +i guo.c	

	&& ReiserFS 文件系统,最大管理6TB

*创建文件系统
	**mkfs	-t
		mkfs -t ext3 /dev/sda3	--在sda3上创建文件系统
	**mke2fs


//=================================================================================================
	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	
//=================================================================================================
	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	CentOS Linux	
//=================================================================================================


*修改启动界面,只启动命令行界面
	** vi /etc/inittab 
		更改id:5:initdefault --->id:3:initdefault

*启动window界面
	** startx
	
*vi
	

*更改网卡ip	
	** ifconfig eth0 192.168.1.9 netmask 255.255.255.0 up 		 -- use 'up' to work this command at once
	**ifconfig eth0:0 192.168.1.4 netmask 255.255.255.0 up		--generate a virtual ip
		**cp /etc/sysconfig/network-scripts/ifcfg-eth0 /..../ifcfg-eth0:0  --将配置的虚拟ip保存为真正ip
			vi ifcfg-eth0:0
				--DEVICE=eth0:0
				--IPADDR=192.168.1.4  	--change those two places 
		**service network restart			--restart a network card
		
		**虚拟机下 Dertermining IP information for eth0....failed - no link present check cable
			**	  在 /etc/sysconfig/network-scripts/ifcfg-eth0 末尾添加
					  check_link_down() {
			      return 1;
			      }
			**	  service network start 重启
			

	
	** ifconfig eth0:1 down		--down (close) a ip

	**service network restart			--restart a network card


*更改ip配置方式	
	** /etc/sysconfig/network-scripts/ifcfg-eth0

*
	**wget http://www.baidu.com/.../zhang.txt 	--download a file from webservice
	http://xinwen.xcu.edu.cn/uploadfile/tongzgg/UploadFiles_tzgg/201105/20110513104637910.doc


*网络诊断工具
	**route 	see the ip route tablp

	** traceroute baidu.com	 --查看访问baidu.com 经过的路径
	** curl --head baidu.com --查看baidu使用什么服务器
	** netstat -a -l	--show all ports useed
	** netstat -ant

*进程工具
	** ntsysv   --查看守护进程
	** setup		--配置网络

	** chkconfig --list	查看启动项
	** chkconfig --list| grep mysql --查看mysql的启动情况
	** chkconfig mysqld on	--将mysql设为开机启动
	** chkconfig  --levels 123 mysqld on	--设置为在运行级别 123 自动启动



*安装rpm包 搭建lamp环境
	**  rpm -qa|grep mysql 	--查看mysql是否已安装	(软件包管理程序(Red Hat Package Manager))
	**	 mount /dev/cdrom /mnt	--挂载光盘到 /mnt
	**	ls http*	--显示 http* 的文件
	**	rpm -ivh httpd-devel-2.2.3-45.el5.centos.i386.rpm	--安装相应的 .rpm
	**  rpm -e mysql	--uninstall mysql	用--nodeps强行卸载
	**	service httpd start	 --启动apache
	**	vi /var/www/html/test.php	--写一个php文件 ,网页文件都放在 /var/www/html/中
			这时候不能看见mysql的信息,需要添加rpm -ivh php-mysql-5.1.6-27.el5_5.3.i386.rpm 
	**	service mysqld start	--启动mysql
	**	mysql -u root -p	--进入mysql命令行
	**	rpm -V mysql 	-- verify soft
	**	rpm -qi  openssh-server-3.5p1-6		--show the infomation of software installed
	**	rpm -ivh --replacefiles --replacepkgs VMwareTools-6.0.2-59824.i386.rpm		--强制重新安装
	**	rpm -Uvh   VMwareTools-6.0.2-59824.i386.rpm           --update software        		              
	**	rpm -Va		--check all rpm 
	**	
	
	

*日志
	** 配置文件 /etc/syslog.conf
	** 日志存储目录	 /var/log/
	&&  cat wtmp	存放的是远程登录的者的信息,是二进制文件, cat wtmp 显示的是乱码
			strings wtmp	才能够正常的查看二进制文件信息
	**  lastlog |more 	--show the last time users logined 
	**  last	--show all the users who logined since the OS first running
	**	lastb	--show the list of invalidate users  who have tring logining
	**	w --show the users online
	** logrotate --日志滚动

*安装proftpd
	**安装tar包
		*	tar -xf proftpd-1.3.0.tar	解压
		* ./configure  --prefix=/usr/local/proftpd -- configures this package to adapt to many kinds of systems
		**	make && make install 	--compile and  install
		**	 ./sbin/proftpd  & --run the proftpd in backgroud

*查看 xinet
	** ls /etc/xinetd.d/	all server under xinet 


*安装openVS
	**wget http://download.openvz.org/openvz.repo			--第一次在CentOS中添加openVZ repository
		rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
		cp openvz.repo /etc.recpo.d
	**yum install ovzkernel 	--安装openvz内核
	** cat /boot/grub/menu.lst	--安装过后,启动文件会增加openVS的信息
	**yum install vzctl vzquota		--安装openvz工具和插件




	**	hwclock  --查看硬件时钟
			 date 052217532011		--set time
	**	runlevel	--查看当前运行级别
		init[0123466]	--change the runlevel
		telinit [0123456Ss		--the same to upper

	** grep -v '^#' openvz.repo   --show the  content which is not start by '#' 
	
	**	/etc/rc.d/init.d	--该目录下包含各个运行级别的服务程序脚本

*GRUB
	**vi /boot/grub/grub.conf		--查看GRUB的配置文件
	** grub-md5-crypt		--encript the password
	** password --md5 $1$EszU60$Mc2BwxeWUH/8q3iqbRknz0	appent to grub.conf

**系统引导流程
		固件firmware(CMOS/BIOS)
		↓
		自举程序BootLoader(GRUB)
		↓
		载入内核Kernel
		↓
		启动进程init
		↓
		读取执行配置文件/etc/inittab
		→
		POST 加电自检
		→
		载入内核
		→
		驱动硬件


**	echo "123456" |md5sum	 --show the result  encripted by md5 (f447b20a7fcbf53a5d5be013ea0b15af )






//=================================================================================================
	Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu		
//=================================================================================================
	Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu				Ubuntu		
//=================================================================================================


*alt+f2	--run a soft
	alt+f1	--run 'start'
	ctrl+alt+l	--lock the screen	


*安装ssh
	** sudo apt-get install openssh-server		--install  OpenSSH Server 
	**	ps -e | grep ssh	--ensure ssh has start or not
	**	sudo /etc/init.d/ssh resart		--restart ssh	server

*JDK	安装
	**vi /etc/profile
			&&JAVA_HOME=/home/yangguowei/jdk
				JRE_HOME=/home/yangguowei/jdk
				PATH=$PATH:$JAVA_HOME/bin:JRE_HOME/bin:
				CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:
				export JAVA_HOME JRE_HOME PATH CLASSPATH
	**source /etc/profile (命令使环境变量生效)


*tomcat 的安装
	**	tar zxvf apach-tomcat-6.0.16.tar.gz
	**	#vi /etc/profile 
    export TOMCAT_HOME=/usr/local/apach-tomcat-6.0.16
	**	source /etc/profile  //让当前配置立即生效
	**	$ /usr/local/apach-tomcat-6.0.16/bin/startup.sh 	---启动tomcat服务器 
	
	** 	ps -ef | grep tomcat  	--show tomcat process ,Tomcat will show up as a "java" process
			ps -ef |grep tomcat			
	


*mysql	安装
	**sudo apt-get install mysql-server mysql		--install 	mysql
	**	sudo restart mysql #重启
			sudo start mysql #启动
			sudo stop mysql #停止
	**	sudo aptitude purge mysql-server mysql		--uninstall mysql
	
	
	**	sudo apt-get install aptitude		install command of aptitude
			sudo aptitude install kchmviewer-nokde 
			sudo aptitude remove kchmviewer-nokde


	**	mysql -u root		--go into mysql	
	**	show variables like 'character%';		--show mysql's charset
	
	**修改MySQL字符集
		**	sudo vi /etc/mysql/my.cnf
				在[client]下添加				default-character-set=utf8
				在[mysqld]下添加				default-character-set=utf8

*硬盘
	**	sudo fdisk -l		--show disk subarea
			df

	**	cat /proc/meminfo		--show the info of memory 

	**增加swap分区
		**	sudo dd if=/dev/zero of=/mnt/256M.swap bs=1M count=256		--Creating a file for 512 MB size you want: ,不能有空格
		**	sudo mkswap  /mnt/256M.swap		--Formatting that file to create a swapping device: 
		**	sudo swapon  /mnt/256M.swap			--Adding the swap to the running system: 
		**	sudo vi /etc/fstab		--Making the change permanent: 
				/mnt/256M.swap  none  swap  sw  0 0		--Add this line at the end of the file: 
		**	reboot
*install oracle
	**	sudo dpkg -i libaio1_0.3.107-3ubuntu2_i386.deb		--install a  utility tool
			在处理时有错误发生: oracle-xe-universal原因是因为没有装libaio
	**	sudo dpkg -i oracle-xe-universal_10.2.0.1-1.0_i386.deb		--package manager for Debian
	**	/etc/init.d/oracle-xe configure 		--	configure oracle	
			Specify the HTTP port that will be used for Oracle Application Express [8080]:8099 
			Specify a port that will be used for the database listener [1521]:1521  
			18.initial configuration:   		--initiate a password
			Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:y 
	**	username: sys 	password: 123456		
			
			
	**	 $LANG		--show the language of system		
			
			
			

//=================================================================================================
	red hat linux						red hat linux					red hat linux					red hat linux					red hat linux					
//=================================================================================================
	red hat linux			    	red hat linux					red hat linux					red hat linux					red hat linux					red hat linux								
//=================================================================================================
			
*启动新的终端
	**	press Ctrl-Alt-Space	==>		release Space without releasing Ctrl and Alt		
			==>		 press the function key for the workspace you want to use — for example, F2.
			
			linux 共有6个终端
			
	**	Ctrl+Alt+F7   返回Xwindow

			
* opehssh 安装			
	**	 ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/openssl --with-md5-passwords
	  	 make &&	make install
	**	 service sshd start
	**	/etc/init.d/sshd status		--show the status of ssh
	**	service iptables stop  //关闭防火墙   
			/etc/init.d/iptables  status			

*	虚拟机tools 安装
	**	vmware-uninstall-tools.pl		--uninstall vmware-tools
	**	
			
			
			
*	恢复 误删的文件
	**	init 1		--take system to a single user mode
	**	Using grep (traditional UNIX way) to recover files		--恢复text文件
			Use following grep syntax:
			grep -b 'search-text' /dev/partition > file.txt
			OR
			grep -a -B[size before] -A[size after] 'text' /dev/[your_partition] > file.txt
			Where,
			-i : Ignore case distinctions in both the PATTERN and the input files i.e. match both uppercase and lowercase character. 
			-a : Process a binary file as if it were text 
			-B Print number lines/size of leading context before matching lines. 
			-A: Print number lines/size of trailing context after matching lines. 
			To recover text file starting with "nixCraft" word on /dev/sda1 you can try following command:
			# grep -i -a -B10 -A100 'nixCraft' /dev/sda1 > file.txt

	**	
	
	
	**	ls -l /lib/modules/2.4.18-6mdk/kernel/fs			--show the type of file system 
	**	
	**	
	**				
			
*硬件管理
	**	vmstat		--show the virtual memory statistics 			
	
*文件系统管理			
	**	sort README		-- sort the content of a text
	**	cat readme1 readme2 |sort >yang		--merge readme1 and readme2 and sort the content write into new file yang
	**	uniq -d yang		---show the content which is repeat
	**	wc -w yang		--statistics the quantity of words in yang 
	**	comm -23 readme r2		--compare the comtent of two text
	**	diff r1 r2		-- compare the comtent of two text
	**	
	**	
	
*	查看linux版本
	**	cat /etc/issue		---show the version of redhat
			cat /etc/redhat-release
			cat /proc/version


*	系统的用户和组管理		
	**	cat /etc/gshadow
			cat /etc/group		--store the message of group
			cat /etc/shadow
			cat /etc/passwd
	**	pwck /etc/passwd	--check whether  /etc/passwd	is ok refer to /etc/shadow
			grpck /etc/group		
	**	redhat-config-users		--启动用户管理UI
	
*	进程管理	
	**	at	 --execute a process at a special time
	**	batch 		--execute a process whe the device is low load
	**	cron		--execute a process periodical
			vi job		--make a file refer the command to do 
				10 07 31  05  2 ls /etc/passwd
			crontab job		--add the file contain command to the crontab
			/var/spool/cron/root		--store the user's tasks
	**	sleep 5; ls 		--sleep a process
	**	fg ./ls 		--recove a process from jobs
			bg ./ls
	
*计划任务	
	**	计划任务的命令
			at	 安排作业在某一时刻执行一次
			batch 	安排作业在系统负载不重时执行一次,使用方法同at
			cron 	安排周期性运行的作业,用于生成cron进程所需要的crontab文件
	**	at 		[-f 文件名] 时间
			at 		-d or atrm 删除队列中的任务
			at 		-l or atq 查看队列中的任务
	**	at命令指定时间的方式
			绝对计时方法
				midnight noon teatime
				hh:mm [today]
				hh:mm tomorrow
				hh:mm 星期
				hh:mm MM/DD/YY
			相对计时方法
				now + n minutes
				now + n hours
				now + n days
	**	指定在今天下午17:30 执行某命令(假设现在时间是下午14:30,2011年1月11日)。
			at 5:30pm
			at 17:30
			at 17:30 today
			at now + 3 hours
			at now + 180 minutes
			at 17:30 11.1.11
			at 17:30 1/11/11
	**	使用命令文件方式
			1. 生成文件at.script:
			2. 使用at命令
				at -f at.script 9:00 2/2/11				or
				at < at.script 9:00 2/2/11
	**	at配置文件
				/etc/at.allow
				/etc/at.deny
	**	crontab的命令格式
				crontab {-l|-r|-e}
				-l 显示当前的crontab
				-r 删除当前的crontab
				-e 使用编辑器编辑当前的crontab文件。
	**	crontab文件格式
			minute hour day-of-month month-of-year day-of-week commands
			
			minute 一小时中的哪一分钟[0~59]
			hour 一天中的哪个小时[0~23]
			day-of-month 一月中的哪一天[1~31]
			month-of-year 一年中的哪一月[1~12]
			day-of-week 一周中的哪一天[0~6]
			commands 执行的命令
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	**	
	
	
	
*网络管理	
	**	/etc/xinetd.d/  --store the infomation of net	,保存服务的配置
	**  ntsysv   --查看守护进程
	**  setup		--配置网络
	
	**	rpm -qa |grep squid		--check whether has insatlled the DHCP
			rpm -qa |grep dhcp

*DNS	
	**	rpm -qa |grep bind		--check whether has insatlled the DNS
	**	service named statt		--start the service of DNS
	**	rndc named		--show the status of DNS service
	
*远程登录	
	**	rpm -qa |grep telnet		--check whether has insatlled the telnet
	**	vi  /etc/services			---config telent ,set the port of  telnet 
	**	telnet 127.0.0.1		--telnet a host
	
*邮件服务器 Sendmail Server, POP,IMAP
	**	邮件传递代理 (MTA)
			邮件存储和获取代理 (MSA)	
			邮件客户代理 (MUA)
	**	rpm -qa |grep sendmail	--
	**	rpm -qa |grep imap		
	**	
	
*	mysql 数据库
	**	 mysqladmin -u root password 123456		--set a password for mysql
	**	 mysqladmin -u root -p   password [newpasswd]		--modify the password
	
//=================================================================================================
	RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL							
//=================================================================================================
	RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL		RHEL							
//=================================================================================================
	
*	网络管理和诊断
	**	sysctl  --configure kernel parameters at runtime
	**	cat /etc/resolv.conf		--查看域名服务器ip
	**	dig baidu.com		--查看域名对应的ip
	**	cat /etc/hosts		--查看host表
	
	**	dmesg|grep eth		--查看操作系统引导网卡的信息
	**	lspci		--查看所有的PCI设备		
			---这两条命令查看网卡的硬件信息
			
	**	ethtool eth0		--查看链路链接是否正常
	**	ls /lib/modules/2.6.18-8.el5/kernel/drivers/net/		--网卡驱动存放位置
	
	**	lsmod |grep pcnet32		--查看当前系统装载的模块是否有 pcnet32
			lsmod 		--program to show the status of modules in the Linux Kernel	
	**	modinfo /lib/modules/2.6.18-8.el5/kernel/drivers/net/pcnet32.ko		--查看 pcnet32.ko 模块信息
	
	**	netstat -anp |grep :80		--查看某一端口信息
	**	tcpdump host 192.168.160.138 and tcp port 80	--抓取通过tcp协议与本机192.168.160.138的80端口通信的数据包
	**	nmap 192.168.160.1		--扫描目标主机的端口
			-O :查看目标主机的操作系统
			
* 日志系统
	**	rpm -qa sysklogd		--查看日志记录软件包是否安装			
	**	ps -eaf |grep syslog		--查看日志进程是否运行
			ps -eaf |grep klog
	**	cat /etc/syslog.conf		--日志配置文件
	
	**	rpm -qa logrotate		--查看日志转储软件呢包是否安装
	**	more /etc/logrotate.conf	--配置
	
	**	rpm -qa psacct		--记账功能
	
* 路由配置	
	**	route add -net 127.0.0.0 netmask 255.0.0.0 dev lo		--add a static route
	**	rpm -qa iproute		--路由表管理软件
	
*防火墙	
	**	iptables -L		--查看默认的防火墙规则
	**	
	**	
*firefox 安装 flash 插件	
	**	先解压tar。gz文件
	**	 sudo cp libflashplayer.so /usr/lib/firefox-addons/
		 sudo ln /usr/lib/firefox-addons/libflashplayer.so /usr/lib/mozilla/plugins/libflashplayer.so
	**	
	**	
	**	
	**	
	**	
	**
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics