Chapter 4 basic knowledge of advanced programming in UNIX environment

Source: Internet
Author: User

1. switch from the current user to the root user: directly enter the su command, and then enter the root password. If you have not set the root command password before, the login will fail. Here, you need to run the sudo passwd command to set the password, then follow the above input to convert from the root command to a common user: Use the exit command. A problem occurs when using logout. Bash: Logout: not login shell: Use 'exit 'indicates that you are not currently using the login shell. Use the exit command to exit. When you use the root command to log on to a login user, you can use the logout command to exit, which has been verified.

2. chown is used to change the file user ID. The format is as follows: chown root. out means to put. change the user ID of the out file to root. You can set the user ID below. If the user is not root, you can execute the root permission file. chmod changes the file mode, for example, chmod U + s. out consciousness sets the current user permission (u) To add permissions (+) and open the Set User ID (s), when executed, it has the permission of the file owner.

3. CAT has three main functions: 1. display the entire file at a time. $ Cat filename2. create a file from the keyboard. $ Cat> filename; only new files can be created, and existing files cannot be edited. 3. combine several files into a file: $ cat file1 file2> file; warning: we want to know> it means creating,> is appending. Never confuse. Making mistakes is not a joke;

Parameters:
-N or -- number indicates the number of all output rows starting from 1.
-B or -- number-nonblank is similar to-N, but is not numbered for blank rows.
-S or -- Squeeze-blank when there are two consecutive blank rows or more, it is replaced by a blank row
-V or -- show-nonprinting

4. A. Normally, there will be a gap between DF and Du output results.
The Du-s command accumulates the total number of directories, symbolic links, and blocks used by the specified file system;
The DF command displays the block distribution chart of the file system to obtain the total number of blocks and the remaining number.
The file system allocates some disk blocks to record some of its own data, such as I nodes, disk distribution charts, indirect blocks, and super blocks. This data is invisible to most user-level programs, usually referred to as meta data.
The du command is a user-level program that does not consider meta data, while the DF command checks the disk distribution diagram of the file system and considers meta data.
Therefore, the used space calculated by DF is slightly larger than that calculated by Du.
B. In case of exceptions, the used space calculated by DF is much larger than that calculated by Du.
This is also a problem encountered before the Rocket said. df shows that file system 100% is used, while du still has 6 GB of free space, the hardware vendor does not know how to explain the problem. This is why I was curious to come back to check the problem at night.
The reason is that DU is used based on the file name and directory name, while DF is used based on the disk block usage.
When an application is writing a large file, we rm or MV this file (UNIX is allowed to do this, Windows is silly at this point ), the application occupies the handle and writes data directly to the disk based on the disk location indicated by the handle, without checking whether the file is deleted.

DU/etc/| sort-Nr | the more command indicates to display the directory/etc/. when viewing the usage of the directory, the sort parameter-Nr indicates to reverse sort by numerical sorting, because we want to sort the directory size, we cannot use the output of the human-readable size. Otherwise, the directory size contains the words K and M, which may lead to incorrect sorting.

5. In man's case, many commands are followed by parentheses, which are numbers. What does this mean?

1. commands or executable files that can be operated by users
2. Functions and tools that can be called by the system core
3. Some common functions and function libraries
4. Description of Device Files
5. Set the format of a file or some files
6. Games
7. Conventions and protocols, such as Linux standard file systems, network protocols, and ASCII codes
8. management commands available to the system administrator
9. kernel-Related Files

6. Environment Variables

Path = DF/DF; $ indicates the process ID; echo $ shell: prints the current shell and runs the command line interface program.

7. tty

Tty devices include virtual consoles, serial ports, and Pseudo Terminal devices. Tty is also a Unix Command Used to give the name of the current terminal device.

A terminal is a type of terminal device. It has multiple types and generally uses tty for short.

 

Chapter 4 basic knowledge of advanced programming in UNIX environment

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.