Linux运维基本知识与命令

1,Linux系统管理员账户?
root
2,[root@svr5 ~]#  解释每一个部分的意思
root 帐户
svr5 主机名
~    所在目录/root
3,Linux系统有哪几个TTY控制台
TTY1-6 字符界面
TTY7 图形界面
4,如何查看内核,并解释每一个部分的意思
# uname -r
2.6.18-371.el5
主版本号 2
次版本号 6
修订版本号 18
红帽修订    371
5,查看系统具体属于RedHat哪一个版本
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.10 (Tikanga)
6,显示现在什么位置
# pwd
7,进入/etc/sysconfig/network-scripts下
# cd /etc/sysconfig/network-scripts
8,长格式并提供易读的属性显示/boot下的vmlinuz开头的文件
[root@localhost ~]# ls -lh /boot/vmlinuz*
-rw-r--r-- 1 root root 2.1M 2013-09-06 /boot/vmlinuz-2.6.18-371.el5
[root@localhost ~]# find /boot -name vmlinuz* -exec ls -lh {} \;
-rw-r--r-- 1 root root 2.1M 2013-09-06 /boot/vmlinuz-2.6.18-371.el5
9,列出/etc目录属性
[root@localhost ~]# ls -ld /etc
drwxr-xr-x 90 root root 4096 05-22 19:44 /etc
10,递归显示/boot目录下的文件和内容
[root@localhost ~]# ls -R /boot/
11,显示root下面所有文件包括隐藏文件
[root@localhost ~]# ls -a /root/
12,查看/boot和/etc/pki分别占用多大空间
[root@localhost ~]# du -sh /boot/ /etc/pki/
6.5M    /boot/
792K    /etc/pki/
13,创建/vod/movie/cartoon,递归显示/vod目录结构
[root@localhost ~]# mkdir -p /vod/movie/cartoon
[root@localhost ~]# ls -R /vod/
14,把system-config-network-tui链接成/sbin/netconfig
[root@localhost ~]# which system-config-network-tui
/usr/sbin/system-config-network-tui
[root@localhost ~]# ln -s /usr/sbin/system-config-network-tui /sbin/netconfig
[root@localhost ~]# ls -l /sbin/netconfig
lrwxrwxrwx 1 root root 35 05-22 20:19 /sbin/netconfig -> /usr/sbin/system-config-network-tui
15,把/boot/grub  /etc/host.conf拷贝到/root/Desktop下
[root@localhost ~]# cp -r /boot/grub/ /etc/host.conf  /root/Desktop/
16,删除Desktop下的grub和host.conf
[root@localhost ~]# ls /root/Desktop/
grub  host.conf
[root@localhost ~]# rm -rf /root/Desktop/grub/ /root/Desktop/host.conf
[root@localhost ~]# ls /root/Desktop/
17,创建/root/ls-man.txt文件,在将这个文件移动到桌面
[root@localhost ~]# touch /root/ls-man.txt
[root@localhost ~]# mv /root/ls-man.txt  /root/Desktop/
18,把ls-man.txt改名为manls.txt
[root@localhost ~]# mv /root/Desktop/ls-man.txt /root/Desktop/manls.txt
[root@localhost ~]# ls /root/Desktop/manls.txt
19,查找shutdown这个命令的绝对路径
[root@localhost ~]# which shutdown
/sbin/shutdown
20,创建myhttpd.conf文件,使用locate查找,是否能够查找到这个文件?
[root@localhost ~]# touch myhttpd.conf
[root@localhost ~]# locate myhttpd.conf
21,更新数据库 /var/lib/mlocate/mlocate.db,使用locate查找,是否能够查找到这个文件?
[root@localhost ~]# updatedb
[root@localhost ~]# locate myhttpd.conf
/root/myhttpd.conf
22,删除myhttpd.conf文件,使用locate查找,是否能够查找到这个文件?
[root@localhost ~]# rm -rf myhttpd.conf
[root@localhost ~]# locate myhttpd.conf
/root/myhttpd.conf
23,查找/boot下的链接文件
[root@localhost ~]# find /boot -type l
/boot/grub/menu.lst
24,查找/boot下的目录
[root@localhost ~]# find /boot -type d
25,查找/etc下名字叫resol开头的,以.conf结尾的文件
[root@localhost ~]# find /etc -name resol*.conf
/etc/resolv.conf
26,以易读的属性并长格式显示/boot下以.img结尾的文件
[root@localhost ~]# ls -lh /boot/*.img
-rw------- 1 root root 2.8M 05-21 22:07 /boot/initrd-2.6.18-371.el5.img
[root@localhost ~]# find /boot -name *.img -exec ls -lh {} \;
-rw------- 1 root root 2.8M 05-21 22:07 /boot/initrd-2.6.18-371.el5.img
27,查找/boot下以.img结尾的并且大于2M的文件
[root@localhost ~]# find /boot -name *.img -a -size +2M
/boot/initrd-2.6.18-371.el5.img
28,查找/var下大于等于5天前变动过的文件名
[root@localhost ~]# find /var/ -mtime +4
29,查看/etc/passwd前5行
[root@localhost ~]# head -n 5 /etc/passwd
30,查看/etc/passwd尾5行
[root@localhost ~]# tail -n 5 /etc/passwd
31,查看/etc/passwd的第8-12行
[root@localhost ~]# head -n 12 /etc/passwd | tail -n 5
32,统计系统中有多少个账户
[root@localhost ~]# wc -l /etc/passwd
32 /etc/passwd
33,计算/etc目录下.conf配置文件的个数
[root@localhost ~]# find /etc -name *.conf | wc -l
244
34,显示/etc/hosts中127.0.0.1的内容
[root@localhost ~]# grep 127.0.0.1 /etc/hosts
127.0.0.1               localhost.localdomain localhost
35,显示/etc/passwd中以root开头的内容
[root@localhost ~]# grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
36,显示/etc/passwd中以bash结尾的内容
[root@localhost ~]# grep bash$ /etc/passwd
root:x:0:0:root:/root:/bin/bash
37,去除/etc/hosts.allow中的空行,把结果显示出来
[root@localhost ~]# grep -v "^$" /etc/hosts.allow
38,显示/etc/hosts里面不以#号开头的内容
[root@localhost ~]# grep -v "^#" /etc/hosts
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
39,计算以/bin/bash作登陆shell的用户个数
[root@localhost ~]# grep /bin/bash$ /etc/passwd | wc -l
1
40,查找/etc/hosts中包含127.0.0.1或者localhost的内容
[root@localhost ~]# grep -E "127.0.0.1|localhost" /etc/hosts
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
41,以易读的属性并长格式显示/root下的内容将结果重定向到/root/gztest.txt里面
[root@localhost ~]# ls -lh /root/ > /root/gztest.txt
42,分别使用gzip和bzip2对/root/gztest.txt进行压缩和解压
[root@localhost ~]# gzip gztest.txt
[root@localhost ~]# gzip -d gztest.txt
[root@localhost ~]# bzip2 gztest.txt
[root@localhost ~]# bzip2 -d gztest.txt.bz2
43,把/etc/mail打包并压缩到/root/mail.tar.gz
[root@localhost ~]# tar -zcf /root/mail.tar.gz /etc/mail
44,把/etc/mail打包并压缩到/root/mail.tar.bz2
[root@localhost ~]# tar -jcf /root/mail.tar.bz2 /etc/mail
45,将mail.tar.gz解压到/tmp下,然后删除/tmp/etc目录
[root@localhost ~]# tar -zxf /root/mail.tar.gz -C /tmp/
[root@localhost ~]# rm -rf /tmp/etc/
46,将mail.tar.bz2解压到/tmp下,然后删除/tmp/etc目录
[root@localhost ~]# tar -jxf /root/mail.tar.bz2 -C /tmp/
[root@localhost ~]# rm -rf /tmp/etc/
47,请在 /tmp 这个目录下建立一个名为 vimtest 的目录
[root@localhost ~]# mkdir /tmp/vimtest
48,进入vimtest 这个目录当中
[root@localhost ~]# cd /tmp/vimtest/
49,将 /etc/man.config 复制到本目录底下
[root@localhost vimtest]# cp /etc/man.config .
50,使用 vim 打开本目录下的 man.config
[root@localhost vimtest]# vim man.config
51,在 vim 中设定一下行号
:set nu
52,移动到第 58 行,向右移动 40 个字元,请问你看到的双引号内是什么目录?
:58
40->
/dir/bin/foo
53,移动到第一行,并且向下搜寻一下‘ bzip2 ’这个字串,请问他在第几行?
1G
/bzip2 118/137
54,我要将 50 到 100 行之间的‘小写 man 字串’改为‘大写 MAN 字串’,并且一个一个挑选是否需要修改,如何下达指令?如果在挑选过程中一直按‘y’, 结果会在最后一行出现改变了几个 man 呢?
:50,100s/man/MAN/gc
55,修改完之后,突然反悔了,要全部复原,有哪些方法?
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu.......
:q!
56,我要复制 65 到 73 这九行的内容(含有MANPATH_MAP),并且贴到最后一行之后
:65
9yy
G
P
57,21 到 42 行之间的开头为 # 符号的注解资料我不要了,要如何删除?
:21
:21,42s/^#//g
58,将这个档案另存成一个 man.test.config 的档名
:w man.test.config
59,在第一行新增一行,该行内容输入‘I am a student...’
1G
O
I am a student...
60,储存后离开吧
:wq/:x/ZZ

 

 

 

 

 

 

 

 

 

 


 

本文出自 “CPD” 博客,转载请与作者联系!

Linux运维基本知识与命令,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。