Linux Command Daquan Summary

Source: Internet
Author: User
Tags bz2 chmod clear screen create directory unpack disk usage

Directory-related commands: Ls,dir,cd,clear,mkdirls displays files and directories for the specified directory

LS-A lists all files under the directory, including the. Hidden files at the beginning

LS-L displays a detailed list of the specified directories

Ls-r list files under all subdirectories

Ls-f a character after each file name to indicate the type of the file

/Represents a catalog file

* Indicates execution file

@ denotes symbolic link file

= Scoket File

| Pipeline files

DIR = ls is also the file and directory that displays the specified directory, which is seldom used, and is generally used with LS

CD Switch Directory

cd ~ = CD switch to the working directory of the current user.

CD-Switch to the previous catalog

Cd.. Go back to the top level directory

CD/Switch to root directory

Clear Clear screen PWD displays the absolute path of the current directory mkdir create directory

mkdir a b c D create multiple directories in the current directory

MKDIR-M 777 AA BB creates the AA,BB directory in the current directory, and the permissions are all permissions.

Mkdir-p a/b/c/d/e Creating a multilevel subdirectory

mkdir dir{1,2,3,4,5} = = mkdir dir1 dir2 dir3 dir4 DIR5

FILE-related commands: CP,MV,RM,LNCP Copying files and directories

-r: Copy directory

-V: (Show operation procedure)

-A: Copy all

-P: Permissions do not change after replication

MV Move and rename

Mv/root/install.log/root/install.log.bak

Mv/root/install.log.bak/install.log

Mv/install.log ~ (~ = user's working directory)

RM Delete files and directories

-R Delete Directory

-F Force Delete without confirmation

-I need to confirm RM/*-RF

RM *-RF

RM *.C-RF

RM a B c D-RF

LN creates a link

-S creating Symbolic links

-F Mandatory Links: Divided into Symbolic links (soft links) and hard links.

Soft Link: shortcut, convenient. Can operate on directories and files, which can span partitions and occupy an I node.

Ln-sf/var/log.

Ln-sf/boot/grub/grub.conf grub.conf

Hard Link: Protect files, can only operate on files, cannot span partitions, do not occupy I node.

Help aspect Command: Man,help,info,wiki,doc,blog man: Help, can provide help based on commands, configuration files, functions and the like.

Eg:man ls

Mans vsftpd.conf

Man-a Open Query Open character all help documents

Location of the Help document:/usr/share/man/man*

Info: Help information.

Eg:info ls (exit: Q or CTRL + C abort)

Help: Helpful Information

Eg:help or LS--help

Document Catalog:/usr/share/doc/

Documentation of the program's Help information, white papers, cases.

cd/usr/share/doc/vsftpd-*/

Blog,wiki,google. Display aspects of the command: Cat,tac,head,tail,more,lesscat display the contents of small files, head to tail

TAC displays the contents of the small file to the end of the head

-N: Show line numbers

Head displays the first 10 lines of the file

Tail display the following 10 lines of the file

Cat-n/root/install.log |head

Cat-n/root/install.log |tail

Head-3/root/install.log

Tail-2/root/install.log

Cat-n 30.txt |head-20 |tail

-F Dynamic display of file changes.

Tail-f/var/log/messages (Ctrl + C abort)

More split screen display the contents of large files, support up and down screen

Less split screen displays the contents of large files, supporting the search function

More/root/install.log (space) down the screen, enter (enter) down one line down the screen, b up, f down, support

PGUP,PGDW).

Less/root/install.log (Space down, J down, k up, support PGUP,PGDW, support lookup).

/char (find char characters, press N, N to continue looking).

Q exit

Permission Aspect Command: Chmod,chown chmod Modify the permissions of the file, based on letters and numbers.

-r modifies permissions for subdirectories.

A All (default) u user Rights G Workgroup permissions o other groups

Chown Modify the owner and the Working Group.

Chown Owner.group File|dir-r The sub-directory of the owner and the Working group

Find a facet command: Find,locate,slocate,whereis,which

Find finds files or directories under the specified directory.

The Find Directory option value option:

-name "*.c" searches for files that contain the end of. C.

find/etc/-name "*.conf"

find/etc/-name "Hosts"

find/etc/-name "host*"

-size [+-][n]bkm Find the size of the file.

Find. -size +1k

Find.-size 1k

Find.-size-1k

Find.-size 0 looks for empty files, 0k.

-ctime [+-]n creation time

-mtime [+-]n Modification time

