1.统计/usr/bin目录下的文件个数
[[email protected] ~]# ls /usr/bin | wc -l 1306 [[email protected] ~]# |
2.取出当前系统上所有用户的SHELL,要求,每种SHELL只显示一次,并且按顺序进行显示
[[email protected] ~]# cut -d: -f7 /etc/passwd | sort -u /bin/bash /bin/nologin /bin/sync /bin/tcsh /sbin/halt /sbin/login /sbin/nologin /sbin/shutdown [[email protected] ~]# |
3.思考:如何显示/var/log目录下每个文件的内容类型?
[[email protected] ~]# file /var/log/* /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行
[[email protected] ~]# head -6 /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <[email protected]> # Modified for RHS Linux by Marc Ewing and Donnie Barnes [[email protected] ~]# head -6 /etc/inittab | tail -1 # Modified for RHS Linux by Marc Ewing and Donnie Barnes [[email protected] ~]# |
5.取出/etc/passwd文件中倒数第9个用户的用户名和SHELL,显示到屏幕上并将其保存至/tmp/uses文件中
[[email protected] ~]# tail -9 /etc/passwd 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 [[email protected] ~]# tail -9 /etc/passwd | head -1 zhangfengzhe10:x:1102:1102::/home/zhangfengzhe10:/bin/bash [[email protected] ~]# tail -9 /etc/passwd | head -1 | cut -d: -f1,7 zhangfengzhe10:/bin/bash [[email protected] ~]# tail -9 /etc/passwd | head -1 | cut -d: -f1,7 | tee /tmp/users zhangfengzhe10:/bin/bash [[email protected] ~]# cat /tmp/users zhangfengzhe10:/bin/bash [[email protected] ~]# |
6.显示/etc目录下所有以pa开头的文件,并统计其个数
[[email protected] ~]# ls -ld /etc/pa*/ 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/ [[email protected] ~]# ls -ld /etc/pa*/ | wc -l 3 [[email protected] ~]# |
7.不使用文本编辑器,将alias cls=clear一行内容添加至当前用户的.bashrc文件中
[[email protected] ~]# echo "alias cls=‘clear‘" alias cls=‘clear‘ [[email protected] ~]# echo "alias cls=‘clear‘" >> ~/.bashrc [[email protected] ~]# tail -1 ~/.bashrc alias cls=‘clear‘ [[email protected] ~]# tail ~/.bashrc alias cp=‘cp -i‘ alias mv=‘mv -i‘ # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi alias cls=‘clear‘ [[email protected] ~]# |
LINUX的重要哲学思想:
组合小命令完成复杂功能。
Linux管道及IO重定向小练习,布布扣,bubuko.com
时间: 2024-10-04 19:47:38