Interview written---linux knowledge point __linux

Source: Internet
Author: User
Tags chmod disk usage file permissions ide hard drive

Linux is an open source, free operating system, its stability, security, processing concurrency has been recognized by the industry, many medium-sized, large and even mega-projects are using Linux. Linux kernel: redhat, Red Flag Linux, Ubuntu, SuSE, Fedora, their core is the same (Note:linux is actually a general term, such as noodles is a general term, you can have a whistle surface, noodle, dozen halogen noodles, etc.)

Features of Linux
-Free/Open source
-Multithreading/multiuser support
-Good security
-Superior to memory and file management

shutdown Command
Shutdown-h now (shutdown immediately) Shutdown-r Now (restart your computer) reboot (restart your computer)

go to Desktop
StartX

User Login
Log in as little as possible with the root account login, because it is the system administrator, the greatest authority, unavoidable operation error. You can log on as a normal user, and then use the "Su-" command to switch to system administrator status

User Logoff
Enter the logout at the prompt

VIEditor is the most famous editor of Linux, but also we learn Linux must master tools, Linux can also use VI for the development of programs, such as Java programs, C programs. Input I, enter into insert mode; Enter the ESC key and enter the command mode; Enter a colon: Wq to exit Save: q! means to exit without saving


Linux file system is a hierarchical tree-like directory structure, the topmost layer in this structure isroot directory "/", and then create additional directories under this directory, and it is very important to understand the Linux file directory deeply.

- /
-Root, store root user related files
-Home, storing files for ordinary users
-Bin, a directory where common commands are stored, such as Vi,su
-Sbin, you must have certain permissions to use the command
-MNT, default mounting directory of optical drive and floppy drive
-etc, storage of configuration related files
-Var, storing frequently changing files, such as sock files for network connections
-Boot, storing related files for boot system boot
-usr, install a default directory of software, equivalent to Windows program files

Introduction to Common commands
pwdThat shows which path is currently under

User Management for Linux

useradd user name, adding user
"Case" Useradd xiaoming

passwd user name, set password for new user
"Case" passwd xiaoming, change Xiao Ming's password

Userdel user name, delete user
"Case" Userdel xiaoming, delete user but save user home directory
"Case" userdel‐xiaoming, delete user and user home directory

logout, current user launches
Who am Iand who is the current user

CDs, changing directories
ls, listing files and directories
Ls‐a, displaying all files in the directory, including hidden files
ls‐l, displaying long column table style
mkdir, create a directory
rmdir, delete empty directory
Touch, create an empty file

cp, copy command
"Case" Cp‐r dir1 dir2, recursive replication command (copy subdirectory information)

mv, moving files and changing file names
rm, deleting files and directories
RM‐RF *, delete all contents, include Directories and files, R indicates recursion, F indicates coercion
Ln, a symbolic connection, similar to creating a shortcut to a file

ln‐s Source target
"Case" Ln‐s/etc/inittab Inittab,inittab point to the actual file/etc/inittab Inittab

More, show the contents of the file with pagination, CTRL + PAGE UP turn, Sky grid down
less, displaying file content with pagination

grep, querying content in text
"Case" assumes that there is a Hanyang keyword in a file Test.java, you can use the grep name command to find it, grep n "Hanyang" test.java,n to appear on the nth line

|, Pipeline command, in Linux and UNIX systems, give the results of the previous command to the following command processing
"Case" ls‐l/etc/| More

-Man [command], assistance, similar to help in DOS

-Find, search for files and directories. In Linux, because file systems are made up of hierarchical structures, it is not easy to find specific files and directories throughout the system. and the "Find" command solves the problem.

- searches for and displays files and directories with the specified name in a specific directory
"Case" found/-name man: means to search for a file or directory that has a name of man from the root directory
-Search for files or directories that have been accessed/changed over a period of time
"Case" find/home-amin-10: Files or directories accessed within 10 minutes
"Case" find/home-atime-10: Files or directories accessed within 10 hours
"Case" find/home-cmin-10: Files or directories that have changed in 10 minutes
"Case" Find/home-ctime + 10: A file or directory that was changed 10 hours ago


