| 您的当前位置:首页 --> CentOS入门 |
| centos基本命令 |
| 浏览次数:1249 关键词 ( 命令 centos ) |
123[root@localhost ~]# help pwd。。。[root@localhost ~]# ls --help1[root@localhost ~]# man ls123456789 [root@localhost ~]# pwd/root[root@localhost ~]# cd /home[root@localhost home]# pwd/home[root@localhost home]# cd /usr/local/src/[root@localhost src]# pwd/usr/local/src[root@localhost src]#1234567 [root@localhost ~]# cd /home[root@localhost home]# pwd/home[root@localhost home]# cd /usr/local/src/[root@localhost src]# pwd/usr/local/src[root@localhost src]#1234567891011121314151617[root@localhost src]# cd[root@localhost ~]# pwd/root[root@localhost ~]# cd -/usr/local/src[root@localhost src]# pwd/usr/local/src[root@localhost src]# cd ..[root@localhost local]# pwd/usr/local[root@localhost local]# cd .[root@localhost local]# pwd/usr/local[root@localhost local]# cd ~[root@localhost ~]# pwd/root[root@localhost ~]#12345[root@localhost src]# mkdir /usr/local/nagios[root@localhost src]# tar zxvf nagios-3.5.0.tar.gz -C /usr/local/nagios[root@localhost src]# cd !$cd/usr/local/nagios[root@localhost nagios]#12 [root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0bak[root@localhost ~]#1234567[root@localhost local]# cp nagios/ /usr/local/src/cp: 略过目录"nagios/"[root@localhost local]# cd nagios/[root@localhost nagios]# lsnagios[root@localhost nagios]# cp -r nagios/ /usr/local/src/[root@localhost nagios]# cp -ra nagios/ /usr/local/src/nagios112345678910111213141516 [root@localhost ~]# cd /home/[root@localhost home]# touch justinmv[root@localhost home]# lsjustin justinmv lost+found t[root@localhost home]# mv justinmv justin1[root@localhost home]# lsjustin justin1 lost+found t[root@localhost home]# mv justin1 /usr/local/src/[root@localhost home]# lsjustin lost+found t[root@localhost home]# cd /usr/local/src/ && lsjustin1 nagios nagios1 nagios2 nagios-3.5.0.tar.gz[root@localhost home]# touch justin1[root@localhost home]# mv -i justin1 /usr/local/src/mv:是否覆盖"/usr/local/src/justin1"? y[root@localhost home]#12 [root@localhost ~]# id justinuid=500(justin) gid=500(justin) 组=500(justin)123[root@localhost ~]# whoamiroot[root@localhost ~]#123[root@justin ~]# usersroot[root@justin ~]#123[root@justin ~]# whoroot pts/02013-10-22 17:34 (10.15.72.73)[root@justin ~]#12345[root@justin ~]# w19:51:03 up 2:19, 1 user, load average: 0.08, 0.02, 0.01USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot pts/010.15.72.73 17:34 0.00s 0.22s 0.01s w[root@justin ~]#1234[root@localhost ~]# !!whoamiroot[root@localhost ~]#1234#为网卡建立软连接wk[root@localhost ~]# ln -s /etc/sysconfig/network-scripts/ifcfg-eth0 /root/wk[root@localhost ~]# ls -lh /root/wklrwxrwxrwx. 1 root root 41 9月 23 15:55 /root/wk-> /etc/sysconfig/network-scripts/ifcfg-eth0说明:命令别名通常是命令的缩写,对于经常使用的命令,通过设置别名可以简化操作,提高工作效率。1234567891011121314151617181920[root@localhost ~]# alias wk='/etc/sysconfig/network-scripts/ifcfg-eth0'[root@localhost ~]# aliasaliascp='cp -i'aliasl.='ls -d .* --color=auto'aliasll='ls -l --color=auto'aliasls='ls --color=auto'aliasmv='mv -i'aliasrm='rm -i'aliaswhich='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'aliaswk='/etc/sysconfig/network-scripts/ifcfg-eth0'[root@localhost ~]# unalias wk[root@localhost ~]# aliasaliascp='cp -i'aliasl.='ls -d .* --color=auto'aliasll='ls -l --color=auto'aliasls='ls --color=auto'aliasmv='mv -i'aliasrm='rm -i'aliaswhich='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'[root@localhost ~]#1[root@localhost ~]# vim /root/.bashrc1[root@localhost ~]# source .bashrc12345#列出最近执行过的3条历史命令[root@localhost ~]# history 315 wc/etc/resolv.conf16 wc-l /etc/passwd17 history3123[root@localhost ~]# !16wc-l /etc/passwd35 /etc/passwd123456#使用shutdown命令马上重启系统[root@localhost ~]# shutdown –r now #使用shutdown命令马上关闭系统[root@localhost ~]# shutdown –h now #使用shutdown命令设置在15分钟以后自动重启系统[root@localhost ~]# shutdown –r +15halt:马上关闭系统reboot:马上重启系统。“init 0”:关闭系统“init 6”:重启系统说明:Linux系统中标准的输入设备为键盘,标准输出设备为屏幕,但在某些情况下,我们希望能从键盘以外的其他输入设备读取数据,或者将数据送到屏幕外的其他输出设备,这种情况称为重定向。Shell中输入输出重定向主要依靠重定向符号来实现,重定向的目标通常是一个文件。输入重定向:输入重定向就是将命令中接收输入的途径由默认的键盘重定向为指定的文件,需要使用“<”重定向操作符。如命令“wc < f1”就表示将f1文件的信息作为wc命令的输入。 输出重定向:输出重定向是将命令的输出结果重定向到一个文件中,而不是显示在屏幕上。输出重定向使用“>”或“>>”操作符,分别用于覆盖、追加文件。“>”重定向符后面指定的文件如果不存在,在命令执行中将建立该文件,并保存命令结果到文件中。“>”重定向符后面指定的文件如果存在,命令执行时将清空文件的内容并保存命令结果到文件中。12 #查看/etc/passwd文件的内容,并将输出结果保存到pass.txt文件中。[root@localhost ~]# cat /etc/passwd > pass.txt执行该命令后,会在当前目录下生成一个名为pass.txt的文件,文件中的内容就是“cat /etc/passwd”命令执行的结果。“>>”重定向操作符可以将命令执行的结果重定向并追加到指定文件的末尾保存,而不覆盖文件中原有的内容。 12 #查看/etc/shadow文件的后3行内容,并将输出结果追加保存到pass.txt文件中。[root@localhost ~]# tail -3 /etc/shadow >> pass.txt说明:管道符“|”用于连接左右两个命令,将“|”左边命令的执行结果作为“|”右边命令的输入,这样“|”就像一根管道一样连接着左右两条命令,并在管道中实现数据从左至右的传输。1234567891011121314 #分页显示/etc目录下所有文件和子目录的详细信息。[root@localhost ~]# ls -lh /etc | more#显示/etc目录下包含有“net”关键字的所有文件和子目录的详细信息。[root@localhost ~]# ls -lh /etc | grep net-rwxr-xr-x. 1 root root 1.3K 4月 10 2012 auto.net-rw-r--r--. 1 root root 74 5月 31 2012 issue.net-rw-r--r--. 1 root root 767 11月 30 2009 netconfig-rw-r--r--. 1 root root 58 5月 23 2012 networksdrwxr-xr-x. 2 root root 4.0K 1月 8 19:14 xinetd.d#统计一下/etc目录下所有以“.conf”结尾的文件的个数。[root@localhost ~]# ls -l /etc/*.conf | wc –l44 #查看/etc/httpd/conf/httpd.conf文件中除了以“#”开头的行和空行以外的内容。[root@localhost ~]# grep -v “^#” /etc/httpd/conf/httpd.conf | gerp –v “^$”123456 [root@localhost ~]# date && printf "The date command was succussful"2013年 09月 23日 星期一 16:53:54 CSTThe datecommandwas succussful[root@localhost ~]# data && printf "The date command was succussful"-bash: data: commandnot found[root@localhost ~]#123456789101112131415161718 [root@localhost ~]# date || ls -l2013年 09月 23日 星期一 16:59:44 CST[root@localhost ~]# date && ls -l2013年 09月 23日 星期一 16:59:50 CST总用量 96-rw-------. 1 root root 1357 9月 18 15:58 anaconda-ks.cfg-rw-r--r--. 1 root root 43294 9月 18 15:58 install.log-rw-r--r--. 1 root root 10151 9月 18 15:55 install.log.sysloglrwxrwxrwx. 1 root root 41 9月 23 15:55 wk -> /etc/sysconfig/network-scripts/ifcfg-eth0drwxr-xr-x. 2 root root 4096 9月 22 14:22 公共的drwxr-xr-x. 2 root root 4096 9月 22 14:22 模板drwxr-xr-x. 2 root root 4096 9月 22 14:22 视频drwxr-xr-x. 2 root root 4096 9月 22 14:22 图片drwxr-xr-x. 2 root root 4096 9月 22 14:22 文档drwxr-xr-x. 2 root root 4096 9月 22 14:22 下载drwxr-xr-x. 2 root root 4096 9月 22 14:22 音乐drwxr-xr-x. 2 root root 4096 9月 22 14:22 桌面[root@localhost ~]# |
| 下载次数:7 |
| 下载地址:点击下载 |
| 本资源为程序自动采集,如有侵权请联系我们移除 admin#80vps.com 来信请将#替换为@ |
| 下一条 centos系统中网络配置相关 上一条 tcpkill清除异常tcp连接 |