Linux学习基础02_N36032

本文介绍了Linux系统下实用的命令技巧,包括用户信息转换、算术运算、文件管理、用户创建、权限设置、IP地址提取、用户UID查询、文件复制与替换等操作,通过具体示例展示了如何高效地进行系统管理和文件操作。

1、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中。
tr 'a-z' 'A-Z' < /etc/issue >/tmp/who.out
或者
cat /etc/issue |tr 'a-z' 'A-Z' >/tmp/who.out

2、计算1+2+3+..+99+100的总和。
echo {1..100} | tr ' ' '+'|bc

3、常用的用户及文件管理命令有哪些,并演示命令及用法。
useradd
usermod
userdel
groupadd
groupmod
groupdel
chown
chgrp
chmod
setfacl

4、创建用户gentoo,附加组为bin和root,默认shell为/bin/csh,注释信息为“Gentoo Distribution”。
useradd -G bin,root gentoo
usermod -s /bin/csh gentoo
usermod -c "Gentoo Distribution" gentoo

5、在/testdir/dir里创建的新文件自动属于webs组,组apps的成员如tomcat能对这些新文件有读写权限,组dbs的成员如mysql只能对新文件有读权限,其他用户(不属于webs,apps,dbs)不能访问这个文件夹。
groupadd webs
groupadd dbs
mkdir -p testdir/dir
chgrp webs /root/testdir/dir
chmod g+s /root/testdir/dir
useradd -G apps tomcat
useradd -G dbs mysql
setfacl -m g:apps:rw /root/testdir/dir/
setfacl -m g:mysql:r /root/testdir/dir/
setfacl -m d:o::- /root/testdir/dir/

6、找出ifconfig中的ip地址。要求结果只显示本机的IPv4地址。
ifconfig ens33 |grep -w "inet"|tr -s " "|cut -d" " -f3

7、查出用户UID最大值的用户名、UID及shell类型
grep getent passwd|cut -d: -f3|sort -n|tail -1 /etc/passwd |cut -d: -f1,3,7

8、复制/etc/rc.d/init.d/functions文件至/tmp目录,替换/tmp/functions文件中的/etc/sysconfig/init为/var/log
cp /etc/rc.d/init.d/functions /tmp
%s@/etc/sysconfig/init@/var/log@g

转载于:https://blog.51cto.com/14182153/2349556

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值