Author: graynight
Basic course 1-shell text processing tool
Bash shell
* Matches zero or multiple characters.
? Match any single character
History and Tab play the same role in vro switches.
How to return to the main directory: 1.cd 2.cd/root 3/cd ~
Text processing tool:
Less and cat. Use cat to fill the screen with content in an instant. You can use less to present the content one by one and exit with the Q key.
Head-n indicates the first n rows
Tail-n displays the last n rows of the file
Grep extracts keywords from the file, which is equivalent to searching ).
Wc word count: calculates the total number of words, the total number of rows, the total number of bytes, and the total number of characters.
-I: calculates the number of rows only.
-W: calculate the total number of words only
-C: calculates the total number of bytes.
Tr converts the characters in a set into the corresponding characters in another set.
Data Display date
Cal display calendar
A simple description of the whatis command
Makewhatis generate Database
Help Show help
Man displays the command manual, the up and down keys on the keyboard flip pages, q key exit
Info displays more details than man
Important directories:
Main Directory:/root (System Administrator)
/Home/User Name (normal user)
User executable file directory:/bin/usr/bin/user/local/bin
System executable file directory:/sbin/usr/local/sbin
Other mount points:/media/mnt
Configuration:/etc
Temporary File:/tmp
Kernel and boot Loader:/boot
Server data:/var/srv
System Information:/proc/sys
Shared Library:/lib/usr/local/lib
Touch creates an empty file or updates the file Timestamp
The pre-built file database on the locate query system may only search for directories with read and execution Permissions
-I: perform case-sensitive searches.
-N X lists only the first X matching items.
The find directory condition is slower than the locate command but more accurate than the locate command. If no directory is specified, the current directory is used. If no conditions are specified, all files are matched. You can execute commands on the files you find. You may only search for directories with read and execution permissions.
You can use the OK and-exec options to run commands on the found files. If you use the OK option, a confirmation prompt will be prompted before running each matching file. If you use-exec, the command will not allow you to confirm all matching files in the second team.
The find condition accepts numeric values as parameters.
Find-size + 1024 K greater than 1024 K
Find-size-1024 K less than 1024 K
The find command can be matched according to the timestamp.
-The atime file was last read.
-The last time the mtime file was changed
-The data in the ctime file or the original data was last changed
Find-ctime-10 file modification date less than 10 days
TCP/IP network configuration
Nic interfaces use continuous numbers such as eth0 eth1
View ifconfig commands
Use ifup to enable the interface
Use ifdown to disable the interface
You can also use a graphical interface for management.
The device configuration is saved in the text file/etc/sysconfig/network-scripts/ifcfg-ethX
Other global network settings/etc/sysconfig/network
DNS configuration/etc/resolv. conf
Use ps to view process information. By default, processes on the current terminal are displayed.
-Option a includes processes on all terminals
-The x option includes processes that do not connect to the terminal.
-U option includes the process owner information
-O property options display custom information
Ps axo comm. pid. user | grep XXX
Search for pidof by exact program name
Signal: the most basic communication mode between processes. It is a simple message that can communicate with processes using commands such as kill.
Send kill signal pid to process
The name or number of the sent signal can be used.
Signal 15 term (default) Clean termination
Signal 9 kill immediate termination
Signal 1 hup re-reading configuration file
Killed 3428
Kill-15 3428
Scheduling priority: the scheduling priority determines the CPU usage, and the priority is affected by the process's "Good Intentions. The value range is-20 to 19. The smaller the default value, the higher the CPU usage priority. Run the ps-o comm and nice commands to view the value.
Change the scheduling priority: when the process is started: nice-n 5 command. After startup: renice 5 pid.
Normal users cannot set the nice value to a number smaller than 0, only the root user can
Top interactive process management tool: displays a list of processes running on your system on the screen, updated every 5 seconds.
Configure the IP address of the NIC: Dynamic (DHCP): dhclient eth0 static: ifconfig xx. xx
DNS Client configuration: edit/etc/resolv. conf to add nameserver xx. If multiple nameservers are specified, the system will retrieve servers in order.
Default GATEWAY: define global default GATEWAY = xx in/etc/sysconfig/network. xx. xx. xx you can also define the default GATEWAY of a network device in the ifcfg file under/etc/sysconfig/network-scripts/to automatically overwrite the configured GATEWAY in the ifcfg file. xx. xx. xx
File compression
Some common compressed file extensions
*. Z compress compressed files
*. Bz2 bzip2 files compressed by the program
*. Gz gzip compressed files
* The data packaged by the. tar program is not compressed.
* .Tar.gz tar files are compressed by gzip.
Compress-d [file name]-d is the decompression parameter. If you use the original compress file, it will be replaced by the compressed file.
Bzip2 [-dz] File Name-d decompression-z compression bzcat file name .bz2 read compressed file content
Gzip [-d #] File Name-d decompression # compression level 1 is the worst, 9 is the best, 6 by default, zcat file name reads compressed file content level is lower the faster
Tar [Option] File Name
-Whether z has both gzip
-X unzipping a compressed file
-T view the files in the tarfile
-C. Create a compressed file
-V display files during compression
-F use the file name
-P: use the original attribute of the source file.
-P can use absolute paths.
-N is a new file than the subsequent date (XXXX/XX) to be packaged.
Hardware and system logs
Access the driver through/dev, and files in the/dev directory can be used to access the driver.
Read data from the serial port: cat/dev/ttyS0
Write Data from the serial port: echo "data">/dev/ttyS0
Ls-l/dev/ttyS0 serial port device
Ls-l/dev/sda1 USB device
/Dev/hda/dev/hdc IDE Hard Drive
/Dev/sda/dev/sdb scsi sata or USB storage device
/Dev/md0/dev/md1 software RAID
/Dev/tty0-6 virtual console
/Dev/null/dev/zero software device
/Dev/random/dev/urandom: random Number
Who I am viewing Terminal
Hal-device lists snapshots of all connected devices in text mode. hal management is available (hardware extraction layer)
Lspci and susb respectively list the devices connected to the pci and usb Bus
Log daemon: syslog klogd
Log File:
/Var/log/dmesg kernel boot program
/Var/log/messages standard system error information
/Var/log/maillog email system information
/Var/log/secure security authentication information
User Management
Add new user: useradd
Set Password: passwd account name
Add a group account: newusers
When a user account is created, a dedicated group user with the same name is also created and assigned to this dedicated group.
Group Management
You can use the groupadd command to create a new group.
Use the groupdel command to delete a group
Use groupmod to change the name
Use the chage username option to change the password validity period, or use the option-m Password Change shortest interval-M Password Change shortest interval-E password failure on this day
Su-user Account change
User
1. Each user is assigned a unique user ID (UID)
2. the user name is saved in the/etc/passwd file.
3. When users log on, they are allocated a home directory and a running program.
Group
1. All users belong to a group
2. Each group is assigned a unique group ID (GID) stored in/etc/group.
3. All users in the group can share files belonging to the group.
Priority of Permissions
1. If the UID is assigned, apply the user permission
2. Otherwise, if the GID matches, the Group permission is applied.
3. If none of them match, apply other permissions.
Linux file access permission type
1. UID permission
2. GID permission
3. Other QIT Permissions
Permission type
1. r. Read the file or list the contents of the directory.
2. w. Write the file, or create or delete the file in the directory.
3. x execute the program or transfer it to the directory
4.-: no permission
Change file owner
1. Only the root user can change the file owner.
2. Only the root user can change the file group.
3. The chown command is used to change the user
4. The chgrp command is used to change the group
Change File permissions-symbolic Method
Chmod files
The mode here is: u g or o represents the user group and other users + or-represents granting or rejecting r w x represents reading, writing, and executing respectively.
Number: 4. Indicates reading 2. Indicates writing 1. Indicates executing 0. Indicates canceling all permissions.