Linux Learning Basics 1

Source: Internet
Author: User
Tags file copy parent directory

A basic knowledge of Linux

1.1 ls Displays the current directory or file Ls-l view the details of the file Ls-ld view the directory details

-rw-r--r--. 1 root root 969 2 months yum.conf

First field: file type; the types of files in Linux have the following categories 1-binary file d directory C character device file

B Block Device file (block), p (pipe) pipe file, S (scoket) socket file, L link file.

The second character rw-r--r--9 characters each three a group represents the permissions of the other person in the group to which the owner belongs;

R: Read permission, W: Write permission, x: Execute permission, here to explain is the file read and write execute permission and the directory read and write Execute permission difference

The Read permission of the file indicates that the contents of the file can be viewed, such as cat less

Write permission indicates that the contents of the file can be modified

Execute permission representation can be executed as a program

The Read permission of the directory indicates that information such as LS can be viewed in the directory file, but cannot be used at this time ls-l

Write permission indicates that a file can be created in the directory

Execute permission represents CD into this directory when he has both execute and Read permissions, you can use Ls-l to view the details of a file

Third Field link number

Fourth field Fifth field owner belongs to group

Size of the Sixth field file Note: If the device file is not displayed at this time, the size of the file represents the primary sub-device number

Seventh field last access time any file or directory has three time 1access 2modify 3change

Access represents the time modify represents a modification to the contents of a file, and any modification to this will affect the change time

The check for these three commands is the STAT command: Stat file name


1.2 Ways to get help

There are two kinds of commands in Linux, one is internal, and an external command can be viewed by type.

Type cd; CD is a shell builtin built-in command

Type install; Install is/usr/bin/install External command

The built-in command can be used to view the Help file using the command--help or the assist command

External commands need to use the man document to help

Man's help document is divided into the following categories of 1 ordinary user Commands 2 system calls 3 library calls 4 device files 5 file Formats 6 Games 7 Miscellaneous 8 administrative commands; You can view the Help documentation for external commands by using the Whatis command:

[Email protected] tmp]# whatis sed

SED (1p)-stream editor

SED (1)-stream editor for filtering and transforming text

The Help file here is opened in the form of more documents, you can use the space key to turn back one screen enter to turn back half screen b forward one screen;


1.3 command on the date

Date display is System time Hwclock indicates hardware time hwclock-w set hardware clock to synchronize from system clock

Hwclock-s setting the system clock to synchronize from the hardware clock

Date 1114212216.30 indicates that the current time is November 14 21:22 16 30 seconds (Note the format at this point)

Sometimes we can need a specific time display format as we use date directly

[[Email protected] tmp]# Date

Monday, November 14, 2016 21:23:30 CST

[Email protected] tmp]# date +%y%m%d%h%m%s

20161114212432

This digital display mode is remembered only if the sun and moon are lowercase and all uppercase.

Cal 2016 View calendar

Cal 12 2016 view 2016 December calendar

1.4 Common File Operation commands

1 Create a file touch; A touch file represents the creation of a file when the file does not exist, which means the update of its access time when the file exists

Touch

-A with new access time

-M update Modify time

-C do not create file

-s-a set access time to the specified time format for [[CC]YY]MMDDHHMM[.SS]

2 Creating a directory mkdir

-p recursively Create a directory

-V shows its execution process

Mkdir-p/tmp/{x,y} = mkdir-p/tmp/x/tmp/y

It's in the right time. {,} Linux Expand the comma-delimited character in the curly braces

3 copy of the file CP

-R or-R indicates that its subdirectories are all copied

-p means to preserve the original properties of its files; Here note that the default is only when you copy a file with the CP command, the file's owner is currently logged on as the system user, such as the current system login is root he copied the User1 file after the copy of the file owners are root, in order to maintain the original file properties must use the-P option , although the-p option was used to copy a soft link to the original file for the soft connection file, the soft connection itself must use-p (uppercase), and the-r option can be used with-a (archive backup);

