Basic knowledge of Linux personal summary

Source: Internet
Author: User
Tags bz2 php website tidy inode usage

Basic knowledge of Linux personal summary

The first chapter:

1. Linux development, Representative Linux distributions: Suse, Slackware, Ubuntu, RedHat, CentOS


2. GNU was a free software campaign launched by Richard Stallman in 1983 with the goal of creating a completely free operating system that required us to be free to use, freely change, free to release software, and the GPL to provide a free agreement.


3. Vim, emacs, GCC, etc.

4. Slightly


Chapter II


1. Our so-called 32-bit, 64-bit refers to the data width of the CPU GPRS (general-purpose registers, universal Register). A 64-bit CPU can perform a larger range of integer operations than 32 bits, and can support larger memory. It is not possible to simply assume that the performance of a 64bit processor is twice times the performance of a 32bit processor because of a digital change. In fact, in 32bit applications, 32bit processor performance even stronger, even the 64bit processor, the current situation is also under the 32bit application performance is stronger.


and the operating system is also differentiated 32-bit and 64-bit, the current mainstream computer hardware is mostly 64-bit CPU, so all support the installation of 64-bit operating system, of course, install 32-bit operating system is also possible, as for the installation of 32-bit or 64-bit system mainly to see how much our computer memory, If you install 64-bit more than 4G, it would be better to install 32-bit instead.


To see if the system is 32-bit or 64-bit use command uname-a if the display has x86_64 is a 64-bit system, and the display i386,i586 or i686 is a 32-bit system.


2. The swap partition, which is the virtual memory under Windows, is primarily used when the system is running out of memory, or when it is almost exhausted, and the older data inside the memory is temporarily put into swap so that some of the memory allocated to other programs can be freed up. Generally when we install the system, we have to divide a portion of disk space to swap, usually we divide the memory size of twice times to swap, but sometimes your server has a large amount of memory such as 32G or even 64G, then there is no need to divide the size of twice times to swap, because that is too wasteful. My suggestion is that when the memory is not 8G, the memory is twice times, if more than 8G can be divided into 16G.


3. Grub is a boot loader based on the gun, which is a multi-OS manager that is used to boot different systems. Grub can manage Windows systems and can also manage Linux systems.


4. Before partitioning, there is an option "encryption system" in the lower left corner, and if checked, set the grub password.


5. Slightly



Chapter III


1. sshd listens to 22 ports by default, this port we can customize the change, change the/etc/ssh/sshd_config configuration file, port 22 to port 1122, then sshd will listen to the 1122 port.


2. PuTTY, SECURECRT, Xshell, etc.


3. Need to modify/etc/sysconfig/network-scripts/ifcfg-eth0, generally need to modify ipaddr, NETMASK, GATEWAY, DNS1, DNS2


4. Service network restart or/etc/init.d/network restart


5. Temporary shutdown Selinux:setenforce 0 The method of permanently closing SELinux is: Vim/etc/selinux/config Open this configuration file, so that: selinux=disabled


6. See how many NICs you can use Ifconfig-a to view network card IP usage ifconfig


7. Logging in to a Linux system with a key is more secure than a password.


Fourth Chapter


1. Rmdir-p cannot delete the non-empty directory successfully, rmdir-p error when deleting a nonexistent directory, prompting "no file or directory"


2. The direct return will not be deleted if the input is not ' y ' nor ' n ' will not be deleted


3. Mkdir-p/HOME/1/2/3/4


4. You will be prompted if you want to overwrite the file


5. There was a total of 4 ' root ', press N to move down one line and press N to move up.


6. Because read a directory, can be said to open the directory, and then to view the file inside, this open process is to execute this directory, so must have the Execute permission to read the file inside.


7. The formula for calculating default permissions through Umask is:


1) directory (RWXRWXRWX)-(umask) = (directory permission), in this case umask=001= (--------x), so the permissions of the directory is (RWXRWXRWX)-(--------x) = (rwxrwxrw-) =776


