linux操作系统实践期末考试

选择题

I. Single Choice Questions (2 * 20 = 40 points)

#####################################################

  1. Command “ls -l” list the detail infomation of files. Which one is a soft link file according to the first ten characters?
    A. -rw-rw-rw-
    B. -rwxrwxrwx
    C. drwxr–r--
    D. lrwxr–r--

  2. Which file contains the user contains the absolute pathname for the user’s login shell?
    A. /etc/profile
    B. ~/.bash_profile
    C. /etc/passwd
    D. /etc/shadow

  3. Which option to umask would set my default file permissions such that files are created with these permissions: user has read/write, group has read/write, and everyone else has read only?
    a. umask 002
    b. umask 022
    c. umask 220
    d. umask 775

  4. What does the & character do when placed at the end of a command?
    A. It causes the process to be stopped.
    B. It restarts a stopped process.
    C. It causes the process to be placed into the foreground.
    D. It causes the process to be placed into the background.

  5. What is the shell metacharacter that matches zero or more characters?
    A. Square brackets [ ]
    B. Pound sign
    C. Dollar sign
    D. Asterisk (*)

  6. UNIX supports the following file types:
    A. Ordinary file, directory, link file, block special file, character special file, named pipe (FIFO), and socket
    B. Text files, C/C++/Java source files, graphics files, multimedia files, html files, and directories
    C. Text files, C/C++/Java source files, and directories
    D. All of the above

  7. You can copy directory ~/courses into directory ~/backups by using the following command:
    A. cpdir ~/courses ~/backups
    B. cp -r ~/courses ~/backups
    C. cp -d ~/courses ~/backups
    D. All of the above

  8. Which command will show you the usage of the file system?
    A. ps
    B. du
    C. df
    D. free

  9. Which one of the following is an accurate statement regarding this regular expression? [^1-8A-Za-z]
    A. It matches all letters and numbers except 9.
    B. It matches all letters and numbers except 9 and 0, but only at the beginning of a line.
    C. It matches 9, 0, and other nonletter and nonnumber characters.
    D. It matches characters other than letters or numbers.

  10. Which operation system doesn’t use a Linux kernel?
    A. Ubuntu
    B. Redhat
    C. AIX
    D. Centos

  11. The directory names stored in the PATH variable is used to
    A. Set your home directory.
    B. Search the executable file.
    C. Set the kernel directory.
    D. None of above.

  12. The UNIX command that renames file’s name is
    A. cp
    B. mv
    C. ls
    D. rm

Unix/Linux中的mv命令 常用格式与作用: 格式:mv file1 file2

作用:将文件file1改名为file2.

==========

格式:mv file dir

作用:将file移动到目录dir中去.

==========

格式:mv file1 file2 file3 dir

格式:mv -t dir file1 file2 file3

作用:将文件file1、file2和file3移动到目录dir中.

==========

格式:mv -i file1 file2

作用:将file1改名为file2,如果file2已经存在则询问是否覆盖.

==========

格式:mv -f file1 file2

作用:将file1改名为file2,即便file2已经存在也直接覆盖。

==========

格式:mv dir1 dir2

作用:如果dir2存在,则将dir1移动到dir2中,否则将dir1改名为dir2.

  1. The command ‘ls -l /tmp/a.txt’ is executed and the information is displayed as follow.
    -rwxr-xr-x 1 someone somegroup 49 2017-10-29 11:06 /tmp/a.txt
    Which is true about the permission of the file a.txt
    A. Everyone can modify the file.
    B. Only file ower can modify the file
    C. The user in the same group can modify the file
    D. Others can modify the file

  2. If you cann’t terminate a process(process id is 1024) using command “kill 1024”. What can you do to terminate the process? Select one.
    A. kill -9 1024
    B. kill -1 2014
    C. kill +9 4077
    D. killall 1024

  3. which command won’t delete file “a1.txt”?
    A. rm a.txt
    B. rm a*.txt
    C. rm a?.txt
    D. rm ?a?.txt

  4. If you want a partition mounted at boot time, which file do you need to modify?
    a. /etc/partitions
    b. /etc/mount
    c. /etc/mtab
    d. /etc/fstab

  5. Which one of the following statements correctly describes the > and >> symbols in the context of the bash shell?
    A. > appends standard output to an existing file, and >> writes standard output to a new file.
    B. > writes standard output to a new file, and >> appends standard output to an existing file.
    C. > writes standard error to a new file, and >> appends standard error to an existing file.
    D. > pipes standard output to a new file, and >> pipes standard output to an existing file.

  6. Under the Bash, the command “find / -name ‘stdio.h’ >a.txt 2>/dev/null”
    A. Is illegal
    B. Saves the result into a.txt, display error message on the screen
    C. Display the result on the screen, ignor the error message
    D. Saves the result into a.txt, ignore the error message

  7. Your usb disk’s file system is fat32, which is the right command to mount the usb device to your linux system
    A. mount -t ext3 /dev/sdb /mnt
    B. mount -t vfat /mnt /dev/sdb
    C. mount -t vfat /dev/sdb1 /mnt
    D. mount -t vfat /dev/sdb /mnt

