一、试完成下列小题:

(1)、在根目录下创建目录aa。((Create directory aa in the root directory.)

cd /->mkdir aa

(2)、在根目录下创建一个文件cc,然后把cc拷贝到aa下。(Create a file cc in the root directory and copy cc to aa.)

touch cc->cp cc aa

(3)、更改目录aa的权限为777,然后查看是否更改成功。(Change the permission of directory aa to 777, and check whether the change is successful.)

chmod 777 aa->ls -l

(4)、创建用户bob,更改目录aa的拥有着和组群都为bob,然后查看是否更改成功 。(Create user bob, change the directory aa owner and group to BOB, and check whether the change is successful.)

   bob aa->chgrp bob aa->ls -l

(5)、删除该目录以及该目录下的所有文件并不作提示?(Delete this directory and all files in this directory without prompt?

rm -rf aa

二、试完成下列小题:

(1)、用命令把当前工作目录切换到"/root",并用命令查看是否切换成功。(Use the command to change the current working directory to "/root", and use the command to check whether the switch is successful.)

cd /root->pwd

(2)、用命令新建文件"testfile",然后为其创建软链接和硬链接文件,查看其inode编号、文件类型、文件权限、连接计数、大小等属性。(Create a new file "testfile" with the command, and then create soft and hard linked files for it. Check INODE number, file type, file permissions, connection count, size and other properties.)

touch testfile->ln testfile test->ln –s testfile file-> ls –l

(3)、创建文件file1,并将file1改为file2,然后将文件file1和文件file2移动到目录/tmp下,并查看是否移动成功。(Create file file1 and change file1 to file2, then move file file1 and file file2 to the directory/TMP, and check whether the move is successful.)

touch file1->cp file1 file2->mv file1 file2 /tmp->ls /tmp

三、试题成下列小题:

(1)、查找系统命令pwd指令文件的位置(Find the location of the system command PWD instruction file)

which pwd

(2)、查找whereis文件,且只将二进制文件查找出来(Find the file whereis, and only find the binary file)

whereis -b whereis

(3)、查找和pwd相关的所有文件(Find all files related to PWD)

locate pwd

(4)、搜索etc目录下所有以sh开头的文件(search etc directory for all files beginning with sh)

locate /etc/sh

(5)、建立目录/tmp/a/b/c,若不存在目录/tmp/a及/tmp/a/b,则自动建立。(create directory /tmp/a/b/c, if it is not exist of /tmp/a and /tmp/a/b, automatically set up)

mkdir -p /tmp/a/b/c

四、用vim编辑器在/tmp下新建一个文件名aa插入如下内容:(Using the Vim editor, create a new filename aa under/TMP and insert the following)

abcdefg

1234567

ABCDEFG

zyxwvuts

7654321

ZYXWVUTS

使用vim创建新文件:

vim /tmp/aa

i 键切换为输入模式

输入以下内容:

abcdefg

1234567

ABCDEFG

zyxwvuts

7654321

ZYXWVUTS

完成录入后,先按Esc键回到命令模式,再输入 :wq 保存并退出编辑器

(1)、显示文档每一行行号(Display the number of each line of the document)

方法一:

在末行模式下输入set nu”即可显示文件的行号

方法二:

如果要让vim编辑器永久显示行号,需要修改vim编辑器对应的配置文件vimrc。一般在当前用户的根目录下创建vimrc文件,命令如下:

sudo su#登录root用户

vim,vimrc#创建vimrc文件

[.vimrc]文件中添加如下内容

:set number

(2)、删除第二行中的第3到6个字符并撤销操作(Delete the third to sixth characters in the second line and undo the operation)

方法一:
删除光标所在处的字符,点击一次x键只能删除一个字符。

方法二:

删除光标所在处后的4个字符(nx),输入4x

撤销方法:ctrl+R

(3)、复制第二行,并粘贴到第6行(Copy the second line and paste it into line 6)

光标放在第二行

小写yy复制单行

P粘贴在光标下一行

五.用vim编辑器在/tmp下新建一个文件名bb插入如下内容:(Using the Vim editor, create a new filename bb under/TMP and insert the following:)

abcdefg

1234567

ABCDEFG

zyxwvuts

7654321

ZYXWVUTS

使用vim创建新文件:

vim /tmp/bb

i 键切换为输入模式

输入以下内容:

abcdefg

1234567

ABCDEFG

zyxwvuts

7654321

ZYXWVUTS

完成录入后,先按Esc键回到命令模式,再输入 :wq 保存并退出编辑器

(1)、删除第2至6行中的第3值6个字符(Delete the third value of 6 characters from lines 2 to 6)

光标放在第2行第3个字符-----ctrl+v---光标移到第6个字符再移至第6----d

(2)、在第4行插入空白行,并输入“ZYX127”;(Insert a blank line in the fourth line and enter "ZYX127")

光标放在第3行末尾---按小写o—输入“ZYX127”

(3)、在第2行到第7行中查找“127”,并用字符串“hello”替代。(Find "127" in lines 2-7 and replace it with the string "hello".)

2,7 s /127/hello/g

(4)、在vim编辑器中运行date命令,并把结果插入到文档的第5行,然后并保存此文件并退出vim编辑器(Run the date command in the Vim editor and insert the result into line 5 of the document. Then save the file and exit the Vim editor)

光标放在第4行末尾---:r!date

六、新建一个分区并挂载到文件夹mz(Create a new partition and mount it into the folder mz)

(1)、新建硬盘分区vda4。(Create a new hard disk partition sda4.)

第一步:进入fdisk指令交互模式:fdisk /dev/sda

第二步:使用n 命令创建新的硬盘分区:n(如果sda4已经存在,先删除dd ,然后按n ,p,)

第三步:使用P命令显示分区列表:p

第四步:使用w命令保存并退出:w`

reboot 重启电脑

(2)、对vda4分区格式化。(Format sda4 partition.)

格式化:mkfs -t ext4 /dev/sda4

(3)、在根目录下新建一个目录mz,并将vda4分区挂载到目录mz上。(Create a new directory mz in the root directory, and mount the sda4 partition on the directory mz.)

在桌面上创建目录:mkdir cz

挂载:mount -t ext4 /dev/sda4 cz

ls cz

七、对文件和目录解压缩(Unzip files and directories)

(1)、在根目录下创建目录bb和文件x、y、z;(Create directory bb and files x, y, z in root directory)

cd /

mkdir bb

touch x

touch y

touch z

ls

(2)、对这x、y、z三个文件进行压缩和解压操作;(Compress and decompress the x, y and z files)

gzip x y z

ls

gunzip x.gz y.gz z.gz

ls

(3)、把x、y、z三个文件移动到bb下;(Move x, y and z files to bb)

mv x y z bb

(4)、对目录bb进行打包并压缩并解包解压缩;(Pack and compress directory bb and unpack and uncompress it)

(压缩的时候可以任选一种gzip,bzip2 You can choose either gzip or bzip2 for compression)

tar -czvf aaa.tar.gz bb

rm -rf bb

tar -xzvf aaa.tar.gz

八、使用rpm命令进行软件包的安装、查询、删除(Use RPM command to install, query and delete software packages)

(1)、切换到root下,手动将要安装的vsftpd软件包所在的文件夹packages的vsftpd-2.2.2-11.el6.i686.rpm复制到root文件夹下。(Copy VSFTPD Packages VSFTPD -2.2.2-11.el6.i686. RPM to root: Packages VSFTPD -2.2.2-11.el6.i686. RPM to root: Packages VSFTPD -2.2.2-11.el6.i686. RPM)

cd

(2)、使用rpm查询软件包vsftpd是否安装到当前系统中,如果没有安装,则安装。(Use RPM to check whether the package VSFTPD is installed in the current system. If not, then install it.)

rpm -q vsftpd

(3)、使用rpm安装软件包vsftpd。(Install the package VSFTPD using RPM.)

rpm -ivh vs

(4)、删除软件包vsftpd。(Delete the package VSFTPD.)

rpm -e vsftpd

九、创建用户和组群(Create users and groups)

(1)、创建用户rjxy

useradd rjxy

(2)、创建用户test,并设置该用户的UID号为1050;(Create user test and set UID number of this user to 1050)

Useradd test -u 1050

(3)、创建用户abc并设置该用户的宿主目录为/home/xyz;(Create user ABC and set the host directory of user as /home/xyz)

useradd -d /home/xyz abc

cat /etc/passwd | grep abc

(4)、创建用户new,并指定该用户的主组群为rjxy组群;(Create user new, and specify the primary group of this user as rjxy group)

useradd -g rjxy new

(5)、创建名为guess的组群,并设置GID为1060;(Create a group named guess and set the GID to 1060)

useradd -d /home/xyz abc

cat /etc/passwd | grep abc

(6)、修改用户test的登录名为doc。(alter user test login name doc)

vim /etc/passwd

找到旧用户名改为新用户名,但是 /home/旧用户名 不能更改,若更改重启后,便登陆不了系统了。

vim /etc/shadow

找到旧用户名改为新用户名

十、 磁盘配额(Disk quota)

(1)、对dev/sda4配置磁盘配额,使用vim编辑器修改/etc/fstab文件。(Configure the disk quota on dev/sda4 and modify the /etc/fstab file using Vim editor.)

 mkdir /home/quota

vim /etc/fstab

/dev/sda4 /home/quota ext4 defaults,usrquota,grpquota 0 0

(2)、重新挂载文件系统以使修改生效。(mount the file system again for the changes to take effect.)

init 6 重新启动操作系统

mount -s 看是否挂载成功

(3)、在/home/quota目录下创建配额文件,为启用了配额的文件系统生成当前次盘用量表。(Create a quota file in the /home/quota directory, and generate the current file size for the file system with quota enabled.)

quotacheck -acug

setenforce 0

ls -l /home/quota/

quotacheck -avug

(4)、执行edquota rjxy命令,把用户rjxy的软硬限制分别为100000和200000,即软限制100KB,硬限制200kB。(Executing the edquota rjxy command to set the hard and soft limits of the user rjxy to 100000 and 200000 respectively, namely, the soft limit of 100KB and the hard limit of 200KB.)

useradd rjxy

edquota rjxy

最后一行修改

/dev/sda4 0 100000 200000 0 0 0

(5)、启动磁盘配额,为rjxy用户设定权限,可以对/hone/quota目录进行写操作。(Start disk quotas and set permissions for the rjxy user to write to the /hone/quota directory)

chmod 777 /home/quota

(6)、切换到rjxy用户并进入/home/quota目录。(Switch to rjxy and enter /home/quota directory.)

su rjxy

cd /home/quota/

pwd

(7)、创建一个大小为300M的空文件。(Create an empty file with size 300M)

dd if+/dev/zero of=testfile bs=300M count=1

十一:bash变量

(1)、设置一个变量名为name,其变量值为tom,然后再为变量name增加内容andjack。(Set a variable named name with the value of tom and add content to name andjack.)

name=tom--->回车

name="$name"and jack---->回车

(2)、自定义一个变量x,并为其赋值tom,并转换成环境变量,然后换一个shell环境,然后输出变量x的值。(Customize a variable x, assign the value Tom to it, and change it to an environment variable, then change to a shell environment, and output the value of the variable x.)

x=tom--->回车

export x---->回车

bash---->回车

echo $x

(3)、为y变量读取来自键盘输入的变量值为tom,并且输入时会有提示内容“please input your name:“。(Read the variable value of TOM from the keyboard for Y variable, and there will be prompt content "Please input your name:" when input.)

read -p "please keyin your name:" y---->回车----->tom---->回车

(4)、声明一个变量z为整数型变量,然后为其赋值56,然后并且输出变量的内容。(Declare a variable z as an integer variable, assign the value 56 to it, and print the contents of the variable.)

declare -i z

z=56

十二:数据流重定向和管道命令(Data flow redirection and piping commands)

(1)、先进入/root目录下,然后查看文件test1的标准输出时利用标准输出重定向符号,里面并且写上两行字符分别为linux!和world!,然后查看文件test2的标准输出重定向符号并把test1的内容作为test2的输入,然后查看文件test2。然后再把test1的内容标准输出到test2中并且不会覆盖其原来的内容。(When entering the /root directory and looking at the stdout of file test1, use the stdout redirect symbol, and write two lines of characters in it: Linux! And the world!, then look at the standard output redirection symbol of file test2 and take the contents of test1 as input to test2, then look at file test2. The contents of test1 are then standardised out to test2 without overwriting the original contents.)

cd-->回车

cat > test1--->回车-->linux!-->回车-->world-->回车--->ctrl+d

cat > test2 < test1

cat test1 >> test2-->回车

(2)、利用last指令列出当前与过去登录的用户信息同时利用cut指令截取每行的第1-6个字符出来。(Use the last command to list the information of current and past logged users. At the same time use the cut command to intercept the 1st to 6th characters of each line.)

last | cut -c 1-6-->回车

(3)、利用grep命令把/etc/passwd文件中包含关键字符”root“的行搜索出来。(Search for lines in /etc/passwd containing the key character "root" using grep.)

cat /etc/passwd | grep 'root'--->回车

十三:历史命令和命令执行控制符号&&与||( History command and command control symbol && and | |)

(1)、列出当前系统中记录的所有历史记录,然后再立即清空当前shell所有历史命令的记录(List all the history records of the current system, and then immediately clear the record of all the history commands of the current shell)

history-->回车

history -c------->回车

(2)、判断/tmp目录下是否有tt文本文件,如果有就输出”exist“,如果不存在则输出”not exist“。(Determine whether there is a TT text file in the/TMP directory. If there is, output "EXIST"; if not, output "NOT EXIST".)

ls /tmp/tt && echo "exist" || echo "not exist"---->回车

十四:正则表达式(Regular expression)

(做下面的题之前首先start.txt文本文件拷贝到/root目录下,并把当前目录调为/root。 Start.txt file in /root directory and change the current directory to /root.)

(1)、从文件start.txt中查找含When或者Then的行,要显示行号。(Find a line containing WHEN or THEN in the file start.txt, and display the line number.)

grep -n '[WT]hen' start.txt--->回车

(2)、从文件start.txt中中查找以大写字母开头的行和查找不是以大写字母开头的行,然后再查找以“.”结尾的行。(from a file start.txt in the search for begin with a capital letter in the line and find not begin with a capital letter, and then search for ". "at the end of the line.)

grep -n '^[A-Z]' start.txt---->回车

grep -n '^[^A-Z]' start.txt---->回车

grep -n '\.$' start.txt---->回车

(3)、从文件start.txt中查找包含至少含有两个t的字符串所在的行。(select  from start.txt where a string containing at least two 't' is found)

grep -n 'tt*' start.txt---->回车

(4)、使用sed工具从文件start.txt中删除第2到4行的内容。(Delete lines 2 to 4 from the file start.txt with the sed tool)

nl start.txt | sed '2,4d'----->回车

(5)、使用sed工具把start.txt中的2~4行替换成“hi tom”。(Use the sed tool to replace lines 2 to 4 in start. TXT with "Hi Tom".)

nl start.txt | sed '2,4c hi tom'---->回车

linux上机考试题(Linux基础)相关推荐

  1. ()shi linux字符设备,Linux字符设备驱动基础(三)

    Linux字符设备驱动基础(三) 6 创建设备节点 6.1 手动创建设备节点 查看申请的设备名及主设备号: cat /proc/devices # cat /proc/devices Characte ...

  2. Linux系统编程——进程基础知识

    Linux系统编程--进程基础知识 1.程序和进程 程序,是指编译好的二进制文件,在磁盘上,不占用系统资源(cpu.内存.打开的文件.设备.锁-) 进程,是一个抽象的概念,与操作系统原理联系紧密.进程 ...

  3. LINUX常用命令(基础)

    LINUX常用命令(基础) 收藏LINUX常用命令(基础) 1. man 对你熟悉或不熟悉的命令提供帮助解释eg:man ls 就可以查看ls相关的用法注:按q键或者ctrl+c退出,在linux下可 ...

  4. Linux技术研究-基础篇(raid与LVM,配额)

    Linux技术研究-基础篇(raid与LVM,配额) 创建RAID-5 若想建立新的md1设备 只在/dev下建立还不够 重启后会消失 固化的方法是 为了使udev自动产生/dev/md1, /dev ...

  5. linux shell概述,Linux学习 -- Shell基础 -- 概述

    Shell是什么? 命令解释器 编程语言 Linux支持的Shell类型 cat /etc/shells 主要学习 bash 脚本执行方式 echo echo -e 单引号 -- 原始字符串  双引号 ...

  6. Linux上机实验1

    Linux上机题(总分100分) 1.          在计算机上添加两块IDE接口的硬盘,硬盘空间为10GB(共4分) 2.       将这两块硬盘进行分区,分别依次建立三个主分区,大小分别为2 ...

  7. 【Linux开发】linux设备驱动归纳总结(一):内核的相关基础概念

    linux设备驱动归纳总结(一):内核的相关基础概念 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  8. linux网络设置与基础服务命令(ifconfig、hostname、route、netstat、ss、ping、traceroute、nslookup、route)

    文章目录 linux网络设置与基础服务 前言 查看网络配置 使用ifconfig命令查看网络接口地址 查看指定网络接口信息 使用 hostname命令查看当前主机名称 使用route命令查看路由表条目 ...

  9. Linux实战考试题:批量创建用户和密码-看看你会么?

    批量创建10个用户stu01-stu10,并且设置随机8位密码,要求:不能用shell循环(例如:for,while等),只能用linux命令及管道实现. 此题考察的是基础命令的熟练运用,因此,限制了 ...

  10. linux 认证考试 题库,Linux认证考试题库及答案

    1.一个文件的'权限是-rw-rw-r--,这个文件所有者的权限是什么() a.read-only b.read-write c.write 答案 b 2.下面哪个值代表多用户启动() a.1 b.0 ...

最新文章

  1. go mod 相关的八个命令
  2. JPush (极光推送) For Xamarin.Android
  3. 后缀树的构造方法-Ukkonen详解 [转]
  4. c语言 包络算法,包络检测C程序
  5. Java枚举类型(enum)详解
  6. JS面试之对象(2)
  7. 这篇带你熟悉 SpringBoot+RabbitMQ 方式收发消息
  8. Java字节码深入解析
  9. java 克隆一个对象_Java对象克隆
  10. java——Random类和Math.Rondom
  11. 董明珠给格力员工加薪 10 亿;张小龙回应微信 7.0 界面变丑;库克怒怼高通 | 极客头条...
  12. Linux如何运行exe驱动,在Linux下可用Wine安装和运行360驱动大师、CCleaner
  13. ezcad旋转轴标刻参数_激光打标机软件ezcad中菜单下的多文档标刻功能介绍及其操作设置...
  14. 海量数据和高并发下的 Redis 业务优化实践
  15. 30个外贸业务员常用邮件模板案例分享
  16. 网络安全行业是蓝景吗?
  17. r5驱动 索尼exmor_卡片机“X”档案 ——索尼Exmor R CMOS技术解析
  18. PostgreSQL12.2-CN-v1.0中文手册.chm下载
  19. 怎么把图片用手机进行压缩?来试试这两个工具
  20. 关于微信开发者没有上传按钮的问题

热门文章

  1. 计算机软件著作权模板及个人申请全套攻略-软著
  2. 海康SDK-javademo实现报错问题解决
  3. InnoDB存储引擎概念与原理解析
  4. mysql新建数据库并执行sql文件
  5. linux中Chmod + X
  6. linux系统国产制图软件,国产操作系统也能用的国产图表绘制软件,替代Visio就用它了...
  7. unity引用类型序列化_Unity 序列化 总结
  8. 如何在线查看.mmap格式文件
  9. unity package 包下载不下来
  10. 好用的局域网文件共享工具