UNIX/Linux Final Review Exam Questions

foreword

After the exam, let me write some thoughts. I divided it into five big questions. The questions are quite interesting. The front is to describe the facts and make up the story (hhh Zhang Fei and Liu Bei have designed the program together), and then dig a space to let You fill in some commands and keywords for noun explanations. The big questions behind are all from computer experiments and usual code homework, such as judging whether the current user is the main user, returning to the main directory, etc. Personally, I feel that Chaoxing’s multiple-choice questions are not very useful. , it is better to look at the ppt at the end of the term and the experimental code left in the usual time.

1. Multiple choice questions

  1. The PID of the process init is (1)
    There are 3 special processes under Linux, idle process (PID = 0), init process (PID = 1) and kthreadd (PID = 2)

  2. The (sh) command cannot log in to
    the FTP server remotely through the shell. Method 1: Directly input ftp plus ip address ftp 192.168.10.xxx.
    The telnet command is used to log in to a remote host and manage the remote host.
    sftp user@ip - use sftp to log in to the sftp server.
    The sh command is the method command to execute the .sh file under linux

  3. (apropo pwd) Cannot get help information for command pwd.
    apropos: Used for keyword lookup to locate the name and description of a man page. It is equivalent to using the man command with the -k option

  4. The file used to store user passwords is: (/etc/passwd)

  5. The current directory is /dev, execute su -; the result of pwd is (/dev)
    su - refers to switch users, and switch to root by default. If the switch is successful, the current working path will not be changed, but the result of the operation is obviously to enter the password...

  6. The command to get the first logged-in user is (w)
    w——displays the user information currently logged in to the system, including the login time, so you can see who was originally logged in

  • f Turn on or off Show from where users log into the system.
  • h Does not display the header information row for each field.
  • l Use detailed format list, which is the default value.
  • s uses a concise format list, does not display user login time, terminal session jobs and CPU time consumed by programs.
  • u Ignore the name of the executing program and the information about the CPU time consumed by the program.
  • V Displays version information.
[root@card-web03 ~]# w
 17:28:45 up 84 days, 23:32,  1 user,  load average: 0.01, 0.03, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/1    123.115.76.110   17:06    5.00s  0.03s  0.00s w

The meaning of the output results:

  • USER login username
  • TTY login terminal
  • FROM which IP address to log in from
  • LOGIN@ login time
  • IDLE User idle time
  • JCPU refers to the time taken by all processes connected to the terminal. This time does not include
    the time of background jobs in the past, but includes the time taken by currently running background jobs.
  • The time taken by the current process of the PCPU
  • WHAT currently running command
  1. The command to unmount the mounted CD-ROM is (umount /mut/cdrom)
  2. The function of executing the command ls ~ is (display the contents of the current user's home directory)
  3. How can it be done so that the document has implementation authority when it is created (amend the value of umask)
    "umask" authority mask is. Generally, the default umask value is 022, and the final effect is that the newly created directory permission is 755, and the file permission is 644. So as long as the user's umask value is modified, the default permissions can be controlled.
  4. What is the way to hide the file (modify the file name to ".filename")
  5. Which of the following regular expressions can represent any number of arbitrary characters? (*)
  • . : A hard link to the current directory
  • *: match all characters, wildcard
  • ? : any character
  1. You can display the execution result of the previous command: (echo $?)
variable meaning
$0 The filename of the current script
$n Arguments passed to the script or function. n is a number indicating the number of parameters. For example, the first parameter is $1 and the second parameter is $2.
$# The number of arguments passed to the script or function.
$* All parameters passed to the script or function.
$@ All parameters passed to the script or function. When enclosed by double quotation marks (" "), it is slightly different from $*, which will be mentioned below.
$? The exit status of the previous command, or the return value of a function. 0 means no error, other means error.
$$ The current shell process ID. For shell scripts, this is the process ID where the scripts reside.
  1. The command (tar) can realize the compression of the file

  2. (find) has the lowest search efficiency,
    because the find command traverses the hard disk to search, which consumes a lot of hard disk resources, so try not to use find when you can use which, whereis, and locate.
    insert image description here

  3. A reasonable permission setting for the /etc/passwd file should be (644)
    insert image description here
    r=4, w=2, x=1, -=0
    rw-=6
    r–=4
    r–=4
    insert image description here

  4. Which of the following commands can display the usage of the mounted file system space (df)
    The df command is used to report the disk space usage of the file system. To see the type of all mounted filesystems, just run: $ df -T

  5. The command to view the size of the directory file /etc is (du /etc)

  6. Change the operating level of the linux system to (3), and enter the text mode after restarting. Run level 0: The system is in shutdown state. The
    default run level of the system cannot be set to 0, otherwise it cannot be started normally . NFS) run level 3: full multi-user state (with NFS), enter the console command line mode after login run level 4: the system is not used, reserved run level 5: X11 console, enter the graphical GUI mode run level 6 after login : The system shuts down normally and restarts. The default operation level cannot be set to 6, otherwise it cannot be started normally. 3, that is, text mode, 5, that is, graphics mode







  7. To change the shell permanently, you need to use the chsh option (-s)

  8. The directory for storing system management commands is (/sbin)

  9. cat testfile is equivalent to cat < testfile

  10. The command to check if someone else has used my account is (last)

  11. The terminal used for system management is called (console)

  12. The option used to display the process related to the terminal in the ps option is (a), and the process not related to the terminal is (-x)

  13. Desktop environment software: KDE, GNOME, CDE

  14. TWM is not based on any GUI components

  15. The default operating level of linux is (3)