Linux挂载命令mount用法及参数详解
mount是Linux下的一个命令,它可以将分区挂接到Linux的一个文件夹下,从而将分区和该目录联系起来,因此我们只要访问这个文件夹,就相当于访问该分区了。
命令格式:mount [-t vfstype] [-o options] device dir

1、-t vfstype 指定文件系统的类型,通常不必指定,mount 会自动选择正确的类型。

光盘或光盘镜像:iso9660 DOS fat16文件系统:msdos Windows 9x fat32文件系统:vfat
Windows NT ntfs文件系统:ntfs Mount Windows文件网络共享:smbfs UNIX(LINUX)
文件网络共享:nfs 2、-o options 主要用来描述设备或档案的挂接方式。

loop:用来把一个文件当成硬盘分区挂接上系统 ro:采用只读方式挂接设备 rw:采用读写方式挂接设备
iocharset:指定访问文件系统所用字符集 3、device 要挂接(mount)的设备。
4、dir设备在系统上的挂接点(mount point)。
https://www.linuxprobe.com/mount-detail-parameters.html

  1. Which one of the following files will execute once when you log on
    A. /etc/passwd
    B. /boot/vmlinuz-2.6.9-5.ELsmp
    C. ~/.bash_profile
    D. /etc/shadow

命令题
###################################################

II. Short Answer Questions (3 * 17 = 45 points)

###################################################

  1. Create a alias that you can use command ‘rename’ to rename file names.
    alias rename=mv

  2. You have backgrounded a job called big Certkiller . When you type jobs and the command line it comes back with the following info.
    jobs
    [1] Running job1
    [2] - Running big Certkiller
    [3]+ Stopped job5
    Type the command any switch(es) that would bring big Certkiller to the foreground.
    alias rename=mv

  3. Print all lines where the student’s first name starts with S in /tmp/student_record
    grep ‘^S’ student_record

  4. Create a soft link, called “chuqin”, in your current directory to the file /tmp/class/present.log.
    ln -s ./chuqin /tmp/class/presemt.log

  5. You want a file “/bin/backup” to execute every Friday night at 23:00. Write down the line that you need to add to the crontab file.
    您希望在每周五晚上23:00执行文件binbackup。写下需要添加到crontab文件中的行。

  6. Delete all the blank lines in /tmp/student_record
    sed ‘/1*$’ /student_record

  7. You download the apache web server compressed archive httpd-2.4.3.tar.gz from website apache.org. Type the simplest command with options to unpack httpd-2.4.3.tar.gz.
    gzip -d httpd-2.4.3.tar.gz

  8. sort lines with department as the sort key in ascending order in /tmp/student_record.
    sort -k4 -n student_record

  9. Replace the department name “EECS” with “CS” in /tmp/student_record
    sed ‘s/EECS/CS/’ student_record

  10. Display the number of the child directory in the current directory. Type in the command that would accomplish this.
    ls -l | grep ‘^d’ | wc -l

  11. Write down the command that only show the number(ie. 66) which is the usage percentage of the the file system that root directory mounts on.
    写下只显示数字的命令(即。66),表示根目录挂载的文件系统的使用率。

  12. Change the permission of the file myfile.txt. Assign read, write and execute permission to the file owner, read and execute permission to the group owner, and no permission to everyone else.
    alias rename=mv

  13. Give a command to search files with suffix “.cpp” in your home directory. Store the output of the command in a file called “cpp.txt” in your current directory. If the command fails, the error message is ignored, not output to screen or any files.
    find ~ -name ‘*.cpp’ -print > cpp.txt

  14. Print all lines where the student’s GPA is less than 3 in /tmp/student_record
    grep ‘CS’ student_record | awk ‘$4<3{print $0}’

  15. Print all the student names in CS department, whose GPA is less 3 in /tmp/student_record
    grep ‘CS’ student_record | awk ‘$4<3{print $1,$2}’

  16. Printing all the lines containing “Tom” in /tmp/student_record
    grep ‘Tom’ studnet_record

  17. The file /tmp/class/present.log contains the dates on which each student logins in the lab. Can you find out how many times you login in the lab? The format of the file as follow
    s16188 09-19
    s16190 09-19
    s16193 09-19
    s16229 09-19
    s16230 09-19
    grep ‘s192882’ /tmp/class/present.log | wc -l

脚本题
##################################################

III. Writing shell script ( 4 + 5 = 9 points)

##################################################

  1. Write a script that read a string from keyboard. If n is equal “gdufs”, print “right”, else print “wrong”.
    编写一个从键盘读取字符串的脚本。如果n等于gdufs,打印正确,否则打印错误。
read -p 'input a string: ' a
if [ "$a" = "gdufs" ]
then
   echo "right"
else
   echo "wrong"
fi
  1. Write a script that read a integer from keyboard. If the integer is greater than 100, you are required to input again, until you input the integer less than or equal to 100, then print the message “ok”.
    写一个从键盘读取整数的脚本。如果该整数大于100,则需要再次输入,直到输入小于或等于100的整数,然后输出ok消息。
read -p "input an integer: " a

while [ "$a" -ge "100" ]
do
   read -p "input again:" a
done

echo "ok"
 

  1. \t ↩︎

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值