Linux Common commands

Source: Internet
Author: User
Tags bz2

1. View Ipifconfig or IP A2. Restart the reboot3. Shutdown shutdown-h now4. Stop CTRL+C5. Restart the network or one of the Services service network restart II. directories and Operations commands
6. View the working directory
pwd
7. Switch working directory What does the interview mean, note that it is not open! Not open! Not open!
CD [Directory location]
8. Display Directory Contents
ls [-a\-l\-al]
9. Create a new directory
mkdir-p [path] Directory name
-P is used to create a multi-level directory, if and in the path, the folder will be created with the directory
10. Space occupancy of statistical catalogues and documents
du [options] [directory or file name]
-A: All files are included in the statistics, not just the statistics directory
-
H: Display information in more readable byte units (k, m), etc.
-S: Counts the total amount of space occupied by each parameter
Third, the file Operation command
11. Create a new empty file or update a file time stamp
Touch file name
12. View File Types
File
file name
13. Copying Files or directories
CP [option] source file or directory directory file or
directory
-
R: Recursively replicate entire directory tree
-P: Keep the properties of the source file
unchanged
-
F: Force overwrite the target file or directory with the same name
-I
: reminders when files or directories need to be overwritten
14. Delete Files or directories
RM [Options] File or directory
-
F: Force deletion of files or directories, no reminders
-I
: Remind users to confirm when deleting files or directories
-
R: Recursively delete entire directory tree
15. Move a file or directory
mv [options] source file destination file
If the destination file location is the same as the source file location, it is equivalent to renaming
 
16. Find the Linux command file and display the location (the search scope is specified by the PATH environment variable)
which command or program name
17.whereis
18. Find File locate (faster search in the background database)
Locate file name
/var/lib/mlocate Database location, updated daily
ipdatedb Updating the database
 
19.find Lookup (compare wasted resources)
used to find files or directories
Find
search scopes Find what to look for
Conditions:
-name: File name
-size: File size
-user: File Properties
-type: File type,
Example: find/var/log/-mtime +10
Description:
-10:10 files modified within the day
documents modified from 10:10 day
files modified +10:10 days ago
atime: File access time
ctime: Changing file properties
mtime: Modifying file contents
20. Establishing a connection for a file or directory
LN [-s] source file or directory link file or directory
-S: Create a symbolic link file, omit this key to establish a hard link
 
about linked Files
Symbolic Link: The path to the original file, called the soft link
Hard Links: points to the data storage location for the original file
You cannot establish a hard-link file for a directory,
hard links must be in the same partition as the original file
 
with window for
Soft connect = Shortcut key: Source file plus absolute path must not be wrong
hard link = copy
 
Additional: SCP from remote replication
Example: The 192.168.62.10 above the/root/folder, download to the local/home/new/, using the remote side of the root login
scp-r [email protected]:/root//home/new/
 
