Linux

関連コンテンツ

Nginx is installed but command not found

Problem. I installed nginx on my Debian 12 server following the steps in the official documentation Installing NGINX Open Source | NGINX Documentation. At first, everything is OK😇. Running sudo nginx -v returns the correct version of nginx.However, recently, when I ran the same command, it returned command not found:sudo nginx sudo: nginx: command not found nginx bash: nginx: command not foundEither sudo nginx or nginx gives the same result😣.Solution. To solve this problem, first you need to determine the path of your installed nginx. Your nginx may be contained in /usr/local/sbin or /usr/sbin. Once you find your nginx path, for instance, /usr/local/sbin/nginx, you can directly runsudo /usr/local/sbin/nginx -v nginx version: nginx/1.22.1This would output the version of nginx, which solves the problem.However, if you don't want to input the entire path of nginx everytime, you must add the path of nginx to the environment variables as follows.First, output the environment variables by running echo $PATH. You may found that the path of nginx is not in the output. Meanwhile, the output of the command which nginx is also void. Therefore, you need to check the file of environment variables:sudo vim /etc/profileIn /etc/profile, I found that /usr/local/sbin and /usr/sbin are in PATH only when I'm a root user. So we just need to add /usr/local/sbin or /usr/sbin to another PATH. For example:if [ $(id -u) -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/sbin:..." else PATH="/usr/local/sbin:/usr/local/sbin:..." fi export PATHAfter saving /etc/profile, reset the command linesource /etc/profileThen run nginx -v to check if it returns the correct version😄.nginx -v nginx version: nginx/1.22.1
2024-06-06 20:16:35

Linux是什么?Linux简介

1. Linux操作系统这个词严格来说是不对的,因为Linux其实只是个宏内核,Linux的各个发行版才算得上是真正的操作系统。相比于Windows和unix,Linux是免费开源的(虽然某些发行版是付费的),其实Linux就诞生于这样的背景下。Linus还是学生的时候,他的一个老师因为不想用付费的unix教学,因此自己写了一个操作系统,免费开源。而Linus根据这个操作系统,自行开发出Linux系统。值得一提的是,手机安卓系统用的是Linux内核,而苹果系统用的则是unix系统的一个分支。在电脑的操作系统中,目前市场占比最高的仍然是Windows系统,Windows的图形界面相较于Linux的重命令行对于用户更友善,更易使用。而在服务器的操作系统中,很多服务器都使用Linux系统,因为Linux占的内存更小,相较于Windows更轻,服务器跑久了也不容易卡。同时,服务器基本上都是纯命令行的,因为安装桌面占用空间,因此使用纯命令行的Linux更合适,据说当初Linus就是不喜欢图形界面的。其实Linux也是可以安装图形环境的(即桌面),如GNOME、Xfce,但是有些云服务器,比如我现在用的腾讯云的轻量云服务器,Linux系统是不支持图形界面的,就算安装了桌面,运行起来也是不会有界面。如果喜欢使用用户交互的界面,可以选择安装Windows server,或者更换其他支持Linux桌面的云服务器。Windows server用起来跟平常电脑里用的Windows差别不大,甚至知乎上还有人说拿Windows server当生活用的系统。2. Linux系统的发行版本包括Centos、Debian、Ubuntu等。Centos系统安装和环境配置的难度较大,Debian和Ubuntu的安装更为简单友好、快速,无需用户再自行配备环境依赖。Ubuntu是基于Debian的开源系统,而Debian相比Ubuntu占内存更小,性能更好。网络安全方面比较知名的系统Kali Linux就是基于Debian开发的。
2024-06-05 15:30:25

Linux文件权限01

设置文件属性与权限三个常用的修改权限命令:chown修改文件属主,属组chgrp修改文件属组chmod修改文件权限例 使用chown命令修改文件的属主 从root改为Ybaci修改属主的同时修改属组,在属主与属组之间加入“.”即可只需要更改文件的属组而不需要更改属主,使用chgrp命令修改文件权限使用chmod命令给该属组增加执行权限,当查看属组权限字符位出现“x”,说明增加执行权成功 chmod u+x给该属组增加写入权限,当查看属组权限字符位出现“w”,说明增加执行权成功 chmod g+w同时给所有对象增加读,写,执行权限,在chmod命令后加“a”符号,然后覆盖当前全部权限chmod a=rwx file同时给所有对象删除某一个权限 chmod a-x同时删除所有对象的全部权限 chmod a=- filechown:将某个资源的访问权限给予别人chmod:改变某个文件的访问模式与命令
2024-08-27 20:37:11