Change directory and view current directory commands
- CD: Go to User's home directory
- CD ~: Go to the user's home directory
- CD-: Returns the directory where it was before entering this directory
- Cd.. : Returns the parent directory (if the current directory is "/", then "/"; "..." after execution) Meaning for the parent directory)
- Cd.. /.. : Returns to the top level two directory
- PWD: Displays the current user's working directory location
Commands to display the contents of a file
- Cat: Used to display the entire contents of a specified file
- More: Displays the contents of the specified file in pagination
- Less: Displays the contents of the specified file in pagination, more powerful than more.
- Head: Used to display the first n rows of the file.
- Tail: Used to display the contents of the following n rows of a file.
- grep: Finds the contents of a file. Find a row containing some information, eg (Find rows in file day containing un): $ grep un day
Find File command:
- Find: Finding files within a specified range
- Locate: Search files faster than find
- Whereis: Used to locate Program files and provide the location of the binary executable file, source code files, and user pages of this file. You can use the-B option to find only binary executables.
User and version Information view
- Who: see who is logged in on the current system and which console they are working on.
- WHOAMI: Show your user name
- Uname: Displays version information for the current system
- Uname-a: Displays all the useful information for the current system
- Uname-r: Only the kernel version information is displayed
View commands
- Man: Getting Help for a command
- Whatis: Extract a simple introductory text from the user manual of a program to help you understand the general purpose of the program.
- Apropos: You can reverse a command by using the manual. For example, find the command that contains search in the user manual: Apropos search
commands for creating and deleting directories
- mkdir: You can create one or several directories at a time.
- $ mkdir Document Picture # #新建两个目录
- $ mkdir ~/picture/temp # #在主目录下新建名为temp的目录
- $ mkdir-p ~/tempx/job # # If there is no tempx in the home directory, a subdirectory structure can be completely created with the-p option
- RmDir: Delete directory, only empty directory can be deleted
Move, copy, delete
- MV: Move files and directories (-I option to prompt for file coverage with the same name) and rename them while moving.
- CP: Copy files and directories (-I option to prompt for file overwrite with the same name)
- RM: Delete files and directories. Powerful than RmDir, you can recursively delete all files and directories under the directory.
- Rm-i: prompt whether to delete
- Rm-f: Automatic answer to prompt y
- Rm-r: Recursively deletes all files and subdirectories under the directory.
Permissions for files and directories
- Change file permissions: chmod
chmod user Group +/-Permission file name
User groups: File owner (U), Group of documents (g), others (O) and All Persons (a)
Permissions: Read (r), write (W), execute (x)
chmod u+x days (increases the owner's execution rights for file days)
chmod a-x Days
chmod ug=rw,o=r Days (grants read/write permissions to the owner and the group, but only to other users.) )
chmod o=u days (the permissions of others are set to the same as the permissions of the owner.) )
PS: Remember that only the owner and root of the file have permission to modify the file.
Chown: The command used to change the properties of a file.
CHGRP: The command used to change the file group.
Chattr: Used to set files with non-delete and modify permissions.
Lsattr: Used to display hidden properties of a file or directory.
Create a file
Find command
Find: The command that finds the specified directory or file.
Whereis: Find the specified file source and binary files and manuals, etc.
Which: the location used to query for commands or aliases.
Locate: Quickly find the content specified in the system database .
Grep: Finds content that satisfies a condition within the specified file or standard output, standard input.
Commands to shut down and restart your computer
Shutdown:-R restarts immediately after shutdown
-K does not really shut down, but only sends a warning message to all users
-H does not restart after shutting down the machine
Poweroff: For power off and off
Init: Changing the operating level of the system
level 0 for shutting down the system
Level 1 for single user mode
Level 2 for Multi-user usage (but without network functionality)
Level 3 for Multi-user usage (with network full function)
Level 4 for user-defined usage patterns
Level 5 indicates the mode when entering x Windows
Level 6 to restart the system
Reboot: for computer restart
Halt: For shutting down a computer system
Compress and Package commands
Tar: Used to package multiple files or directories, but not compressed, and also unpacked with commands
Gzip: For file compression and decompression commands, the file name extension is end of . GZ .
Gunzip: Used to decompress the gzip compressed document.
BZIP2: Used to compress and decompress files or directories
Bzcat: Used to display the contents of a compressed file.
Compress/un Compress: Compression / decompression . Z File
Zcat: View Compressed file contents at the end of Z or GZ.
Gzexe: compressing executable files
Unarg: Extracting . Arj Files
Zip/unzip: compressing and decompressing . zip Files
User Action Commands
Su: Switch User command
Sudo: A system administrator's identity Execution command
PASSWD: Used to modify the user's password
File connection command
Ln: Creates a connection for the source file and does not copy the source file, that is, it takes up a small amount of space.
Can be divided into software connections and hard links.
Soft Connect: Also known as symbolic Connection, a shortcut is created for a file or directory.
Hard link: Give a file more than one name, put in a different directory, easy for users to use.
The Ln command parameters are as follows:
-F: When creating a connection, delete the file or directory with the same name as the destination object first.
-D: Allows system administrators to hard-link their own directories.
-I: asks the user before deleting the file or directory with the same name as the destination object.
-N: Treats thedestination object as a generic file when creating a soft connection.
-S: Creates a soft connection, which is a symbolic connection.
-V: Displays the file or directory name before connecting.
-B: Files that will be overwritten or deleted at the time of connection are backed up.
Help Command-----Man
otherCommand
who: The display system has those users in use.
-ami Show Current user
-u: Show the user's actions / work
-S: Use a short format to display
-V: Show program version
Free: View memory usage of the current system
Uptime: Shows how long the system has been running
Ps: Show the dynamics of the instantaneous process
Pstree: Displays all the processes in the system in a tree-like manner
Date: Displays or sets the day and time of the system.
Last: Displays the user information of the monthly login system
Kill: kills some specific process
Logout: Exiting the system
Useradd/userdel: Add user / Delete user
Clear: Clear Screen
PASSWD: Set User password
VI Editor
First open a file with the VI command
Last-line mode command:
: N,m w path/filename Save specified range document ( n table Start Row,m table end row)
: q! force quit after making changes to the file
: Q No changes have been made to the file exit
Wq or x Save Exit
DD deletes the cursor in the row
: Set number Displays line numbers
: n jumps to n rows
: S replacement string: s/test/test2/g/g global replacement/can also be substituted with%
/Find String
Common commands for network communication
ARP: Network address display and control
FTP: File transfer
Lftp: File transfer
Mail: Send / receive e-mail
MESG: Allows or denies other users from sending information to the terminal they are using
Mutt e-mail management program
Ncftp : File transfer
Netstat: Displays the network connection . routing table and network interface information
Pine: Send and receive emails, browse newsgroups
Ping: To see if the network is connected smoothly
Ssh: Remote login in Safe mode
Telnet: Telnet
Talk: Talking to another user
Traceroute: Displays the path through which a host was reached and the time it was used.
Wget: Automatically download files from the Internet
Write: Writing information to other user terminals Rlogin: Telnet
Absolute path: such as/etc/init.d
Current directory and upper-level directory:./. /
Home directory: ~/
Switch directory: CD
View Current Process: PS
Execution exit: Exit
View current path: pwd
Clear screen: Clear
To view the current user id:
commands for displaying directories and files
Ls: A command to view all folders.
Dir: command to display the specified folder and directory tree: List directory contents in a tree view
Du: Show directory or file size
What command is used to count the contents of a file? (line number, number of words, number of bytes)
WC command-c counts bytes. -L COUNT the number of rows. -W counts the number of words.
What commands do you use to view a list of used commands?
History
What commands do you use to view IP address and interface information?
Ifconfig
To create an empty file:
Touch
commands for displaying directories and files
Ls: A command to view all folders.
Dir: command to display the specified folder and directory tree: List directory contents in a tree view
Du: Show directory or file size
Linux Common commands