1. Change the working path, equivalent to the CD in DOS: (. Indicates this level of directory,.. Indicates a parent directory)
Cd
Cd..
Cd/user/bin
CD Home
2. Display the working path:
Pwd
3. List the files in the directory, equivalent to the dir command in DOS:
ls [option] [file-list]
"Option common":
-A (all) displays all files and directories including hidden files
-I (inode) displays the inode number of each file
-L (Long) displays files under the current path in long format (10 items)
4. Create a new directory:
mkdir Directory
5. Delete the empty directory:
RmDir Directory
Rmdir-p testdir/temp
6. Copy the file:
CP Source_file Dest_file (not fully copied and overwritten)
Cp-r Source_dir Dest_dir
Cp-p source Dest (fully copied and overwritten)
********************************
"Issues with file attributes":
Ls-l
-rw-r--r--1 Root Other 7 16:44 a
-rw-r--r--1 User1 staff 7 16:45 C
-rw-r--r--1 User1 staff 7 16:45 D
Umask 066
********************************
CP a B;
CP a C;
Cp-p a D;
Cp-p A E;
********************************
Ls-l
-rw-r--r--1 Root Other 7 16:44 a
-RW-------1 root Other 7 16:47 B (cp a B; B does not exist, attributes are different)
-rw-r--r--1 User1 Staff 7 16:47 C (CP a C; C present, not covered by a)
-rw-r--r--1 root Other 7 16:44 D (Cp-p a D; d exists but is covered by a)
-rw-r--r--1 root Other 7 16:44 E (cp-p a E; completely copy A to C)
8. Copy files between different hosts:
Rcp/temp/test1 Ts1:/export/home/test1
rcp host1:/var/adm/sulog Sulog
9. Links. Make two files share the same disk space.
"Hard link":
ln exist_file new_file
"Symbolic link":
Ln-s Exist_file New_file
10. Move the file or rename the file:
MV Existing_file New_file
11. Delete command:
RM [option] FileName
"Option common":
-R
-I.
12. Display file by screen:
More filename
"During execution":
Space shows the next screen
Enter to display the next line
Q or ^c exit display
=
! Command
13. Find the string in the file and display the line that meets the requirements:
grep [option] string file_list
"Option common":
-V
-N
-I.
-C
"Example":
grep sh/etc/passwd
14. Show file start n rows or last n rows:
head-5 filename
tail-5 filename
Head filename
Tail filename
tail-f filename
15. Count the number of lines, characters, and words of the specified file
WC [option] filename
"Option common":
-C
-W
-L
"Example":
Wc/ect/hosts
Showing the result: 283/ect/hsots
16. View File types:
File filename
"File type":
ASCII text
Command text
Empty file
Audio data
中文版 text
.....
17. Find the file location:
Find path expression
"Expression common":
-name filename
-user username
-print
-exec command \;
"Example":
Find/-name core-print-exec rm{} \;
18. Change file permission information:
chmod who [operation] [permission] filename
"Who": U g o A
"Operation": +-
"Permission": R W X
chmod a+x File
chmod u=rwx,g=rx,o=r File
"Binary form":
File rwx r-x r--111 101 100
chmod 754 File
19. Modify the file owners and groups (Chwon and CHGRP commands):
Chown owner filename
Chown uid:gid filename
Chown-r owner filename
20. Modify the user password or other user information:
passwd
passwd username
Passwd-e
Passwd-h
Passwd-d
Passwd-l
21. Display or modify the system clock:
Date
Date mmddhhmmyyyy
22. Display information about the computer system and the operating system on the standard output:
UNAME-M Display the core structure of the machine
UNAME-R Displays the version number of the operating system release
Uname-s Display system name
Uname-a display all of the above information
23. Show System process Status:
Ps-e
"Example":
Ps-e
PID TTY Time CMD
1837 PTS/2 0:00 SH
1931 PTS/3 0:00 PS
"Common Processes":
Gated, inetd, Mountd, NFSD, Rlogind, in.named ...
24. Kill a process:
Kill PID
Kill-9 PID
Kill-hup PID
Kill-1
25. Display the usage of disk space:
Df
Df-k
26. Display the number of hard disk blocks used by directories and files:
Du [-A] [-s] [-K] [directory] (-a displays the structure of the specified directory in block,-K in kilobytes,-s in blocks (512 bytes))
"Example":
Cd/opt
Du-k
********************************
Cd/usr
Du-s
********************************
Du-a/usr
27. Displays the size of the disk space used by the user:
quot [-AF] [filename ....]
A displays all systems that have been hooked up
F Show the number of files
"Example":
Quot-af
28. Create a new empty file:
Touch filename
"Example":
Touch/reconfigure
29. Provide users with manuals, documentation, and concepts to help:
Mans LS
Man TCP
Mans resolv.conf
30.VI commands are commonly used:
"Start":
VI File
VI + File
VI +n File
VI +/string File
"Exit":
Q
Wq
Q!
wq!
"Screen control":
Half-screen mobile ^d (down) ^u (UP)
Full Screen mobile ^f (forward) ^b (backward)
"Insert Command":
I I
A A
o O
"Delete command":
x D0
d$ DG
DD NDD
Dw
"Modify Command":
CW R C $
CC C0
"Copy command":
yy yw Nyy
"Paste Command":
P p
"Other":
Cancel Last Action U
Repeats the last action.
"Common character meanings":
W write a file or represent a word
Q Exit Edit
0 beginning of Line
$ End of line
H Screen top Line
L Screen Bottom Line
D Delete
C Modification
Y copy
P Paste
G file End
M Screen Middle Line
X Delete
"Vi-line command":
Exit:
Q
Wq
Q!
wq!
Search string:
/string N
N
? string n
N
String substitution:
: [address]s/search-string/replace-string
[Address] n
N1,n2
%
"Example":
:%s/hs/huasun
"Set environment Variables for VI":
: Set Number
: Set Nonumber
: Set list
: Set Nolist
: Set All
:!command
Linux Common commands