- search for files of a specified size
"Case" find/home-size +10k: means to find files with a size of 10k in the/home directory


-redirect command
-Ls-l > A.txt, the contents of the list are written to the file A.txt (overwrite write)
-Ls-al >> Aa.txt, the contents of the list are appended to the end of the file Aa.txt
-Enter information from the file: Database_program < Database_data
-EN, view environment variables


-Compression and decompression
-process. zip files in zip and unzip
-Basic usage of zip command
-Zip File.zip *:zip after the compressed file name, then enter the text to compress after it
Pieces can be
-Automatically delete the original file after compression
"Case" Zip m file.zip to.txt: Compress to.txt file into File.zip file, To.txt automatically delete
-Compress subdirectories together
"Case" zip‐r file.zip *: Compressing subdirectories in the current directory
-Ignore the contents of subdirectories
"Case" zip‐j file.zip *
-Remove compressed or unnecessarily compressed files
"Cases" zip‐n. mpg:. jpg:. gif: The first file should be separated by ":" In the middle.
-Compress files after one day
"Case" Zip‐t 102002 file.zip: File compression after October 20, 2002 in the current directory
-Do not compress the original file of the linked file
"Case" Zip‐y file.zip *
-Compression rate problem, -1~-9, of which-9 of the highest compression rate
"Case" zip-9 file.zip *
-Exclude files that do not need to be compressed
Case Zip File.zip *-x file2.txt: Exclude file2.txt files from the current directory when compacting
-Unzip the. zip file with the unzip command
-Extract files directly
"Case" unzip File.zip
-Exclude files that do not need to be decompressed
"Case" unzip file.zip‐x File2: Other files are uncompressed except file2 files
-View the contents of the compressed package
Case Unzip‐z File.zip: View the contents of a File.zip package, or use "-l" "V" to view the contents of a compressed package
-processing. gz files with gzip and gunzip



Each user in Linux must belong to a group and not be independent of the group. In Linux, each file hasowner, group, other groupThe concept.
1 Owner: Typically the creator of the file, who creates the file, becomes the owner of the file naturally. You can see the owner of the file with the Ls‐ahl command. You can also modify the owner of a file by using the Chown username file name.
2 File group: When a user creates a file, the group that contains the file is the group that the user is in, the Ls‐ahl command can see all of the files ' groups, or you can use the CHGRP group name file name to modify the group where the file resides.
3 other groups: except the owner of the file and the users of the group, other users of the system are other groups of files.


file Permissions
The contents of the ls-l are shown below:
-rwxrw-r‐-1 root root 1213 Feb 2 09:39 ABC

-10 characters to determine what different users can do with a file
-the first character represents a file (-), a table of contents (d), a link (l)
-Each of the remaining characters is set (RWX), read (R), write (W), execute (x)
-The first group of rwx: The permissions of the owner of the file are read, write, and execute
-The second group of rw-: the permissions of the same group of users as the file owner are read, write, but not executed
-Third group r--: the permissions of other users who are not in the same group as the file owner are read and write-unable and executed
The number can also be expressed as: R=4,w=2,x=1 so rwx=4+2+1=7

-1 indicates the number of files connected
-Root indicates that the user
-Root indicates the group where the user is located
-1213 indicates file size (bytes)
-Feb 2 09:39 indicates the date of last modification
-ABC indicates file name

commands to change permissions
chmod change permissions on files or directories
chmod 755 ABC: Assigning ABC permissions Rwxr-xr-x
chmod U=RWX,G=RX,O=RX ABC: IBID. u= user Rights, g= group permissions, o= different groups of other user rights
chmod u-x,g+w ABC: To remove the permissions that the user performs for ABC, and to increase the group write permissions
chmod a+r ABC: Add read permissions to all users

