Basic operations for files and directories
1 mkdir command: Create a directory
1.1 Mkdir-p \data\jxm\-P Create a recursive directory
2 Touch command: Create a file
2.1 Touch 1.txt means to create a file.
3 CP : Copy command
3.1 cp-r/data/jxm/./-R is copied along with the catalogue
4 MV: Moving Files
4.1 mv/data/test.txt/home/to move the test file to/home/
4.2 mv Test.txt hellotest.txt Rename the file test hellotest
5 pwd View current directory
5.1 pwd: \usr\local indicates that the current directory can be variable
6 RM : Delete
6.1 rm-r 1.txt Delete file-rf Force Delete, dangerous operation, generally move file to/tmp/> Acess.log to empty the file.
7 adb : Switch Directories
7.1 CD. Return to last directory cd/etc/sysconig switch directory
8 seq print a sequence of numbers
8.1 seq-s ":" 10 1:2:3:4:5:6:7:8:9:10–s Specify delimiter
9 cat commands:
9.1 Cat 1.txt View file content 1.txt means file name
9.2 Cat >> 1.txt <<EFO
123
345
Efo
Indicates adding file contents to the 1.txt file
9.3 cat-n 1.txt n means adding line numbers when viewing the contents of a file
Ten echo command
10.1 echo "123" > 1.txt means to add 123 content to 1.txt if content in the file will be overwritten
10.2 echo "My qq is" >> 1.txt means append 456 content to 1.txt.
10.3 echo ' seq 1 3 ' >> 1.txt ' indicates the result of executing the SEQ command is put into 1.txt; You can also use echo $ (SEQ 1 3 10)
One Head
11.1 Head 1.txt View file header default first 10 lines
11.2 Tail 1.txt default view file end 10 lines, more view file, you can page
A grep Command: Filter
12.1 gerp ' 456 ' 1.txt filter out files in 456
12.2 grep ' QQ ' 1.txt will filter the line of QQ letters in the file.-V indicates non-QQ content
- sed command: Good at fetching rows
13.1 Sed-n 1,2p 1.txt take the first and second lines in the file 1.txt N to cancel the default output p print
13.2 Sed-i S#100#4510607#g 1.txt-i representative modify S represents replace G for all replacements replace the string 100 in the file with 4510607
- awk command: Good at fetching columns
14.1 awk ' {if[nr==10]print$1} ' 1.txt print$1 means printing the first column of content, nr==10 means that line 10th is equal to using = = in Shell
the Find command: Find command
15.1 Find/-type f-name "1.txt" means the file whose name is 1.txt. /indicates the current directory lookup,-type represents the type
- ls-l (lang) display file contents in long format
16.1 ls-a Show hidden file-d display directory
- Xargs
17.1 often co-ordination | Pipelines can be used with many commands that cannot be processed by a pipeline, such as Find/-type f-name "Install" |xargs ls-l Xargs
- Mans , help– command to see the use of commands
Network Test common commands
+ ifconfig eth0 View network card IP address
19.1 ifconfig eth1|sed-n ' s#^.*r:\ (. *\) BCAST.*#\1#GP '
19.2 Regular expression ^. Start with any letter *r: End \ (. *\) any character bcatst start. *# End S Replace g all replace P end
- netstat View network Status
20.1 Netstat–r viewing the System routing table –l the service being monitored
System common Commands
+ chkconfig--list View System-initiated services
21.1 Chkconfig--list|grep 3:on View the services initiated by 3 mode
A which see where the command is located
22.1 which CP see where the CP command is located
at Mount command: Hanging on
23.1 Mount win7.iso/mnt/hangs the 2.iso file below the/mnt
23.2
- alias Show Aliases
24.1 alias AA=CP the CP command alias AA; Ualias AA Remove Alias
24.2 execution of the command can be an absolute path, so the name does not take effect such as/BIN/CP
- Tar
25.1 Tar zcxf test.tar.gz test.txt the file txt into test.tar.gz:
25.2 tar zvxf test.tar.gz-c/test/extract test.tat.gz to/test/directory-C specified directory
- History View history Commands
26.1 history-c Empty Command
- Su-root switch to Administrator;
27.1 W See who is in the login system
- uname-a View the version of the system
28.1 Uname–a Viewing the kernel version of the system
in Usradd Add Users
29.1 passwd root Modify the administrator password to change the password must be answered passwd
29.2 useradd jxm Add user name
- Groupadd Adding user groups
30.1 useradd xiaoyi-g Guanliyuan Add user Xiaoyi to Guanliyuan Group-G Specify user join group
to Date Show Time
31.1 Date +%f-d 3day formats the file output and prints 3 days after the log +3 represents 3 days ago
+ LN Original file hard link file
32.1 Ln Oldboy Testoldboy If a file has multiple hard-link files and all hard-linked files are deleted, the file will not be deleted.
- ln-s original file software link file
33.1 ln–s Oldboy oldboytest Soft Connect as a shortcut to Windows
the df-h View the space contents of a hard disk
34.1 Df–h the use of file partitions
* Du-sh to view the size of a file or directory
35.1 Du-sh/var difference var directory size
$ rpm RPM Package Management Tools
36.1 RPM–IVH Package name installation shows the installation progress
36.2 RPM–QF find file belongs to that package
36.3 RPM-UVH Upgrade Package
36.4 Rpm–e Uninstall Package
Panax Notoginseng Yum Package Group Management tools
37.1 Yum install software package Group
37.2 Yum gourplist List of installed and installable package groups
37.3 Yum Remove Package Group
- free-m commands to view server memory
38.1
the chattr changing the properties of a file
39.1 Chattr-i/etc/passwd/etc/shadow/etc/group/etc/gshadow to lock these files, you cannot add users,-p recursively change file properties
+ lsof View Port Usage
40.1 lsof-i:22 View the services used for Port 22
A Ps-ef View the tasks that the system is running
the Kill Kill
42.1 kill PID to kill the task corresponding to the PID
+ chmod 755 1.txt permissions to modify files
43.1 7 means read and write execution 5 reads and executes 4 reads 2 writes 1 executes
- Chown change the owner of a user
44.1 Chown Xiaoyi Test 1.txt Xiaoyi on behalf of user test on behalf of user group
$ DD : You can create files of a certain size in Linux
45.1 DD If=/root/install.log Of=/root/acsx.txt bs=100m If represents the input file of the output file of BS represents the size commonly used to back up the hard disk
$ fdisk : View the device name and number of drives in the system
46.1 Fdisk-l
- Vmstat : can monitor Linux overall memory, CPU condition
47.1 Vmstat 2 1 2 indicates that the interval default is the number of seconds 1
- Route : Routing Commands
48.1 Route–n View routing status
48.2 route–add–net 192.168.0.1 netmask 255.255.255.0 GW 192.168.0.1 Add route netmaks mask GW Gateway
the Crontab Scheduled Tasks
49.1 Crontab–l Viewing the system's scheduled tasks
49.2 Crontab–e modifying system timing tasks
- Whereis : is locating executables, source code files, Help files in the file system location
50.1 Whereis RM
50 Commands under Linux