2. Short answer questions

  1. Write the command
    cat file1 file2 > fileall to merge the files file1 and file2 into one file fileall
  2. Write three commands that can achieve shutdown
  • init 0
  • halt
  • shutdown
  1. Write the command
    tar -zcvf /etc.tar.gz ./* to pack all files and directories in the /etc directory into a file etc.tar.gz
  2. Write the difference between internal commands and external commands of the linux system
  • Internal command: part of the shell code, resides in the memory after the shell starts, and executes quickly
  • External command: the program saved in the file system is loaded into the memory for execution when it is called

  1. vi has several working modes, and there are three ways to switch between them , command mode, text editing mode and ex escape mode——
  • Command mode (press iao and its uppercase mode) to enter text editing mode
  • Text editing mode (press Esc) to enter command mode
  • Command mode (press:) to enter ex escape mode
  1. Write a command that looks for a file named bash in the /bin directory
  2. How to determine if the ps command is present in the system? If so, what is its function?
  • Test –e ps
  • The ps command can easily view the processes owned by the user.
  1. Explain the difference between double quotes and single quotes in quoting capabilities
    Double quotes can restore literal meaning to symbols other than $, '', \
    Single quotes are more powerful and can make all characters lose their special meaning and become literal interpretation
  2. Please explain the difference between su -john and su john when using the su command to switch user identities
  • su -john will change account to john and change working directory to john's home directory
  • su john only switches accounts but does not change the work path
  1. There is a subdirectory dira in the current directory, write the command to copy them to the upper-level directory and rename them to dirb (there is no directory named dirb in the upper-level directory before copying)
    cp -r dira …/dirb
  2. Execute echo in the shell , the result is 32687; then execute bash and then execute ' echo, the result is 32687; then execute bash and then execute `echo, the result obtained is 3 2 6 8 7 ; then execute b a s h and then execute ' e c h o echo,所得结果为35781,请问接着执行suspend后再执行 ', what is the result and why? 32687 Because the current process is suspended by the suspend command, so `, what is the result and why? 32687 Because the current process is suspended by the suspend command, so' , what is the result and why ? 3 2 6 8 7Because the current process is suspended by the su s pen d command , the ID number of the previous process is saved
  3. After the user successfully executes alias files=‘ls -l | grep ^-’the statement, the displayed content after executing the files command is:
    ^ # The beginning of the anchor line, such as: '^grep' matches all lines beginning with grep.
    At the same time | indicates that the output of the previous command is used as the input of the next command
    ls -l will display the long information of all files in the current folder
    grep ^- will match all lines starting with -
    and then use the result as the alias of the file files
  4. Knowing that the directory /temp/dir is not empty, write two methods to delete /tem/dir
  • rm -r /temp/dir (delete recursively)
  • rm -f /temp/dir (delete directly)

  1. Write the command find /etc -name "hosts" to find a file named hosts in the /etc directory
  2. How to check whether a command name is an alias?
    #Display all defined alias
    alias
    alias -p

Guess you like

Origin blog.csdn.net/KQwangxi/article/details/122042709