Change owner (chown) and user Group (CHGRP) commands
Chown xiaoming ABC: Change the owner of ABC to Xiaoming
CHGRP Root ABC: Change the group that ABC belongs to root
Chown root/ABC: Change ABC the owner of this directory is root
Chown‐r root/abc: Changes to ABC this directory and all of the files and directories under it are owned by root

change user Group
When adding a user, you can specify which group to add the user to, as well as the admin rights of ROOT to change a
The group where the user is located
-USERMOD‐G Group name User name
You can change the initial directory of the user login by using the-usermod‐d directory name

Linux Partition detailed
The partitions of the hard disk are mainly divided into basic partitions (Primary portion) and extended partitions (Extension portion). For a single hard drive, the number of basic partitions and extended partitions cannot be greater than 4, and basic partitions can be used immediately but not partitioned. The extended partition must be partitioned again before it can be used, meaning it must be partitioned two times. So what's the point of having an extended partition? It is the logical partition (Logical portion), and the logical partition is not limited in number

For Windows users, several partitions have several drives, and each partition gets an alphabetic identifier, which can then be used to specify the files and directories on the partition. Their file structure is independent and very well understood. But for these users to start Redhat Linux, but a bit annoying. Because ofRedhat Linux users, regardless of a few partitions, to which directory to use, it ultimately has only a root directory, a separate and unique file structure。 Each partition in Redhat Linux is used to make up the entire file system. because itA processing method called "loading" is adopted., its entire file system contains a complete set of files and directories, and links a partition to a directory. The partition to be loaded will make its storage available in this directory.

Several important commands
mount Command
Mount [-parameters] [device name] [Mount Point]
Uninstall Command
Umount [Mount Point]
View disk usage
DF [-parameters]
-Df-h
-Df‐l
-DF [Directory full path] to see which partition a directory is in

View Linux system partition specifics
Fdisk‐l

Shell Programming
In fact, the interactive interpretation and execution of user input commands as an imperative language is only one aspect of shell functionality. The shell can also be used for programming. It provides a means to define variables and parameters and a rich program control structure. Using shell programming resembles a batch file in DOS, called shell script, or shell program or shell command file.

Shell script file:
-is a text file
-A collection of commands
-Have permission to execute
-Mode of execution (./filename)

Export can be temporarily added to a system path, such as Export path= $PATH: $HOME/bin:/root/test/t1, output environment path, referencing the original value $path, $HOME represents the work home directory,: is the path separator


Shell wildcard characters
-* Representing multiple letters or numbers
Represents a letter or a number
"Case" ls * ls a? LS f080[1-6].tif


-Escape character \
"Case" ls/mnt/win1/my\documents

-Single quotation mark: Do not process any variables and commands
"Case" Echo ' Welcome $NAME, the date is date '

-double quotes: Handling variables but not processing commands
"Case" echo "Welcome $NAME, the date is date"

-Inverted quotation marks: use each word in quotation marks as a command, and if it is a variable, evaluate it first and then treat it as a command
"Case" Echo Welcome $NAME, the date is ' date '


Review history
-History, view history of used commands
-History 5, this description shows the last 5 commands used
-! 5, this description executes the command with history number 5

-!ls, this note executes the last command that starts with "LS"


Test topic:

One, the choice question

1.cron Background Resident Program (daemon) for:
A. Responsible for the sharing of files in the network
B. Managing the print subsystem
C. Tracking management System Information and errors
D. Scheduling of day-to-day tasks of the management system

2. In most Linux distributions, which of the following belongs to the block devices.
A. Serial port
B. Hard disk
C. Virtual Terminals
D. Printers

3. Which of the following Linux commands can display one page at a time.
A. Pause
B. Cat
C. More
D. grep

4. How to find out how much space you have in the current directory.
A. Use DF
B. Use du/
C. Use Du.
D. Use DF.

5. How to change the permission settings for a file.
A. attrib
B. chmod
C. Change
D. File

6. If you need to find out which package (package) The/etc/my.conf file belongs to, you can perform:
A. Rpm-q/etc/my.conf
B. rpm-requires/etc/my.conf
C. rpm-qf/etc/my.conf
D. Rpm-q | Grep/etc/my.conf

