Linux common commands (replication)

Source: Internet
Author: User
Tags clear screen safe mode uncompress

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

Modify directories, file permissions, and host and array commands

Chmod: The permission command used to change the specified 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.

commands for creating and deleting directories

Mkdir: Used to create a directory

Rmdir: Used to delete empty directories

Rm-f: Used to delete a directory that is not empty

Create and delete, rename, copy a file commands

Touch: Create a new file

Vi: Create a new file

Rm: Deleting files or directories

Mv: Commands to rename or move files

Cp: Copy command

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 as a paging, with the difference between the more and less pages using the same key.

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.

TAIL-F: The data content of the display file after n rows for auto-refresh.

Find command

Find: Finds the specified 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 a string in the file that matches the criteria.

Commands to shut down and restart your computer

    

shutdown:-r Restart immediately after shutting down the machine

-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

Change directory and view current directory commands

Cd: Enter the working directory

Cd.. : It will go back to the previous level command

PWD: Displays the current user's working directory location

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 the destination 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

Other commands

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

Top: Dynamically displaying processes

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 network connections. routing tables 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

Now the number of interviews will be asked about a Linux problem, and the project into the UAT will be sent to Linux, so it is necessary to know a few Linux commands.

The first and most useful one:

Man look at the command in detail, as long as it feels that the command is not clear, man it can be.

Mans LS

LN Creates a linked file

Ln-s SourceName Destname

ls list file
-L: Line by row and detailed properties listed
-A: Lists all files including hidden files that begin with.

Ls-lqt/bin

Cat Reads text content
-N: Show line numbers
-B: Line numbers are displayed and blank lines are ignored

Cat-n 1.txt

WC: Count
-L: Number of rows
-W: Word Count
-C: Number of characters
Wc-l file1 file2 ... Multiple files can be counted

CP Copy File directory
-I: Interactive mode, if the destination file exists, asks whether to overwrite
-r: Copy directory
CP file1 file2 file3 .... dir means file1,file2 ... Copy to Dir
Cp-r dir1 dir2 dir3 ... Dirn will Dir1, dir2,dir3 ... Copy to Dirn

File View Files Type

File test.sh

MV move file, change file name
-I: Interactive mode, if the destination file exists, asks whether to overwrite
-R: Move directory, change directory name

RM Delete File
-I: Interactive mode, asking whether to delete
Rm-r dir1 dir2 dir3 ... You can delete multiple

mkdir Creating a Directory
-p:parent, parent directory does not exist, the parent directory is created

Mkdir-p Test/test

RmDir Deleting a directory
Equivalence and Rm-r
RmDir dir1 dir2 dir3 ....
Rm-r dir1 dir2 dir3 ....

chmod changing permissions
Chmod-r 777 dir Change the directory under All file permissions to 777, must be-r

Permission-rwxrwxrwx
421421421
Front-Indicates file type is normal file
The next three bits represent owner permissions
The next three bits represent group permissions
The last three bits represent other user rights
If a permission is not assigned, use-represents. -RWXR--RWX indicates that the group does not have write and execute permissions
File plus Night has executable permission, but indicates whether to allow files to be found in this directory

Chown Change Owner

CHGRP Change Group

Command &
Add & After command to run in background
Find. -name "*.sh" &

FG puts the background process in the foreground
FG%1 puts the first job in the background to the foreground

Bg
Put the foreground process in the background

Jobs
Show background or pending processes

Ps
Show All Processes
PS-F displays full information, including CPU time, start time ...

Kill
-9 Forced end

More display text content, one screen at a time, press space to continue
Find/-name "*.sh" | More

Tail Displays the contents of the back from the specified position
Tail-f Server.log for running side view logs on top of server
Tail-10 dos2unix.sh See the last 10 lines

Head
Corresponds to Tail

Sort sorts
-R Reverse Order
-D Dictionary order
ls | Sort-r

TR character substitution
-D Delete the specified character ls | tr-d ' log '
ls | Tr ' d ' g ' turns D into G

At time Date job
Timing Scheduling

Compress
-F Compressed Files
-V Show Compression scale
COMPRESS-VF Project.tar will generate Project.tar.z and Project.tar be deleted

Uncompress
-F Unzip the file
-V Show Compression scale
Uncompress Project.tar.z will generate Project.tar and project.tar.z be deleted

Tar
-C Create a new document
-X Unpack the package
-V Displays the file name being processed
-F supersedes the default file name
TAR-CVF Project.tar project/* Package All files under project directory
TAR-XVF Project.tar


Crontab
Usage rights: All users
  
How to use:
  
crontab [-u user] File
crontab [-u user] {-l |-r |-e}
  

CRONTAB specifies that the user executes the program at a fixed time, in other words, the user's time table. -u user refers to the setting of the time table for the specified user, which presupposes that you must have permission (for example, root) to specify another's time schedule. If you do not use the-u user, it means setting your own schedule.

Linux common commands (replication)

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.