当前位置: 首页 > article >正文

Linux常用操作练习题:

1.用cat显示/etc/passwd,并显示行号

[root@rhcsa001 ~]# cat -n /etc/passwd
     1	root:x:0:0:root:/root:/bin/bash
     2	bin:x:1:1:bin:/bin:/sbin/nologin
     3	daemon:x:2:2:daemon:/sbin:/sbin/nologin

2.将/etc/passwd文件中的前20行重定向保存到/hoem下改名20_pass.txt

[root@rhcsa001 ~]# head -n 20 /etc/passwd >> /home/20_pass.txt
[root@rhcsa001 home]# ls
 20_pass.txt  redhat

3.在当前目录下创建空文件夹/web/test1

[root@rhcsa001 ~]# mkdir -p ./web/test1
[root@rhcsa001 ~]# tree
.
└── web
    └── test1

2 directories, 0 files

4.查看当前工作目录的命令

[root@rhcsa001 ~]# pwd
/root

5.将/tmp下的文件file1复制到当前目录下,文件名仍为file1

[root@rhcsa001 ~]# cp -r /tmp/file1 ./
[root@rhcsa001 ~]# ls
 file1

6. 显示环境变量path,将/root加入到$PATH中

7. 拷贝文件/etc/passwd到/tmp目录下

8. 查看/tmp/目录的使用空间

9. 删除空目录dir1

[root@rhcsa001 ~]# rm -rfv dir1/

10. 将/root下的所有文件删除

[root@rhcsa001 ~]# rm -rfv *
removed 'dir1/file1'
removed directory 'dir1'

11. 将目录dir1设定成任何人皆有读取及执行的权利,但只有拥有者可作写修改

12. 在/下建立目录test,在test建立文件1.txt和2.txt,分别在文件1.txt和2.txt中输入 :                    “I am chinese”,“are you ok?”

[root@rhcsa001 ~]# cd /
[root@rhcsa001 /]# mkdir test

[root@rhcsa001 /]# cd ./test/
[root@rhcsa001 test]# echo "I am Chinese" >> 1.txt
[root@rhcsa001 test]# echo "Are you OK?" >> 2.txt
[root@rhcsa001 test]# ls
1.txt  2.txt
[root@rhcsa001 test]# cat 1.txt 
I am Chinese
[root@rhcsa001 test]# cat 2.txt 
Are you OK?

 64. 在当前目录下新建一个名称为a.txt的文件,并在文件里面输入如下内容:
Hello Linux!  
Jishou university!  

[root@rhcsa001 ~]# touch a.txt
[root@rhcsa001 ~]# vim a.txt 
进入命令模式
按i键,进入插入模式进行文本编辑
:wq!进入底行模式并进行保存退出

[root@rhcsa001 ~]# cat a.txt 
Hello Linux!
Jishou university!

13. 在/etc/passwd文件中查找所有以“root”开头的文件

[root@rhcsa001 ~]# vim /etc/passwd
进入文件后,进入末行模式输入 :/root

14. 在dir1目录中建立一个空文件file1

[root@rhcsa001 ~]# mkdir dir1
[root@rhcsa001 ~]# cd ./dir1
[root@rhcsa001 dir1]# touch file1
[root@rhcsa001 dir1]# cd ~
[root@rhcsa001 ~]# tree
.
└── dir1
    └── file1

1 directory, 1 file

16. 创建用户win1,UID、GID等均按默认

17. 创建用户win2,默认主目录为/think,其余默认

18. 用cat命令将file1、file2、file3合并为文件filenew
21. 将目录dir1改名为dir2

42. 将文件file1改名为file2
24. 建立source文件的符号链接,命名为source.soft

[root@rhcsa001 ~]# touch source
[root@rhcsa001 ~]# ln -s source source.soft
[root@rhcsa001 ~]# ll
total 0
-rw-r--r--. 1 root root 0 Sep 30 19:00 source
lrwxrwxrwx. 1 root root 6 Sep 30 19:00 source.soft -> source

40. 创建install.login文件的软链接文件install.soft,硬链接文件install.hard

[root@rhcsa001 ~]# touch install.lodin
[root@rhcsa001 ~]# ln -s install.lodin install.soft
[root@rhcsa001 ~]# ln  install.lodin install.hard
[root@rhcsa001 ~]# ll
total 0
-rw-r--r--. 2 root root  0 Sep 30 19:04 install.hard
-rw-r--r--. 2 root root  0 Sep 30 19:04 install.lodin
lrwxrwxrwx. 1 root root 13 Sep 30 19:04 install.soft -> install.lodin