2) file (rw-rw-rw-)-(umask) = (file permission), in this case umask=001= (--------x), so the permission of the file is (rw-rw-rw-)-(--------x) = (rw-rw-rw-) =666


So it concludes that when Umask is 001, directory permissions are 776 and file permissions are 666


8. find/var/-type f-mtime-1


find/root/-type f-mmin-60


9. find/etc/-type F! -mtime-365


10. Because there will be one in each directory. and. In other words, each directory below the subdirectory will certainly have itself and its first level of directory, then once the hard link is set to create a confusion, the settings will lead to a dead loop. A hard-linked file does not take up space, it only copies the inode information for the file, and hard-linked files cannot be created across partitions.


11. Common Files and binary files-to indicate that the directory with D, the link file (should be said to be soft connection) with L, block equipment with B, the socket with S, the serial port device is denoted by C.


Chown-r user1:users Dira


13. Default directory permissions are 755, document permissions are 644, directory default permissions = (rwxrwxrwx)-(umask), file default permissions = (rw-rw-rw-)-(umask)


chmod-DIRB


Chattr +a file so that files can only be written and cannot be deleted


Chattr +i file makes it impossible to delete, rename, link, write, add data


16. A point represents the current directory, and two points represent the parent directory.


• CD-Represents the last directory you have entered


18. The second column value indicates that there are several files using the same inode, if a directory of this column is 3, we can get it by using Ls-al dir/|grep ' ^d ' |wc-l this command


19. There is no locate command, need to install Mlocate package, yum install-y mlocate, first use error, because the corresponding database file has not been generated, the manually generated command is: updatedb


20. Copy using/BIN/CP:/BIN/CP a.txt b.txt


. tail-f file


chmod used to change file permissions, find./-type F |xargs chmod 644


. Echo $HOME


chmod o+wt dir


25. Soft connection can be understood as a shortcut to the source file, the soft connection file record is the path of the source file, occupies very small space. When the source file is deleted, then the soft connection file becomes a bad file and cannot be used.


Hard link and source file inode information is exactly the same, you can say that the hard-link file just copied a copy of the source file inode information, in our opinion, hard-link files and source files No difference, delete any one file is not affected by the other, the only one is missing an inode, Hard links can only be created under the same partition, and soft connections are unrestricted. Hard-link files and source files may look like two files, but only occupy one file of disk space.


Cat modifies Atime, chmod changes CTime, vim changes atime,ctime,mtime, and touch changes three times.


Fifth Chapter



1. Look at the number in the third field (delimited by ': ') of the root account in the first line of the configuration file/etc/shadow, please figure out how this number came from?


The number of days between January 1, 1970 and the last time the password was changed. For example, the root password date change time is Sunday, September 1, 2013, then the third field of root in profile/etc/shadow is 15949, which is calculated as follows:


15949 = (2013-1970) *365+mod ((2013-1970)/4) + (5*31+2*30+28) +1=15695+10+241+1=15949



2. Write a password that you think is tough.


2zbzhsi4#?fega8


3. Check the information to understand the difference between/sbin/nologin and/bin/false, do you know what occasion they use?


/sbin/nologin not allow account login, but can be used in the FTP account, that is, the FTP account even if the setting of the item can also be logged in via FTP


/bin/false strictly prohibit user login system, prohibit the use of all services


4. Think about how many files will be modified when we create a new account?

/etc/passwd

/etc/shadow

/etc/group

/etc/gshadow


5. If we have created a normal user User1, the default user's home directory for/home/user1, do experimental proof can directly modify the/etc/passwd configuration file User1 home directory that field and change User1 home directory? (Hint: You can use the "CD ~" command to enter the current user home directory to verify the method)

[Email protected] ~]# Useradd user1

[[email protected] ~]# grep user1/etc/passwd

User1:x:502:503::/home/user1:/bin/bash

[Email protected] ~]# sed-i ' s#/home/user1#/tmp# '/etc/passwd

[[email protected] ~]# grep user1/etc/passwd

User1:x:502:503::/tmp:/bin/bash

