Linux operating System 2 common Linux commands

Source: Internet
Author: User
Tags clear screen

Knowledge Content:

1. Directory and file operation

2. Command line edit shortcut keys

3. User management and user group management

4. Redirection, piping

5. System commands

6. Other commands

I. Directory and file operations

1.ls

Description: LS is a list abbreviation for listing a specified directory or file

Syntax: LS [options] [parameters]

Common options:

1 -A: Displays all files and directories (ls default file name or directory name is ".") As shadow, will not be listed)2 -A: Show save Shadow File "." and ".." 3 -D: Displays only the directory name, not the list of contents under the directory. Displays the symbolic link file itself without displaying the list of directories it points to;4 -L: Displays a list of contents in a long format. Output information includes file name, file type, permission mode, number of hard connections, owner, group, file size, and last modified time of file, from left to right
1 LS lists the files and directories in the current directory. No hidden files 2 ls-a  lists all files and directories in the current directory, including hidden files 3 ls-l  list details (without hidden files)  4 ls/home/list files and directories in the specified directory

The ls-l command output is as follows:

The information in each of these lines can be divided into seven segments:

The first segment of information represents the permissions for a file or folder, which is fully represented as drwxrwxrwx, and the first character d indicates that the file type is a folder

The following rwx, respectively, represent permissions, read | Write | excute,3 group RWX, respectively, the permissions of the file user, the user with the same group of people, other people's rights, if it is-indicates that users do not have this permission

The second segment of information indicates the number of hard links in the file

The third paragraph of information indicates the owner: root

The fourth segment of information indicates the owning user group: root

The fifth message indicates the file size in bytes

The sixth paragraph of information indicates the modification time

The seventh message indicates the file name

2.cd

Summary: CD is an abbreviation for change directory for changing the directory where the user resides

1 CD into the root directory of the current user (root directory is/root, the root of the other user is/home under the user directory)2 CD. Enter the current directory (CD ~ also enters the current directory)3CD: Go to the top level directory 4 cd/.../: Enter a directory (absolute directory)5 CD: Enter a directory (relative directory) 6 CD-Go to the previous directory

Note: The CD followed by the directory name will be directly switch to the specified directory, but after the CD can not be followed by the file name, the file name will be an error!. Indicates the current directory, ... Represents the previous level of the directory

3.pwd

Description: PWD is the abbreviation for print work directory for printing the current working catalog

1 pwd Print Current working directory

4.mkdir

Summary: mkdir is an abbreviation for make directory for creating catalogs

1 mkdir dirname Create a new directory directly under the current directory 2 mkdir-p dirname1/dirname2/... Create multi-level catalogs at once

5.rmdir

Summary: RMDIR is an abbreviation for remove directory, used to delete empty directories, which can only be used to delete directories cannot delete files, generally use RM instead of RMDIR

1 rmdir dirname Delete a directory under the current directory 2 rmdir-p dirname  Delete the specified directory if the upper-level directory of the directory has become empty directory

6.du with DF

Du: Viewing files in a directory for disk space usage

DF: View entire disk space usage

1 du displays the space occupied by the files in the current directory 2 du filename Displays the space occupied by the specified file 3 du catalogname Displays the space occupied by the specified directory 4 5 DF View System disk device, default is KB 6 df-h Use-h option to display view system disk device in units above KB, readability 7 df-a View disk devices for all file systems

7.touch

Summary: Create a new empty file, if the file you want to create already exists, update the time label of the existing file to the current time of the system (the default), the original data will be preserved

1 Touch new_file Create an empty file in the current directory

8.cat

Description: Displays the contents of the file and prints it on the screen

1 Cat-n Print line number 2 Cat-a show all content including special characters

Other commands similar to CAT are used to display files, followed by filenames

TAC     and Cat are also printing file content to the screen, but starting from the countdown to the first line to print 2 more    ctrl+d up screen, CTRL + less    Space Key page, J Move Down, K move up 4 head    Display the first 10 lines of the file, you can use head-N to display the first n rows 5 tail    display the last 10 lines of the file, you can also display the last n rows with tail-n 

9.rm

Description: RM is the abbreviation for remove, used to delete files or directories

1 RM    Delete file, there will be a prompt 2 RM-R Delete directory, can be used to delete non-empty directory, if the directory is not empty will prompt 3 RM-f Force Delete directory, do not prompt 4 RM-RF Delete a file or directory without prompting

Note: It is best to back up the files before deleting them in Linux, especially some important files

1 mv filename/opt/filename.bak2

10.cp

Summary: CP is a copy abbreviation for copying a file or folder, the command format is CP [option] [source file] [destination file]

Options:

1 -f: Forcibly copy the file or directory, regardless of whether the destination file or directory already exists,2 -I: Before overwriting the existing file, ask the user first,3 -L: Make a hard connection to the source file, instead of copying files;4 -r/R: Recursive processing, all files under the specified directory are processed together with subdirectories,5 -B: The target file is backed up before overwriting the existing file target;
1 CP-R recursively replicate folder (directory)2 cp-i security option, encountering an existing file will ask whether to overwrite

11.mv

Description: MV is shorthand for move, for moving files or directories, and for renaming, directory format MV [options] [source file or source directory] [destination file or directory]

