Common UNIX Commands

Source: Internet
Author: User
Tags chmod clear screen file copy file system split touch valid file permissions

First, matters needing attention

The command and argument must be separated by a space, and the arguments and arguments must be separated by a space.

A line cannot be more than 256 characters, and case sensitivity.

Second, the meaning of special characters

File name with "." Start with hidden files/directories, just add "." in front of the file/directory name. You can hide it.

~/represents the home directory.

./current directory (one point).

.. /Top level directory (two points).

; Multiple commands are used together.

> >> output redirection. Writes the output of a command to a file. If the file exists, the contents of the file are overwritten;

If it does not exist, create the file before writing the content.

Output redirection, meaning that the original screen output becomes a file output, the content is exported to the file.

< << input redirection. The original command was entered via the keyboard, but with the less than sign, the command can be entered from the file.

Indicates that the carriage return is not completed and continues.

* Matches 0 or more characters.

? Matches one character.

[] matches the contents of the brackets [a-z][a-z][0-9].

! Event.

$ to fetch the value of the environment variable.

| Pipeline. Use the output of the previous command as input to the latter command, and connect several commands together.

| often with tee, tee saves the content to the document and displays it.

Third, universal followed by the command character

-A (all).

-e All (every), more detailed than a.

-F Remove protection.

-I add a hint.

-P enforcement.

-R Directory Management.

Split-screen display midway operation

Space continues to open the next screen;

Enter to continue to open the next line;

B In addition to open a screen;

F In addition to open the next screen;

h Help;

Q or CTRL + C exit;

/string to find a matching string from the top down;

The string looks up the matching string from the bottom up;

n continue to find.

Iv. Exit Order

Exit exits; The DOS internal command is used to exit the current command processor (Command.com) before resuming a command processor.

Ctrl+d the same effect as exit, the table aborts this operation.

Logout can be used to exit when CSH, other shells are not available.