7. If the current system is running at level 3, you can switch to level 5 to run without rebooting the system.
A. Set level = 5
B. Telinit 5
C. Run 5
D. alt-f7-5

8. The command is used to change the IDE hard drive settings.
A. Hdparam
B. Ideconfig
C. hdparm
D. Hddparm

9. Which of the following commands lists all tasks that are defined to run at a later specific time.
A. ATQ
B. Cron
C. Batch
D. At

10. The function of the following command is: Set ps1= "[\u\w\t]\\$"; Export PS1
A. Change the error message prompt
B. Change the command prompt
C. Change some terminal parameters
D. Change the secondary command prompt

11. As an administrator, you want to delegate a file to each new user's directory. BASHRC, then which directory should you decentralize the file so that the new user can automatically copy the file to their own directory when they create the home directory.
A./etc/skel/
B./etc/default/
C./etc/defaults/
D./etc/profile.d/

12. In bash, the role of the Export command is:
A. Running commands in a child shell
B. Enabling command history to be used in a child shell
C. Setting environment variables for other applications
D. Providing NFS partitions to other systems in the network

13. In systems using the shadow password, the permissions of the/etc/passwd and/etc/shadow two files are correct:
A.-rw-r-----,-R--------
B.-rw-r--r--,-r--r--r--
C.-rw-r--r--,-R--------
D.-rw-r--rw-, R------r--

14. Which of the following parameters can delete a user and delete the user's home directory at the same time.
A. Rmuser-r
B. Deluser-r
C. Userdel-r
D. Usermgr-r

15. There is a backup program mybackup that needs to be run from Monday to Friday 1 o'clock in the afternoon and 8 o'clock each time, and which of the following crontab will do the work.
A. 0 13,20 * * 1,5 MyBackup
B. 0 13,20 * * 1,2,3,4,5 MyBackup
C. * 13,20 * * 1,2,3,4,5 MyBackup
D. 0 13,20 1,5 * * mybackup

16. How to uninstall a mounted file system from the current system
A. Umount
B. Dismount
C. Mount-u
D. Remove this filesystem entry from/etc/fstab

17. If your umask is set to 022, the default permissions for the file you create are:
A.----w--w-
B.-w--w----
C. R-xr-x---
D. rw-r--r--

18. How to find the path of a binary command xconfigurator in a single command.
A. Apropos Xconfigurator
B. Find Xconfigurator
C. Where Xconfigurator
D. Which xconfigurator

19. Which command is used to load all the file systems defined in/etc/fstab.
A. Amount
B. mount-a
C. Fmount
D. mount-f

20. Run a script, the user does not need what permissions.
A. Read
B. Write
C. Execute
D. Browse on the directory

21. In Linux, how to identify the 2nd extended partition of the slave hard disk that is connected to the IDE0.
A./dev/hdb2
B./dev/hd1b2
C./dev/hdb6
D./dev/hd1b6

22. How to prioritize the process when the application is starting.
A. Priority
B. Nice
C. Renice
D. Setpri

23. In bash, adding "1>&2" after one command means:
A. Standard error output redirection to standard input
B. Standard input Redirect to standard error output
C. Standard output redirection to standard error output
D. Standard output Redirect to standard input

24. Which of the following commands can replicate F1.txt as f2.txt?
A. CP F1.txt | F2.txt
B. Cat F1.txt | F2.txt
C. Cat F1.txt > F2.txt
D. Copy F1.txt | F2.txt

25. The command to display the last few lines of a file is:
A. TAC
B. Tail
C. Rear
D. Last

26. How to quickly switch to the user John's home directory.
A. CD @John
B. CD #John
C. CD &john
D. CD ~john
 

27. To convert all characters in a stream to uppercase letters, you can use which of the following commands.
A. TR A-Z
B. Tac-Z-A-Z
C. sed/a-z/a-z
D. Sed--toupper
 

