Home  >  Article  >  System Tutorial  >  Comprehensive detailed explanation of CentOS commands

Comprehensive detailed explanation of CentOS commands

PHPz
PHPzforward
2024-01-08 09:09:451066browse

1, displays the currently used shell

[root@localhost ~]# echo $SHELL

2, display all shells used by the current system

[root@localhost ~]# cat /etc/shells

3, display hash cache

hash: show cache -r: clear cache

4, multiple commands can be used; separated by symbols

5,history

-c: Clear command history

-d: Delete the specified command in the history

    #: Display the latest # history

-a: Append the newly executed command history of this session to the list and to the history file

-n: Read unread lines in the history file to the history list

-r: Read history files and append them to the history list

-w: Save the history list to the specified history file

-p: Expand historical parameters into multiple lines, but do not exist in the history list

-s: Expand the historical parameters into one line and append them to the history list

6,Ctrl

l: Clear screen, equivalent to clear command

c: Cancel the execution of the command

-a: Move the cursor to the front of the command line

-e: Move the cursor to the end of the command line

-u: Delete the current cursor position to the beginning of the line

-k: Delete the current cursor position to the end of the line

7,Esc

-b: Move one word to the left

-f: Move one word to the right

8, local help file storage location/usr/share/doc/

9. After the CentOS system is installed, if there is no man help, you can use the following command to create the database

CentOS6 uses: makewhatis

CentOS7 uses: mandb

10, How to operate the man command

space, ^v, ^f, ^F: scroll to the end of the file

b, ^b: Flip to the beginning of the file

d, ^d: turn half the screen to the end of the file

u, ^u: turn half the screen to the beginning of the file

^n or ^e or ^j: Turn one line to the end of the file

^y or ^p or ^k: turn a line to the beginning of the file

q:Exit

    #: jump to line

# 1g: Return to the beginning of the file

g: Go to the end of the file

/keywork: Use string as keyword, search from the current position to the end, the characters are not case-sensitive

                 n: Next N: Previous

?keywork: Use string as keyword, search from the current position to the beginning, the characters are not case-sensitive

                    n: Next N: Previous

11, File system structure

/boot: Boot file storage directory, kernel files (vmlinuz), boot loader (bootloader, grub) are stored in this directory.

/bin: Basic commands for all users; cannot be associated with independent partitions, and are programs used when the OS starts.

/sbin: Basic management commands; it cannot be associated with independent partitions and is a program used when the OS starts.

/lib: Basic shared library files and kernel module files (/lib/modules) that the program depends on during startup

/lib64: Auxiliary shared library file storage location dedicated to x86_64 systems

/etc: Configuration file directory

/home/USERNAME: Ordinary user home directory

/root: Administrator’s home directory

/media: Portable mobile device mount point

/mnt: Temporary file system mount point

/dev: Storage location of device files and special files

b: block device, random access

c: character device, linear access

/opt: The installation location of third-party applications

/srv: Data used by services running on the system

/tmp: Temporary file storage location

/usr: universal shared, read-only data

                                                                                                   

lib: 32-bit use

      lib64: Only exists in 64-bit systems

include: C program header files (header files)

share: structured independent data, such as doc, man, etc.

Local: The installation location of third-party applications

/var:variable data files

cache: Application cache data directory

      lib: application status information data

Local: Dedicated to storing variable data for applications under /usr/local

lock: lock file

Log: Log directory and files

                                                                                                     

run: running process-related data; usually used to store process pid files

spool: application data pool

      tmp: Save temporary data generated between two system restarts

/proc: A virtual file system used to output kernel and process information

/sys: Virtual file system used to output information related to hardware devices on the current system

/selinux: security enhanced linux, the storage location of selinux-related security policies and other information

12, file type

-: Ordinary file

d: directory file

b: block device

c: Character device

l: Symbolic link file

p: Pipe file pipe

s: socket file socket

13, ls usage

-a: Include hidden files

-l: Display additional information

-R: Directory recursion through

-ld: Directory and symbolic link information

