Linux-Common commands, common linux commands
Common Linux commands
1. ls (list)
Ls: list all files in the current directory (excluding hidden files)
Ls-a: List all files in the current directory (including hidden files)
Ls-l: Lists All files in the current directory and displays details.
Ls-a-l ls-l-a ls-al ls-la: all the above four types indicate listing all files in the current directory and displaying details (including hidden files)
2. cd (change directory Modify/switch directory)
Cd: Switch Directories
(*** Two hidden files are generated by default when a folder is created: (1 ). (2 ).. these two hidden files store the paths of the current directory and the upper-level directory respectively, and run cd. and cd .. the actual principle is to enter the directory path in the file ***)
3. pwd (print work directory print current path/absolute path)
Pwd: displays the first path (from the root path)
4. mkdir (make directory to create an empty folder)
Mkdir: creates an empty folder.
Mkdir-p: cascading Folder creation (for example, mkdir-p abc/def)
5. mv (move the file between directories and modify the file name)
Mv source file pathname target file pathname: Move the source file to the target file path (only modifying the file path and not renaming the file)
(For example, mv abc/1.txt./1.txt)
Mv source file name target file name: Rename the file (the file is modified but the file is not moved/the file path is modified)
(For example, mv 1.txt 2.txt)
(*** Relative path and absolute path ***)
Pathname --------- D: \ winshare \ enume. c
Path ---------- D: \ wishare
File name (name) ---------- enume. c
6. touch (create an empty file)
Touch: Create an empty file
(For example, touch 1.txt)
7. cp (copy a file or folder)
Cp source file pathname target file pathname: copy the source file to the target file (copy a common file)
(For example, cp 1.txt..././abc/1.txt)
Cp-r source file pathname target file pathname: copy the source file to the target file (copy folder)
Cp-f Source File pathname target file pathname; forced copy (overwrite)
(In general, cp-f or cp-rf is usually used in actual operations)
8. rm (remove a file or folder)
Rm pathname: delete an object
Rm-r pathname: delete a folder
Rm-f pathname: Force delete a file or folder (reduce error message)
9. cat (directly display the file content in the command line and input the content to the file)
Cat name: displays the file content directly under the command line (in the case of less practical and file content)
10. rmdir (remove directory Delete empty folder)
Rmdir pathname: delete an empty folder
11. ln (link connection file)
(*** The shortcut in Windows and the file it points to are two independent files, both of which occupy the hard disk space, but when users access the shortcut, the effect is equivalent to accessing the object to which the object is directed ***)
(*** Two types of linked files in Linux ***)
Soft connection (symbolic link): the effect is equivalent to the shortcut in Windows
Ln-s source file name symbolic connection file name: Creates a symbolic link file for the source file
(For example, ln-s src. c link. c, that is, link. c is a symbolic connection file of src. c)
Hard Link (not in windows): hard link is actually the same file on the hard disk. The effect is similar to a file on the hard disk. Each time a file is deleted, as long as there are other hard connections, this file will not be deleted. Only when all the connection files are deleted will this file be deleted from the hard disk.
Ln source file name connection file name: Creates a hard connection for the source file
(For example, ln a. c B. c creates a hard connection file B. c for a. c)
(*** The difference between a hard connection and a soft connection is that after a soft connection deletes the source file, the connection file also becomes invalid. After a hard link deletes the source file, the linked file is not affected, that is, there is no master-slave relationship. ***)
12. man (query man manual and obtain help information)
Man 1 xxx: 1 indicates querying Linux commands (here xxx indicates Linux commands)
(For example, man 1 ls queries all Linux commands of ls)
Man 2 xxx: 2 indicates that Linux APIs are queried (xxx indicates Linux APIs)
Man 3 xxx: 3 indicates that the c library function is queried (xxx indicates the c library function)
13. apt-get (install and uninstall software programs online in ubuntu)
Apt-get install xxx: install software xxx
Apt-get remove xxx: uninstall software xxx
(Note: the release, kernel, and customization of the Linux operating system cause incompatibility of the software in Linux. Installing the software in Linux is difficult, the installed software may not be usable. ubuntu solves this problem and is suitable for a certain release version. All the software has a list, then, the user will use the apt-get install method to install the software and connect to the Ubuntu server. The server will download the appropriate software package for installation Based on the Ubuntu version, this ensures the software compatibility .)
Basic Linux knowledge
1. The meaning of the first 10 characters (-- rw-r --) in the ls-l file details
Character 1: indicates the file type
-: Common file (.txt. out)
D (directory): folder
L (link): indicates the symbolic connection file (the file to which it points will be printed later)
S (socket): indicates the socket File
P (pipe): indicates the MPs queue file.
Character 2: represents