Linux command Summary "to be Continued"

Source: Internet
Author: User
Tags gdb debugger

1. Package: Tar-czf small.tar.gz Small (directory name); Compress and package directory

2. Unpacking: Tar zxvf file name

DATE-S 2015 2 12 modification time

CP Name

CP-RF Name
# pwd
#Desktop/test1/
Cp.. /.. /etc/passwd./
Cat.. /.. /etc/passwd > Test.txt Redirection

mkdir–p -gen Catalogue

rm–r Delete Empty directory

Rm–rf name (dir) Continuous Strong delete

MV similar to CP

OD read non-text file

Cat/less/more/tac/head/tail Read

Useradd adding users

Userdel Deleting a user
Modify Terminal font Color: vim/etc/dir_colors find "DIR 01;34 # directory", directly modify 34.

Pipelines and redirects

I. Redirection

Redirection means: Redefine the request and turn it to another location.

Eg:ls-l >lsoutput.txt

This statement, ls-l this instruction (request) is originally to display the contents of the current directory on the terminal, after the execution of this statement has completed the redirection of the ls-l instruction: not in the terminal display, but to save the display content in the file Lsoutput.txt file.

If you want to terminate a process with the KILL command in a script, it is possible that the process is over when you execute the KILL command, and it will output annoying error messages on the terminal. Redirect the output to it! That is, instead of letting it appear on the terminal, redirect the output to a file. This can be written in the script:

Kill-hup 1234 >killout.txt 2>killerr.txt

Because the file descriptor number for the standard error output is 2, use the "2>" operator.

The above command redirects both the standard output and the error output to Killout.txt and Killerr.txt respectively. If you want to redirect both sets of output to a file, you can use the ">&" operator to combine two outputs. As shown below:

KILL-1 1234 >killouterr.txt 2>&1

Two. Piping

You can use the pipe operator "|" To connect the process.

PS-XO Comm | Sort | Uniq | Grep-v SH | More

This command first sorts the output of the PS command alphabetically (sort command is sorted), then uses the Uniq command to remove the process with the same name, and then uses grep-v sh to delete the process with the name Sh. Then use the more command to display the results paginated on the screen.

(redirect) the > number is to save the previous content in a later file
Input to

The vertical bar indicates that the link process is the pipeline

> is the cover write, meaning that the previous content is all gone;
>> is the append write, the previous content does not move.

wc< File Read a few lines of file size from this file

A.OUT<FILE1>FILE0 a.out extracting data from file1 to output a.out results to FILE0

sudo–u User Use User

WC output line number file size

Shutdown-h now (halt PC)
Shutdown-r Now (Rebot your PC)
Df
Fdisk-l

Ehco $PATH/shell

Stand-alone mode: Power on by E (kernel),----> single---->b

sudo passwd Change Password

DWRX-----D Catalogue
L---------l link

R 4 W 2 x 1

DWRXWRXWRX 4 root root passwd Sep 7
Permissions Connection number User (owner) group size date File

chmod

Chgrp

Chown 777

User-----Group---Other


CHGRP changed the first one.

Absolute path from root/start

Relative command relative to current path


Use of the VI Editor:

(1) Create a new file with the VI editor hello.txt, enter the content Abcdefghijk, and save the exit
VI hello.txt a Abcdefijk shift+: Wq (ZZ)

(2) Open hello.txt, copy content to 2nd, 3, 4 lines, and then delete line 4th
VI hello.txt yy pp DD (4d)

or delete the 3rd line of content 3d (ND)

(3) Cancel the last operation
U
(4) Save the contents of line 1th to 3rd of Hello.txt to Hello1.txt
1, 3 W hello.txt

(5) In Hello.txt, the line number is displayed
Set Nu (number)

(6) Read the time of the current system into the file Hello.txt.
R!date

0: Moves the cursor to the beginning of the current line

$: Moves the cursor to the end of the current line

Move cursor

In command mode, type

0: Moves the cursor to the beginning of the current line

