liunx learning

Liunx learn from
liunx command

liunx file formats:

 -:表示普通文件 
 d: 表示目录文件 
 b:表示快文件 
 c: 表示字符设备文件 
 l: 表示软链接文件 
 p: 表示管道文件 
 s: 表示套接字文件 

(centos7.6 / bin / bash)
w Displays the current logged-in user's operation
who displays the current login user information
whoami Displays the name of the currently logged in user
which determines whether the external command cmd path which
whereis who can see the external command path, see Help Manual
tty terminal displays the current directory
who am i to display the current directory and link address terminal
init # switch to shut down the current terminal and a terminal
terminal switch runlevel view of
free memory to see
lscpu view the CPU
lsblk view the hardware to mount
cal view a calendar
date to see the software date
hwclock , clock date -s to see hardware hardware modifications prevail software -w time to modify the hardware to the software, whichever time
when timedatectl status viewing area
timedatectl list-timezones see all time zones
timedatectl set-timezone change the time zone
echo echo displays the character "" weak references' 'strong references recognize the command
history to see the history command
PWD (OLDPWD) see the current directory relative directory, the directory absolute
ps aux to see the current process
df to view the disc mount
uanme -r -n system name followed by the version number of the host name
alias alias
View cache hash

Some command usage: 1

A, ls lists the contents of the current directory or the specified directory

Usage: ls [options] [files_or_dirs]
example
ls -a contain hidden files
ls -l to display additional information
ls -R recursively through the directory has been viewing in the end
ls -ld directory and symbolic link information
ls -1 file Branch show
ls -S Press descending order
ls -t Sort by mtime
ls -u with the -t option to display and press atime new to old Sort
ls -U directory stored in the order shown by
ls -X sort by file extension
ls -d list the current file attributes , sub directory information are not listed

After a supplementary concept to create a file or directory has three timestamp:
Access Time Access time, atime, read the contents of the file
modify time modification times, mtime, change the contents of the file (data)
Change Time to change the time, ctime, metadata changes
stat You can view

Two, touch creates an empty file (-)

Usage: Touch [OPTION] ... FILE ...
-a change only atime and ctime
-m change only the mtime and ctime
-t [[CC] YY] MMDDhhmm [.SS] timestamp specifies atime and mtime of
-c if file does not exist, will not be created

Three, cp copy files and directories

cp [OPTION] ... [-T] the SOURCE DEST
cp [OPTION] ... the SOURCE ... DIRECTORY
cp [OPTION] ... -t DIRECTORY the SOURCE ...
from the directory to the root of
cp SRC DEST
SRC file:
If the target does not exist: New DEST, SRC and DEST content to fill in
if the target exists: If the file is DEST: the contents of the SRC to DEST covered in
security-based, it is recommended to use the -i option to the cp command
if DEST is a directory : new with the same name as the original file in the DEST file and the new file is filled to the SRC content

covering the front tips -i
-n does not cover, both the order noted
-r, -R recursively copy all the contents of the directory and internal
-a archive --preserv = All equivalent -dR
-d --no---preserv the dereference = links does not copy the original files, just copy the link name
--preserv [ATTR_LIST =]
the MODE: rights
ownership: the owner is a group
timestamp:
links
xattr
context
All
-p = the MODE equivalent --preserv, Ownership, timestamp
-v --verbose
--force -f
-u --update only copy the source file than the file update target or target does not exist
-b target exists, front cover to back, in the form of ~ filename
--backup = Numbered target exists, plus front cover to back numeric suffix

Four, mv moves and subtlety file
mv [OPTION] ... [-T] SOURCE DEST - a file to a directory
mv [OPTION] ... SOURCE ... DIRECTORY - the root of the directory
mv [OPTION]. .. -t DIRECTORY SOURCE ...
commonly used options:
-i interactive
-f Force
-b target exists, back up before overwriting

Five, rm delete
rm [OPTION] ... FILE ...
commonly used options:
-i Interactive
-f Force delete
-r recursive
--no-preserve-root delete /
Example: rm -rf / *

Sixth, directory operations

Show tree directory tree
-d: Displays directory
-L level: Specifies the number of displayed hierarchy
-P pattern: only matching pattern to the path specified by the
mkdir create directory
-p: no error is present in, and automatically create the required each directory
-v: display detailed information
-m MODE: when you create a directory permissions directly specified
rmdir to delete empty directories
-p: father recursive delete empty directories
-v: show Details
rm -r recursively remove a directory tree

There is a complementary concept of inode, soft connection, hard links need to understand

Check the file type, and then determine the appropriate application using the Open command or
file [options] <filename> ...
Common options:
-b list the files when the identification result, the file name is not displayed
-f filelist filelist file in the file list type the name of the file
after the specified delimiter -F replace the default output file name ":" separator
-L to view the corresponding soft link corresponding to the file type
--help displays command-line help

Seven standard I / O

Standard input and output
program: data + instruction
reads data: the Input
Output data: Output
open file has an fd: file descriptor (descriptor)
the Linux program to provide three I / O devices
standard input (STDIN) -0 receiving input from the keyboard default
standard output (sTDOUT) -1 default output to the terminal window
standard error (STDERR) -2 default output window to the terminal
I / O redirection: change the default location
sTDOUT and STDERR may be redirected to a file
command operations symbol file name
supported operating symbols include:

The STDOUT redirected to a file
2> The STDERR redirected to a file
&> redirect output to file all the
contents of the file are overwritten
set -C prohibited contents overwrite the existing file, but can be added
| file cover forcibly
set + C allows cover

On the basis of the original content, additional content

ls /erro /boot >fb.txt 2>&1
ls /erro /boot 2>fb.txt >&2
ls /erro /boot 2>&1 > fc.txt
(ls /erro /boot 2>&1) > fc.txt
(uanm -r;hostname) > fc.txt
标准输入的重定向 <
bc < bc.txt
cat < bc.txt
cat < bc.txt > bc2.txt
cat < bc.txt > bc.txt 清空
cat < bc.txt >> bc.txt 无限递归

Eight, conversion and delete characters

conversion and delete characters tr
tr [OPTION] ... SET1 [SET2 ]
Options:
-c -C --complement: Take character sets complement
-d --delete: delete all characters belonging to the first character set
-s - -squeeze-repeats: continuous duplicate characters are represented by a single character
-t --truncate-set1: the first character corresponding to a character set into a second set of characters corresponds to the character
[: alnum:]: letters and numbers [ : alpha:]: letters [: cntrl:]: control (non-printing) characters
[: digit:]: digital [: graph:]: graphic character [: lower:]: lowercase letters
[: print:]: printable characters [: punct:]: punctuation [: space:]: whitespace characters
[: upper:]: uppercase letters [: xdigit:]: hexadecimal characters

Guess you like

Origin blog.51cto.com/14421850/2415261