[Email protected] ~]# Su-user1

-bash-3.2$ Echo $HOME

/tmp

-bash-3.2$ CD

-bash-3.2$ pwd

/tmp

Prove that you can change the user's home directory by changing the/etc/passwd


6./etc/passwd file with ":" As a delimiter, what does the third and fourth fields mean? What happens if I change the third field in a row to ' 0 '?

The third one represents the user ID, the fourth is the group ID, and if the third field is changed to 0, the user becomes root


7. Add a new group GROUP11, and then add an account user12, so that the account belongs to the group is just new.

Groupadd group11; Useradd-g GROUP11 User12


8. If you delete a group The Times is wrong: "Cannot remove the primary group of user ' aming '" What does this mean? How to solve the problem?

This is because there are users in the deleted group, you need to delete the account in the group, and then delete the group


9. How do I delete an account with the home directory of the account?

Userdel-r username


10. If your Linux does not have a command "MKPASSWD", which package do you need to install?

Yum Install-y expect



11. Can I change my password for a normal account?

can modify


12. What does it mean when you use SU with '-' appended to it?

Plus-Indicates that when a user is switched, all user environment variables for that user, such as $home, are used, $BASH


What is the role of sudo?

Using sudo allows the normal account to temporarily have root privileges without knowing the root password, for increased security


14. When creating the system account, what is the account name to conform to?

can be uppercase and lowercase letters, numbers, minus signs (not appearing in the first place), dots, and underscores, other characters are illegal. Although the user name can appear in the point, but not recommended, especially the first point, the other minus is also not recommended, because it is easy to cause confusion.


In the Linux system, do you know how big the maximum UID can be? What is the minimum UID for creating a normal account by default?

The average user has a maximum uid of 65535, and the current Linux core (version 2.6.x) can support up to 4294967295 (2^32-1). The default normal account has a minimum UID of 500


16. Consider if a user can belong to more than one user group at a time? If so, how do you add a user to another group? How do I join multiple groups at once?

Can belong to multiple user groups at the same time, usermod-g GROUP1,GROUP2,GROUP3 username


Sixth chapter

1. Please check the information to understand these terms:/dev/hda,/dev/hdb,/DEV/SDA,/dev/sdb, what is the difference between them?

/dev/hda,/dev/hdb is a block file for the IDE interface hard disk. /dev/hda represents the first IDE disk, and/DEV/HDB represents the second IDE disk.

/DEV/SDA,/dev/sdb is a block file for the SCSI interface hard disk. /DEV/SDA represents the first SCSI disk, and/DEV/SDB represents the second SCSI disk.


2. Why are the results of du-b/etc/passwd and du-k/etc/passwd inconsistent? According to the truth 1024b equals 1k Amin/etc/passwd 1181b and use K to indicate that it is 4k.

Because the block size of the default format disk is 4096 bytes or 4K, even a small file will have a block size of 4k. The du-b will be counted in B units of the file size, so the results are inconsistent.


3. Please check the information to understand these concepts of disk: Heads, sectors, cylinders.

Head (heads): The head is fixed on a movable manipulator for reading and writing data. Modern hard drives are both read and write, so the number of heads is equal to twice times the number of discs. The maximum number of heads is 255 (8 bits). The first magnetic head can be used to indicate which surface the data is on.

Sector (sectors): Draws a straight line from the center of the disk, dividing the track into several arcs. An arc segment on each track is called a sector. A sector is the smallest constituent unit of a hard disk, usually 512 bytes. The maximum number of sectors on a track is 63 (6 bits).

Cylinder (cylinders): concentric tracks of the same radius in all the magnets form "cylinders". The maximum number of cylinders is 1023 (10 bits). A cylinder is the smallest unit of a disk partition.



4. How big is each cylinder space when calculating the partition? The second disk of Amin is 8589 MB (8589934592 bytes) with a total of 1044 cylinders.


Cylinder Space size = number of heads * Number of sectors per track * Sector size =255*63*512 (bytes) =8225280 bytes


