您的位置:首页 > 运维架构 > Linux

Linux-基础命令测试(一)

2015-06-08 22:55 375 查看
1、 用root用户登录Linux ,创建目录/perm ,在/perm目录下创建文件newfile ,授予/perm目录所有用户都有rwx权限;创建普通用户testuser ,切换到testuser执行“rm /perm/newfile”是否可以执行
[root@localhost ~]#
[root@localhost ~]# mkdir /perm
[root@localhost ~]# touch /perm/newfile
[root@localhost ~]# chmod 777 /perm/newfile
[root@localhost ~]# ls -l /perm/newfile
-rwxrwxrwx. 1 root root 0 4月  21 04:57/perm/newfile
[root@localhost ~]# useradd testuser
[root@localhost ~]# passwd testuser
[root@localhost ~]# su testuser
[testuser@localhost perm]$ rm newfile
rm:是否删除有写保护的普通空文件 "newfile"?y可以2、 在/root目录下创建文件newfile2 ,移动文件newfile2到/perm目录下同时改名为file01 ;改变/perm/file01文件的所有者为系统用户adm ,改变其所属组为系统用户组games ;改变/perm/file01文件权限为“rwxrw-r--”;在/perm目录下,分别给file01生成一个软链接文件file01.soft和一个硬链接文件file01.hard ;删除/perm目录
[root@localhost ~]# touch newfile2
[root@localhost ~]# mkdir /perm
[root@localhost ~]# chmod 777 /perm/
[root@localhost ~]# mv newfile2 /perm/file01
[root@localhost ~]# chown adm /perm/file01
[root@localhost ~]# chgrp games /perm/file01
[root@localhost ~]# ls -l /perm/file01
-rw-r--r--. 1 adm games 0 4月  21 05:09/perm/file01
[root@localhost ~]# chmod 764 /perm/file01
[root@localhost ~]# ls -l /perm/file01
-rwxrw-r--. 1 adm games 0 4月  21 05:09/perm/file0
[root@localhost ~]# ln -s /perm/file01/perm/file01.soft
[root@localhost ~]# ln  /perm/file01 /perm/file01.hard
[root@localhost ~]# ls -l /perm/
总用量 0
-rwxrw-r--. 2 adm games  0 4月  21 05:09file01
-rwxrw-r--. 2 adm games  0 4月  21 05:09file01.hard
lrwxrwxrwx. 1 root root  12 4月  21 05:14 file01.soft ->/perm/file01
[root@localhost ~]# rm -rf /perm
3、 查看/etc目录的详细信息(权限、大小等);查看/etc/目录下文件的详细信息时实现分页浏览;在/etc目录下查找5分钟内被改变过内容的文件;在/boot目录下查找文件名为grub.conf的文件并同时列出文件的详细信息;在根目录下查找系统中大于100MB小于150MB的文件
[root@localhost~]# ls -l /etc/ | more
[root@localhost~]# find /etc -ctime -5
[root@localhost~]# find / -size +100M -a -size -150M
[root@localhost~]# find /boot -name grub.conf
/boot/grub/grub.conf
4、查看系统安装时是否安装了php软件包;用grep查看Apache配置文件/etc/httpd/conf/httpd.conf的DocumentRoot选项信息;树状显示/etc/httpd目录下文件结构
[root@localhost ~]# cat install.log | grep php
[root@localhost ~]# cat /etc/httpd/conf/httpd.conf| grep DocumentRoot
[root@localhost ~]# tree /etc/httpd
5、查看用户配置文件/etc/shadow的帮助信息;查看命令cd的帮助信息
[root@localhost ~]# man /etc/shadow
[root@localhost ~]# man --help
6、创建目录/comp ,拷贝文件/etc/services到/comp目录下,分别对services文件进行压缩,生成 .gz .zip .bz2三种格式的压缩包;拷贝目录/etc到/comp目录下(保持目录属性不改变),把etc目录压缩生成etc.tar.gz,把services文件的所有压缩包使用rm删除(只用一条rm命令,非执行三次rm操作);在/comp目录下创建文件hidefile ,并设置为隐藏
[root@localhost ~]# cp -a /etc/services comp/
[root@localhost ~]# zip –r comp/services.zipcomp/services
[root@localhost ~]# gzip -r comp/services
[root@localhost comp]# bzip2 services
[root@localhost ~]# cp -a /etc comp/
[root@localhost ~]# tar -cvf comp/etc.tar.gzcomp/etc
[root@localhost ~]# rm -rf comp/services.*
7、查找命令ifconfig的绝对路径并判断此命令哪些用户可以执行;更改本机IP地址为192.168.9.250(练习后改变回来)
[root@localhost ~]# whereis ifconfig
ifconfig: /sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz
[root@localhost ~]# ifconfig eth0 192.168.9.250255.255.255.0
8、ping本机地址测试,要求发送10次ICMP包且包大小为1000 byte
[root@localhost ~]# ping -c 10 -s 1000192.168.216.1589、设置命令“cp -rf”的命令别名为dircp ,查看当前在线用户
[root@localhost ~]# who
10、查看/etc目录下文件名以.conf结尾的二进制文件有多少个
[root@localhost ~]# find /etc/ -name"*.conf" | wc -l
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux 用户登录