Linux Getting started the next day-Getting started with basic commands (top)

Source: Internet
Author: User
Tags clear screen custom name

first, the common command introduction

Common commands can be consulted: http://man.linuxde.net/

  Common shortcut keys : http://blog.csdn.net/avilifans/article/details/11847371

Tab: Click Complete, double-click List all ↑↓: History command Flip Ctrl+C: Force termination
Ctrl+d: Equivalent to enter exit, exit Ctrl+L: Clear Ctrl+A/E: Move cursor to beginning/ End ...

Frequently used help instructions (learn about Linux which complex options can be found through Help:)

 http://blog.csdn.net/chenghuikai/article/details/45219017

 Full English name for common commands:

Https://www.cnblogs.com/DreamDrive/p/6945523.html

  

Second, the command format

  Before the introduction of the command, first introduced $path this thing, this is our previous on the win platform introduced "system PATH variable", the input command is in the directory specified by the path variable, so we can use the path of LS in any location

Just as we have configured Java's PATH environment variable to use Java in any directory of any CMD window, Linux has a similar path, which is also a bunch of directories, and we can use the Echo $PATH to view:

  

  Multiple paths in path use a colon: split, and there is a number of points (different user path), if the same command in a different directory, then the first match to use the one found.

To add a custom directory, you can use: path= "${path}:/root"