5. Find out what the IDE and SCSI interface disks are different, how many logical partitions can the SCSI disk (SDA, SDB) divide (this understanding)?


SCSI hard disk and ordinary IDE hard disk compared with a lot of advantages: fast interface, and because mainly for the server, so the performance of the hard disk itself is relatively high, hard disk speed, cache capacity, CPU occupancy is low, the scalability is much better than the IDE hard disk, and support hot Plug and unplug.


For a question about how many logical partitions can be divided, understand.


6. What happens if the specified block size is not 1024 2048 4096 when the disk is formatted as a EXT4 file system? What is the minimum size of the specified block and what is the maximum?


When you format the file system, if you specify a block size that is not a standard value of 1024, 2048, 4096, there are several things that can happen:

(1) When the specified block is less than 1024, the error "Invalid block size" is indicated and cannot be formatted.

(2) When the specified block is greater than 1024 and less than 2048, it is actually formatted with a block size of 1024.

(3) When the specified block is greater than 2048 and less than 4096, it is actually formatted with a block size of 2048.

(4) When the specified block is greater than 4096 and less than or equal to 65536, the prompt block value is too large, whether to continue, select Y to continue, the value is not greater than the specified block of 4K integer multiples (from 4K to 32K) to format.

(5) When the specified block is greater than or equal to 65536, the prompt block value is too large, whether to continue, select Y to continue, then the format of 65536 bytes.

(6) When the specified block is greater than 65536, the error "Invalid block size" is indicated and cannot be formatted.


7. How do I see what type of file system each partition is in the current system?


Mount or Df-t


8. What are the/dev/zero and/dev/null files in the Linux system and what are the roles?


/dev/zero is a built-in 0, it can provide a steady stream of 0, it can be used to write to the device or file string 0, you can use it to create a specified length for initialization of the empty file, such as temporary swap files.


/dev/null It is an empty device, also called a bit bucket, any output written to it will be discarded. Commonly used to suppress output of standard output and standard errors. If you do not want the message to display or write to the file in standard output, you can redirect the message to the bin.


9. What is the main use of DF and du two commands under Linux?


DF View disk partition and file system Information


Du view the size of the disk space occupied by the directory or file


10. Under the Linux system, what is the command to partition a new disk? And what commands are you using to format the disk?


FDISK is a new disk partition, and you can format the disk with commands such as MKFS.EXT2, Mkfs.ext3, MKFS.EXT4, MKE2FS, and so on.


11. What command do we need to use to get the relevant error message if we cannot mount the disk using mount?

Dmesg


12. When uninstalling a disk or partition, error: "Umount:/newdir:device is busy." How do we do that?

Report this error, probably because the current user in the/newdir directory, you can exit this directory, you can also use the command umount-l/newdir


13. How do I get the uuid of a partition?

Blkid


14. How do I use the DD command to generate a file of size 500M?

DD If=/dev/zero of=/bigfile bs=1024k count=500


15. What is the command to view memory size? How do I display it in m units?

Free-m


16. How can I view the number of Inode usage for each file system?

Df-i


17. Use the VMware virtual machine to allocate a 1G virtual disk and use the Fdisk partitioning tool to divide the newly added disk into 3 primary partitions, 200M and then 3 logical partitions, respectively 100M.

Fdisk/dev/sdb Enter, first press N, press p, enter 1, then enter 1, and then enter the +200m; press N, press p, enter 2, then enter, and then input +200m; press N, press p, enter 3, then enter, type +200m, press N, press E, then press two to enter; Press N, then enter, input +100m; Press N, then enter, input +100m, press N, then enter, input +100m;


18. When partitioning the disk, the maximum number of primary partitions can be divided into several extended partitions, the expansion of the relationship between partition and logical partition what?

Up to 4 primary partitions, up to one extended partition, can be partitioned within an extended partition only after an extended partition has been partitioned, meaning that the logical partition is within the extended partition.


