Shell Programming--shell Common commands

Source: Internet
Author: User
Tags clear screen create directory parent directory file permissions

Browser tab switch: Ctrl+tab

Terminal
Open Terminal Quick build: ctrl+alt+t
Close Terminal shortcut key: Ctrl+shift+q
Open a new Terminal tab shortcut: Ctrl+shift+t
Close the Terminal tab shortcut key: Ctrl+shift+w
Switch between terminal pages shortcut key: Ctrl+pgup
Terminate process: Ctrl + C
Exit Program: Ctrl+d
Open Web page in Firefox: Firefox www.baidu.com

Clear screen: Ctrl + L

[Column directory content LS]
Ls-a: List all files and directories
Ls-l: Long Format list
LS-F: Short format list, file name plus a symbol to indicate attributes, executable file plus x, directory/
LS-R: Recursively lists directories and their subdirectories
Ls-t: Sort by file according to modified time
[Create directory MkDir]
Mkdir-p a/b/c: Create parent directory and subdirectories at the same time
[Delete directory RmDir]
Rmdir-p a/b/c: Remove the empty directory when you delete a directory
[Delete file or directory RM]
Rm-r Mydir: Remove the empty directory when you delete the directory. This option must be used when deleting a directory
[Change working directory CD]
CD ~-: Switch to the directory you just left
[Display the file's top K-line content]head-n K Filetest
[Displays the last K line of the file]tail-n K filetest
[Show file contents or merge files Cat]
Cat-n myfile: Displays the contents of the MyFile file and adds line numbers for all rows
Cat file1 file2 > File3: Merge file1,file2 content into File3
Cat > MyFile: Read content from the keyboard and save it to file MyFile, end by Ctrl+d
[String Filter command grep]
Grep-i pattern [file]: The difference between ignoring the case
GREP-V pattern [file]: Reverse search, display mismatched content
[File Sort command Sort]
sort-f [file]: ignoring case
sort-r [file]: Output sort results in reverse order
Sort file1 > File2: Sort file1 in dictionary order and output to File2

[Make the newly modified initialization file effective without rebooting: source file]

[I/O redirection]
<: standard input redirection, usually referred to as input to a file
such as: WC </etc/passwd
Override mode standard output redirect. If the file does not exist, it is created; otherwise overwritten
such as: ls-l >/tmp/dir.out #覆盖方式
>>: Append mode quasi output redirect. If the file does not exist, it is created or appended to its tail.
such as: Ls-l >>/tmp/dir.out #追加方式

[File Rights Management]
Owner Rights U:user, group permissions g:group, external permissions O:other
Basic permissions: Read R:4, write W:2, execute x:1
[Change file Permissions chmod]: Add permissions +, delete permissions-, set permissions =
such as: chmod u+wx,g=rx,o-x testfile
[Change file owner Chown]:chown user filelist
[Change file belongs to group CHGRP]:CHGRP group FileList


[Process Management Basic command]
Ps-f: Viewing a running process
Kill-9 PID: Terminating Process Execution
Pstree: Process tree and Process status query
Top: Dynamic display of running processes
Uptime: Viewing elapsed time and average load of the system
Free: Shows the number of unused and used memory in the system
Vmstat: Reporting on virtual memory usage

[User Management]
System files related to users and groups:/etc/passwd,/etc/shadow,/etc/group
User management: Useradd,usermod,userdel
User group Management: Groupadd,groupmod,groupdel
User Password management: passwd
Example
Create user group: Groupadd groupname
Modify user group: Groupmod-n newgroupname Oldgroupname
Delete user group: Groupdel groupname
Add User: Useradd-d homedir-g groupname-m-S Shell accountname
Set Password: passwd accountname
Modify User: Usermod-l newname oldname
Delete User: Userdel-r AccountName


Shell Programming--shell Common commands

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.