Linux Small white Primer Four

Source: Internet
Author: User
Tags bz2 readable

Excerpt from Zhu Youpeng Teacher's public lesson video

1. Linux commands
1.1. Find
Function: In the Linux file system, to find where a file is placed.
Example:find/etc-name "Interfaces"
Summarize:
(1) When do I use Find?
When you know the name of the file you are looking for, but you have forgotten which directory it is placed in, to find the file, use Find.
(2) How to use Find?
Find path-name "file name"

1.2. grep
Function: In a text file, find a word.
Example:grep-nr "SUN" *
Summarize:
(1) When do you use grep?
When you want to find out where a symbol is located (possibly a file or a folder of multiple files), use grep
(2) How to use?
Grep-nr "symbol to find" the directory or collection of files to find
Note:-n means that the row number is displayed in the find result, and-r means that you want to recursively find

1.3, which and Whereis
Function: Find out where an application (binary file) is
Example:which LS whereis ls
Difference
Which displays only the path of the binary file
Whereis displays the path to the binary file, and its source or man manual location

1.4, Uname
Features: viewing system Information
Example:uname-a

1.5. Boot and shutdown
Shutdown-h now immediately shuts down the machine
Init 0 shutdown
Shutdown-r now restart
Reboot restart

1.6, Tree/lstree
Function: Displays the tree structure in which files and directories begin with the root directory

1.7, Mount/umount
Function: Used to mount the disk to the file system
Example:mount-t nfs-o nolock 192.168.1.141:/root/rootfs/mnt Mount
Umount/mnt Uninstall

1.8, disk space-related
Df-h displaying a list of mounted partitions
Du-h list the size of a file or folder
Du-h file name, you can list how large this file, listed in a way that people better understand the way. Unlike Ls-l, the list is in bytes.

1.9. User Management
Useradd user1 add a user named User1
Userdeluser1 Delete a user named User1
passwd user1 to set a password for a user named users
AddUser user1 add a user named User1, while creating the host directory, user shell, and so on.
The difference between AddUser and Useradd:
AddUser is a script, and Useradd is a binary application. AddUser is troublesome when creating a user, but all information is set at once, while Useradd settings are simple but require additional settings for the host directory, password, and other information.

1.10. Rights Management
Role: The right to manage files in the system.
chmod (change mode) to modify file permissions, more commonly used, remember
Chown (change owner, modify master)
CHGRP (change group, modify file groups)
Ls-l List of properties
-rwxr-xr-x
A total of 10 characters, the first representing the file attributes (d for folders,-for normal files), and the remaining 9 to be divided into three groups. Three of each group represents R readable W writable x executable. If it is a letter that has this permission, if yes-indicates that the permission is not available. The first group represents the permissions of the file owner, the second group represents the permissions of the group user who is the owner, and the third group represents the permissions of the other users.

There is another way to represent a permission, represented by a number.
The encoding rules are as follows:
R Readable 4
W writable 2
X executable 1
-No Permissions 0

With this coding rule, the Rwxr-xr-x code is 755.

The first way to modify permissions:
To change the permissions to rwxr--r--, the corresponding encoding value is 744.
The Modify command is:chmod 744 file name

The second way to modify permissions:
Modify on the basis of the original permission, that is, to increase or decrease a permission.
The code for three groups of users is: The group G of the owner of the main U is the other user O
Such as:
To be a master add executable permissions chmod u+x file name
Other users add writable permissions chmod o+w file name
The owner of the group to remove executable permissions chmod g-x file name

We need to change chown and CHGRP:


1.11, file packaging compression and decompression
TAR-CZVF dir.tar.gz dir/ Package dir directory as dir.tar.gz
TAR-CJVF dir.tar.bz2 dir/Package dir directory as dir.tar.bz2
tar-zxvf dir.tar.gz decompression dir.tar.gz
TAR-JXVF dir.tar.bz2 Decompression dir.tar.bz2

1.12. Sed and awk
The regular expression. Match plus replace.

1.13. format File System
Mkfs/dev/hd1
Mkfs-t vfat 32-f/dev/hd1 Create a FAT32 file system

1.14. Network configuration command
Ifconfig eth0 192.168.1.13 Set IP address
Ifconfig eth0 up boot NIC
Ifconfig eth0 down disable NIC
Ifup eth0 Start Network card
Ifdown eth0 Disable NIC
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 set both IP and subnet masks

2, Virtual machine Linux Internet problem
2.1. Three kinds of settings for virtual machine network in VMware
First type: bridging (bridged)
Second type: NAT
The third type: Host only. In this mode, only the host can surf the Internet, the virtual machine cannot surf the internet.

2.2, Virtual machine access mode 1:nat way
Setup steps:
First step: On the right-hand side, select NAT mode on the network adapter, hardware, and Settings, menu bar virtual machine
Step two: vi/etc/network/interfaces, open the file and edit the content into:
Auto Lo
Iface Lo inet Loopback

Auto Eth0
Iface eth0 inet DHCP
Address 192.168.1.141
Netmask 255.255.255.0
Gateway 192.168.1.1

Step three: Perform/etc/init.d/networking restart restart NIC

2.3, Virtual machine access Mode 2: Bridge mode
First step: Bridging. On the menu bar, settings, hardware-and network adapter, select Bridge mode on the right.
The second step: Bridge to connect to the Internet network card. On the menu bar edit, virtual network Editor, choose to Bridge to your own windows in the Internet network card (usually WiFi network or wired network)
Step three: Set up DHCP and restart the NIC.
Vi/etc/network/interfaces, open the file and edit the content into:
Auto Lo
Iface Lo inet Loopback

Auto Eth0
Iface eth0 inet DHCP
Address 192.168.1.141
Netmask 255.255.255.0
Gateway 192.168.1.1

Save exit. The command line then executes the/etc/init.d/networking restart restart the NIC


3. Build TFTP server


4. Build NFS Server

Linux Small white Primer Four

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.