Bash command/File management-BASIC commands

Source: Internet
Author: User
Tags control characters

Shutdown Init 0

Restarting Init 6


Installing VNC

Installing tigervnc.rpm

Connecting to VNC

Vncviewer [IP]

=============================

[[Email protected] ~]# Date

Wednesday, October 24, 2012 09:38:54 CST

[Email protected] ~]# WhoAmI

Root

==============================

Command option Parameters

[[Email protected] ~]# Date

[Email protected] ~]# date +%f

[Email protected] ~]# date-s 12:30

==============================

CTRL + a jumps to the front

CTRL + E jumps to the last

Ctrl + K Delete from current position to last

CTRL + U Remove from current position to top


LS Displays the file of the current directory

LS object displays information about the specified object

Ls-a object displays all files in the specified location

Ls-l displaying the current file as list details

LS-LH Display capacity units (K, M, G)

ll = = Ls-l

Ll-r recursively displays the contents of the specified directory, displaying all content within the directory

Ls-d/var view/var directory itself

Parameters have long format and short format, generally in short form


PWD View the current work path


CD into the specified directory

Path to CD/directory

Cd. means to enter the current position

Cd.. Represents the top-level directory, which is the parent directory

CD directly to enter the home directory of the current user

CD ~ Represents the home directory into the current user/root

CD-Indicates the previous work path entered


/root directory, top-level directory for all directories

/bin Store binary Command file

/sbin store only binary command files that administrators can run

/dev Storage hardware's device files

Home directory for normal users

/lib/usr/lib/lib64/usr/lib64 These are storage function library files

/root Administrator's Home directory

/USR storage application installation files, and help files, etc.

/var store mail, logs, schedules, tasks, etc.

/etc store configuration files for various services

The location where the/tmp temporary files are stored

mapping files for/proc storage System parameters

/mnt/misc/media are empty directories, which are blank mount points reserved by the system for the user (waiting for the other device to hook up)

File operations

Normal files and directory files

LL View

D Represents a catalog file

s socket file

B-Block device files

C-Character device files

P Pipeline File

L link file, i.e. shortcut

find/dev/-type C

Find specified location specified type (C|P|S|B|D|L)


FILE/DEV/SDA viewing the type of a specified object


Touch file name If the specified file name exists, this command updates the access time of the file, and if the specified files do not exist, create the file

RM file name Deletes the specified file name

-F Force forces rm-f forced removal


The path and name of the mkdir directory to create the specified directory

Mkdir-p dir1/dir2/dir3 Creating a multilevel directory


Rm-r Directory Recursive deletion

RM-RF directory forced recursive deletion (use caution)

RmDir Empty directory name Delete empty directory


About copy and cut

CP [Source file path]< source file name > < destination file path >[target filename]

Cp-r Directory name target location ==> copy directory

MV [source file path]< source filename > [target path]< target file name > can be cut or renamed

======================================================

======================================================

Touch file{1..4} ==> Touch file1,file2,file3,file4

CP File{.txt,.bak} ==> CP file.txt file.bak Copy and rename

MV File{.txt,} ==> mv file.txt file clipping and renaming


* Number wildcard with a string (including null values)

? The number is a character (not including a null value)


Bash Shell also supports tab completion

Bash Shell Support help

Command Man (System Help) command--help (third-party help software)

The help command Info command usually uses the first two

man [options] [command]

Mans LS

Search:/-h

Press/< keywords > search keywords under man

Press N to turn, n up, Q to exit

=====================================================

Man 1 ls (default = 1)

Type of Part man manual

1 User Commands

2 kernel system calls (from user space to kernel entry points)

3 Library functions

4 Special Documents and equipment

5 File formats and specifications

6 games

7 specifications, standards and other pages

8 System Administration Commands

9 Linux kernel API (kernel call)

=====================================================

RM [uf]*-F Delete Files beginning with u and f

[] represents u or F, * represents a wildcard.

RM */*-RF Delete the contents of all directories under the current path, but do not delete the directory itself.

Directory/Directory files


Cat < file name > display file contents

-N Display Line number

-a displays control characters, such as line breaks, Windows newline character ^m$

WC/ETC/PASSWD the number of rows, words, and characters of a statistic file

Wc-l/etc/passwd Statistics file amount of rows

Wc-w/etc/passwd Statistics file number of words

Wc-c number of characters in/etc/passwd statistics file


Head-n/etc/passwd Display the first n rows of a file (10 rows by default)

Tail-n/etc/passwd Display the following n rows of the file (10 rows by default)

more | Less is the content of a split-screen display file

More Install.log percent display, press space to flip a page, press ENTER to turn the line, press B to turn, press Q to exit

Less Install.log No percentage display, turn over does not automatically exit


grep "Content to filter" file name filters rows with specified content from a file

grep "Root"/etc/passwd-n filter rows with root from passwd

--color to display matching content in color

-N Display Line number


Alias aliases = "Raw Commands and Parameters"

Alias grep= "grep--color" command aliases

Unalias alias Cancellation Alias

Unalias grep


Dos2unix test.txt convert Test.txt to UNIX (Linux) format

Unix2dos test.txt convert Test.txt to DOS (Windows) format


Path: The location where an object is stored

Divided into: absolute path and relative path

If the path is preceded by a heel, it is called an absolute path

Otherwise, it is referred to as relative path, relative to the current working directory position.


Historical records:

History View Historical Commands

! 55 Execution History 55th order

! -55 Execution History bottom 55th order

! CD from historical countdown find commands that begin with a CD

History-c Clear History Command record

!$ the last part of the previous command (space is a separator)

Alt +. Referencing the second half of the previous command

Ctrl + R search history with keywords

================================================

================================================


This article from "Green Forest" blog, declined reprint!

Bash command/File management-BASIC commands

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.