linux study (two) ----- Linux common commands

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/q303705455/article/details/94891365

Linux is frequently used commands and operations

- linux directory structure (linux file system):
/ root directory, similar to windowing the respective disc symbol (the other are contained in the root directory)

  • bin executable binary file
  • boot boot boot files
  • dev hardware device files
  • etc System Configuration
  • home directory of the other users except the main root
  • proc virtual file system that holds the current memory mapping
  • usr for storage system applications, more important
  • var for storing runtime data need to change the
  • lib / lib64 store some local libraries
  • mnt mount mirror data
  • temp temporary folder
  • superuser root directory
  • opt optional additional installation application package is positioned at location

linux common commands are divided into:

  • File directory operation command
  • System Management Commands
  • Shutdown restart command
  • linux channel
  • Backup compression command

The most common operating system-related commands:

Common commands:

  • ls represents the current directory under the file and folder (-a: said it will show all the files in the path, including hidden files; -l: equivalent to ll, detailed queries all the data files)
  • pwd (Print Work dir) shows the current directory
  • cd (Change dir) path into the directory
  • date acquisition system time (date -s 'format' may change time (root privileges) below)Here Insert Picture Description
  • Process command: ps static display process (ps -aux: static display of all processes;)
  • Process Commands: top dynamic display process
  • Pipe command: | Is there a general mix of XX ps grep screening process; for example, PS -ef | grep XX , as shown below
  • Filter command: grep match |
    Here Insert Picture Description
  • pstree tree structure shows the relationship between processes
  • - the current home directory
  • touch to create a file (such as touch aa: create a file aa)
  • mkdir Create a folder (for example, mkdir bb: create folders bb; mkdir -p: recursively create folders, for example, mkdir -p aa / bb / cc: the equivalent of creating a folder for the aa, aa bb file contains clip, bb contain cc, they are all folder and file names can not exist with the same name)
  • rm delete files / folders command (-f: force the removal -r: to delete a folder, recursively delete -rf forced recursive delete, delete highest level)
  • echo output command (echo 'content'> file: to deliver content to a file, if the file does not create, if this file echo 'Content' >> file is overwritten: If you do not create this file, if this Add the contents of the file to the original file contents)
  • cat / tac view the content (cat forward, tac reverse)
  • cp replicated copies (cp src dest format; SCP remote copy command)
  • Cut mv command can also be used as a command to rename
  • find meet the requirements of the query file (usage is typically find -name 'XX': route query named XX) over the corresponding paths
  • Links command: ln can not for the soft link (ln -s aa bb) and hard links (ln aa bb)
  • more / less paging display data
  • Display data header head (head -n 50: Display data header 50)
  • tail data display tail (tail -n 50: 50 show the tail data; tail -f file name: monitoring data can be changed dynamically, the two windows can display data changes)
    Here Insert Picture Description
  • stat read detailed file information (stat file)
  • who / w / whoami display system user / user name
  • du displays disk usage size of the file (for example, du /: He will appear in all sizes root directory)
  • df view disk usage details
  • Repair Disk fdisk command
  • which / whereis location query command, for example, FIG.
    Here Insert Picture Description
  • View netstat network port and use cases (netstat -ano)
  • Check free memory conditions
  • kill kill the process (kill pid; kill -9 pid force kill process (caution); general process ID with ps -aux display)
  • shutdown shutdown -r shutdown shutdown -h shutdown shutdown -r 10: 10 minutes after the restart shutdown -h now immediately shut down
  • halt shutdown
  • exit exit
  • reboot reboot
  • logout logout
  • su switch user (default root user; su username; su - to the root; su - Username: Fantasy to a corresponding user, and the path is switched to the corresponding home directory)
    Here Insert Picture Description
  • useradd useradd Username: create a new user (root permissions), root privileges can change the password for the user.
  • wc wc (word count) wc word files: word count the number of lines in the file, etc.

About init: (0.3.5.6 using poly)
0: Off
1: Single User
2: Multi-User
3: No Interface Mode
4: Reserved Mode (undefined, unused)
5: Interface Mode
6: Restart
ps: by systemctl set-default level switch system, no interface mode multi-user.target; interface mode has graphical.target

Help command:

  • command --help # 调用命令的帮助文档
  • man command # 显示命令的详细使用文档 q退出
  • info command # 类似于man命令 q退出
  • table键进行命令提示和补齐

系统信息命令:

  • uname 查看系统信息
  • uname -a 详细系统信息
  • uname -r
  • uname -m
  • ……
  • cat 文件 # 查看文件内容
  • cat /etc/redhat-release # 查看内核信息
  • cat /etc/issue
  • cat /proc/version # 查看系统信息

归档命令:(归档:把多个文件整理在一起;压缩:将文件用一定算法减少空间)
tar命令:tar -cvf log.tar *.log(将所有后缀名为.log压为一个名为log.tar的包);解归档:tar.xvf log.tar
gzip:用gzip算法将其压缩为一个XX.tar的包,例如gzip log.tar.gz xx xx 解除:gzip -d log.tar.gz解除压缩
归档:tar -zcvf xx.tar.gz xx xx
解归档:tar -zxvf xx.tar.gz

快捷键:Ctrl + r # 命令终端能够查找以前输入的命令
Ctrl + c/z # 终止终端命令
Ctrl + l或者clear 清楚屏幕命令

查看网络ip地址:
1.ifconfig/ip add linux下查看ip地址
2.ipconfig windows下查看ip地址
3.ping 测试网络是否连通

路径问题:

  • 相对路径:. …/ 这些相对于当前所在目录而言
  • 绝对路径: 一般是根目录(/)作为标准

关于文件的权限

rwx(read读,write写,execute执行)的权限:

  • r 4, w 2, x 1
  • 三个为一组,例如rw-rw-r–为664(4+2,4+2,4)
  • u(user代表个人),g(group代表所在组),o(other代表他人)分别对应代表上一点的三个数字664(权限)
  • 修改文件权限:chmod chmod u-w xx.txt:去掉xx.txt写的权限;chmod u+w xx.txt:增加写的权限给xx.txt r和x与之相同
  • 修改文件权限:chmod 也可用数字赋权限,例:chmod 777 a.txt (777相当于最高权限给a.txt)
  • 修改文件对组或用户的权限:chown 例:chown 用户:用户所属组 /soft :把文件的使用权限给用户/用户所属组

**

关于一些相似命令的区别

**

  • ps和top的区别

ps和top都是用来查看进程的命令,ps是静态查看进程,top是动态的查看进程

  • cat和tail -f的区别

cat只有把内容打印到屏幕上,只是文本内容,tail -f是动态监控,可以打开两个终端进行数据监控

  • Difference between soft links and hard links
    can be connected to the original file, the original file for flexible connection symbiotic link is a shortcut, equivalent to hardwired backup copy of the file, the original file is not symbiotic.
    Linux systems soft links and hard links two special "files."
    Soft links can be seen as a shortcut in Windows that lets you quick links to the target file or directory.
    Hard links through the inode file system to generate a new file name, rather than create a new profile.
    Create a very simple method:
    1. soft links (symlinks) LN-ssourcetarget
    2. Hard link (link entity) lnsourcetarget

Guess you like

Origin blog.csdn.net/q303705455/article/details/94891365