Look at the format before you see the meaning of the login prompt character :

  

 which

     root represents the username, and the administrator in Linux is root

    localhost table hostname

    ~ represents the current location (home directory, where the root user's home directory is /root, is a first-class directory, and the other is a level two directory of /home/user1 )

    # Super User prompt

$ Normal user prompt

  Command format

    command [options] [parameters]

      Individual commands do not follow this format

Can be written together when there are multiple options

Simplified and complete options:-A and--all

We learn the format of a command by learning the first command:

    query contents in directory :ls

    

    Instance:

  

  Among them, the front of the-RW-------represents the permissions, the permissions are divided into 10 bits, the specific following:

  The first bit is file type (7 main types)

d: Folder -: Normal file L: Link (shortcut like Windows) B: block device file (e.g. hard disk, optical drive, etc.) p: Pipe file C: Character device file (e.g. Cat serial device) s: Socket file / Data interface files (for example, a Mysql.sock file is generated when a MySQL server is started)

The last 9 bits are divided into three groups, three groups, respectively: owner, Group, others (refers to the relationship between the user and the file), for example, here Follow the U g o match

Note that the location of the three permissions does not change , and if there is no permission, a minus sign [-] is present.

Owner is root ( with read and Write permission ), the owning group is the same group as root ( with reading permission), others ( with Read permission )

1 indicates the number of connections, followed by root root to represent the group that the owner belongs to, and then the file size represented by the number

The size behind here is a bunch of numbers, and we use the human command option-H mentioned above, using the display details with the humanized size combination option-LH:

  

followed by last modified time and file name

Note : If the file name is preceded by one more. ", then this file is" hidden file

Parameter information such as view specified directory (such as etc directory): ls-lh/etc/

note : for general files, RWX is primarily for " The contents of the file "to design permissions,

in LS This command displays a list of the contents of this directory!  W  (Modify contents of directory): This writable permission is great for the directory! Because he says you have the right to move the directory structure manifest, which is the following permissions: Create new files and directories, delete files and directories that already exist, regardless of the permissions of the file! Rename a file or directory that already exists, and move the file or directory location within that directory. In summary, the directory's W permission is related to the file name of the directory under the different action! X (Access directory): Gee! What is the use of directory execution permissions? The directory is just a record file name, you can not carry it? That's right! The directory cannot be executed, and the X of the directory represents the user's ability to enter the directory as a working directory! The so-called working directory is the directory where you are now! For example, when you landed Linux Bird's Linux private cuisine: Basic Learning Article Fourth edition 2725.2  Linux file permissions concept, your home folder is your current working directory. The command to change the directory is "CD" (Changedirectory)! 
View Code

"Update": Change file permissions:

    Once you know how to view permissions, let's see How to Modify permissions (permissions are important in Linux)

chgrp : Change the group to which the file belongs Chown : Change the file owner chmod : Features that change file permissions, SUID, SGID, Sbit, and so on

    Example: Change owner: Chown root:root-r/home/java/jdk1.8.0_131/

If you want to change permissions, you can use the following two ways:

  1. Digital type

RWX respectively corresponds to 421, so that our rwx permission is the sum of the results, for example, rwx for 7,rw-to 6, so that the shape of the following forms of permission commands:

chmod [-R] xyz file or directory options and parameters: XYZ: Is the permission attribute of the number type just mentioned, which is the sum of the numeric values of the Rwx property. -R: Continuous change of recursive (recursive), that is, all files in the secondary directory will be changed

Example: chmod 777. BASHRC

 2. Symbolic type 

The form is as follows:

chmod W x | file or directory # # #    where the U g O represents the previous user group others, and a indicates that all    available operations have a direct assignment (using =), or do not know the original permissions, but only want to give everyone a permission, Use the +

  Example: Set permissions as follows:-rwxr-xr-x (note that the order of rwx is not changed, that is, Rx is actually r-x)

chmod U=rwx,go=rx. BASHRC

chmod a+w. BASHRC

  See also : http://www.cnblogs.com/peida/archive/2012/12/04/2800684.html

 About the default permissions of the file Umask, where the umask of the following three bits means "take off the permissions, here Note that the file default only RW, directory has rwx can take"

So for the file umask the maximum value is 666, and the directory is 777 (this part of the suggestion see Bird's private cuisine introduction)

If you want to modify the Umask, directly enter the number, such as Umask 002--usually, Root will take away more permissions, generally 022, and the average user is 002

  Of course, in addition to the general properties, you can also set some hidden properties of the file (for example, let the file only increase can not be reduced-such as log files), here temporarily do not expand the file's hidden properties of the operation.

Special permissions S&t will be added in the future!

third, file processing command

  1. Directory Processing commands

    Concepts similar to folders in Windows

Common Special Directories:

represents this Layer directory: represents the previous level of directory-represents the previous working directory ~ represents the home folder of "Current user identity" ~account represents account The user's home folder (account is the name of the username)

    build directory :mkdir

  

  Recursive creation is like creating a directory and then creating a subdirectory

  Instance:

  

  You can see that if you do not apply-p directly create a level two directory will be an error

The directory created by default is the default permission used, and you need to restrict permissions using the-m parameter:

mkdir 777 Testdir1

    Switch directory :CD

(Ctrl + L clear screen)

Instance:

  

  Among them. /user equal to relative path/etc/as absolute path

  "Tab key": In Linux, click the tab will be prompted (if only one, will be automatically complete, if there are multiple, press two tab will list all options)

And, in addition to the directory completion, the command can also be automatically complete!

    Query Directory location :pwd

  Instance:

  

Delete empty directory :rmdir

 Because of its intelligent deletion of empty directories, the actual use of the frequency is very small, we use the following RM command

    Delete files or directories : RM

  Instance:

  

 If you do not want him to keep the hint, you can use the above,rm-rf jiangxi/, you can force the deletion without prompting (the command line cannot be recovered)

Note: Root in Linux is the real root, it can be executed: RM-RF/ (delete root), so that the Linux "suicide", it will be executed.

So we should recommend that the Delete command is : rm-r jiangxi/ This form (even if the file is deleted, also with the-R)

    2. File processing commands

    Copy command :CP

  Instance:

 Note here, copy a single file directly using the basic command , if the following directly with/tmp/, then the original copy, if the custom name, then by the custom copy

    To copy the directory, keep up with-R, otherwise you will be quoted an error in the map!

Copied files It is worth noting that the modification time will be problematic (unlike real machines, power outages and motherboard points continue to be timed, not in-depth expansion, to be added)

Show System time:

       

  When you copy a file, the-a option is added, which will make the copy identical to the source file, usually using the-a option when we need to copy the permissions, and the file permissions by default are instruction operators (including time attributes and other hidden properties)

  also, when you need to create a link, you can create a hard-soft link using-l-s , as you would see in the symbolic link with the following: http://blog.csdn.net/niluchen/article/ details/8049304

 Finally, the following questions must be considered carefully when you are ready to use CP:

Do you need complete information about the source file? Is the source file linked (Symbolic link file)? is the source file a special file, such as FIFO, socket, etc.? is the source file a directory?
View Code

Note:the alias of Ls-l is ll

    Cut or rename :mv

  Instance:

  

  Note here that MV clipping does not need to add-r, whether it is a directory or a file (the cause of inconsistency caused by multi-person development)

If the source and destination files are in the same directory, it is renamed: MV Ana ana001; Modify the file name

  Common level of directory role

  

   Please revise the bright color carefully!

  

 Reference : http://blog.csdn.net/u013239236/article/details/48845251

  

You can generally use the MNT mount

  

All blanks are ibid.

General Linux is a rigorous operating system, generally recommended operator directory/root or/home (corresponding to administrators and ordinary users)

  "Update": 2.5. File content View

You can use the more commonly used to do the relevant paging file content view, related options Please refer to the manual

  "Touch Instructions": "Touch the file", update the file time or create a new file

About the time of the file, refer to:

/etc/man_db.conf, the atime of the file will be updated. 
View Code

"File directives" in addition to viewing the file, you can also view the properties of files, use man file

3. Link commands

link command :LN

  Since there are soft and hard points, let's look at the specific soft and hard distinction

  The front and rear doors are in the same classroom, closed a door, can also open from another door, the classroom still open normally. Do not recommend using

 Instance:

Create Hard links without options

  

  Instance:

  Special note the soft link color is different, and the source file location is marked out

If you do a soft link, use the absolute path!

Linux Getting started the next day-Getting started with basic commands (top)

Related Article

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.