There are several scenarios for this command:

    • The destination file is a directory, but the directory does not exist, rename the source directory
    • The destination file is a directory, but the directory exists, move the source file or source directory to the directory
    • The destination file is a file, but the file does not exist, rename the source file
    • The destination file is a file, but the file exists and asks whether to overwrite

12. Commands to change file permissions

1 chgrp 2 Chown 3 chmod 4 Umask

13. Commands to modify special properties of a file

1 chattr 2 lsattr 3 Set UID 4 Set GID 5 Sticky bit

14. Search for files related commands

1 which 2 Whereis 3 Locate 4 Find

15.CMP Compare files (rows and columns of output differences) 6 diff compare files (text at the output difference)

16.grep

Second, command line edit shortcut keys

1 Ctrl + A  moves to the command first character 2 Ctrl + e  moves to the end of the command 3 CTRL + U removes the cursor to the command line at the first character 4 Ctrl + k Delete cursor at the end of the command line One character 5 Ctrl + l Clear screen 6 Ctrl + c Cancel 7 Ctrl + ARROW keys move one word at a time        /c6>  

Third, user management and user group management

1. User Management related commands

(1) Su and sudo

SU: Switching users

sudo: Represents the Get temporary root permission command

1 su switches to the root user 2 Su- root switch to root user 3 Su- username switch to normal user 4 sudo followed by some special operations.

(2) Who series

1 whoami; Displays the user name under the current user 2 Who am I: Displays the user name at login 3 who: Shows users who are currently actually logged on to the system (does not show those who switch users with the SU command)

(3) Useradd

Summary: Create a new system user

Syntax: User [options] [parameters]

The parameters are as follows:

1-c< Notes >: Add note text. Note text is saved in the comment field of passwd;2-d< Log in Catalogue >: Specifies the starting directory for user login;3-D: Change the preset value;4-e< Validity Period >: Specify the expiration date of the account;5-f< Buffer days >: Specify how many days after the password expires to close the account;6-g< Group >: Specify the group to which the user belongs;7-g< Group >: Specifies the additional group to which the user belongs;8-m: Automatically establish the user's login directory;9-M: Do not automatically set up the user's log in directory;Ten-N: Cancel the creation of a group named after the user name; One-R: Set up the system account number; A-s<shell>: Specifies the shell used by the user when logging in; --u<uid>: Specifies the user ID.

(4) Userdel

Description: Used to delete a given user, as well as files related to the user. If no option is added, only user accounts will be deleted, not related files

Syntax: Userdel [options] [parameters]

The parameters are as follows:

-F: Force delete user, even if user is currently logged -r: Delete user and delete all files related to user

(5) passwd

Description: Used to set the user's authentication information, including user password, password expiration time, etc.

Syntax: passwd [options] [parameters]

1 -D: Remove password, only system administrator can use 2 -f: Enforce 3 -K: Set to update 4 only after password expiration expires  -L: Lock password 5 -S: Lists information about the password, only the system administrator can use 6 -u: Unlock the locked account
1 passwd without any options and parameters is to change the root user password 2 passwd username change the password for username

Note: Files related to user and group account information

Store user information:

1 /etc/passwd2 /etc/shadow

Storage Group Information:

1 /etc/Group2 /etc/gshadow

2. User group Management related commands

Groupadd

Groupdel

Iv. Redirection and piping

V. System commands

1 su  [...]              Log in root user/ other user    2 apt-get install/remove   Install delete file 3sudo ...               executing commands with root privileges 4 Top                     Dynamic View system process information (Q exit)5PS                      View System process information 6 Kill                      

Vi. Other Orders

1.clear to clear any information on the current screen terminal

2.date and Cal

Date Summary: The dates and times used to display or set the system

Cal Brief: Show Calendar

1 Date Output Current time 2 ' 050316552018 ' Set the time 3 cal output Calendar (the calendar for the month in which it is now) 4 cal year Output calendar 5 Cal month Year output calendar for a month

More about the date command see this: https://www.cnblogs.com/hunttown/p/5470527.html

3.man, Help, Info

The Man:man command is a help instruction under Linux that allows you to view information such as instruction help, configuration file Help, and programming help in Linux with the Man command.

Help: Useful information for displaying commands inside the shell. The help command can only display command assistance information inside the shell. The Help information for external commands can only be viewed using the man or info command

Info: is the help directive for the Linux info format. In terms of content, the info page is better, easier to understand, and friendlier than the man page, but the man page is really easy to use. A man page has only one page, and the info page almost always organizes its contents into multiple sections. The trick to understanding the info command is to learn how to navigate through a separate Info page and learn how to switch between nodes and child nodes, which is actually more difficult to learn and use .

4.echo

Description: Used to print the value of a shell variable in the shell, or to output the specified string directly

Detailed Explanation: Http://man.linuxde.net/echo

1 " Hello "  Output Hello to the screen

5.exit

Description: The equivalent of exiting the shell and returning the given value. The current script execution can be terminated in a shell script. Execution exit causes the shell to exit with the specified state value. If you do not set a status value parameter, the shell exits with a preset value. A status value of 0 means execution succeeds, and other values represent execution failures

Exit the current shell:

1 [email protected]:/home/wyb# exit2exit3 $

Linux operating System 2 common Linux 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.