Linuxawk commandsawklinux commands

Basic linux operating commands?

What are the most common operating commands in linux? The following is a specific introduction:

linux system in the operation of many commands, the most commonly used operation commands are: cd command, cd command, grep command, find command, cp command, mv command, rm command, ps command, kill command, killall command, file command, tar command, cat command, chgrp command, chown command, chmod command, pwd command, vim command, gcc command, time command.

1, cd command

This is a very basic, used to switch the current directory, its parameters are the path of the directory to be switched to, can be an absolute path, can also be a relative path.

2. ls command

This is a very useful command for viewing files and directories.

3, grep command

The command is often used to analyze a line of information, if there is information we need, the line will be displayed, the command is usually used together with the pipeline command, used for some of the output of the command filtering and processing and so on.

4, find command

find is a very powerful command based on find, relatively speaking, it is relatively more complex to use, the parameters are more.

5, cp command

The command is used to copy the file, copy means, it can also be multiple files at once copied to a directory.

6, mv command

The command is used to move a file, directory or name change, move.

7, rm command

This command is used to delete files or directories, between remove.

8, ps command

The command is used to select a point in time to run the process and output, the meaning of process.

9, kill command

The command is used to a job (%jobnumber) or a PID (number) to transmit a signal, it is usually used with ps and jobs command.

10, killall command

This command is used to send a signal to a process started by a command.

11, file command

This command is used to determine the basic data of the file that follows the file command.

12, tar command

This command is used to pack the file, the default situation will not be compressed, if you specify the appropriate parameters, it will also call the appropriate compression program (such as gzip and bzip, etc.) for compression and decompression.

13, cat command

The command is used to view the contents of a text file, followed by the name of the file to be viewed, usually available pipeline with more and less together, so you can view the data page by page.

14, chgrp command

This command is used to change the user group to which the file belongs.

15, chown command

This command is used to change the owner of the file, and the chgrp command is used in the same way, just modify the file attributes are different.

16, chmod command

This command is used to change the permissions of a file.

pwd command

Function: displays the absolute path to the working directory where you are currently located.

18, vim command

The command is mainly used for text editing, it receives one or more file names as parameters, if the file exists to open, if the file does not exist to create a file with the file name.

19, gcc command

For a person who uses Linux to develop C programs, this command is very important, it is used to the C language source program files, compiled into an executable program.

20, time command

This command is used to measure the execution time of a command (i.e. program).

What is the function of awk?

AWK is an excellent text-processing tool, Linux and Unix environments available in one of the most powerful data processing engine. This programming and data manipulation language (which gets its name from the first letter of the last name of its founders, Alfred Ehou, Peter Weinberg, and Brian Collingham) has its greatest power depending on the knowledge one possesses. awk has been improved to generate new versions of nawk, gawk, and is now used daily under the default linux system, gawk, and you can view the source of the awk that is being applied by using the command The source of awk

Write the commands and usage of ubuntulinux system to view the local cpu and memory information, and how to interpret these commands?

View CPU informationcat/proc/cpuinfoDisplay current hardware informationsudolshwGet CPU serial number or motherboard serial number#CPUIDsudodmidecode-t4|grepID#SerialNumbersudodmidecode|grepSerial# CPUsudodmidecode-t4#BIOSsudodmidecode-t0#Motherboard:sudodmidecode-t2#OEM:sudodmidecode-t11Display current memory sizefree-m|grep "Mem"|awk'{print$2}'View hard disk temperature sudoapt-getinstallhddtempsudohddtemp/dev/sda

What are some common commands used in linux?

Linux is an essential system for us as developers and is frequently encountered. However, there are more Linux commands, some of which are not commonly used and hard to remember. So, how can we use Linux commands more efficiently without having to learn them comprehensively? Today I'll share with you some of the more common and useful Linux commands that I use in my development process.

01 Viewing files or logs

Viewing the contents of a file or a log file is something that I believe almost everyone comes across. Among them, the most used are the head, tail, and cat commands.

1, head

Signifies the head, view the first few lines of data.

headtest.log: test.log file the first few lines of the log

head-n20test.log: view test.log file the first 20 lines of the log

head-n-20test.log: view test.log in addition to the last 20 lines of the log

2, tail

indicates the tail, view the last few lines or real-time log.

tail-ftest.log: real-time view of the last few lines of the test.log file log content

tail-f-n20test.log: real-time view of the last 20 lines of the test.log file log content

tail-n20test.log: view test.log file last 20 lines of the log

tail-n+20test.log: view all logs after 20 lines of the test.log file

3. cat

Used to view the contents of the file.

cattest.log: view all the contents of the test.log file

02 local copy

Copying files or directories between different directories on the same server is also often used.

1. Copying files

cptest.log/home/geshan/logs: Copy the test.log file to the /home/geshan/logs/ directory

cptest.log/home/geshan/logs/cptest.log: Copy the test.log file to the /home/geshan/logs/ directory and rename it cptest.log

2. Copy the folder

cp-rlogs//home/geshan/: copy the logs directory and all the files in the directory to the /home/geshan/ directory, at this point the directory will have the logs directory

cp-rlogs//home/geshan/testlogs/: copy the logs directory and all the files under the directory to the /home/geshan/testlogs/ directory, and rename the logs directory to testlogs, provided the /home/geshan/ directory does not have a testlogs directory

Note: -r or -R indicates a loop that loops through all files and directories in the directory. The same is true for all the following commands.

03 Remote Copy

When we need to copy a file or directory from a remote server to a locally logged in server, most people think of logging in to the remote server first to download the file, then logging in to the local server to upload the file again. This is cumbersome and not very efficient.