$: Moves the cursor to the end of the current line

CTRL-D: Move the cursor down 12 lines Dàdown

Ctrl-u: The cursor moves up 12 lines uàup

CTRL-F: Move the cursor down 22 lines

Ctrl-b: Cursor moves up 22 lines

NG: Moves the cursor to the nth row, such as 100G

Copy, cut, paste, cancel, modify

In command mode, type

YY: Copy the current row to the temporary buffer nyy-à5yy Copy the current next 5 rows

DD: Deletes the current row and saves its contents to a temporary buffer

NDD: Deletes multiple rows and saves its contents to a temporary buffer, such as 3DD replication currently under 5 rows

P: Copy the temporary buffer contents to the next line in the current row

P: Copy the temporary buffer contents to the previous line of the current row

U: Cancel the last modification

. : Repeats the last action
Or Used to search forward or backward in a file

Edit Multiple Files

Command format: VI file1 file2 file3 .....

First edit file1, in command mode, type: N will edit the next file, type: N will edit the previous file.
Type: AR will display the list of edited files.

Read into a file content

Command format: In command mode, type: R file

Function: Reads the contents of file files into the next line of the cursor

Save part of a file as another file

Command format: n1,n2 w file

Example: 5,20 w t2.txt, saves the contents of line 5th through 20th of the file to the file t2.txt.


Letter Buffer

"WDD: Delete the current row and save the copy in buffer W D-->delete

"WP: Copy the contents of buffer W to the next row of the current line w----> write P--->copy

"Ayy: Copy the contents of the current row into buffer a

Using shell commands


Command format:! Command
R! LS record into text
R! Date is recorded in the text

Some simple operations:

(1) Create a directory: Create a folder named after "name" in the root directory.
Go to root directory cd/mkdir name

(2) Enter the newly created directory to create the file "a" and "B".
CD name Touch a touch B or touch a B

(3) Create the directory ex3 under the current folder.
mkdir ex3

(4) Enter the EX3 directory and copy the A file from the previous level directory to the current directory, renamed "C".
CD ex3 CP. /A./

(5) Use the MV command to change the file name "C" to "D".
MV C D MV with rename feature can also move files

(6) Delete D.
Rm-rf D (RM d)

(7) Return to the previous level directory.
Cd.. /

(8) Use the "find" command to find a file named "B" under the "/" directory.
Cd/find-name b

(9) Displays the absolute path of the working directory.
Pwd

.. /Return to previous level directory

./Current root directory


Use of GCC:

(1) Compile the program work.c with the GCC compiler, generate the executable program ework, and knock out the command on the terminal

Vim work.c (write content) Wq gcc work.c-o ework (build executable)


O-->output

(2) How to execute Ework

./work

(3) explanation gcc helloworld.c–o Hello command

Enter the compiled file HELLOWORLD.C output executable Hello

(4) How to view the GCC installation path

which GCC

(5) How to view GCC version information

Gcc-v

(6) To add debug information to work.c compile time, command behavior?

Gcc-g (Gcc-g-o ework work.c) Note:-O immediately following the output of the file/GCC work.c-g-o ework

G----(-G, the symbolic information necessary to produce the symbolic debugging tool (GNU GDB), to debug the source code, we must add this option. )

View the GCC version you are using
# gcc-v
View the GCC directory, which is the GCC installation path.

# which GCC

Use of the GDB debugger:

# Vim WORK.C
#wq
# gcc-g-o work1 work.c-------> here the-G command must be debugged to execute GBD
# GDB
# file Work1
# Run/next/step/break Number (terminates the first few lines)/continue/quit
# Whatis + variable (display variable type)/print variable (display variable at that time value)

Unpack the tar for the package

TAR-ZXVF package_name

./executable File

Enter
--------------------------------

Un zip decompression

Chmod-r Permissions File-r is to change permissions along with all files in the directory and directory

Df-h Display usage by g

Dpkg-l List of installed software

Swapon Open Swap partition

Linux command Summary "to be Continued"

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.