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

Linux-基础命令测试(二)

2015-06-08 23:44 441 查看
1、用root用户登录Linux ,创建目录/perm ,在/perm目录下创建文件newfile ,授予/perm目录所有用户都有rwx权限;创建普通用户wlr ,切换到wlr执行“rm /perm/newfile”是否可以执行
[root@localhost~]# mkdir /perm
[root@localhost ~]# touch /perm/newfile
[root@localhost ~]# chmod 777 /perm
[root@localhost ~]# useradd wlr
[root@localhost ~]# passwd wlr
更改用户 wlr 的密码。
新的密码:
无效的密码: WAY 过短
无效的密码:过于简单
重新输入新的密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# su - wlr
[wlr@localhost ~]$ rm /perm/newfile
rm:是否删除有写保护的普通空文件 "/perm/newfile"?y
[wlr@localhost ~]$ ls
2、在/root目录下创建文件newfile2 ,移动文件newfile2到/perm目录下同时改名为file01 ;改变/perm/file01文件的所有者为系统用户adm ,改变其所属组为系统用户组games ;改变/perm/file01文件权限为“rwxrw-r--”;在/perm目录下,分别给file01生成一个软链接文件file01.soft和一个硬链接文件file01.hard ;删除/perm目录
[root@localhost ~]# touch /root/newfile2
[root@localhost ~]# mv /root/newfile2 /perm/file01
[root@localhost ~]# chown adm /perm/file01
[root@localhost ~]# chgrp games /perm/file01
[root@localhost ~]# chmod 764 /perm/file01
[root@localhost ~]# ln -s /perm/file01 /perm/file01.soft
[root@localhost ~]# ln /perm/file01 /perm/file01.hard
[root@localhost ~]# rm -rf /perm/
3、查看/etc目录的详细信息(权限、大小等);查看/etc/目录下文件的详细信息时实现分页浏览;在/etc目录下查找5分钟内被改变过内容的文件;在/boot目录下查找文件名为grub.conf的文件并同时列出文件的详细信息;在根目录下查找系统中大于100MB小于150MB的文件
[root@localhost ~]# ls -ld /etc
drwxr-xr-x. 103 root root 12288 5月  28 03:49/etc
[root@localhost ~]# ls -l /etc | more
总用量 1780
drwxr-xr-x. 3 root root   4096 5月  27 17:46abrt
drwxr-xr-x. 4 root root   4096 5月  27 17:49acpi
-rw-r--r--. 1 root root     44 5月  27 17:54adjtime
-rw-r--r--. 1 root root   1512 1月  12 2010aliases
................................省略部分..........................................
[root@localhost ~]# find /etc -mmin -5 -a -typef                     #因为我没改过所以没有
[root@localhost ~]# find /boot -name grub.conf-exec ls -l {} \;
-rw-------. 1 root root 811 5月  27 17:52/boot/grub/grub.conf
[root@localhost ~]# find / -size +204800 -a-size -307200
find: “/proc/30990/task/30990/fd/5”: 没有那个文件或目录
find: “/proc/30990/task/30990/fdinfo/5”: 没有那个文件或目录
find: “/proc/30990/fd/5”: 没有那个文件或目录
find: “/proc/30990/fdinfo/5”: 没有那个文件或目录
/mnt/sr0/images/install.img
/sys/devices/pci0000:00/0000:00:0f.0/resource1
/sys/devices/pci0000:00/0000:00:0f.0/resource1_wc
4、查看系统安装时是否安装了php软件包;用grep查看Apache配置文件/etc/httpd/conf/httpd.conf的DocumentRoot选项信息;树状显示/etc/httpd目录下文件结构
[root@localhost ~]# grepphp /root/install.log            安装的rpm包
[root@localhost ~]# grepDocumentRoot /etc/httpd/conf/httpd.conf
# DocumentRoot: Thedirectory out of which you will serve your
DocumentRoot"/var/www/html"
# This should be changedto whatever you set DocumentRoot to.
#    DocumentRoot/www/docs/dummy-host.example.com
[root@localhost ~]# tree/etc/httpd                     #tree系统用没有需要自己安装
/etc/httpd
├── conf
│   ├── httpd.conf
│   └── magic
├── conf.d
│   ├── php.conf
│   ├── README
│   └── welcome.conf
├── logs ->../../var/log/httpd
├── modules ->../../usr/lib64/httpd/modules
└── run ->../../var/run/httpd
5、查看用户配置文件/etc/shadow的帮助信息;查看命令cd的帮助信息
[root@localhost ~]# man 5shadown
Cannot open the messagecatalog "man" for locale "zh_CN.UTF-8"
(NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N")

No entry for shadown insection 5 of the manual
[root@localhost ~]# helpcd
cd: cd [-L|-P] [dir]
Change the shell working directory.

Change the current directory to DIR.  The default DIR is the value of the
HOMEshell variable.
……………………….省略部分……………………
6、创建目录/comp ,拷贝文件/etc/services到/comp目录下,分别对services文件进行压缩,生成 .gz .zip .bz2三种格式的压缩包;拷贝目录/etc到/comp目录下(保持目录属性不改变),把etc目录压缩生成etc.tar.gz,把services文件的所有压缩包使用rm删除(只用一条rm命令,非执行三次rm操作);在/comp目录下创建文件hidefile ,并设置为隐藏
[root@localhost ~]# mkdir /compcp /etc/services/comp
[root@localhost ~]# cp /etc/services /comp
[root@localhost ~]# cd /comp/
[root@localhost comp]# zip services.zip services
adding:services (deflated 80%)
[root@localhost comp]# bzip2 -k services
[root@localhost comp]# gzip services
[root@localhost comp]# rm -f services.*   (-f 强制删除,不提示确认)
[root@localhostcomp]# cp -rf /etc /comp
[root@localhostcomp]# cd /comp/
[root@localhostcomp]# tar -zcf etc.tar.gz etc
[root@localhostcomp]# touch hidefile
[root@localhostcomp]# mv hidefile .hidefile
7、查找命令ifconfig的绝对路径并判断此命令哪些用户可以执行;更改本机IP地址为192.168.9.250(练习后改变回来)
[root@localhost ~]# which ifconfig
/sbin/ifconfig
只有root可以使用ifconfig(sbin目录下的命令只有root可以执行)
[root@localhost ~]# ifconfig eth0 192.168.1.250
8、ping本机地址测试,要求发送10次ICMP包且包大小为1000 byte
[root@localhost ~]# ping -c 10 -s 1000 192.168.1.250
9、设置命令“cp -rf”的命令别名为dircp ,查看当前在线用户
[root@localhost ~]# vi~/.bashrc

1 # .bashrc
2
3 # User specific aliases and functions
4
5 alias rm='rm -i'
6 alias dircp='cp -rf'
………………………….省略部分………………………
[root@localhost ~]# who
root     pts/0        2015-05-28 04:14 (192.168.1.250)
10、查看/etc目录下文件名以.conf结尾的二进制文件有多少个
[root@localhost ~]# mkdir/test
[root@localhost ~]# touch/test/find.list
[root@localhost ~]# find/etc -name *.conf -a -type f > /test/find.list
[root@localhost ~]# wc -l/test/find.list
231 /test/find.list
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux 用户登录