Description of the file copy CP file1 file2 when File2 does not exist, it means to copy the file1 and change the name File2, when the File2 file exists, the File1 file is overwritten in the File2 file;

Description of directory replication CP dir1 DIR2 when directory 2 does not exist, the directory 1 is copied and renamed to Dir2, and when Dir2 is present, the directory 1 is copied to the subdirectory of directory 2;


4 The Cut MV Cut command of a file does not require the-r option as a file and directory operation

5 Install Copy files (and add execute permissions) install can only copy files cannot copy directory

install-d Creating a Directory

install/etc/passwd/tmp/passwd

6 du viewing the file size (you can view the file or the size of the directory)

Du-s viewing only the total size of a file without the-S option defaults to the size of all subdirectories in the directory, respectively


7 LS View the properties of a file

-L View detailed properties

-a show all files including hidden files including their parent directories

-a same as-a but does not display the parent directory

-I displays its I node number, the so-called Inode represents the unique identifier of the file, when the file name is more specific, you can delete its inode to delete the file


8 echo Print out

-E means that a specific escape character is used to indicate a special meaning such as \ n line break


9 ID View basic information for the current user

-U view its UID (file name)

-G view its GID (basic group)

-n-u indicates that its user name is displayed

-G view its attachment group

groups for general users The default group is called the base group , and If you do not specify its base group when creating a user, the base group is called a private group for a group that has only one person. However, when the user is created, other groups are specified (not private groups) This group is also a basic group but it is not a private group other than the base group is called an additional group or an additional group.

1.5 Viewing of text files

1 cat

-N Displays the number of rows per row

-e Displays the terminator of each line; Note that the line ending symbol for the Linux text file is $, while the line end symbol for Windows is enter+$;

2 more view text document the man document is viewed with this command, and when you look at the document, you can also use the search

/keyword search backwards? Keyword search forward from behind

The 3less command is the same as more but less will not exit at the end, but more automatically exits

4 Head indicates the first 10 lines of the file are viewed by default from the beginning of the file header

Head-1/etc/passwd View First row

5 tail means viewing from the end of the file to see only 10 rows by default

Tail-1/etc/passwd indicates the last line to view

The Tail-f/file indicates that the last 10 lines of the file are viewed dynamically and will be displayed as soon as the file is updated.


1.6 Editing and viewing of text files cut sort Uniq WC join TR

1 cut-d:-F1,3/ETC/PASSWD represents the first field in the delimiter and the third field displayed as:

-D indicates that the specified delimiter-F represents the specified delimited field

2 Sort the default effect is sorting (sorted by the first letter of the first character)

-t specifies the delimited notation memory mode direct

-K Specify delimited fields

-N Sort by number

-U means that the same duplicate rows are displayed only once

-F ignores character casing ignore case

-R indicates reverse display

SORT-T:-k1,3/etc/passwd

3 Uniq Show Duplicate rows

-D duplication Show only duplicate rows

-C count Displays all rows and displays the number of repetitions

4 WC display text file number of words in bytes

-L line display number of rows

-C Display of bytes

-W Word Display word count

-L Displays the maximum number of bytes in a row

5 Join represents a connection and displays

Join Fiel1 File2

The cat File1 displays as follows

Hello 95

Linux 85

Test 30

The cat Fil2 displays as follows

Hello 2005

Linux 2009

Test 2006

Join Fil1 FIL2

Hello 95 2005

Linux 85 2009

Test 30 2006


5 TR convert or delete characters

TR [option] .... SET1 [SET2] where set represents the character set

[Email protected] one]# echo "Abcdeee" | Tr-d ' AB '

Cdeee

2 Convert all lowercase letters in the/etc/passwd file to uppercase

Tr ' A-Z ' A-Z ' </etc/passwd the default TR is not parameters, so here's a redirect to send it to him.





This article is from the "CCNA Study notes" blog, so be sure to keep this source http://2858259639.blog.51cto.com/8111214/1872816

Linux Learning Basics 1

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.