I. Linux basic management commands and Linux management commands

Source: Internet
Author: User

I. Linux basic management commands and Linux management commands

1. Shutdown and restart command

(1) shutdown command: shutdown [Option] Time

Option:-c. Cancel the previous shutdown command.

-H Shutdown

-R restart

Example: shutdown-h now # shut down immediately, root User

+ 10 & # shutdown in 10 minutes

& # Define the absolute restart time

(2) Other shutdown commands (not necessarily saved properly): halt

Poweroff (linux/aix/solaris/bsd)

Init 0 (call system level)

(3) other restart commands: reboot

Init 6

(4) system running level:

① Rhel and suse:

0 Shutdown

1 single user mode

2. Network-less single-user mode

3 has ------- more -------------

4 Reserved

5. logon with GUI at the same level 4

6. Restart

Runlevel: view the system running level and display the previous and current level (the first is N, indicating that the previous running level is not available );

Modify the default level:/etc/inittab

② Debian/Ubuntu:

0 Shutdown

1 single user/system maintenance status

2 users

3 users

4 Users

5 Users

6. Restart

/Etc/inittab to view the running-level configuration files (Mo 2) S and s are in single-user mode

 

2. Disk management commands

Df-h # view partition usage

Fdisk-l # view the number of attached hard disks and Their partitions

Fdisk-cu/dev/sdb # format the hard disk

Mount-a # mount all file systems (mount-o remount/opt only remount/opt)

Umount/opt # uninstall the File System

 

3. Command for viewing computer hardware device properties:

Uname-a # view kernel/operating system information (64-bit or 32-bit version)

-R # kernel version

-N # Host Name (= hostname)

Cat/proc/cpuinfo # view CPU information (= lscpu)

Cat/proc/meminfo # view memory details

Free (-m) # memory size (-s 1 every 1 second)

Ps aux = ps-ef # Process

Lspci-TV # list all PCI devices (-TV is displayed in a tree)

Lsusb-TV # -------------- USB device

Lspci | grep Ethernet # Nic

Lspci | grep audio # Sound Card

Lspci | grep VGA # Video Card

Cat/etc/issue.net # system release version

Cat/proc/version ----------------------

Lsb_release------------------------

Cat/etc/redhat-release ---------------------

4. View clock commands

Tzselect # Real clock partition 5 → 9 → 1 → 1

Cal # display calendar (cal-y 2016)

Date # display system time

-S 12:11 # modify the system time

2012/09/11 # ------------ date

"

Hwclock # display hardware clock (provided by button battery)

-W # synchronize system time into hardware clock

-S # synchronize the hardware clock to the system time

 

5. File Processing Command

(1) ls [Option] [file or directory] # list directory content

-A # Show All files (protecting hidden files starting)

-L # display details (ls-l = ll) (. Indicates ACL permission, 1 indicates reference count, and has been called several times)

-D # view directory Properties

-H # humanized display size

-I # display inode (each file has an ID number)

-I # list file attributes

-T # list file names based on the last file modification time

-F # list file name types (* Common file,/directory, @ Symbolic Link, | operating OS, = socket)

-R # display directory and subdirectory file names

Ls-laR/# display all files under the root

(2) file command # determine the file type

(3) directory file processing commands

① Create a directory: mkdir [-p] [directory name]

Example: mkdir-p xue/id # recursive Creation

② Switch Directory: cd [Directory]

Example: cd ~ # Go to the current user's home directory

Cd -------------------------------

Cd-# enter the last directory

Cd .. # Go to the upper-level directory

Cd. # enter the current directory

Cd ../return the parent directory

Cd ../../

Absolute path: Starting from the root directory, first-level recursive search, "." working directory, "." working directory parent directory. Example: cd ../usr/local/src/

Relative Path: search by reference to the current directory. Cd/etc/

③ Display the current working directory: pwd

④ Delete the empty directory: rmdir [directory name]

⑤ Delete a file or directory: rm-rf [file or directory] (delete it after deletion)

-Rf # Delete non-empty directories

6. copy and paste command: cp [source file or directory] [target directory]

-R # copy the directory ????????????????

-P # joint file property copy (including time)

Mv [original path] [target path] # Move and rename

(4) command for viewing file content:

Nl # display row number

Cat # do not show the row number (all file content)

More # display %

Less # % not displayed (display by PAGE, Ctrl + B backward, Ctrl + F forward, enter a line to display, q Exit)

Head # first 10 rows (head-2)

Tail # the last 10 rows

(5) file link:

Hard link soft link (symbolic link)

Ln [source file] [target file] ln-s [source file (absolute path)] [target file]

① Files only ① files can be Directories

② Multiple files, one node ② one file, two nodes

③ Not cross-path, cross-partition ③ cross-path, cross-partition

④ One change, the other will also (differentiate cp) ④ modify any file, and the other will change

⑤ Delete source file, available (front backdoor) ⑤ Delete source file, unavailable (similar to shortcuts)

6. It has the same I node and block and can be considered as the same file. ⑥ Have their own I nodes and block blocks, but data

It can be identified by I nodes. Only the file name and I node of the original file are saved in the block, with no actual data.

(6) file search command:

① File search command: locate

② File -----------: find

③ Command -----------: wheris and which

④ String ----------: grep

⑤ Difference between find and grep:

(7) file search command

① Locate

# Locate yum. conf | grep conf $

# Updatedb update database

② Whereis

# Whereis yum. conf

③ Which

# Which yum find the absolute path of the executable command

④ Find is based on hard disk search and does not rely on databases

# Find/etc/-name "*. conf" | more: find the file with the suffix. conf and layer it

# Find/etc/-name "*. conf"-size + 20 k search for files with a suffix greater than 20 k. conf

# Ll-h/etc/lvm. conf check the lvm. conf size

# Du-a-k/etc/lvm. conf to view the file size

# Find/etc/-name "*. conf "-size + 20 k-exec du-a-k {}\; cp {}/ opt/\; view the file larger than 20 k, display the file size, and copy it to opt

\; # Line feed

# Ls/opt View File Content

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.