Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux common basic commands

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Shut down and restart the system

1.1 shutdown [option] [time] [warning message] (root permission)

-k: do not really shut down the system and issue a warning message to all users.

-r: restart after shutdown.

-h: do not restart after shutdown.

-f: quickly shut down the system and restart without disk detection.

-n: quickly shut down the system without going through the init program to shut down.

C: the terminal shuts down the system.

-[time]: sets the time to shut down the system.

Shut down the system immediately: shutdown-h now

Shut down the system after 45 minutes: shutdown-h 45

Restart the system and issue a warning message: shutdown-r now "system will be reboot now!"

1.2 halt [options]

-w: do not really shut down the system, write "wtmp" (/ var/log/wtmp) record.

-d: do not write "wtmp" records.

-f: force system shutdown or restart without calling "shutdown".

-I: turn off all network interfaces before shutting down the system or rebooting.

-p: the default, calling "power off" when shutting down the system.

1.3 reboot

Reboot causes the host to restart, while halt causes the host to shut down the system.

1.4 init

Init is the ancestor of all processes, and its process number is always 1. Sending a "TERM" signal to init will terminate all user processes, daemons, and so on. The "shutdown" command uses this mechanism. Init defines seven runlevels, of which init0 is to shut down the system and init1 is to restart.

Linux run level:

0: stop running, all processes terminate, shut down the system.

1: single-user mode, used to maintain the system, only a small number of processes.

2: multi-user mode, except that the NFS service is not started, everything else is the same as runlevel 3.

3: complete multi-user mode, enter the character interface of the Linux system.

4: not used (customizable)

5: complete multi-user mode (with X window-based graphical interface).

6: reboot the computer.

Displays the current system runlevel: runlevel

Switch runlevel: init 2

Turn off the computer: init 0

Restart the computer: init 6

two。 File and directory management

2.1 ls [parameters] [Catalog name] display directory

-a displays all files and directories.

-l list in detail the file type, permissions, owner, file size and other information in addition to the file name.

-r display the documents in reverse order (originally in English alphabetical order).

-t list the documents in the order of their establishment.

-An is the same as-a, but not listed "." (current catalogue) and ".." (parent directory).

-F add a symbol after the listed file name, such as executable file, add "*", and directory add "/".

-R if there are files in the directory, the files in the directory will also be listed.

-I find the I node of the file

2.2 cd [name] switch directories

Jump to the root directory: cd /

Jump to your home directory: cd ~

Enter the current directory: cd.

Skip to the top level of the directory at this time: cd..

Skip to the top two levels of the directory at this time: cd.. /..

2.3 mkdir [- p] [directory name] create a directory

-p: make sure the directory exists and create one if it doesn't exist.

Mkdir lml: create a subdirectory called lml under the working directory.

Mkdir-p lml/Test: create a Test subdirectory under the working directory lml, or one if lml does not exist.

2.4 rmdir [- p] [directory] Delete an empty directory

-p: when the subdirectory is deleted, make it also an empty directory, delete it as well.

Rmdir lml: delete the lml directory (must be empty).

Rmdir-p lml/Test: delete Test (empty), or delete lml if lml is also empty.

2.5 rm-rf [name] Delete directory

-r: delete the directory

-f: force deletion

2.6 cp [parameters] [original file or directory] [target file or directory] copy

-r: copy the directory.

-p: copy the attributes of the associated file.

-d: if the target file is a linked file, copy the link properties.

-a: equivalent to-pdr.

2.7 mv [original file or directory] [target directory] cut or rename

When the original file and the target file are in the same directory, it is renamed.

2.8 pwd

Displays the absolute path to the current working directory.

3. Link management

3.1 ln-s [original file] [target file] generate link file

-s: create a soft link

4. Search management

4.1 locate [name] search for files

Background database searched by / var/lib/mlocate locate

4.2 updatedb updates the database

4.3 find [search scope] [search criteria] search for files

Wildcard characters:

*: match any content

?: match any character

[]: match any character in square brackets

Find / root-iname [name]: case insensitive

Find / root-user [root]: search by owner

Find / root-nouser: find files without owners

Find / var/log/-mtime + 10: find files modified 10 days ago

-files modified within 10:10 days

The file revised on the 10:10 day

+ files modified 10:10 days ago

Atime: file access time

Ctime: changing file properties

Mtime: modifying the contents of a file

Find. -size 25k: find files whose size is 25KB (k lowercase, M uppercase)

Find. -inum 262433: find files whose I node (ls-I) is 262433

Find / etc-size + 20k-a-size-50k: find files larger than 20KB and less than 50KB in / etc directory

-a: logic and (both conditions are met)

-o: logical or (one of the two conditions satisfies)

Find / etc-size + 20k-a-size-50k-exec ls-lh {}\

4.4 grep [parameter] ["string"] [file name] matches a qualified string in the file

-I: ignore case

-v: excludes the specified string

5. Help manage

5.1 man [Command] get help for the specified command

6. Compression management

6.1 .zip compression

Zip [compressed file name] [original file] compressed file

Zip-r [compressed file name] [original directory] compressed directory

.zip unzip

Unzip [compressed File] extract the .zip file

6.2. GZ format compression

Gzip [original file] compressed to .gz format, the original file will disappear

Gzip-c [original file] > compressed file is compressed to .gz format, and the original file is retained.

The gzip-r directory compresses all the subfiles under the directory, not the directory

.gz decompression

Gzip-d [compressed file] unzipped the file

Gunzip [compressed file] unzipped file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 206

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report