PHP interview four-linux part

Source: Internet
Author: User

PHP surface question four--linux part (advanced part) iv. Linux Section 1. Please explain the use of the following 10 shell commands (Sina Technology Department)

Top, PS, MV, find, DF, Cat, chmod, CHGRP, grep, WC

Top: This command provides real-time monitoring of the state of the system's processor, which shows the resource consumption of each process in the system in real time. This command can be used to sort the system task processes in terms of CPU, memory usage, and execution time, and can also be displayed through interactive commands.
PS: Shows the dynamic of the system process in an instant.
MV: File/directory rename or change storage location.
Find: Finds the specified file under the specified path.
DF: Check disk space usage.
Cat: Prints the contents of the file to standard output.
chmod: Change the permissions of the file.
CHGRP: Change the group to which the file belongs.
grep: Filters the text, searches each line of the file according to the specified string, and outputs the line content, if found.
WC: Counts the number of bytes, words, and lines in the specified file, and displays the output of the statistic results.

Related topics: Write more than 15 commonly used Linux commands and features that you know about.

LS: List directory
CP: Copy
RM: Delete
Cat: Print the contents of a file to standard output
mkdir: Creating a Directory
Tar: Packaging compression
PS: View Process
Top: View Machine usage
DF: Check disk space usage
Find: Finds the specified file under the specified path
grep: Filtering text
CD: Change the current working directory
Mount: Mount/unload the specified file system
Ifconfig: Configuring the network or displaying the current network interface status
Telnet:: Telnet

What are the commands for selecting, copying, pasting, and deleting in the 2.VI editor (Cool News)

Checked: V (in characters), V (in units of behavior)
Copy: Y, such as yy,nyy,y1g,yg,y0,y$
Paste: P (pasted after cursor), p (pasted before cursor)
Delete: D, such as Dd,ndd,d1g,dg,d$,d0

3. Get the number of file lines (Cool News)

wc-l filename

4. Enter the last 5 lines of the file into another file (cool)

Tail-n 5 File1>>file2

5. Find the line that contains hello in the file (Cool News)

grep Hello filename

6. Find all the directories in the current directory named CVS directory (Cool News)

Find./cvs-maxdepth 1-type D-print

7. How to make a program run in the background and direct the input to the specified file (Cool News)

Available commands: Nohup program >> file name 2>&1
Note that the 2>&1 will be placed after the output file name)

8. How to add the contents of one file to the end of another file (Cool News)

Cat File1>>file2

9. How to display the output of a file in real time (Cool News)

Use more or less

10. How to execute a program on a regular basis (cool News)

You can use at or crontab, where at is the command to process the end of the dispatch only once, and the crontab will loop all the time for routine work.

How to replace the specified string in the 11.VI editor (Cool News)

Use the S command, for example:
: n1,n2s/word1/word2/g, replace word1 between line N1 and N2 row with Word2
: 1, $s/word1/word2/g, replace word1 with Word2 from first line to last row

[!] 12. When the CVS document is in conflict with the update. How to tell what you have edited and what you have updated (Cool News)

When using CVS, if a conflict occurs, double-click the conflicting file (identified as red) to display the File comparison window. Where Blue is required for incoming updates, where gray is required for outgoing modifications, where red is a conflict that needs to be resolved manually.
You can first update the blue needs to be passed in, then manually resolve the red part, choose to leave the left or right, and select mark as merge to the file is marked as a merge, the content in the left window will be prompted by the outgoing server, That is, both the gray and red sections are submitted to the server based on the contents of the left window.
If the conflicting file opens without any color hints, you can choose Update and override to use the text on the server
Update the local file.

13.Linux, how to view all users ___

cat/etc/passwd

The Crond service on 14.Linux can set a scheduled task on the server, if I need to set up a script that executes/tmp/test.sh every 2 minutes how to set the scheduled task, write out the action method.
    1. First log in with the root user's permission.
    2. Switch to/etc/init.d/directory, use command: Crond start Crond Service
    3. Switch to the/etc/directory, using the command: crontab–e
    4. Edit as follows:/2***/tmp/test.sh
15. What are the Linux commands that look at disk space utilization? See what system processes are running commands? What commands are used to detect Linux performance (CPU, disk IO, memory, network, etc.)? (Aspire)

command to view disk space usage: DF
View System process commands: Top
Commands for detecting Linux performance: Ps,free,vmstat,netstat

16.Linux terminate a process with what command? Packing compression and unpacking what order? What is the difference between a soft connection and a hard link? What is the command to establish a soft connection? (Aspire)

command to terminate a process: Kill
Package compression and unpacking command: Tar
command to establish a soft connection: ln-s source file Destination link name
A hard link is a file system's inode to produce a new file name, not a new file, it just creates a new filename in a directory to link to an inode number management record, and soft link is to create a separate file that will let the data read to the file it links to the file name, Similar to shortcuts in Windows.

17. Tell me the difference between the Find command and the grep command under Linux

Find: Files found in disk/partition, can be equipped with type can be equipped with a size time, etc., the file name or file size or access times to find the specified files.
grep: Find the strings in the file that match the criteria and print the matching lines, and you can use regular expressions.

18. There is a Mail.log document, which contains several e-mail addresses, which are separated by ' \ n '. Request from

Pick out Sina.com email addresses (including reading from files, filtering to print out).
Mail.log content is as follows:
[Email protected]
[Email protected]
[Email protected]
[Email protected]
[Email protected]
Reference Answer:
cat mail.log|grep sina.com

PHP interview four-linux part

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.