Linux System Command Format
Syntax: command [- options] Object
ls -Ls / etc
Description:
1, when more than one option, you can write together.
2, two special directory. .. and, respectively, represent the current directory and the parent directory of the current directory.
- File processing command
1. Display the directory file ls
-a show all files, including hidden files
-l way to display a list of detailed information
-d directory attributes View
-H -l size with the use of user-friendly display file or directory
Example: ls -al shows details of all files
2. Change directory cd
cd / back to the root directory
cd ~ / cd back to the user's home directory
cd .. / cd ..// back to the parent directory (the parent directory)
cd. directory does not jump
cd ../..// back to the parent directory parent directory (the two directories)
3. Display working directory pwd currently resides
例:[root@CentOS viper] # pwd
/home/viper
4. Create an empty file touch
例:touch text
5. Create an empty directory mkdir
-p create directories recursively
例:mkdir -p test/{one/{music,fig},two/{music,fig}}
6. Copy the file or directory cp
-R recursively copy the directory and the directory or file
Example: cp file1 file2 dir to copy files file1, file2 to the directory dir
Example: cp -R dir1 dir2 dir1 include the file copy all files and subdirectories below it to the next directory dir2
7. Move the file / directory or modify the file / directory name mv
Example: mv dir1 dir2 dir1 the file in the current directory renamed dir2
Examples: mv file dir file to move files in the current directory to the directory dir
8. Delete the file or directory rm
-r delete a directory
-f Force delete files or directories, no prompt appears
Example: rm file delete file file
Example: rm -r dir delete the directory dir
9. The display file contents cat
Only less suitable for viewing the contents of the file.
Example: cat text view text files
10. paging file contents more
(Spaces) or f display the next page
(Enter) to display the next line
q or Q to exit
Example: more text view text files
11. Before the display file contents head a few lines of
-number displays n lines before the file
Example: head -20 text line 20 front view the text contents of the file
12. After a few lines display file contents tail
After the file is displayed -number n lines
-f dynamic display file
20 lines of content after tail -20 text view text files: Cases
13. establish hard / soft connection ln
-s establish a flexible connection
Example: ln -s text.s text build text files flexible connections text.s
Soft source file is deleted after the connection can not be used
Example: ln text.h text hard to establish connection text.h text file
After a hard link to delete the source files can continue to use
- Rights Management Command
1. Change the file or directory permissions chmod (r x-readable writable executable w)
chmod {ugo} + - = {rwx} [file or directory]
chmod {number} [file or directory]
Example: chmod u + r file document file to add the user read permission
Example: chmod 777 file to file documents All users can write readable executable permissions
2. Change the file or directory belongs to user chown
Example: chown user file belongs to the user for the user to change the file file
3. Change the file or directory belongs to the group chgrp
Example: owning group chgrp whi file change file file is whi
- File search command
1. Display the file system directory which command
例:which ls 查看ls命令所在文件路径
2.显示系统命令所在目录 whereis
例:whereis ls 更加详细的查看ls命令所在文件路径
3.查找文件或目录 find
例:find /etc -name init 在目录/etc中查找文件init
4.查找文件或目录 locate
例:locate file 列出所有跟file相关的文件
5.在文件中搜寻字符串匹配行并输出 grep
例:grep ftp /etc/servies 在servies文件例查找带ftp的行
- 帮助命令
1.获得帮助信息 man
例:man ls 查看ls命令额帮助信息
2.获得帮助信息 info
例:info ls 查看ls的帮助信息
- 压缩解压命令
1.压缩文件 gzip
只能压缩文件不能压缩目录,不保留原文件
例:gzip text.gz text 把text文件通过gzip压缩
2.解压缩.gz的压缩文件 gunzip
例:gunzip text.gz 解压texxt.gz文件
3.打包目录 tar
-c 产生.tar打包文件
-x 解包.tar文件
-v 显示详细信息
-f 指定压缩后的文件名
-z 打包的同时压缩
例:tar -zcvf text.tar.gz text 打包text文件
tar -zxvf text.tar.gz 解包text.tar.gz
4.压缩文件或目录 zip
-r 压缩目录
例:zip text.zip text 压缩text文件
zip -r dir.zip dir 压缩dir目录
5.解压所有.zip文件 unzip
例:unzip text.zip 解压text.zip文件
- 网络通信命令
1.测试网络连通性 ping
-c 自定义发送请求包数量,然后结束
例:ping ww.baidu.com
2.查看网络设置信息 ifconfig
-a 显示所有网卡信息
例:ifconfig -a 显示所有网卡信息
3.向另一个用户发信息,以Ctrl+D作为结束 write
例:write viper 向viper这个用户发送消息
4.向所有用户广播信息 wall
wall Happy New Year! 向所有用户发送消息
- 系统关机命令
1.关机/重启 shutdown
-h 关闭系统
-r 重启系统
例:shutdown -h now 立即关闭系统
shutdown -r now 立即重启系统
2.重启系统 reboot
例:reboot 重启系统