Learning unix command
consisting of a .os of
computer hardware and software composition
software is divided into system software and application software,
system software is the operating system
1.kernel kernel
1. Hardware Management
2. Managing memory (memory allocation)
3. Managing swap space (virtual memory )
from the start portion of hard disk space, operating system through frequent swapped out of memory, enough to achieve the effect of
4. the management process
program static
process start the program became processes, each of which corresponds to uniquely identify the program
threads of a process corresponding to more than threads
5. the control system hardware and system program (drive)
6. management daemon
running in the background, the system starts startup, shutdown when the system is shut down
7. file system management
2.shell provide the user sends a command interface
is the interface between user and kernel
-playing interpreters and translators
advanced language people can recognize
the machine to the machine language
whoami view the current user's username
$ represents the average user
# administrator on behalf of
the first switch administrator needs to set an administrator password
sudo passwd root
switch users
common to super su
super to ordinary exit
3.File system file system, all hardware are mapped to a file
tree structure is formed of an inverted file, directory, subdirectory of / for the root directory
path
pathname: uniquely identify the file
relative to the current directory path relative to
an absolute path of the root path
relative path does not begin with /
two.
Modify the user password passwd
modify user password have certain requirements, does not require super user
1. The password characters 6-8
2. password has at least two characters, and a special character or a numeral
3. The user name and password can not identical
4. old password and the new password characters at least three different
view all user information cat / etc passwd /
user information returned briup: x: 1000: 1000: briup ,,,: / home / briup: / bin / bash
portions meaning username: password text placeholders: uid: gid: Note: the user's home directory: the default shell
sudo CAT / etc / password to view information about Shadow
sudo temporarily elevate privileges
follow the principle of least privilege: try to ordinary operations user completes
$ 6 $ R / HxX3gQ $ kj2E2Z3p8IE86s.I6bnLccqClB0vTBQAfndFAzeZngovuyAJfDNVmDweKtGF / AznY1NqAur7V2T5F7G4vxLMl0: 18102: 0: 99999: 7 :::
Space Command Line distinguish the different parts of
a single line command input up to 256 characters
different from the doc
case sensitive
different command prompt
1.clear clear screen
2.pwd view the current directory
cd into the path of an address directory
cd .. back to the parent directory CD .. .. continuously returned two
3.ls files and directories in the current directory
ls -l show details of files and directories in the current directory
ls / files and directories under the root directory
ls / display etc etc files and directories
ls -l / etc show details of files and directories under etc
LS -d the -l / etc displays detailed information itself can write a -dl LS / etc
LS -R / etc subdirectory and sub-sub-display directory until the last inside information
ls -a: shows all files and directories containing hidden files and directories
ls -t: Sort display based on the last modified time
ls -F display file catalog file type / * executable text file (none)
4.touch create or update a file access and modification time
touch b.txt c.txt test create multiple file
touch file can only be created, can not discriminate based on suffix
5.mkdir Create a directory
mkdir GAM
mkdir GAM1 gam2
mkdir GAM / lol
mkdir Game / the Game1 If the parent directory does not exist by default can not create
mkdir -p game / game1 will automatically create multi-level directory
some directories are needed to create certain privileges
sudo mkdir / etc / gam
Change the file permissions 6.chmod
chmod o + w a.txt other increased write permission
chmod gw a.txt group minus the write permission
chmod g = rw a.txt group permissions to read and write
the chmod UX, G + W a.txt
the chmod 664 a.txt numeric way to change permissions
7. cp copy files
1. copy the source file to the destination
CP -i a.txt d.txt
2. the replication source to the destination directory
CP a.txt GAM
CP b.txt ABC (file) GAM
CP b.txt GAM c.txt
3. copy the source directory to the target directory
cp -r gam2 GAM1
-i If the target file already exists you will be prompted to overwrite, if the target file does not exist and will not be prompted to automatically create a file, overwriting the file contents
cp followed by multiple files, the last one will go to determine whether the catalog, others are text files
-r copy a directory
8. vi a.txt enter a.txt file for editing
1. vi move around
Arrow keys to move the command mode
2. vi How to delete a character, delete a row, replace a character
Command mode cursor to a specified location by x
dd Delete the current line
r replace one character
3. vi how to copy a word, line copy, paste
Yw copy command mode cursor location to a word in the first space
yy copies current line
p copying operation after paste
4. vi How to Save, Save As, and save the file and exit vi
: W save
: W newfile saved as a new file
: Wq save and quit vi
5. vi how to file documents in all the words hello, are replaced by hi
Enter the command mode: 1, $ s / hello / hi / g
6 vi lookup operation
In command mode / keywords you want to find (look down)? The keywords you want to find (look up)
7. common operations:
In the command mode, enter the following command:
i: insert a character before the current cursor
I: Move the cursor to the beginning of the line
a: a character is inserted after the current cursor
A: To the end of the line
o: move to the next line
O: to move the line
yy: copy this line cursor
4yy: Copy the start line where the cursor down 4 lines
p: Paste
dd: Cut the line cursor
2dd: cursor line cut down 2 rows
D: start from the current cursor shear until the end of the line
d0: cut from the current cursor starts until the beginning of the line
x: delete the current cursor, each time only removes a
X: delete the current cursor in front of that, each time only removes a
h: J leftward movement: Move down k: l move up: Move
H: move to the top of the current screen
M: the current screen to an intermediate
L: move to the bottom of the current screen
ctrl + f: folded downwards a Code
ctrl + b: an upturned Code
ctrl + d: half turn down a page code
ctrl + u: upturned half page code
20G: to quickly locate the twenty lines of code
gg: quickly return to the first line of the entire code
G: quickly to the whole of the last line of the code
w: jump backward a word length, i.e., a skip to the beginning of the next word
b: ahead one word length, i.e., jump to the beginning of a word
u: undo just the
ctrl + r: Anti revocation
Select a code uses the following two commands
v: Select from the current cursor backward begin, continue to press the left direction key
V: Select a row, we need to continue to press the up and down arrow keys
>>: Move the Code
<<: leftward Code
: Once on command Repeat
{: Press segment is moved, the shift
}: Press section moves down
dw: Delete the cursor starting position of a word (a word), contains the character under the cursor
r: Replace a character
R: Alternatively the cursor and the following characters
/ Things to look for: Search (need to press Enter)
n: Next
One of: N
shift + zz: the equivalent of wq
In the line mode, as follows:
:% S / abc / 123 / g: abc line mode, it is replaced with the current file 123
: 1,10s / abc / 123 / g: abc between the first row to the tenth row bar 123 is replaced
w: save
q: quit
wq: Save and Exit
q !: forced to exit without saving
In edit mode, as follows:
Ctrl + n input or automatically ctrl + p completion, the displayed list of names with the same prefix.
8.mv moving files or directories
to move the source file to the target file source file exists, paste the contents of the source file past, and delete the source files
mv b.txt c.txt
source file does not exist, can not be cut copy
mv ab.txt c .txt
target file does not exist, the source file exists if the target file does not exists, then modify the file name
mv c.txt ab.txt
will move the source file to the target directory
mv a.txt Game
mv ab.txt Game2
mv d.txt Game2 gam2
the source directory to the target directory
Music Videos GAM1 Game
Music Videos gam2 / GAM d.txt
Music Videos GAM / d.txt a.txt
9. rm delete files and directories
RM -i GAM / GAM c.txt / b.txt
rmdir GAM
rmdir only removes empty directories
RM -r GAM
RM delete non-empty directory, the directory needs -r identified as
RM -r game3
10. man displayed next instruction which operation
man ls ls command which commands to view
the space key: the display screen by screen
B: roll back to the previous screen
f: the next screen
Enter: line by line display
11./
String / string to find
/ A
n-: Find an associated string
q: quit
find based on keywords
man -keyword tou
Three yuan characters: the characters have some special significance, can replace some elements of
role:
1. Simplified string
2. fuzzy matching
; $, <>, *, |,>
1 represents the home directory ~
2 * represents 0 to more than characters
Touch a.txt b.txt c.txt ab.txt abc.txt
mkdir GAM GAM1 GAM3
LS a *
LS ab *
LS * a c
RM a *
LS * .txt
3.? represent a single character has one and only one character placeholder
ls a? .txt
ending in C, the third to last character is a file
LS * a? C
4. [] single character matches the character series
touch link1.txt link2.txt n.txt k.txt
Link * 2 * .txt LS
. LS * [Link] * TXT. 4
LS [LinkA] .txt
matched to any one of the brackets single character file
5 .; connecting a plurality of commands, there is no relationship between the order
date: Date
cal : current month's calendar
cal 2017 to obtain the corresponding month of the calendar year all
cal 4 2017 display the corresponding year and month of the calendar
date; cal
6. The | Pipe command
output of a previous command as the next command is
more: split-screen display
LS -l / etc | More
. 7>, >>, <redirect command.
> Redirect the output
>> redirect the output
<weight directional input
standard output screen ---
standard keyboard input ---
and in conjunction cat
cat / etc / passwd> a.txt
contents of the file is no longer displayed on the screen, but on the specified file,
and the information content into file overwrites
sudo cat / etc / shadow >> a.txt
contents of the file are no longer displayed on the screen, but on the specified file,
and the information content inside the file will be added to
cat <a.txt
/dev/null>a.txt CAT
/ dev / null file black hole, not put into things, things could get it out
8 .: a no-op
:> a.txt
the above two methods are empty file