Linux Basics (b)

1, linux shutdown and restart

Shutdown:

shutdown -h 10:20 # specified time shutdown

shutdown -h now # immediately shut down

shutdown -h +10 # 10 minutes after shutdown

Shut down the system halt #

Restart:

immediately restart shutdown -r now #

shutdown -r 10:20 # specified time to restart

reboot # reboot

init 6 # reboot

cancel the shutdown shutdown -c #

 

2, unzip

Linux common compressed file: tar, bzip2, ZIP, RAR
.tar using the tar command operations
.bz2 bzip2 command operation using the
.gz gzip command operation using the
.zip using the unzip command to extract
.rar using the command unzip unrar

The most common is the .tar.gz file, that is, after the tar package, using gzip compression

Create a compressed file:

tar zcvf filename.tar.gz dir /
unzip the file:

tar zxvf filename.tar.gz

 

3, system and network

3.1

uname -a # output current kernel information

3.2 ps: view the process thread state, and the top is some overlap

ps -eflgrep java # find java thread

3.3 top view cup load load, CPU usage. Some of the highest use of memory or cpu process

top -H p pid # viewing thread status of a process

pidof mysqld # pid mysqld view of

3.4 free view memory, more friendly than the top, including physical and virtual memory swap

3.5

df -h # view disk usage, parameters h, it can be friendly show, -k: display each file system capacity KBytes of, -m: display each file system with a capacity of MBytes

3.6 ifconfig View Address

ping www.baidu.com # view network through barrier

3.7 

netstat -ant # tcp view the current connection, from the local port for viewing or ip (ss alternatively)

3.8 yum: Management Pack tool
yum install wget -y # install wget command

3.9 systemctl: management back-office services, and is compatible with the service command

For example, restart MySQL, following a recommendation

service mysql restart
systemctl restart mysqld

3.10 su: used to switch the user
su username
su - username # cleanly switch to another account without the accident, recommended

3.11 View File Size:

du -h filename parameters; -k: KBytes listed in capacity display, -m: lists the capacity to display MBytes

3.12 Disk Format

mkfs -t ext4 / dev / hdc6 # partition / dev / hdc6 (you can specify your own partition) formatted as ext4 file system

 

4, file belongs to user and group

ls -l # Display user and group attributes of a file and the file belongs, such as:

drwxr-xr-x. 2 root root 6 at 20:04 on July 13 common

drwxr-xr-x is the attribute of the file.

Bit 0 is the [  D] is a directory, [  -] is a file, [  L] is expressed as document links (Link File), [  B] it indicates that the interface device is a device for storage of the files inside (randomly access means), [  C] is expressed as a file inside the device serial port device, such as a keyboard, a mouse (one reading unit)

From the first start, three as a group, are: user attributes, group properties, others attribute (user, group, others), permissions are: read, write, execute (r, w, x), no compared with the appropriate permissions: -

Where digital rights to represent individual scores for each authority:

r :4

w:2

x:1

If none: 0

drwxr-xr-x can be expressed as: 755

4.1 modify their user and group:

charp groupname filename # parameter -r, all subfolders under the filename

chown  [-r]  username  filename

chown [-r] username: groupname filename # also modify the relevant user and group

4.2 modify permissions

chmod 777 a.txt # a.txt to file property to: belongs to the user, group, others are read, write, execute

You may also be used +, -, =, a represents the addition, removal, set, all

chmod u = rwx, g = rw, o = r a.txt # a.txt file attribute is set to: the user belongs to (read, write, execute), set (read and write), the other (read)

chmod ax a.txt # remove all execute permissions

chmod 000 -r / # devastating command

 

5. Other

5.1 export to set environment variables

export PATH=$PATH:/home/username/java/jdk/bin

5.2 env displays all current environment variables

5.3 whereis want to know the specific path to execute the command

5.4 crontab: linux tool for local job

5.5 date outputs the current system time, the output format designated parameter -s

hwclock: View hardware time

5.6 xargs: reading the input source and then processed line

# Delete all class files

find .|grep .class$ | xargs rm -rvf

5.7 ssh # ssh tunnel, parameters -v, learn more output process

5.8 scp: for file transfer, can also be used to transfer directory, as well as more advanced sftp command

scp a.txt 192.168.1.1:/tmp/a.txt
scp -r a_dir 192.168.1.1:/tmp

5.9 wget: direct download files using the command line, support for HTTP

wget -c http:links

5.10 mysql connection:
MySQL -u root -p -h 192.168.1.1

 

6, text processing

Statistics: sort, uniq # sort and uniq paired. sort -t specified delimiter, -k used to specify the sort column.

Filter: grep, awk, sed, diff

6.1 pairs of filter content:

Use grep, bring --color parameters, print color can be supported in the terminal, the parameter n is a specified number of output lines, for quick navigation

grep -rm --color filename

If you want to see the contents of the front and rear of a keyword, using ABC parameters:

A: after, before the content of n rows
B: after before, the content of n rows
C: n rows before and after the count content

grep -rm --color keyword -A10 -B2 filename

About 6.2 vim, sed, awk and other advanced knowledge and advanced usage, can be explored in other blog,

 

Reference Address:  https://www.runoob.com/linux/linux-tutorial.html

Guess you like

Origin www.cnblogs.com/BackingStar/p/11183947.html