1, local server copy to remote server

(1) Copy file

Command 1:

scplocal_fileremote_username@remote_ip:remote_folder

Command 2:

scplocal_fileremote_username@remote_ip:remote_file

Command 3:

scplocal_fileremote_ip:remote_folder

Command 4:

scplocal _fileremote_ip:remote_file

The first two specify the user name, and the user password is required after the command is executed; the first one only specifies the remote directory, and the file name remains unchanged; the second one specifies the filename; the third and the fourth do not specify the user name, and the command defaults to the user name of the current server after execution and requires the input of the user password; the third one only specifies the remote directory, and the file name remains unchanged; the third one does not specify the user name, but the command executes with the current server user name and requires the input of the user password. only specifies the remote directory, the file name remains unchanged, and the fourth specifies the file name.

Example 1: Copy test.log from the local server to the /home/geshan/ directory on the 192.168.130.130 server and rename it to

20190125.log

Command:

Example 2: Copy test.log from the local server to the 192.168.130.130 server's /home/geshan/ directory

Command:

(2) Copy directory

Command 1:

scp-rlocal_folderremote_username@remote_ip:remote_ folder

Command 2:

scp-rlocal_folderremote_ip:remote_folder

The first one specifies the username, and the user password is required after the command is executed; the second one does not specify the username, and the username and password are required after the command is executed.

Example: Copy the tomcat directory from the /home/appuser/ directory on the local server to the /home/geshan/ directory on the 192.168.130.130 server Command:

2. Copying from a Remote Server to a Local Server

The scp command for copying from a remote server to a local server is identical to the above command is the same as the above, as long as the command from the local copy to the remote two parameters after the swap order on the line.

(1)Copying a file

Example:

Copying the test.log file from the /home/geshan/ path of the 192.168.130.130 remote server to the /home/appuser/ path of the local server

Command:

scproot@ 192.168.130.130:/home/geshan/test.log/home/appuser/

(2) Copying directories

Example: Copying the tomcat folder from the /home/geshan/ path of the 192.168.130.130 remote server to the local server /home/appuser/path

Command:

Note: There are no spaces between the ip address and the path (i.e., between the colons), otherwise an error will be reported. When communicating with another service for the first time (e.g. copying a file), you will be prompted whether to trust it or not, just enter yes.

04 Compressing and decompressing

Compressing and decompressing files is also frequently encountered. If you download all the files in a directory, you can download the directory directly, but if you download the directory directly, once there are a lot of files, it is easy to lose the files during the download process, and the download speed is also slow. In general, it is the first compression folder and then download. The following gives you an introduction to the four compression and decompression commands.

1, tar command

Decompress:

Compress:

Example: Decompress a log.tar file:

Compress the log directory and named log.tar:

2, gz command

Compress:

Note: Compress as a .gz file source file will disappear! If you want to keep the source files, use the following commands

Unzip:

.tar.gz and .tgz Unzip:

Compress:

Compress more than one file:

Example: Unzip the tomcat.tar.gz file

Compress the tomcat directory and name it tomcat.tar .gz file

3. zip command

Decompression: unzipfileName.zip Compression:

Note: When compressing a directory, you need to add -r, which indicates that looping all the files and directories in the directory. When compressing multiple files or directories, spaces are required between files or directories.

Example: decompress a log.zip file:

Compress the log file directory and name it log.zip:

Compress the log1 and log2 directories and name it log.zip:

Compress the test1.log and test2.log files and name it log.zip:

4. rar command

Similar to the zip command, just change zip to rar.

05 Modify permissions

Linux files and directories have different access permissions, and there are ways to determine who can operate on them.

File or directory access permissions are categorized as read-only, write-only, and executable, representing readable, writable, and executable, respectively.

1, chgrp command

Change the group to which a file or directory belongs. Command:

Example: change the group to which the file test.log belongs to to the group geshan

Change the group to which the logs directory and all the files in the directory belong to to the group geshan

2, chown command

Changing the user to which a file or directory belongs. Command:

Example: change the user of the test.log file to the geshan user

Change the user of the logs directory and all the files in the directory to the geshan user

3. chmod command

Used to change the permissions of a file or directory. Users use it to control access to files or directories. Command:

There are many ways to indicate the meaning of mode, the following is only for the numbers. Most people see that mode has permissions such as 777 or 776, what do these mean?

For convenience, change the mode to abc, where a,b,c is each a number, which means user, group and other permissions respectively. r=4, w=2, x=1, r means Read read, w means Write write, and x means eXecute.

If you want the rwx attribute then 4+2+1=7;

4+2=6 if you want the rw- attribute;

4+1=5 if you want the r-x attribute.

Example: modifying the test.log file for read-write-execute (i.e., 777) operation.

Modify the logs directory and all files in the directory to read-write (666) operation.

Type ll (two lowercase LL) in Linux system, if the file or directory is 777 (read/write execute) permissions, you can see -rwxrwxrwx at the top; if it is 666 (read/write) permissions, you can see -rw-rw-rw at the top.

Note: Generally, to modify the permissions of a file or a directory, you need to have a super user (root) to modify the permissions. to make changes, otherwise it may report insufficient permissions.

These Linux commands are more commonly used and practical commands, will certainly be useful to get the time, if you are helpful, remember to like the collection forwarding oh!

How does linux get to the black command line?

Mine: you can press Ctrl+alt+F2~6

and you can enter the black interface of command line mode.

This black command line is the Linux terminal, and you can enter various Linux terminal commands.

The more common ones are commands like lspwdpsawksedgreptaregrepsortuniqchmodchownfindkillcrontabatcatmoreheadtail.