美文网首页
linux练习

linux练习

作者: xm11211 | 来源:发表于2019-01-28 13:50 被阅读0次

1. 将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中

[root@centos6 ~]#who | tr [:lower:] [:upper:] > /tmp/who.out
[root@centos6 ~]#cat /tmp/who.out
ROOT     TTY1         2019-01-28 04:38 (:0)
ROOT     PTS/0        2019-01-28 04:41 (192.168.48.1)

2. 计算1+2+3+..+99+100的总和

[root@centos6 ~]#seq -s + 100 | bc
5050

3. 创建用户gentoo,附加组为bin和root,默认shell为/bin/csh,注释信息为“Gentoo Distribution”

[root@centos6 ~]#useradd gentoo -G bin,root -s /bin/csh -c "Gentoo Distribution"
[root@centos6 ~]#id gentoo
uid=501(gentoo) gid=501(gentoo) groups=501(gentoo),0(root),1(bin)
[root@centos6 ~]#getent passwd gentoo
gentoo:x:501:501:Gentoo Distribution:/home/gentoo:/bin/csh

4.在/testdir/dir里创建的新文件自动属于webs组,组apps的成员如:tomcat能对这些新文件有读写权限,组dbs的成员如:mysql只能对新文件有读权限,其它用户(不属于webs,aps,dbs)不能访问这个文件夹。

[root@centos6 ~]#mkdir -p /testdir/dir
[root@centos6 ~]#groupadd webs
[root@centos6 ~]#groupadd apps
[root@centos6 ~]#groupadd dbs
[root@centos6 ~]#chown :webs /testdir/dir/
[root@centos6 ~]#chmod g+s /testdir/dir/
[root@centos6 ~]#useradd -g apps tomcat
[root@centos6 ~]#useradd -g dbs mysql
[root@centos6 ~]#setfacl -m g:apps:rx /testdir/dir/
[root@centos6 ~]#setfacl -m g:dbs:rx /testdir/dir/
[root@centos6 ~]#setfacl -m d:g:apps:rw /testdir/dir/  
[root@centos6 ~]#setfacl -m d:g:dbs:r /testdir/dir/
[root@centos6 ~]#chmod o= /testdir/dir
[root@centos6 ~]#setfacl -m d:o::- /testdir/dir/
[root@centos6 ~]#ll /testdir
total 8
drwxr-s---+ 2 root webs 4096 Jan 28 14:29 dir
[root@centos6 ~]#getfacl /testdir/dir
getfacl: Removing leading '/' from absolute path names
# file: testdir/dir
# owner: root
# group: webs
# flags: -s-
user::rwx
group::r-x
group:apps:r-x
group:dbs:r-x
mask::r-x
other::---
default:user::rwx
default:group::r-x
default:group:apps:rw-
default:group:dbs:r--
default:mask::rwx
default:other::---

5. 找出ifconfig中的ip地址。要求结果只显示本机的ipv4地址

[root@centos6 ~]#ifconfig | head -2 | tail -1 | tr -s ' ' | cut -d ' ' -f 3 | cut -d: -f2
192.168.48.128
[root@centos7 bin]$ifconfig | head -2 | tail -1 | tr -s ' ' | cut -d' ' -f3
192.168.48.129

6. 查出用户UID最大值的用户名、UID及shell类型

[root@centos7 bin]$cut -d: -f1,3,7 /etc/passwd | sort -t: -k2 -nr | head -1
nfsnobody:65534:/sbin/nologin

7. 复制/etc/rc.d/init.d/functions文件至/tmp目录,替换/tmp/functions文件中的/etc/sysconfig/init为/var/log

[root@centos6 ~]# cp /etc/rc.d/init.d/functions /tmp
[root@centos6 ~]# vim /tmp/functions
扩展命令模式底部输入   %s#\/etc\/sysconfig\/init#\/var\/log#

相关文章

  • Linux简单介绍

    Linux 相关Linux 下的一些特点Linux 小练习Linux 文件权限Linux 命令-chmodLinu...

  • Day-2 guocheng

    1、linux 是什么 2、为什么需要linux 3、linux 常规操作练习 End

  • Day2-陈海影

    学习linux linux的服务器putty的练习图片发自简书App

  • Linux练习

    按下( )键能终止当前运行的命令 在下列分区中,Linux默认的分区是( ) 在创建Linux...

  • linux练习

    1.https的原理 HTTP缺点 (1)通信使用明文,不加密,内容可能会被窃听;(2)不验证通信方的身份,因此有...

  • linux练习

    1. 域名劫持的解决方法 (1)注意查看可疑电子邮件:留意域名注册中的电子邮件,因为您的网站已被入侵,因此需要您登...

  • linux练习

    1. 将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中 2. 计算1+2+3+..+99+...

  • linux练习

    1.创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建...

  • linux练习

    1.编写脚本/root/bin/backup.sh,可实现每日将/etc/目录备份到/root/etcYYYY-m...

  • linux练习

    1.简述TCP三次握手 假设客户端是A 服务端是B(1)A告诉B想要与B建立连接(SYN),同时A进入连接请求已发...

网友评论

      本文标题:linux练习

      本文链接:https://www.haomeiwen.com/subject/yxjajqtx.html