19. When I use Fdisk-l/dev/sdb to view disk partition status, I find that there are several partitions: SDB1, SDB3, SDB5, SDB6, sdb7, so please figure out how many primary partitions and several logical partitions there are in this disk?

One primary partition, three logical partitions (SDB5,SDB6,SDB7)


20. What is the method to see how much block size (1024,2048,4096) is specified when a partition is formatted?

There are two ways of doing this:

The first one is a stupid method, touch 1; echo 1 > 1; Du-sh 1 Look at the size of 1 K, is 1k block size is 1024,2k block size is 2048,4k block size is 4096

The second method is that tune2fs-l/dev/sda1 |grep ' Block size '


Seventh Chapter

1. What is the difference between VI and VIM, and what is the relationship between them?

Vim is a text editor developed from VI and can be viewed as an upgraded version of VI. Vim's main function is completely compatible with the original VI, unlike VI, VI will not display color, and vim will be based on the contents of the file display different colors, easy to read and edit. and vim with code completion, compile and error jump and other convenient programming rich features, in the programmer is widely used. (Vim and Emacs are the favorite editors for Unix-like system users.) )


2. How do I view the current system vim version?

Vim--version


3. What do I do if I want to replace all "ABC" in the Document with "Def"? And how do you just replace the first "ABC" that appears in each line?

: 1, $s/abc/def/g

: 1, $s/abc/def


4. When searching for a keyword, what is the line of the keyword where the cursor is positioned? In other words, is the cursor positioned to the top of the keyword that appears on the line or the bottom of the keyword appears in the row, or another situation? What do I do if I want to move from the current keyword to the next keyword? How do I move to the previous keyword?

You need to see when Vim enters the document, where the cursor is located, and the positioning keyword is based on where the cursor is located.

If using/searching for keywords, press ' n ' to move down, press SHIFT + N up, if used? Search keywords, and the former is just the opposite.


5. When you finish editing the document, press ESC to enter command mode and enter the command: x what happens?

Input command: X can also save the file and exit, a bit similar: WQ, but there is a difference between the two.

: x #写入文件并退出. The file modification time is not updated unless the file is modified and the file modification time is updated.

: Wq #强制性写入文件并退出. Force write even if the file is not modified, and update the file's modification time.


6. How to quickly move the cursor to the right or left 10 characters in normal mode?

Right: 10 spaces

Left: 10l


7. What does VIM + filename mean and what will happen to vim +10 filename?

Vim + after entering the document, navigate to the last line

Vim +10 After entering the document, the cursor is positioned to line 10th


8. After opening a document with Vim, I want the cursor to jump to line 20th, what do I do? How do I jump to the last line?

Jump To line 20, enter 20G

Last line, enter G


9. Vim when the document is opened, the default is not to display the line number, how do you let it display line number?

: Set Nu


After Vim opens the document, I want to replace the first ' ABC ' in line 20-50 with ' EFG ' How to do it? What if you want to replace all of them?

: 20,50S/ABC/EFG replaces only the first one

: 20,50s/abc/efg/g Replace All


One. Vim how to quickly delete the first 100 lines after opening a document?

First press ' GG ' to the first line, then enter 100d


When Vim opens a document, how do you copy a line and paste it below line 20th?

Navigate to the row you want to copy, enter yy, then enter 20G, and then enter P


Eighth Chapter

1. Gzip, can bzip2 directly compress the directory?

Cannot compress directory directly


2. Please write quickly, using gzip and bzip2 to compress and decompress a file command.

Gzip 1.txt

Gzip-d 1.txt.gz

Bzip2 1.txt

Bzip2-d 1.txt.bz2


3. When the tar is packaged, how do you want to exclude multiple files or directories?

Tar cvf 123.tar--exclude a.txt--exclude b.txt 123/


4. Please experiment, if not add "-" is correct, such as tar zcvf 1.tar.gz 1.txt 2.txt?

No, no, no, no problem.


5. How to package and unpack with tar. tar.gz,. tar.bz2 compression pack?

Tar zcvf 1.tar.gz 1

