2023年7月26日发(作者:)
Linux进程管理练习题做了⼗⼏道练习题,记录⼀下1.列出/etc⽬录下所有以.conf结尾的⽂件,把输出结果重定向到/var/tmp/中ls /etc/ | awk '/.conf$/{print}' > /var/tmp/2.定义⼀个ipadd变量,值为eth0⽹卡ip,要求此变量在所有shell中都⽣效ipadd=ip #
⽹卡IP地址export ipadd3.将系统环境变量PATH值改为/bin,然后执⾏passwd,能否修改当前⽤户密码?当前系统环境变量及passwd可执⾏程序位置[root@localhost ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin[root@localhost ~]# which passwd/usr/bin/passwd如果把PATH改为/bin,执⾏passwd将找不到该命令,因为passwd命令在/usr/bin⽬录下4.更改当前系统语⾔,永久⽣效[root@Centos6 ~]# echo $LANG #
查看当前使⽤语⾔en_-8[root@Centos6 ~]# locale #
当前使⽤的语⾔包LANG=en_-8LC_CTYPE="en_-8"LC_NUMERIC="en_-8"LC_TIME="en_-8"LC_COLLATE="en_-8"LC_MONETARY="en_-8"LC_MESSAGES="en_-8"LC_PAPER="en_-8"LC_NAME="en_-8"LC_ADDRESS="en_-8"LC_TELEPHONE="en_-8"LC_MEASUREMENT="en_-8"LC_IDENTIFICATION="en_-8"LC_ALL=[root@Centos6 ~]# yum groupinstall chinese-support #
下载中⽂语⾔包[root@Centos6 ~]# vim /etc/profile #
在/etc/profile⽂件中加⼊⼀⾏...export LANG="zh_-8"...[root@Centos6 ~]# . /etc/profile #
执⾏⽂件[root@Centos6 ~]# echo $LANGzh_-8[root@Centos6 ~]# ls abc #
系统语⾔为中⽂ls: ⽆法访问abc: 没有那个⽂件或⽬录5.通过终端连接到Linux,找出sshd进程并终⽌此进程[root@Centos6 ~]# ps aux | grep sshdroot 2783 0.0 0.0 66260 1208 ? Ss 08:34 0:00 /usr/sbin/sshdroot 3486 0.0 0.2 104636 4612 ? Ss 13:26 0:00 sshd: root@pts/0
root 3544 0.0 0.0 103340 872 pts/0 D+ 13:42 0:00 grep --color=auto sshd[root@Centos6 ~]# kill 2783[root@Centos6 ~]# ps aux | grep sshdroot 3486 0.0 0.2 104636 4612 ? Ss 13:26 0:00 sshd: root@pts/0
root 3546 0.0 0.0 103340 904 pts/0 S+ 13:43 0:00 grep --color=auto sshd此时Linux ssh服务关闭,新开⼀个终端连接会显⽰连接失败恢复sshd服务[root@Centos6 ~]# /etc/init.d/sshd start正在启动 sshd: [确定]6.找出系统中⼩于1k的⽂件并复制到/var/tmp/find_dir中,放后台执⾏[root@localhost ~]# mkdir /var/tmp/find_dir/[root@localhost ~]# find / -size -1k -exec cp {} /var/tmp/find_dir/ ; &[root@localhost ~]# ls /var/tmp/find_dir/ | wc -l34457.对系统的组账户⽂件统计,并对gid做排序,输出到⽂件~/,并对输出做⾏数统计[root@Centos6 ~]# cat /etc/group | awk -F: '{print $3}' | sort -n > ~/ # sort默认按ansi排序,加-n对数字从⼩到⼤排序[root@Centos6 ~]# cat ./ | wc -l1078.⽤sed修改~/⽂件,将x86_64改为i386,并作备份[root@Centos6 ~]# cp ./ ./[root@Centos6 ~]# sed 's/x86_64/i386/g' ./
9.找出系统所有以.iso结尾的⽂件,在~下新建⼀个⽂件,拷贝到/tmp⽬录下,使⽤locate命令看能否找到两个iso⽂件?[root@Centos6 ~]# find / -name *.iso/mnt/testdir/[root@Centos6 ~]# touch ./[root@Centos6 ~]# cp ./ /tmp/[root@Centos6 ~]# yum install mlocate -y[root@Centos6 ~]# updatedb[root@Centos6 ~]# locate *.iso #
只能找到⼀个/root/ate是按⽂件名找⽂件,相当于find -name,它是在⼀个索引数据库⾥找⽂件10.将虚拟机联⽹,⽤elinks访问,将其html代码下载下来到/tmp/中[root@Centos6 ~]# yum install elinks -y #
⼀个浏览器[root@Centos6 ~]# wget --no-check-certificate -O /tmp/[root@Centos6 ~]# cat /tmp/ #
查看源代码....11.给root发封邮件,主题为The task is so hard,正⽂为I’ll do this work try my best.[root@Centos6 ~]# echo "I'll do this work try my best." | mail -s 'The task is so hard.' root[root@Centos6 ~]# To: root@omainSubject: The task is so -Agent: Heirloom mailx 12.4 7/29/08Content-Type: text/plain; charset=us-asciiFrom: root@omain (root)Status: RI'll do this work try my best.发邮件命令:echo 正⽂ | mail -s 主题 ⽤户或邮箱参考⽂章:
发布者:admin,转转请注明出处:http://www.yc00.com/news/1690367781a339105.html
评论列表(0条)