28. Use what commands to view Linux startup information.
A. mesg-d
B. DMESG
C. CAT/ETC/MESG
D. CAT/VAR/MESG

29. Run level definition in:
A. In the kernel
B. In/etc/inittab
C. In/etc/runlevels
D. Using the RL command

30. How to mount all the file systems defined in the/etc/fstab file (Mount).
A. mount-a
B. mount/mnt/*
C. Mount
D. Mount/etc/fstab

31. Using the LN command will generate a symbolic link new to the old file, and if you delete the old file, you will be able to access the data in the file.
A. Impossible to visit again
B. Still have access
C. Access depends on the owner of the file
D. Access depends on the permissions of the file

32.XT2FS file system, the default is how much space is reserved for root users.
A. 3%
B. 5%
C. 10%
D. 15%

33. Which command is used to display the usage of the inode in each partition of the system.
A. df-i
B. df-h
C. Free-b
D. Du-a-C/
 

34. In most Linux distributions, the run-time level of the graphical approach is defined as.
A. 1
B. 2
C. 3
D. 5

35. Find all instructions in the system documentation about the word print.
A. Man Print
B. which print
C. Locate Print
D. Apropos Print

36.man 5 passwd meaning is.
A. Show how to use the passwd command
B. Displaying the structure of the passwd file
C. The first five elements showing the description of the passwd command
D. Display the first five description documents about passwd.

37. How to find all rows that begin with "*" in the file.
A. Find \* File
B. wc-l * < file
C. grep-n * File
D. grep ' ^\* ' file

38. What parameters in the PS command are used to display the process of all users.
A. A
B. b
C. u
D. x

39. The command to display binary files is.
A. OD
B. Vil
C. View
D. Binview

40. How to display the number of users registered on the Linux system (including system users).
A. account-l
B. NL/ETC/PASSWD |head
C. WC--users/etc/passwd
D. WC--lines/etc/passwd

41. At the end of a line to add what symbol, indicating that the next line continues.
A./
B. \
C.;
D. |

42. The meaning of command kill 9 is:
A. Kills the process whose PID is 9.
B. Kills all processes belonging to UID 9.
C. Sends SIGKILL to the process whose PID is 9.
D. Sends sigterm to the process whose PID is 9.

43. How to delete a non-empty non-empty directory/tmp.
A. del/tmp/*
B. rm-rf/tmp
C. rm-ra/tmp/*
D. rm-rf/tmp/*

44. What commands can be used to run command cmd1 at midnight today.
A. At midnight CMD1
B. Cron-at "00:00" cmd1
C. Batch-t "00:00" < cmd1
D. Echo "CMD1" | At midnight

45. Your system uses an incremental backup strategy, and when you need to restore the system, you need to restore the backup data in what order.
A. Last full backup, then incremental backup from earliest to most recent
B. Last full backup, then from the most recent to the earliest incremental backup
C. The earliest to the most recent incremental backup, and then the last full backup
D. Most recent to the earliest incremental backup, and then the last full backup

46. The variable settings for all users should be placed under which file.
A./ETC/BASHRC
B./etc/profile
C. ~/.bash_profile
D./ETC/SKEL/.BASHRC

In 47.Linux system, the command LS is generally defined as the alias of LS--color so as to identify different types of files in different colors. However, how to use the original LS command.
A. \ls
B.; ls
C. LS $$
D. LS--noalias

48. What does a script file in a Linux system begin with?
A. $/bin/sh
B. #!/bin/sh
C. use/bin/sh
D. Set Shell=/bin/sh

49. Which of the following expressions indicates that the CMD2 command is executed if CMD1 successfully executed.
A. cmd1&&cmd2
B. cmd1|cmd2
C. cmd1;cmd2
D. cmd1| | Cmd2

50. In which file, define the I/O address of the NIC.
A. cat /proc/modules
b. cat /proc/devices
c. cat /proc/ioports
D. &NBSP;CAT&NBSP;/IO/DMA

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.