Tar zxvf 1.tar.gz

Tar jcvf 1.tar.bz2 1

Tar jxvf 1.tar.bz2


6. Find a larger file and use tar to separate the file into a. tar.gz and. tar.bz2 compression package, compare which package will be smaller, so that the conclusion is gzip compression effect is good or bzip2 compression effect is good?

Theoretically, TAR.BZ2 's compression packets are smaller, but in some cases, the opposite is the case. But most of the time bzip2 compression effect is good.


7. When packing and compressing with tar, what is the default compression level? Think about how you can change the compression level? (Note that tar itself does not have this function oh, you can try to split packaging and compression)

When the tar package is compressed, it is based on the default compression level of gzip and bzip2, and the Gzip tool default compression level is 6,BZIP2 default compression level is 9.

Change the default compression level you can do this, first tar packaging, and then use gzip or bzip2 compression tool to compress, compress the time to specify the compression level.  such as: Tar CVF 1.tar 123/; Gzip-2 1.tar


Nineth Chapter

1. Distinguish the role of RPM-QI-QF-QL-QA four different combinations of options?

RPM-QI//query for information about an RPM package that has been installed

RPM-QF//query which RPM package is installed for a program file

RPM-QL//Querying all installation files for an RPM package

RPM-QA//query all installed RPM packages


2. Rpm-qi what information will be displayed if followed by a package name that is not installed?

will prompt that the package is not installed


3. Please find out which RPM package This command was installed in?

RPM-QF ' which vim '


4. What are the commands for installing and uninstalling a package using RPM?

RPM-IVH RPM Package file name

RPM-E Package Name


5. When installing a package with RPM, how do I ignore dependencies and force the package to be installed?

RPM-IVH--nodeps


6. How do I upgrade a package using RPM?

Rpm-uvh


7. Use Yum to search for RPM packages that contain the keyword "tidy", install them, install them, and then use Yum to uninstall them.

Yum List |grep Tidy

Yum install-y Tidy Tidy-devel

Yum remove-y Tidy Tidy-devel


8. How can I use Yum to download a RPM package?

Yum install-y--downloadonly--downloaddir=/usr/local/src


9. Please download a PHP source package to the official PHP website and try to compile and install it. (PHP website address http://www.php.net/)


10. Check the data to see the difference between Yum upgrade and Yum update? Under what circumstances are they used?

Yum upgrade and Yum Update are all capable of updating all software packages of the system, and the difference is that upgrade is quite a large-scale upgrade, with the older packages also upgraded. Update and upgrade the focus is not the same, update is mainly to make the software up-to-date, but upgrade more focused on the software features get a big promotion, different from the frequent release of the latest patches. Upgrade does not change the software settings and system settings, the system version upgrade, the kernel does not change, update changes the software settings and system settings, the system version of the kernel are upgraded.

Yum Upgrade: For large-scale version upgrades, updating Linux systems and the entire software version

Yum Update: For installing patch files, updating kernels and packages to the latest


11. How do I see if a package is installed on the Linux system (CentOS)?

Rpm-qa | grep Package Name


/configure: After the completion of the complete, do not know whether there is no success, with what command can be verified?

echo $?


13. If this error occurs in./configure, "configure:error:no acceptable C compiler found in $PATH" What should we do?

Yum install-y gcc


14. Sometimes, you forget how a compilation parameter is written, what do you do?

./configure--help


15. How do I build a yum repository using CDs?

A) mount the disc mount/dev/cdrom/mnt

b) Remove all repo files from the/ETC/YUM.REPOS.D directory rm-rf/etc/yum.repos.d/*

c) Create a new file Dvd.repo

[Email protected] ~]# Vim/etc/yum.repos.d/dvd.repo

Add the following content:

[DVD]

Name=install DVD

Baseurl=file:///mnt

Enabled=1

Gpgcheck=0

d) Refresh repos generate cache # Yum Makecache


This article from "Tangjilinux" blog, declined reprint!

Basic knowledge of Linux personal summary

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.