Iv. file Contents Operation 21. Display the full contents of the file CAT/absolute path 22. View a portion of the file at the beginning of the document (default 10 lines) head-n file name 23. View part of the end of the file (default 10 lines) tail-n file name Tail-f File name 24. Information about the number of words in a statistical file WC [Options] Destination file-L: Count Rows-W: Count the number of words-C: Statistics bytes 25. Finds and displays rows in a file that contain the specified string grep [options] Find file Target file-I: Ignore case when lookup: reverse lookup, Enter a row lookup condition that is not equal to the lookup condition the string to find is enclosed in double quotation marks "^ ..." to indicate that: The beginning of "... $" indicates a ... The end "^$" represents a blank line | : A pipeline, which can be interpreted as the result of the first condition lookup, as the source file for the second condition Lookup 26. Compress and decompress tar options archive file name source file or directory options:-C: Create a package file in. tar format-x: Unpack the. tar format package file-V: Output details-F: Use archive file-Z: Call Gzip-j: Call bzip2 compression: Tar jvcf file name. tar.bz2 source file name extract: Tar JVXF file name. tar.bz2 source file name v. User account Management 1. User accounts Super User: Root ordinary User program User 2. Group account Basic Group (private Group) additional group (total group) 3.UID and GID user representation Number group representation number 27. User account File passwd
file location/etc/passwd stored account basic information
Example: text:x: 500:500:text Demo:/home/text:/bin/bash
user account name: Password placeholder: uid:gid: Full Name: Host directory: Login Shell information
Password string/expiration information location etc/shadow28. Add account useradd option user name Option-u: Specify UID Tag number-D: Specify the host directory, default is/home/ User Name-E: Specify the account Expiration Time-G: Basic group name (or UID)-G: Additional group name (or GID)-s: Specify user's login information 29. Account initial profile copied from/etc/skel 30. Set/change user password passwd options Username-D: Clear password-L: Lock User name-S: View status-u: Unlock username 31. Modify the Account attribute Usermod (Note: The modified user cannot be logged in when the login name is modified) usermod option Username-l (lowercase): Change login name new username in front Old username in the rear-L: Lock user account-U: Unlock user account 32. Delete user account Userdel [-r] User name-r: Indicates the host directory of the connecting user is deleted. Group account Management/etc/group Save group account basic information/etc/gshadow Save password information for group account admin:x: 4:root, adm,adeeee group account name UID GID Group Member list 33. Add group account Groupadd
Groupadd [-G GID] group account name
 
Modify group name: Groupmod-n new name Original name
Modify group number: Groupmod-g GID Group name
 
34. Add/Remove Group
members
gpasswd option group account name
-
A: Adding a user member to a group GPASSWD-A user name group account
-
D: Delete a user member from within a group
-M: Defines a list of group members, separated by commas
 
Groupdel Group account name
 
Vii. File/directory Permissions
access rights: Read, Write, execute
Attribution:
Owner
: The user account that owns the file or directory
array: The group account that owns the file or directory
Example:--rw-r--r--| root root 34298 04-02 00:23
First-: File type-file D directory l Soft Connect file access is the primary array
 
access Rights
Read R 4
Write W 2
perform x 1
 
u file owner G file belongs to group O other users
 
35. Set file, directory permissions
chmod u (g, O, a) + (-, =) R (w, x) file
chmod nnn File
nnn for 421
-r: Recursively modifies permissions for all files and subdirectories under the specified directory
 
36. Set the attribution of files and directories
chown Master File
chown: Genus Group File
chown Owner: Array file
 
37. Additional Bit Permissions
Set bit Permissions
Purpose: 1. For executable file settings, the permission character is "s"
2. When other users execute the file, they will have the permissions of the owner or group of users
chmod u+s
 
VIII. Process Management
38. Viewing Static Process statistics
PS aux
ps-elf
A: Displays all process information under the current terminal
u: Output process information in a user-oriented format
x: Displays process information for the current user under all terminals
 
Filter a process
Ps-ef | Gerp xxxxx39. Viewing dynamic process rank information Top 40. Show relationships among processes in a tree structure pstree-p: List The pid-u of the process: list the corresponding user name of the process-A: Lists the completion commands for the process 41. To terminate the process run CTRL + C Interrupt the executing command kill, killall-9 Nine, the configuration format of the scheduled management instance 1.crontab task
* Indicates any time within the range
, which represents multiple discontinuous points of time for the interval
-Represents a time range for a connection
/Specify the time frequency of the interval
 
* * * * *
Timeshare Month Week
 
Editor: Crontab-e [-u user Name]
View: Crontab-l
Delete: Crontab-r
 
Example: Automatically open sshd service 7:50 every day, 22:50 close
crontab-e
7 * * */sbin/service sshd start
* * * *
/etc/init.d/sshd sshd Stop
2. Automatic support at specified date, point in time some of the pre-set command operations, belong to a scheduled task at [hh:mm] [YY-MM-DD] Press Ctrl+d submit

Linux Common commands

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.