25. 查看/root目录下有哪些文件和目录

[root@rhcsa001 ~]# ls /root

[root@rhcsa001 ~]# ll /root

[root@rhcsa001 ~]# tree /root

29. 查看/etc/passwd文件的前10行

[root@rhcsa001 ~]# head -10 /etc/passwd | cat -n
     1	root:x:0:0:root:/root:/bin/bash
     2	bin:x:1:1:bin:/bin:/sbin/nologin
     3	daemon:x:2:2:daemon:/sbin:/sbin/nologin

cat -n 用于显示行号

38. 查看当前目录中filenew的文件内容

39. 在用户目录中创建目录/a/b/c/d ,在/root目录下创建1/2/3/4

41. 把/root目录下所有文件和子目录拷贝到/a/b/c/d目录下

43. 把/root目录下的install.log拷贝成1.txt,2.txt,3.txt,把install.log拷贝成a.txt,a.doc

44. 把/root下的以txt结尾的文件拷贝到/a目录下。把/root下的以a开头的文件拷贝到/a/b目录下

45. 将文件file复制成file1
46. 把/a目录下1.txt改名为1.c,把/a/b下的a.txt改名a.c
48. 把/a/b/c目录移动到/root/1/2/3/4目录下
49. 把/root目录下install.log的前10行内容输出到文件/a/b/a.log中
52. 删除/a/b目录下的所有文件和子目录。删除/root/a/b目录下所有文件和子目录
60. 测试本机与IP为183.2.172.42的连通性

[root@rhcsa001 ~]# ping 183.2.172.42 
PING 183.2.172.42 (183.2.172.42) 56(84) bytes of data.
64 bytes from 183.2.172.42: icmp_seq=1 ttl=128 time=52.3 ms
64 bytes from 183.2.172.42: icmp_seq=2 ttl=128 time=55.9 ms

62. 查阅passwd命令的使用手册

65. 将文件a.txt重命名为aaa.txt
66. 将/etc/apt中的所有文件复制到当前目录中
67. 删除当前目录下的source.list文件
68. 搜索/etc/passwd中包含root的行,并显示出来
70. 显示file.txt的前5行
71. 显示file.txt的后2行
72. 统计/etc/passwd文件的行数
75. 修改当前用户的密码
78. 测试本机与210.43.65.196是否能正常通信
81. 删除当前目录下子目录dir1中的文件tmp.old
88. 显示当前登录系统的用户
89. 查看/etc目录占用的磁盘空间
92. 显示环境变量USER的值
93. 利用重定向将create.c 的数据输出到 output.c
95. 在你的主目录下建立目录树
        mydir
   shell   program
linux dos  standart


http://www.kler.cn/news/326601.html

相关文章:

  • 【RabbitMQ 项目】前置技术:含同步操作的线程池——C++11<future>使用
  • 使用dockerfile来构建一个包含Jdk17的centos7镜像(构建镜像:centos7-jdk17)
  • Temporal Dynamic Quantization for Diffusion Models阅读
  • Spring中如何为静态变量注入值
  • 虚拟环境默认安装到C盘的修改办法
  • rust一些通用编程的概念
  • 在 Vue 中使用 ECharts:解决 Dialog 中 Tooltip 不显示的问题
  • Webshell分类
  • STM32DMA学习日记
  • 基于基于微信小程序的社区订餐系统
  • 软件测试|数据库常见面试题
  • Java常用三类定时器快速入手指南
  • 音视频整体解码流程和同步流程
  • 单节点集群数据写入测试
  • ESXI识别USB设备
  • 【min25筛】【CF2020F】Count Leaves
  • 【优选算法】(第五篇)
  • RabbitMQ 队列之战:Classic 和 Quorum 的性能洞察
  • pve虚拟机常见问题汇总
  • 【Linux 从基础到进阶】Azure 云服务在 Linux 上的应用
  • 【编程小白必看】MySQL 聚合函数操作秘籍一文全掌握
  • 算法安全自评估报告如何填写?(附模板)
  • 前端项目场景相关的面试题,包含验证码、图片存储、登录鉴权、动态路由、组件划分等项目场景实际的面试题
  • Leetcode面试经典150题-322.零钱兑换
  • django创建项目
  • uview表单校验不生效问题
  • MySql5.7.26安装和配置
  • C#_运算符重载详细解析
  • 随手记:ul-table表格合并方法
  • 爬虫库是什么?是ip吗