Summary of common Linux Commands

Source: Internet
Author: User
LinuxTutorial common command file processing command ls display directory file list-aall-ldetail-d directory attribute cdchangedirectoryrootdirectory upper-level directory pwdprintworkingdirectory display Linux Tutorial
Common Commands


File Processing Command
Ls # display directory file list
-A # all
-L # detail
-D # directory attributes

Cd # change directory
/# Root directory
.. # Upper-level Directory

Pwd # print working directory displays the current working directory

Touch # create an empty file

Mkdir # make directories

Cp # copy a file or folder
-R # recursive replication recursive

Mv # move a file or rename it
Mv [src File/Dir] [dist File/Dir]

Rm # romove
-R # recursive deletion

Cat # display file content

More # display file content by page

Head # view the first n rows of a file

Tail # view the last few lines of a file

Ln # generate a connection file
Ln-s [src] [dist] # Create a soft link



Permission management commands
Chmod # change the permissions mode of a file
Chmod [{ugo} {+-=}{ rwx}] [file/dir]
Chmod [mode = 421] [file/dir]

File permission:
File Directory
--------------------------------------------------------------
R read can view the file content and list the directory content
W write can modify the file content and create and delete files in the directory
X eXecute can eXecute files to enter the Directory

Chown # change file ownership
Chown [newOwner] [file | dir]
Chown well file1 # change the owner of file1 to be user well

Chgrp # change file group ownership
Chgrp [newGroup] [file | dir]

Umask # Display and set the default file permissions
-S # display the default permissions of new files or directories in the form of rwx

File search command
Which # display the directory where the system Command is located

Find # find a file or directory

Locate # list files in databases

Updatedb # update the locate database to create a database for the entire file system directory file

Grep # Search for strings matching rows in the file and output
Grep [string] [srcFile]

Help commands
Man # manual get help information

Info # get help information

Whatis # get simple description of the index
Whatis apropos [anyKey]

Compression command
Laruence basics-pdf 302

Gzip # GNU zip compressed file .gz
Bzip2 # *. bz2

Tar

Tar-jcv-f filename.tar.bz2 distFilename # compression
Tar-jxv-f filename.tar.bz2-C distDir # decompress

-J. use bzip2 to compress/decompress
-Z'S support for gzip compression and decompression

-V display process

-C. create a package file
-X unpack and decompress files

-F filename: specifies the file name to be processed

-C dir indicates decompression in a specific directory


Network Communication commands

Write # Send a message to another user, ctrl + d as the end
Wall [message] [file] # broadcast messages to all users
Ping IP_ADDR # test network connectivity

Ifconfig # View network settings
-A # View all Nic information

Setup # set network information

System shutdown command
Shutdown-h now # immediate shutdown command

Reboot # Restart

Shell application skills
Tab key # command completion

History # command history
! Num # execute the Num command in the history

Alias # alias settings
Unalias # Delete an alias

I/O redirection:
Input:
> # Overwrite redirection. if not, create
>># Append redirection

Output:
<

MPs queue:
| # Use the output of one command as the input of another command



Text editor Vim/Vi
Three modes:
Command mode
Insert mode
Edit mode

Insert command:
A attaches text behind the cursor
A adds text at the end of the line
I insert text before the cursor
I. start inserting text in this row
O insert a new line under the cursor
O insert a new line to the cursor

Positioning command:
$ Move to the end of the row
0 move to the beginning of the row

: Setnu
: Setnonu cancel row number
Gg to the first line
G to the last line
NG to n
: N to row n

Delete command:
Dd deletes the row where the cursor is located.
Ndd delete row n
: N1, n2d delete rows in the specified range

Copy and cut commands:
Yy and Y copy the current row

Cancel command:
U cancel the previous operation

Search and replace commands:
/String forward search for a specified string
N searches for the next occurrence location of a specified string
: % S/old/new/g replace the specified string in full text

Command for saving and exiting:
: W save changes
: Wq: save the modification and exit.
: Q! Exit without saving changes



Analysis of Linux boot process


Linux Software Package management
Binary package management (RPM, YUM)
For example there is a software package: sudo-1.7.2p1-5.el5.i386.rpm

Uninstall:
Rpm-e sudo

Installation:
Rpm-ivh sudo-1.7.2p1-5.el5.i386.rpm

Upgrade:
Rpm-Uvh sudo-1.8p1-5.el5.i386.rpm

----
Benefits of yum: automatically solves software package dependencies and facilitates software package upgrades

Install: yum install
Detection Upgrade: yum check-update
Upgrade: yum update
Package query: yum list
Package Information: yum info
Uninstall: yum remove
Help: yum-help, man yum

Source code package installation
Example: proftpd

Tar-xzvf proftpd-1.3.3d.tar.gz (unzipping)
Cd proftpd-1.3.3d
./Configure -- prefix =/usr/local/proftpd (configuration)
Make (compilation)
Make install (installation)

Script installation (shell, java script)
./Setup. sh

APT software package management:
Search package: apt-cache search
Package Information: apt-cache show
Install: apt-get install
Delete: apt-get remove
Update Software Source: apt-get update
Update the installed package: apt-get upgrade


Linux User Management

Configuration file
User information file/etc/passwd

File format:
Username: Password: UID: GID: annotation description: main directory: command interpreter
Well: x: 500: 500:/home/well:/bin/bash

Password file/etc/shadow
User group file/etc/group

User type
Root User, UID = 0
Common user, UID = 500-60000
Pseudo-user, UID = 1-499

Pseudo users are related to systems and program services, such as bin, daemon, shutdown, halt, and mail, new, games, apache, and ftp.
Pseudo users do not usually need to or cannot log on to the system; they can have no home directory

Add user
Useradd NEW_USERNAME
Passwd NEW_USERNAME # set password

Linux process management
View user information w
JSCPU is distinguished by terminal code. the CPU time consumed when all related processes of the terminal are executed.
Pcpu cpu execution time
WHAT operations are being performed by the user?

View individual user information w USERNAME

View process ps in the system
A. display the processes of all users.
U display user name and start time
L Long Format Display

PID process number
The process ID of the parent PPID process.
TTY process start terminal
Current state of the STAT process (S sleep state, D sleep state that cannot be interrupted, R running state, Z dead state, T stopped)
NI process priority

Ex.
# Ps view processes belonging to you
# Ps-u or-l view detailed information of a subordinate process
# Ps-le or-aux
# Ps-aux -- sort pid can sort processes by execution time, PID, UID, etc.

Kill process shutdown
Kill PID



Linux file system management

Common file system folders:
/Usr/bin stores commands that can be executed by all users
/Usr/sbin stores commands that only the root user can execute.
/Usr stores all commands, libraries, and manuals
/Etc system configuration file

View disk information
Df view partition usage
View the file and directory size in du
Fsck detects and repairs the file system
E2fsck

Add hard disk partition
Fdisk partitioning
Create a file system using mkfs
Mount try mounting
/Etc/fstab write configuration file

Shell Programming

Shell structure:
1 .#! Specifies the shell for executing the script
2. # Comment rows
3. command and control structure
To create a shell program:
Step 1: Create a file that contains commands and control structures.
Step 2: modify the permission of the file so that it can execute
Use chmod u + x
Step 3: Execute./example
(You can also use "sh example" for execution)

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.