Reprint please indicate the source:
http://blog.csdn.net/u011974987/article/details/52695647
This article comes from: "Stromxu's Blog" preface
Linux provides a large number of commands that can be used to efficiently perform a large amount of work, such as disk operations, file access, directory operations, process management, file permissions, and so on. Therefore, working on a Linux system requires the use of system-supplied commands. To really understand the Linux system, you have to learn from the Linux command, learning from the basic commands to further understand the Linux system,
Here's a quick summary of the common basic operations commands. Basic Commands (1) directive name: PWD
The PWD command is also one of the most basic commands used to display the directory where the user is currently located.
(2) directive name: CD
The CD command not only displays the current state, but also changes the current state, and its usage is basically consistent with the CD command under DOS.
CD.. Access to the previous directory CD
-access to the previous directory
CD to enter the user's home directory
(3) directive name: CP
How to use:
CP [Options] Source Dest
Note: Copy one file to another file or copy several files to another directory.
Parameters |
Description |
-A |
As far as possible, file status, authority and other information are reproduced as the original copy. |
-R |
If the source contains a directory name, then the directory of the files are also copied sequentially to the destination. |
-F |
If a file with the same file name exists at the destination, delete it before copying it. |
Like what:
Copy the file AAA (already exists) and name it BBB:
Copy all C-language files to the finished subdirectory:
CP *.c finished
Copying files
CP src.txt dest.txt
cp-i src.txt Dest.txt asked
cp src.txt. Copy to the current directory
cp-r directory dest copy entire directory to the specified path
CP c_?1. / wildcard character copied to parent directory
(4) directive name: MV
How to use:
MV [options] source dest
MV [options] Source ... directory
Description: Move one file to another file or move several files to another directory.
Parameter:-I if the destination already has a file of the same name, first ask whether to overwrite the old file.
Change the profile AAA to BBB:
Move all C-language programs to the finished subdirectory:
Mv-i *.c/finished
(5) directive name: chmod
How to use:
chmod [-CFVR] [--help] [--version] Mode file ...
Description: Linux/unix file access rights are divided into three levels: file owners, groups, others. The use of chmod can be used to control how files are accessed by others.
mode: permission set string, the format is as follows: [Ugoa ...] [+-=] [RWXX] ...] [,...] where u represents the owner of the file, G means that the owner of the file belongs to the same group (group), o means other people, and a says all three are.
+ means to increase permissions,-to indicate cancellation rights, = to represent a unique set of permissions.
R means readable, W is writable, X is executable, x means only if the file is a subdirectory or the file has been set to executable.
-C If the file permission has indeed changed, it will display its change action -F If the file permissions cannot be changed, do not display the error message -v display details of permission changes-
R Make the same permission changes to all the files in the current directory and subdirectories (that is, to change them recursively)
Set the file file1.txt to be readable by all people:
Set the file file1.txt to be readable by all people:
The file file1.txt and File2.txt are set to the owner of the file and are writable by the same group as which they belong, but others are not writable:
Set ex1.py as only the owner of the file can perform:
All files and subdirectories under the current directory are set to anyone can read:
In addition chmod can also use numbers to indicate permissions such as chmod 777 file
Each of these a,b,c is a number, representing the permissions of user, Group, and other respectively.
R=4,w=2,x=1
to rwx the property is 4+2+1=7,
to rw-the property 4+2=6,
to r-x the property 4+1=7.
Create a user
Useradd-m Jack created the user while creating the home directory
userdel-r Jack deletes the user
creating Groups
Groupadd Androidgroup
assigning users to groups
Usermod-g Androidgroup Jack.
file Permissions
R Read W write x perform
drwxr-xr-x
d rwx r-x r-x
D Directory
1. Permissions of the user to which the file belongs (Root has read and write permission to the file)
2. Permissions (read, execute) of the group of users to which the file belongs
3. Permissions of other users of the system (read, execute)
RWX must be in a fixed order
Permission binary octal
--- 0
--x 001 1
-w- 010 2
-wx 011 3
r-- 4
r-x 5
rw- 6
rwx 7
Modify file Permissions
chmod 644 File
Add execution permissions to the user
chmod u+x File
Change the default permissions for creating a directory
Umask 026
777-026
Change the file's owning
Chown user.group file
chown user file
chown. group file
(6) directive name: LS
How to use:
Description: Displays the contents of the specified working directory (listing the files and subdirectories contained in the current working directory).
Parameter description-a displays all files and directories (LS default starts with the file name or directory name as ".") As a hidden file, not listed)
- ---------------------------------------file type, permissions, owner, file size, etc. List the files according to the order
in which they were created---A , but not listed. (current catalogue) and ".." (Parent directory)
-F Add a symbol after the name of the file listed, for example, the executable file plus "*", the directory Plus "/"-
R If there are files under the directory, the following files are listed in sequence
Ls-l
Ls-la All
Ls-l ja* wildcard character lookup
Example:
Lists all files under the current working directory with the name S, and the newer one is behind it:
List all the following directories and archives details in the/bin directory:
List all files and directories under the current working directory; add "/" to the name and "*" After the name:
(7) directive Name: RM
How to use:
Description: Delete files and directories.
Parameter description -I delete the query before the confirmation. -
F Even if the original file property is set to read-only, also delete directly, do not need to confirm each. -R deletes the directory and the file below.
Example:
Delete all C language files and ask for confirmation before deleting:
Delete all files in the finished subdirectory and subdirectories:
(8) directive name: RmDir
How to use:
Description: Deletes an empty directory.
Parameter:-P is deleted when the subdirectory is deleted and makes it an empty directory.
Example:
Delete a subdirectory named AAA under the working directory:
In the BBB directory under the working directory, delete the subdirectory named Test. If the BBB directory becomes an empty directory after Test deletion, BBB will also be deleted.
(9) directive name: Touch
How to use:
[R Reference-file] [--file=reference-file]
[-T Mmddhhmm[cc]yy] [. SS]
[-D Time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create] [--help] [--version]
Description
The touch command changes the time record of the file. Ls-l can display the time record of the file.
Parameter description
a change the read time record of the file
m change the time record of the file
C If the destination file does not exist, no new files will be created.
f not used, it is for compatibility with other UNIX systems and keep
R using reference file Time records, as--file effect
D set time and date, can use a variety of different formats
T sets the file's time record in the same format as the date instruction
(10) directive Name: gzip
Description: The gzip command is used to compress files.
Parameters:-D Unzip compressed files
Example:
If you want to compress the Ye.txt file, you can use the following command:
This allows you to compress the file and add the GZ extension after the filename, which becomes the file ye.txt.gz.
Uncompressed files can be implemented using the GZIP-D command:
This allows you to extract the files and remove the GZ extension. (11) Specify Reset
Reset Empty command line
Well, the temporary use of the order first sorted out, lest forget slightly, and so do not remember the time to turn out to see ~ ~
Learn to understand and organize notes;
I hope we can point out or put forward valuable opinions and learn together, thank you.
Reprint please indicate the source: http://blog.csdn.net/u011974987/article/details/52695647
Personal homepage: xuhaoblog.com