Linux basic commands (mounting, packaging compression, linking, input and output redirection)

1. What is a shell?

  • Shell is the collective name for command language, command interpreter and programming language.
  • The shell itself is an interpreted programming language.
  • Two user interfaces of the operating system: system call interface and console command interface.
  • Shell is a program written in C language, which provides an interface and bridge for users to manage and use the system.
    Insert picture description here

Two, commonly used shell

sh
csh
ksh
tcsh
bash : sh compatible, including the most useful functions of csh and ksh, with command history memory function, job control function, shell programming ability.

Three, user system related commands

1. User switching
su:
su user name is
changed to the identity of other users, which is mainly used to change the identity of ordinary users to super users, and the corresponding user password is required.

2. User management
useradd:
useradd user name to
add user account

passwd:
passwd username is
changed to the account password of the corresponding user

3. System management command
ps:
ps [option]
displays the list of processes run by the user in the current system.

kill:
kill [options] Process number
Output a specific signal to the process of the specified PID, and complete the specified action according to the signal.

Pipes are an important way of information communication in Linux. It connects the output of one program directly to the input of another program without going through any intermediate files. Pipeline refers to a path connecting two or more program pipelines. The character "|" in the shell represents a pipe line. As shown by ps –ef|grep ntp in the previous example, the result of ps –ef is directly input into the grep ntp program.

4. Disk related commands
fdisk:
fdisk [-l]
fdisk can view the hard disk partition status and manage the hard disk partitions. Here we mainly introduce how to view the hard disk partition status. In addition, fdisk is also a very good hard disk partition tool.

5. File system mount command

Mounting refers to the process of establishing a mapping relationship between partitions and directories, and mount point refers to the location of the mount in the file tree.

mount:
mount [option] [type] device file name mount point directory

Four, file related commands

1. cd
changes the current working directory
cd [path]

  • This command can use wildcards.
  • Use "cd -" to go back to the previous working directory.
  • "./" represents the current directory, and ".../" represents the parent directory.

2. ls
lists information about directories and files.
ls [options] [file]

3. mkdir
creates a directory.
mkdir [options] path

mkdir -p ./hi/hello:
-p creates multiple directories at once

mkdir -m 777 ./why:
-m creates a directory with corresponding permissions

4. Cat
connects and displays the relevant information of the specified one or more files.
cat [options] file 1 file 2...

5. cp
cp: Copy the given file or directory to another file or directory.
cp [options] source file or directory target file or directory

6. mv
mv: Rename files or directories or move files from one directory to another.
mv [options] source file or directory target file or directory

7. rm
rm: Delete one or more files or directories in a directory.
rm [options] file or directory

8. chmod
changes file access permissions.

9, grep
searches for specific content in the specified file, and outputs the line standard containing these content.

10. Find
searches for files in the specified directory, and its use authority is all users.

11. In
creates a symbolic link in another location for a certain file. When the same file needs to be used in different directories, Linux allows users not to store the same file in each required directory, but only need to link files in other directories with the ln command, so that there is no need Take up disk space repeatedly.

ln[options] target directory
-s to establish a symbolic link (this is also the only parameter usually used)

The links of ln are divided into soft links and hard links.
The soft link is the ln -s ** ** mentioned above. It will only generate a mirror image of a file at the location selected by the user, and will not repeatedly occupy disk space. Soft links are usually used more often.
A hard link is ln ** ** without parameters. It will generate a file with the same size as the source file at the location selected by the user. Whether it is a soft link or a hard link, the file keeps changing in sync.

12. Touch to
create a file

13, chown
modify file owner and group

14, charp
changes the group ownership of the file

Five, compression and packaging related commands

1. gzip/gunzip
.gz
(1) Function:
compress and decompress files, and gzip can automatically recognize compression or decompression according to the file type.
(2) Format:
gzip [option] compressed (decompressed) file name

2. Tar
(1) Function:
Pack or unpack the file directory. Here we need to distinguish between the two concepts of packaging and compression. Packaging refers to turning some files or directories into a total file, while compression refers to turning a large file into a small file through some compression algorithms. Why distinguish between these two concepts? This is because many compression programs in Linux (such as gzip introduced above) can only compress one file, so when you want to compress more files, you must use its tools to pack these piled files into a package. , And then use the original compression program to compress.
(2) Format:
tar [options] [file name after packaging] file directory list
tar can automatically identify the packaging or unpacking actions according to the file name, where the file name after packaging is the user-defined packaged file name, and the file directory list can be Is the file directory list to be packaged and backed up, or it can be the file directory list to be unpacked

3. bzip/bunzip
.bz2
bzip2recover Repair damaged .bz2 files

4、unzip
.zip

5、compress

6. File comparison and merge related commands

1. diff
(1) Function:
Compare two different files or two files with the same name in different directories, and generate patch files.
(2) Format:
diff[option] file 1 file 2

2. patch
(1) Function: The
command is used in conjunction with diff to apply the generated patch file to the existing code.
(2) Format:
patch [option] [file to be patched [patch file]].

Seven, network related commands

1. Ifconfig
(1) Function: It is
used to view and configure the address and parameters of the network interface, including IP address, netmask, and broadcast address. Its use authority is super user.
(2) Format:
ifconfig has two formats, which are used to view and change the network interface.
① ifconfig [options] [network interface]: used to view the current system network configuration.
② ifconfig network interface [option] address: used to configure the IP address, netmask, broadcast address, etc. of the specified interface (such as eth0, eth1).

2. ftp
(1) Function:
This command allows users to upload and download files using the ftp protocol.
(2) Format:
ftp [option] [host name/IP]. The ftp related commands include usage commands and internal commands. The format of the commands used is listed above, which are mainly used to log in to the ftp server. Internal commands refer to a series of operations after successful login, which will be listed in detail below. If the user defaults to "hostname/IP", he can continue to choose to log in after switching to the ftp internal command.

8. Summary

This time I mainly learned the basic commands of Linux operation. These commands are the basis of using Linux. Linux basic commands include user system related commands, file directory related commands, compression and packaging related commands, comparison and merge related commands, and network related commands. I hope I can master these commands in my future studies!

Attach:

Input and output redirection

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44366125/article/details/105956921