"Linux file View, operation"

Source: Internet
Author: User
Tags parent directory set time

First, how the shell handles commands
    • 1.shell divides the command into multiple parts based on the space characters that appear in the command
    • 2. Determine whether the first field is an internal command or an external command
Internal command: Command path built into the shell (shell builtin) external command: The command paths installed by installing another application or service: The hierarchical relative path of the directory that is necessary to find or locate a file: The path to find from the working directory. Current working directory: The parent directory of the parent directory root of the current working directory is also the root absolute path: The path variable to look up from the root (/): Memory space variable value: null variable for data stored in memory space: Empty environment variable Path (path), absolute path: path=path1:path2:path3: ...
    • 3. Determine whether the other field is an option or a parameter, correctly judged, if it is executed correctly, and returns an error message if the error
    • 4. Press ENTER during command writing to submit the written content to the shell for execution
    • 5. If you want to cancel the command before submitting the shell, use CTRL + C

Second, file view, operation

Help class
Man,help,info,whereis,which,whatis
Directory Operation class
Ls,pwd,cd,mkdir,rmdir
File Operation class
Nano,touch,rm,cp,mv,stat
File View class
Cat,tac,head,tail,less,more
Text Processing
Cut,sort,uniq,tr,sed,awk

1. View
    • Ls-->list
The list displays the contents of the Directory usage:ls[OPTION] ... [FILE] ... []: Optional Content {}: Required content|: Selecting a default parameter is the working directory option:-L: Long format output-RW-------.1Root root1211May One  .:Genevaanaconda-ks.cfg The first bit indicates the type of file:-: Denotes normal file (f,fileB: Indicates block device file (block) C: Character device file (charact) d: Directory file L: Symlink file (symbol link) P: Pipe file (pipe) s: Socket file (socket) second to tenth bit: file's permission bit, three sets of permission bits , each group includes three permission characters, rwx, read and write execution. If you don't have permission, use-instead of the second paragraph, number 1: Indicates the number of times the file has been hard-linked third paragraph: The owner of the file, root fourth: The file see the group, root fifth: The size of the file, the default in bytes to display the sixth paragraph: timestamp (access time, modification time, Change time) Access time: Access Timestamp modified: Modified timestamp (change the content of the data, edit the contents of the data, called modification) Change the time: changes timestamp (metadata, meta data, Edit to metadata is called change) Seventh: file name in Linux, with a. Character as the first character of the filename, is the hidden file-A: Show all files, including hidden files-A: Displays all files, including hidden files, but does not include. and.-h: Display in a human-readable way-D: Replace the property output of the internal sub-file with the properties of the folder-r: Reverse Display-R: Recursive display (recursive)-Z: Show file security context

    • Cat
View Files
-N: Give all line numbers -B: no blank line numbering
Reverse display of TAC Cat

    • Head
Head 3 head 3head: View 50 bytes head -C 1b: View the contents of a sector 512 bytes

    • Tail
start viewing from the end. Option analogy head-F: Content changes at the end of a real-time monitored file

    • More
Page shows the contents of the file only to look back

    • Less
    • Whereis
Displays the binary file of the command, the Help manual path

    • which
To see where the file is, only the binary file path is displayed

    • Whatis
Show Help manual Path only

    • Stat
View file properties (Access time, modification time, change time)

2. Directory operation
    • Pwd

Show working directory (absolute Path) The default working directory is the home of the/root,root user (the host directory), and the first directory where the default user logs in is the host directory

    • Cd

Switch working directory
If there are no parameters, then the default parameter is the user's host directory
CD ~: Switch to the host directory
CD-: Switch to the working directory you used last time

    • Mkdir

Create a Directory

mkdir-p: Create a parent record before creating a subdirectory -V: Displays the Create folder verbose procedure command expansion function, using {}, separated by commas

    • RmDir

Delete directory (only empty directory) if a directory is only. and., then you think this directory is empty
rmdir [OPTION] ... DIRECTORY ...

    • Rm

Removed from

RM [OPTION] ... FILE ... Option:-r: can delete directory -F: Force delete

    • Type

Distinguish whether commands are internal or external commands

Get help internal command: Helper internal Command external command: Mans  Info--help

3. File editing

    • Echo

-N: Do not output line break symbols
-E: Make backslash effective

    • Nano
text Editing Tool, enhanced version of Pico^: Caret 1. Typically, the CTRL key is equivalent to 2in edit mode. In other uses, there are different meanings, such as: can take counter , you can indicate that line breaks are default at the beginning of a line, a newline character is equivalent to a byte ctrl+o Save Ctrl+x exit

    • Touch

Changes the timestamp of the file. A file is created when the file does not exist
-A: Only modify the access time of the file
-M: Modify only the file modification time
-C: Do not create files

4. Time command
    • Clock

Hardware time

    • Date

System time

Set Time:1.DateDay of the month and year. SecondsDate 091703282015Thu Sep - Geneva: -:xxCst -2.Date-S "Year/month/days: minutes: Seconds "Date-S"2015/09/17 15:32:11"Thu Sep -  the: +: OneCst -3.Date+%y

    • Hwclock
RTC: Real -Time clock-s synchronizes hardware time to system time -W  time to synchronize system time to hardware time touch defaults from system time

    • BC Calculator
    • Cal: Calendar

5. Text Processing
    • Cut
Remove sectionsfrom all line of files-d indicates delimited, default space 1  first column eg:cut1 /etc/passwd
Cut-d:-F 7/etc/passwd | Sort | Uniq-c

    • Sort
Sort lines of text files sort, default order ASCII encoding -N: By number size, from small to large -r: Reverse -t: Indicates the separator symbol -k: Indicates the operating area /c5>-u: If there is more than one duplicate of the content is displayed as a line, equivalent to the Uniq command sort3 /etc/passwd

    • Uniq
sort -u-C: Counts the number of consecutive rows of duplicates -u: only output unique rows (discontinuous repetition)

    • Tr
Character Set Conversions TR ' AB ' ' AB ' </etc/passwd -to-bit replacement

    • Wc
Word counter WC byte  for file-l displays only the number of rows-w   displays only thenumber of characters-C shows only the character Count WC /etc/passwd  1427 /etc/passwd

"Linux file View, operation"

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.