Linux Common commands

Source: Internet
Author: User
Tags clear screen parent directory

To get a good command, have a Linux system, and learn some Linux system knowledge, here are some examples:

root directory The file system differs from window in that the root directory is/

Relative path, absolute path

Indicates absolute path/home/ken/xxx with/start

does not start with/to indicate a relative path such as CD./cdir represents the Cdir directory under the current directory

Inode
Shell Bash Tcsh zsh
Environment variables Http://www.cnblogs.com/growup/archive/2011/07/02/2096142.html
Input and output redirection Http://www.cnblogs.com/chengmo/archive/2010/10/20/1855805.html
Pipeline Connect the output of one program directly to the input of another program

There is a list of UNIX commands on the wiki: http://zh.wikipedia.org/wiki/Template:Unix%E5%91%BD%E4%BB%A4

Because Linux and UNIX are compatible, you can refer to learning directly. Here are some of the commands that I commonly use, simply categorize and attach simple instructions:

File System command:

Pwd Show Current working directory

Cd

Cd. To the current directory
Cd.. To the parent directory
CD ~ To user home directory
CD/To root directory
Ls List Directory Contents
Study site: http://www.cnblogs.com/s7vens/archive/2011/12/01/2270426.html

-a lists all files that contain the files that begin with the. file in Linux. The files that begin represent hidden files

-A lists all files, not included. And..

-L Show more information

-H human readable, and-l use the displayed size with units such as Ls-lh Cdir

-I display Inode

-s sort sorted by size

-T Sort by time

-R reverse and sort mates ls-sr xx means reverse ls–tr xxx in reverse chronological order of file size

Example: LS */*.c lists all c files in the level two directory

chmod

Change file permissions, only the file owner and Superuser can modify the file or directory permissions.

Study site: Http://zh.wikipedia.org/wiki/Chmod

Use octal syntax to represent permissions: r=4 w=2 x=1–=0 rwx, 4+2+1=7

chmod 664 MyFile Modify the owner and other users within the group have read and write access to the file, and the other members of the group are only reading permissions

To represent permissions in symbolic mode:

User: U:user file owner g:group file owner Groups o:Others all other user A:all users, equivalent to Ugo

Action: +: Add permissions for the specified user type-: Remove permissions for the specified user type = Set settings for the specified user rights, reset all permissions for the user type \

Permissions: r: Read W: Write X: Execute

chmod ug+rw,o=r myfile

chmod u=rwx,go= myfile

Cat File content View
Cp Copy
CP file1 File2
CP *.c DIR0
CP./ken/* Dir1
Cp–r dir1 dir2 Copy a directory and any subdirectories and files it contains into another directory, like-R and-R
Cp–i Overlay Tips
Cp–f forcibly copied, covered by the way
Rm Delete
Rm–i file with hints
Rm–f Mandatory Delete directory with write protection excepted
Rm–r Deleting a directory recursively
Xargs rm< filelist Bulk Delete
Find. -name ' *.png '-print0 | xargs-0 RM
Mv Move Rename
-I interaction
-F Mandatory
-N does not overwrite existing files, so-I and-F are invalidated.
Touch Change the file access modification time, create a new empty file
Touch myfile file does not exist on new file, file exists on Change access and modification time to current time
Mkdir New Catalog

mkdir test1

-V Displays information each time a new directory is created

-P Create a multilevel directory

MKDIR–VP Test1/test2/test3

User environment:

Clear Clear screen, equivalent to the CLS in Windows

Histrory

View history Commands
Su SU User name Switch user
WhoAmI

Who the current user is, is useful when you are constantly converting an identity operating system.

For example, just starting the user is Ken, after running the command Su Yan, identity becomes the Yan user, Su root after the identity becomes the super user

This command comes in handy when you need to know which user you are currently working with.

Sudo Run as Super User
passwd

Change Password

Exit

Exit
Env Display shows all environment variables and values

Program:

Ps To display a running process
-L Long format
-F Tree Format
-a Show all user processes
-R Running Process

How many CPUs the%CPU process is using
How much memory is being used by the%MEM process
Memory address of the ADDR process
C or CP CPU usage and scheduling information
command* process name, including parameters (if any)
NI Nice value
F Mark
PID Process ID
PPID Parent Process ID
PRI Process Priority
RSS Real Memory usage
S or STAT process status code
Start or stime process startup time
SZ Virtual Memory usage
Time Total CPU Usage
tt or TTY with process-related terminals
UID or username of user process Owner
Memory address of the event that the Wchan process waits for

Top Dynamic Display Process

Kill

kill–9 20345 force kills 20345 process
Date Display and set the system date and time
Time Executing commands and timing
Aa. Show Calendar

Find and edit:

Awk

The file is read line by row, with a space as the default delimiter will be sliced each row, cut the part of the various analytical processing.

$ A represents all fields, representing the first domain, $n represents the nth field. The default Domain delimiter is the "blank key" or "[tab] key"

Last-n 5 | awk ' {print '} ' shows the 1th column of last-n 5 execution results

CAT/ETC/PASSWD |awk-f ': ' {print $} ' per line: separator

Head

Head-n file1 Display the first 10 lines of the file

Tail tail–f file1 dynamic Monitor file growth
Tail–n file1 display file after 10 lines
Wc

Displays the number of lines of the file in bytes file name.

-C Count bytes.

-L counts the number of rows.

-M counts the number of characters. This flag cannot be used with the-C flag.

-W count words. A word is defined as a string separated by a blank, a jump, or a newline character.

Vi Study site: http://www.cnblogs.com/88999660/articles/1581524.html
Find Find Files
You can use the logical operators and, or, and not to correspond to –a-o!
Find–name ' *.bak ' –o–name ' *.log '
Find it! –name ' File1 '
-group Specifying groups
-user the specified user
-empty finding a directory or file of size 0
Reference: http://blog.chinaunix.net/uid-20082146-id-83489.html
Grep Http://www.cnblogs.com/end/archive/2012/02/21/2360965.htm
Whereis Truncate the path to the front end of the provided file name parameter with the extension part of the backend and find out the special file with which the file name matches
Lookups are primarily for locating targets in the path of an environment variable, and are typically used for program command location lookups
More Split screen Display
Xargs Convert a parameter list to a small segment to pass to another command
Http://zh.wikipedia.org/wiki/Xargs

Other:

man man ls view command manual

Shutdown

shutdown–r now restart
shutdown  now shutdown
ping ping xx.xx.xx.xx  Detect network Connectivity
ssh Telnet, now log in more with the tools of SSH
netstat http://www.cnblogs.com/g gjucheng/archive/2012/01/08/2316661.html
nohup http://www.2cto.com/os/201301/185701.html

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.