-atime [+-]n Access time

Find. -mtime-1 the documents that have been changed so far yesterday

-perm [+ +] permissions are greater than or less than a file with a permission

Find/bin-perm 755

The Find/bin-perm +4000 permission contains the SUID bit.

The Find/-perm +2000 permission contains a sgid bit.

The Find/-perm +1000 permission contains a T-bit.


-user user Lookup belongs to a person

User-group group1 find workgroup for group1

-nouser finding a non-master user

-nogroup Finding users without groups

Empty files and directories

Find. -size 0 Finding empty files

Find. -empty finding empty files and empty directories

-exec Shell_command {} \;

-type f\c\d\b\l\s\p #文件类型 \ normal file \ character device \ directory \ Block device \ Symbolic link \ Pipeline

Find. -type l-exec ls-l {} \;

Slocate|locate Quick Find, fast, effective and relatively poor. The database needs to be updated regularly.

1, UpdateDB Create the database, update the database.

2. Locate configure find files or directories that contain configure characters.

Whereis finding commands and Help files

Which find commands and aliases, search only in the path specified by the PATH variable.

Whereis ls

which LS

Compression aspect Command: TAR,GZIP,BZIP2 tar package or unpack commands, backup commands.

-C Package-V display procedure

-F Package File

TAR-CVF 1.tar/var/log/*


Package and Compress commands

-z:gzip Compression or decompression

-J:BZIP2 Compression or decompression

TAR-CJF etc.tbz2/etc/

Tar-czf etc.tgz/etc

Tar-czf etc.tar.tar/etc (file Etc.tar.tar to view the types of files)

Unpack command, restore command:-X unpack-C to specified location

TAR-XVF etc.tar-c/opt

Unpacking and Decompression commands

TAR-ZXVF etc.tar.gz

TAR-JXF etc.tar.bz2-c/opt


Displays the contents of a packaged or compressed file. -T display content

TAR-TVF Etc.tar

TAR-TZVF etc.tar.gz

TAR-TJVF etc.tar.bz2


Compression

Gzip Install.log

Bzip2 Install.log.syslog

Extract

gzip-d = = Gunzip

bzip2-d = = Bunzip2

Power off restart command: Reboot,shutdown,poweroff,halt,init shutdown:

Halt

Poweroff

Init 0

Shutdown-h now

Restart:

Reboot

Init 6

Shutdown-r now

Shutdown shutdown or restart, the system will send the message to all online users.

-R Restart

-H shutdown

-K records the process of shutting down or restarting. It's not a real shutdown.

-C Cancel shutdown or restart

Now immediately

+5 5 minutes later shutdown-h +5

"Asdfasdf" prompt shutdown-r +5 "system

Disk Management command: Df,du,fdisk,mount,nomount DF: View disk usage, partitioning and file system

Df-h user-friendly display disk usage

Df-ht displaying file system types

Df-hi show the size of the I node

Df-tt ext3 show Ext3 's partition

Du: Viewing the size of a directory

DU-S[MKB] Dir1-s Statistics

Du-sm/boot

Du-sm/var/log

Fdisk shows the partition of the hard disk, capacity, and partitioning of the hard disk

Fdisk-l Show the partitioning of all hard disks

Fdisk-l/DEV/SDA

Process Management Command: Ps,pstree,kill,killallps: Displays a detailed list of system processes, processes.

Ps-ef Show All Processes

Ps-aux displaying a detailed list of processes

Pstree Show Process Tree

Init's Process ID number is 1, which is the parent process (System level) for all processes.

Kill kills the process

Kill PID Number Exit normally

kill-9 PID number forced kill

User aspect Command: W,WHO,SU,SUDO,PASSWD w|who shows which user is connected to the local server. W Display in more detail. Su Switch User (super admin switch to normal user, no password required, vice versa)

Su user1 switches to the User1 user, but does not call the User1 configuration file

Su-user1 switch to user1 user, call User1 's configuration file. The environment variable will take effect.

Su-Switch to root user.

sudo authorizes an ordinary user to have the identity of a super administrator.

1, Useradd AAA Create ordinary user passwd AAA change the password of the AAA user

2, Visudo authorized AAA. Press I to add the following to the end of the file, press ESC, enter: X save to exit. AAA all= (All) all

3, SU-AAA switch to AAA

4,/sbin/service sshd restart

Sudo/sbin/service sshd Restart

Enter the password for the AAA user and execute the command for the Super Administrator.

Linux Command Daquan Summary

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.