-1: Files are displayed in separate lines

-S: Sort from large to small

-u: With the -t option, display and sort by time from new to old

-U: Display in directory storage order without sorting

14, stat displays three timestamps of the file

access time: access time, atime, read file content

Modify time: modification time, mtime, change file content (data)

change time: change time, ctime, metadata changes

15, touch command

touch [OPTION]... FILE...

-a: only change atime

-m: only change mtime

-t:STAMP:

         [[cc]yy]mmddhhmm[.ss]

-c: If the file does not exist, it will not be created

16, cp command

-i: interactive

-r, R: Recursively copy the directory and all its contents

-a: Archive, equivalent to -dR --preserv=all

-d: --no-dereference --preserv=links Do not copy the original file, only copy the link name

-p: Same as --preserv=mode, ownership, timestamp

-v:--verbose

-f:--force

17, alias defines alias

Display all available command aliases of the current shell process

[root@localhost ~]# alias

Define the alias NAME, which is equivalent to executing the command VALUE

[root@localhost ~]# alias NAME='VALUE'

Aliases defined in the command line are only valid for the current shell process.

If you want it to be permanently valid, it must be defined in the configuration file

                                        Only for the current user: ~/.bashrc

Valid for all users: /etc/bashrc

Undo the use of aliases: unalias

18, mv command uses

Frequently used options:

-i: interactive

-f: Force

19, use the rm command

Frequently used options:

-i: interactive

-f: Forced deletion

-r: Recursion

20, tree displays the directory tree

-d: Only show directories

-L level: Specify the number of levels to display

-P pattern: Only display paths matched by the specified pattern

21, mkdir creates directory

-p: Exists without reporting errors and can automatically create the required directories

-v: Display detailed information

-m MODE: Specify permissions directly when creating a directory

22, rmdir deletes empty directories

-p: Recursively delete the parent empty directory

-v: Display detailed information

23, rm deletes data

-r: Recursively delete the directory tree

-f: Forced deletion without prompt

24, STDOUT and STDERR are redirected to files

Format: Command Operation Symbol File Name

         >: Redirect STDOUT to a file

    2>: Redirect STDERR to a file

&& gt;: Reset all outputs to the file

& gt;: The file content is covered with

set -C: It is forbidden to cover the existing documents, but you can add forced coverage: & gt; |

set C: Allow overwriting

           >>: Based on the original content, additional content

      2>: Override redirection error output data stream

      2>>: Append redirection error output data stream

The standard output and error output are directed to different locations: the format is as follows;

            COMMAND > /path/to/file.out 2> /path/to/error.out

Merge standard output and error output into the same data stream for redirection: the format is as follows;

&& gt;: Cover the redirect

                                                                                                                                                                                             

COMMAND > /path/to/file.out 2> &1 (The order is important)

               COMMAND >> /path/to/file.out 2>> &1

      (): Merge STDOUT of multiple programs

        (cal 2007; cal 2008)> all.txt

25, tr - convert and remove characters

       tr [OPTION]...SET1 [SET2]

Options:

-c or --complerment: Take the complement of the character set

-d or --delete: delete all characters belonging to the first character set

-s or --squeeze-repeats: Represent consecutively repeated characters as a single character

-t or --truncate-set1: Convert the characters corresponding to the first character set into the characters corresponding to the second character set

Use < to redirect standard input

Some commands can accept STDIN imported from a file

         $tr ‘a-z’ ‘A-Z’

This command will convert all lowercase characters in /etc/issue into writing characters

tr –d abc < /etc/fstab Delete all characters in abc in the fstab file

        [root@localhost ~]# cat > filea

       mage

wangxiaochun

Press ctrl d to leave, you can use files instead of keyboard input

[root@localhost ~]# cat > filea < fileb

26, less: View input page by page

ls -l /etc | less

mail: Send via email input:

echo "testemail" | mail -s "test" user@example.com

lpr: Send input to printer

echo "testprint" | lpr-Pprinter_name

The above is the detailed content of Comprehensive detailed explanation of CentOS commands. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete