Essential Linux knowledge for backend programmers(译)

1、简单认识操作系统
1-1:
cornerstone 基石
kernel 核心
provied 提供
interface 界面,接口
interact 交互
1-2:Simple classification(分类) of operating systems
a variety of 各种
kernel 内核

Windows:单用户
unix:最早的multi-user, multi-tasking 多用户多任务的分时操作系统。
linux:是免费开源的类Unix操作系统,可以安装在各种计算机硬件系统中,比如平板(tablets)路由器(routers)
2、exploration(探索) of Linux
Kernel version(内核版本):
linux不是一个操作系统,他只是一个kernel(内核),
kernel:建立硬件和软件间的通讯平台,提供虚拟存储等功能

Release version(发行版本):一些公司基于linux内核进行2次开发后的版本,比如Ubuntu和CentOS(新手推荐)
3、Linux file system overview。 linux文件概述

3-1、all resources managed by the operating system。
input and output devices(输入输出设备)or directories(目录) are considered as(被视为) one file.
embodiment :体现
this is an embodiment of the UNIX philosophy, Unix物理哲学的体现。so this concept(思想) has also been passed down(传承下来)
treated :对待,视为.
In UNIX systems, all resources are treated as files, including hardware devices. UNIX systems treat each piece of hardware as a file, usually called a device file, so that users can access the hardware by reading and writing files.Unix把所有的硬件都看做文件,称为设备文件,因此用户可以通过读写文件的形式访问硬件。

3.2 File types and directory structures
(1)普通文件:符号是 -
(2)目录文件:符号是 d
(3)字符设备文件:符号是c
(4)块设备文件:符号是b
(5)符号链接文件:符号是l

常见目录描述:
/bin:存储(2进制可执行文件)binary executable files (ls, cat, mkdir, etc.),commonly used commands are generally here;常用命令通常都在这里。

/ etc: Stores system management and configuration files;存储系统管理和配置文件。

/ home: The root directory that stores all user files(存储所有用户的文件和根目录), which is the base point of the user’s home directory(是用户主目录的根节点). For example, the user user’s home directory is / home / user, which can be expressed by ~ user;(/home/user == ~user)

/ usr: used to store system applications;存储系统应用程序

/ opt: Where to place additional installed optional application packages. (放置额外安装的可选程序包)In general, we can install tomcat, etc. here;

/ proc: Virtual file system directory, which is a mapping of system memory.(虚拟文件系统目录,系统内存的映射) You can directly access this directory to get system information(您可以直接访问这个目录来获取系统信息);

/ root: the home directory of the superuser 超级用户的主目录(system administrator) (privileged class ^ o ^);

/ sbin: Stores binary executable files, which can only be accessed by root.(存储只能由根用户访问的文件) Stored here are system-level management commands and programs used by system administrators. Such as ifconfig(系统级的管理命令)

/ dev: used to store device(设备文件) files;

/ mnt: The installation point where the system administrator installs the temporary(临时文件) file system. The system provides this directory for users to temporarily mount (挂载)other file systems.(系统规定此目录供用户临时挂载其他文件系统)

/ boot: stores various files used during system boot;存储系统引导期间使用的各种文件

/ lib: Stores library files related to system operation;存储与系统操作相关的库文件

/ tmp: used to store various temporary files, and is a common temporary file storage point;用于存储各种临时文件,是常用的临时文件存储点

/ var: It is used to store the files that need to be changed during operation. It is also an overflow area for some large files, such as log files of various services (system startup logs, etc.), etc .;它用于存储在操作期间需要更改的文件。它也是一些大型文件的溢出区域,如各种服务的日志文件(系统启动日志等)等

/ lost + found: This directory is usually empty, and the system shuts down abnormally and leaves a “homeless” file (what is called .chk under windows) here.这个目录通常是空的,系统异常关闭并留下一个“无家可归”的文件(在windows下称为.chk)

4、basic Linux commonly used commands常用命令

4-1、文件切换命令
cd xxx是用来切换到子目录xxx的
cd .. 切换到上一级目录
cd -Switch to the directory where the previous operation was located切换到前一个操作所在目录
cd / Switch to the system root directory切换到系统根目录
cd ~ Switch to the user’s home directory切换到用户主目录

4.2 Directory operation(目录操作) commands (addition, deletion, modification and search)
1、ls或者ll ls查看下边所有文件,ll会加上权限
2、find 目录 参数 Looking for a directory (check)查找目录
List all files and folders in the current directory and subdirectories(子目录): find .
/homeFind file names ending in .txt in the directory:find /home -name "*.txt"以.txt结尾的文件
Same as above, but ignore case(忽略大小写): find /home -iname "*.txt"
3、mv 目录名称 新目录名称: Modify the name of the directory (change)改变目录或其他类型文件名称
4、mv 目录名称 目录的新位置: Move the directory location — cut (change)移动(目录和 files and archives)的位置

4.3 File Operation Commands文件操作命令

touch 文件名称: File creation (increase)创建文件,不是文件夹哦!
cat/more/less/tail 文件名称:查看文件

cat:View display file contents查看显示文件内容
more:You can display the percentage(查看百分比)Enter to go down one line, Space to go to the next page, and q to exit and view。
less: You can use PgUp and PgDn on the keyboard to page up and down(进行上下翻页), q to end the view
tail-10: View the last 10 lines of the file, Ctrl + C ends
注:The command tail -f file can dynamically(动态) monitor(监视) a certain(某个) file.(比如tomcat的日志文件,随着项目的启动而改变)

vim 文件: Modify(修改) the content of the file (change)
The vim editor is a powerful component in Linux. vim编辑器是linux强大的组成部分。
In actual development, the main role of using the vim editor is to modify the configuration file. 在实际发展中,VIM主要用于编辑配置文件。

4.4 Compressed file operation commands压缩文件操作

**(1) Package and compress the file: ** 打包压缩文件
Packaged files(打包文件) in Linux usually end in .tar, and compressed commands usually end in .gz.
命令:tar -zcvf 打包压缩后的文件名 要打包压缩的文件
如:tar -zcvf test.tar.gz aaa.txt bbb.txt ccc.txt or: tar -zcvf test.tar.gz /test/

** ( 2) Decompress the compressed package: ** 解压压缩包
命令:tar [-xvf] compressed file
解压到需要位置:tar -xvf test.tar.gz -C /usr解压到/usr目录下

4.5 Linux permission commands权限命令

Each file in the operating system has specific permissions, users, and groups。操作系统的每个文件都有特定的权限用户和组.
divided into readable, writable, and executable被分为r(4),w(2),x(1)

d: stands for directory(文件夹)(r代表可以查看目录下文件,x表示可以cd进目录)
-: Representative file(文件)(r代表可以cat查看文件,x表可以执行)
l: stands for soft link (can be considered as a shortcut in window)(软件链接)

需要注意:It should be noted that super users can ignore the permissions of ordinary(普通) users, even if the file directory permissions are 000, they can still access. Each user in Linux must belong to a group and cannot be independent of the group. In Linux, each file has the concept(概念) of owner, group, and **other groups.**应该注意的是,超级用户的权限可以忽略普通(普通)的用户,即使文件目录权限为000,他们仍然可以访问。Linux中的每个用户必须属于一个组,并且不能独立于这个组。在Linux中,每个文件都有所有者、组和其他组的概念。

owner: Generally, it is the creator of the file. Whoever created the file naturally becomes the owner of the file(谁创建了文件自然成为文件的所有者). Use the ls -ahl command to see the owner of the file(使用命令查看文件). You can also use the chown username and file name to modify the owner of the file.(编辑文件所有者)

File group:
When a user creates a file, the group that the file belongs to is the group that the user belongs to(文件组为创建文件者所在的组). Use the ls -ahl command to see all groups of the file(查看文件所有的组). You can also use the chgrp group name and file name to modify the group that the file belongs to.(使用命令去编辑文件所属组)

Other groups
Except for the owner of the file and the users in the group, other users of the system are other groups of the file(除了文件所有者所在组,系统中其他组均为Other groups)

改变文件权限:
Command to modify file / directory permissions:chmod
Example: Modify the permissions of aaa.txt under / test so that the owner has all permissions, the group the owner belongs to has read and write permissions, and other users have read permissions only(让所有者有所有权限,组有读写权限,其他组有读的权限)

chmod u=rwx,g=rw,o=r aaa.txt

chmod -R u=rwx,g=rwx,o=rwx ./log // Recursively authorize all files in the log directory(递归地授权日志目录中的所有文件)

The above example can also be represented numerically:可以用数字代替

chmod 764 aaa.txt

4.6 Linux User Management用户管理

The Linux system is a multi-user, multi-task, time-sharing operating system. Any user who wants to use system resources must first apply for an account with the system administrator, and then enter the system as the account.Linux系统是一个多用户、多任务、分时的操作系统。任何想要使用系统资源的用户必须首先向系统管理员申请一个帐户,然后作为帐户输入系统。
User accounts can help system administrators track(跟踪) users who use the system and control their access to system resources(帮助系统管理员跟踪使用系统的用户,并控制他们访问系统资源); on the other hand, they can help users organize files and provide users with security protection.(另一方面,可以为系统提供安全保护)

Commands:


> useradd 选项 用户名: Add user account 
> userdel 选项 用户名: Delete user account
> usermod 选项 用户名: Modify account 
> passwd 用户名: Change or create a user's password 
> passwd -S 用户名 : Display user account password information
> passwd -d 用户名: Clear user password

4.7 Linux system user group management

Linux system user group management related commands:

groupadd 选项 用户组 : Add a new user group
groupdel 用户组: To delete an existing(现有的) user group
groupmod 选项 用户组 : Modify the attributes of a user group

4.8 Other common commands

pwd Show current location显示当前位置

sudo + 其他命令 Execute the command as a system administrator, that is, the command executed via sudo is as if it was executed by root himself.以系统管理员的身份执行该命令,也就是说,通过sudo执行的命令就像根用户自己执行的命令一样。

grep 要搜索的字符串 要搜索的文件 --color: Search command, --color stands for highlighted(搜索命令,以当前颜色高亮显示)

ps -ef/ ps -aux: These two commands are to check the current system running process(进程). The difference between the two is the display format(显示格式不同). If you want to see a specific process(查看单个特别进程), you can use this format: ps aux|grep redis(view processes that include a redis string), or you can use it pgrep redis -a.
kill -9 进程的pid: Kill the process (-9 means force termination.)

Network communication commands:
View the network card information of the current system: ifconfig
View the connection with a machine: ping
View the port usage of the current system: netstat -an

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值