Clear clear screen, erase (previous content is not deleted, just don't see, pull back above can look back).

V. Directory Management Commands

PWD Displays the current directory and prints the absolute path of the current directory.

CD into a directory, DOS internal commands to display or change the current directory.

CD Enter/CD ~ All back to their home directory.

Cd. The current directory (space plus a point).

Cd.. Go back to the top level directory (spaces plus two points). Cd.. /.. Up to level two.

Cd/home/hww/person from the absolute path to a directory.

CD ~/person directly into a directory under the home directory ("CD ~" is equivalent to the path of the home directory).

LS Displays all directories and files for the current directory.

Usage ls [-aabccdeeffghhillmnopqrrstux1@] [File ...]

ls/etc/displays all files and directories under a directory, such as in the ETC directory.

Ls-l list displays files (by default, sorted by file name),

Displays the permissions of the file, the number of hard links (that is, the number of files included, the normal file is 1, directory 1+), user, group name, size, modification date, file name.

Ls-t (time) displays directories and files, sorted by modified times.

Ls-lt is a combination of "-l" and "-T" that displays the list in chronological order.

LS-F Displays the file type, the end of the directory "/"; the end of the executable file "*"; the text file (none) with no end.

Ls-r recursively displays the directory structure. That is, the files in the directory and the files under each sub-directory are displayed.

LS-A displays all files, including hidden files.

File permissions

R Read permission. For a normal file, it is the permission to read the file, and for the directory, to obtain the file information for that directory.

W Write permission. To the file, is modified; to the directory, is to delete the files and subdirectories.

(Note deletion of files without write permission can be used rm-f, this is for the convenience of operation, is humanized design).

x execute permissions; to the directory, enter the directory

-Indicates no permissions

Form-rw-r--r--

The first one is file type (-table plain file, D table directory, l table soft link file)

The 2nd to 4th one is the owner, the person who logged in when the file was generated, the highest privilege, the U represents

The 5th to 7th is a group, the system administrator assigned the same group or a few people, using G to represent

The 8th to 10th is the other person, except the group of persons, using O to indicate

All persons, including owners, genera and others, are represented by a

chmod Change permissions;

Usage chmod [-FR] < absolute mode > File ...

chmod [-FR] < symbol mode list > File ...

where < symbol mode list > is a comma-delimited table [Ugoa]{+|-|=}[rwxxlstugo]

chmod U+RW gives the user permission. Similarly, U-RW can also reduce permissions.

chmod U=RW assigns permissions to the user. Unlike add permissions, assigning permissions has an effect of overwriting.

There are several main forms:

chmod U+RW chmod U=RW

chmod u+r, u+w chmod u+rw,g+w, O+r

chmod 777 (a digital way to set permissions is the most common)

When a number represents a privilege, each digit represents a master, a group and other persons;

Where 1 is execution (execute), 2 is write permission (write), 4 is Read permission (read),

Specific permissions are equivalent to the addition of three kinds of permissions, such as 7=1+2+4, which has read-write and execution rights.

In addition, the temporary file/directory permissions for RWT, can be written but not deleted, after the shutdown automatically deleted; Build temp directory: chmod 777 directory name, then chmod +t directory name.

ID Displays the user's valid UID (user word) and GID (group name)

Usage ID [-AP] [user]

ID to show your own.

ID root Displays the root.

Id-a Root displays all the group names of the user's group (for example, root user, is a member of all groups)

DF View File system, view data area

Usage DF [-f Fstype] [-abeghklntvvz] [-O fstype specific options] [directory | block device | resources]

Df-k View file system mode with Kbytes display file size

Vi. displaying the contents of a file

More split screen displays the contents of the file.

Usage more [-CDFLRSUW] [-line] [+ line number] [+/mode] [filename ...].

displaying 7 messages: User name password User ID (UID) group ID (GID) description information (typically empty) user home directory login shell (login shell)

Cat display file content, no split screen (generally used in small files, large files are not displayed); Merging files, merging on the screen only, does not change the original file.

Usage Cat [-USVTEBN] [-| file] ...

Tail real-time monitoring files, generally used in log files, you can see only a few lines.

Usage tail [+/-[n][lbc][f]] [file]

tail [+/-[n][l][r|f]] [file]

Vii. additions and deletions of documents/directories

echo displays a line of content.

Touch if the file/directory does not exist, create a new file/directory, or if the file exists, it is the last access time to update the file.

Usage touch [-ACM] [-R Ref_file] File ...

touch [-ACM] [mmddhhmm[yy]] file ...

touch [-ACM] [-t [[cc]yy]mmddhhmm[. SS]] File ...

mkdir Create directory (must have permission to create directory)

Usage mkdir [-M mode] [-p] dirname ...

mkdir Dir1/dir2 in Dir1 under the construction of DIR2

mkdir dir13 DIR4 DIR5 built multiple

mkdir ~/games User Home directory (created by default in the current directory)

Mkdir-p DIR6/DIR7/DIR8 forces the creation of DIR8; Dir6 and DIR7 are created automatically if there is no previous directory.

Without-p, if there is no dir6/dir7, the creation fails.

CP Copy files/directories

CP source file target file Copy file, if existing file is overwritten

Cp-r Source directory directory to replicate directory, if existing directory to copy the source directory to the target directory,

When there is no target directory, it is equivalent to fully replicating the source directory, except for the file name.

CP beans Apple Dir2 copy beans, Apple files to the Dir2 directory

Cp-i beans Apple to increase whether or not to overwrite the hint

MV Move or rename files/directories

Usage mv [-f] [-i] F1 F2

MV [-F] [-i] F1 ... fn d1

MV [-F] [-i] D1 D2

MV source file name destination file name if the destination file name is not already present, the source file is renamed to the destination, and if the destination files exist, the source file overwrites the target file.

MV source file name destination directory move file

MV Source Directory Destination directory if the destination directory does not exist, the source directory is renamed, and if the target directory already exists, the source directory is moved to the target directory.

RM Delete files/directories

Usage rm [-firr] File ...

RM file name to delete the file.

Rm-r Directory name to delete directory.

The rm–f file can be forcibly deleted with this command parameter as long as it is the owner of the file or directory, whether or not it has permission to delete it.

RM-RF * Delete all files and directories

RmDir Delete Empty directory. Only empty directories can be deleted.

LN creates a hard link or soft link, a hard link = multiple names of the same file; soft link = Shortcut

Usage ln [-f] [-n] [-s] F1 [F2]

ln [-f] [-n] [-s] F1 ... fn d1

ln [-f] [-n]-s D1 D2

ln file1 FILE1.LN creates a hard link. The feeling is the same file, delete one, has no effect on another; two deletes are required.

Ln-s file1 file1.sln Create a soft link. Can operate across the system, break the operational rights, is also a shortcut.

Eight, time display

Date display time, accurate to seconds

Usage date [-u] mmddhhmm[[cc]yy][. SS]

Date [-u] [+format]

date-a [-]SSS[.FFF]

Cal Display Calendar

Cal 9 2008 shows the calendar for September 2008; Cal Displays the current month's

Usage cal [[month] year]

Nine, help

Man Help (format and display the on-line manual pages)

Usage man [-] [-ADFLRT] [-M path] [-t macro package] [-S segment] name ...

Man [-] [-ADFLRT] [-M path] [-t macro-package] [-S section] name ...

Man [-M path]-k keyword ...

Man [-M path]-f file ...

awk output in a certain format (pattern scanning and processing language)

Usage awk [-FC] [-F Source Code | ' Cmds ' [file]

Ten. View Users

Users displays online users (only user names are displayed).

Who shows online users, but more detailed than users, including user name, terminal number, logon time, IP address.

Who am I only show myself, (but including user name, port, logon time, IP address; information =who).

WHOAMI also only displays itself, but only the user name (showing its own valid user name).

W displays more content than the WHO, including idle time, CPU, CPU, and execution commands.

Usage w [-HLSUW] [user]

Su changes the user and needs to enter the password again.

Usage su [-] [username [arg ...]

Su-the equivalent of exiting and then logging back in.

Find

Find File

Use Find [-H |-l] PATH list predicate list

Find/-name Perl looks for a file named Perl from the root directory.

Find. -mtime 10-print from the current directory to find the files that are modified 10 days from now, displayed on the screen.

(note "10" means the 10th day; if "+10" means a range beyond 10 days; " -10 "indicates the range within 10 days. )

Search for characters in the grep file; filter to list only what you want

Usage grep-hblcnsviw mode file ...

Like grep abc/etc/passwd find the ABC character under the passwd file

WC statistics

-L count rows; -W statistical number of words; -C Statistical Character count

such as grep wang/etc/passwd|wc-l statistics passwd file with "Wang" line number

Du view directory status

such as Du-sk * does not add-s will display subdirectories,-K sorted by kilobytes

Usage du [-a] [-d] [-h|-k] [-R] [-o|-s] [-h|-l] [File ...]

XI. Process Management

PS Display process.

Usage PS [-aadeflcjlpyz] [-o format] [-t Item List]

[-u user List] [-u user List] [-Group G list]

[-P Process list] [-G program group List] [-s identifier list] [-Z Area list]

PS shows its own process.

PS-E shows each process, including idle processes.

Ps-f Show Details.

PS-EF Combination-E and-F, details of all processes.

Ps-u uidlist (user list) to see the process of a person in detail.

Kill

Pkill

Sleep

Jobs

Usage jobs [-l]

FG%n

BG%n

Stop%n hangs (only CSH can be used)

CTRL + C

CTRL + Z

Network links

Ping

Usage ping host [timeout]

Usage ping-s [-l | U] [ADLNRRV] [-A addr_family] [-C Traffic_class] [-G Gateway [-G gateway ...]] [-F Flow_label] [-I. Interval] [-I. Interface] [-P TOS] [-P Port] [-t TTL] host [data_size] [npackets]

Ifconfig-a

/sbin/ifconfig View the IP address of this machine

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.