Common shell commands under Linux

Source: Internet
Author: User
Tags parent directory file permissions

1. Export Env_var=value #修改环境变量

2. Env #查看环境变量值

3. Hostname #显示主机名

4. readlink-f filename #文件的完整路径

5. Tar xzf filename.tar.gz; #解压, followed by the-C dirname, means to extract to a directory.

6. Tar czf filename.tar.gz dirname #压缩

7. Ctr+r use keywords to search for the commands we have used.

8. History #查看历史命令

9. kill-9 PID #kill掉某个进程

. Kill%<jobid> #kill Jobid corresponding process

Ll-rt #列出所有文件, and the reverse sort of the modified time,-R for the reverse,-t to sort by time.

ll is equivalent to ls-l, which displays file information in the form of a log list. Each item contains 9 fields. The following were:

Field 1: Represents a file's properties, and the first letter represents the file type. "-": Normal file, "D": Directory, "-L": symbolic link; After 9 letters for file permissions, rwx (read and write execution)

The file is the owner of the permissions, group user rights, and other user rights.

Field 2: Number of file links and directory subdirectories, the default value is 2 for the directory, because the directory defaults to two subdirectories, respectively, '. ' and '. ', which indicates the current directory and its parent directory

Field 3: Owner of the file;

Field 4: The group where the owner of the file resides;

Field 5: The file size, in bytes. For a directory, the size of the directory itself, excluding the size of its child files.

Field 6,7,8: File creation month, date, time.

Field 9: File name, if it is a symbolic link, there will be a pointer to it.

PS #列出所有活动进程, commonly used PS-EF and PS aux,-e for all programs, E for listing the environment variables used by the program, F indicates the display of a tree structure, indicating

The interrelationship of the program. A represents all programs (except session leaders), and u represents a process that user-oriented format,x shows no control terminal.

PS aux display Results The first item represents the process owner or owner ID, and the second represents the PID

grep xx./-rn #在当前目录下递归查找关键词xx, the line number is typed.

PS aux | grep ABC #含有abc的活动进程, GREP-V ABC does not contain the activity process of ABC. There are several process states:

D Non-interruptible uninterruptible (usually IO)
R is running, or the process in the queue
S is in a dormant state
T stop or be traced
Z Zombie Process

Netstat #显示网络相关信息, commonly used Netstat-nalp. A: Show all options, N: Reject display aliases, can show all numbers converted to digital

L: List only the service status that is in Listen (listening); P: Displays the name of the program that established the related link.

DirName xx #输出一个路径的除文件名之外的其余部分,./xx.txt, Output is.

NC #想要连接到某处: NC [-options] hostname port[s] [ports] ...

Bind port Waiting for connection: Nc-l-P Port [-options] [hostname] [port]

Chat: Host1:nc-lp Port; HOST2:NC hostname port So you can send messages to each other.

File transfer: Host1:nc-lp port > Log.txt; HOST2:NC hostname Port < Log.txt

Port scan: nc-v-z-w2 192.168.0.80 1-140 #-V: verbose output;-Z: Turn off input and output;-w:secs timeout.

Telnet #Internet远程登陆服务的标准协议和主要方式, using telnet hostname port.

Screen # Screen-s XX: Set up a session;c-a D to leave this Session;screen-ls: List screen session; Screen-r XX: Resume session.

Nohup #nohup command to run commands specified by the command parameter and any related ARG parameters, ignoring all hang-up (SIGHUP) signals.

If the output of the Nohup command is not redirected, the output is appended to the Nohup.out file in the current directory.

21. REDIRECT #1: Standard output, 2: Error output, such as sh test.sh > res.out 2>&1, redirect standard error output to standard output, and standard output redirected to Res.out. 1>&-turn off standard output.

Common shell commands under Linux

Related Article

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.