1.统计/usr/bin目录下的文件个数
|
1
2
3
|
[root@localhost ~]
1306
[root@localhost ~]
|
|
2.取出当前系统上所有用户的SHELL,要求,每种SHELL只显示一次,并且按顺序进行显示
|
1
2
3
4
5
6
7
8
9
10
|
[root@localhost ~]
/bin/bash
/bin/nologin
/bin/sync
/bin/tcsh
/sbin/halt
/sbin/login
/sbin/nologin
/sbin/shutdown
[root@localhost ~]
|
|
3.思考:如何显示/var/log目录下每个文件的内容类型?
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@localhost ~]
/var/log/acpid
: ASCII text
/var/log/anaconda
.log: ASCII English text, with very long lines
/var/log/anaconda
.syslog: ASCII English text
/var/log/anaconda
.xlog: ASCII English text
/var/log/audit
: directory
/var/log/boot
.log: empty
/var/log/boot
.log.1: empty
/var/log/boot
.log.2: empty
/var/log/boot
.log.3: empty
/var/log/boot
.log.4: empty
|
|
4.取出/etc/inittab文件的第6行
|
1
2
3
4
5
6
7
8
9
10
|
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
|
|
5.取出/etc/passwd文件中倒数第9个用户的用户名和SHELL,显示到屏幕上并将其保存至/tmp/uses文件中
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[root@localhost ~]
zhangfengzhe10:x:1102:1102::
/home/zhangfengzhe10
:
/bin/bash
zhangfengzhe11:x:1103:1103::
/home/zhangfengzhe11
:
/sbin/nologin
zhangfengzheforsys:x:101:102::
/home/zhangfengzheforsys
:
/bin/bash
test1:x:1104:1104::
/home/test1
:
/bin/bash
mandriva:x:4004:3004::
/home/mandriva
:
/bin/bash
fedora:x:2003:2003:Fedora Commnuity:
/home/fedora
:
/bin/tcsh
hbase:x:102:103::
/home/hbase
:
/bin/nologin
openstack:x:4005:4005::
/home/openstack
:
/bin/bash
hive:x:5000:5000::
/home/hive
:
/bin/bash
[root@localhost ~]
zhangfengzhe10:x:1102:1102::
/home/zhangfengzhe10
:
/bin/bash
[root@localhost ~]
zhangfengzhe10:
/bin/bash
[root@localhost ~]
zhangfengzhe10:
/bin/bash
[root@localhost ~]
zhangfengzhe10:
/bin/bash
[root@localhost ~]
|
|
6.显示/etc目录下所有以pa开头的文件,并统计其个数
|
1
2
3
4
5
6
7
|
[root@localhost ~]
drwxr-xr-x 2 root root 4096 Mar 5 2012
/etc/pam
.d/
drwxr-xr-x 2 root root 4096 Aug 17 2011
/etc/pam_pkcs11/
drwxr-xr-x 3 root root 4096 Aug 17 2011
/etc/pango/
[root@localhost ~]
3
[root@localhost ~]
|
|
7.不使用文本编辑器,将alias cls=clear一行内容添加至当前用户的.bashrc文件中
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@localhost ~]
alias
cls=
'clear'
[root@localhost ~]
[root@localhost ~]
alias
cls=
'clear'
[root@localhost ~]
alias
cp
=
'cp -i'
alias
mv
=
'mv -i'
if
[ -f
/etc/bashrc
];
then
.
/etc/bashrc
fi
alias
cls=
'clear'
[root@localhost ~]
|
|
LINUX的重要哲学思想:
组合小命令完成复杂功能。
本文转自zfz_linux_boy 51CTO博客,原文链接:http://blog.51cto.com/zhangfengzhe/1413214,如需转载请自行联系原作者