Linux-Ubuntu directory structure, basic commands, network configuration

One, Ubuntu instructions

Ubuntu is an open source Linux operating system based on desktop applications, and it also exists in the form of Server

Second, the Ubuntu directory structure

Insert picture description here
Root directory description
The content represented by the following colors :
blue : folder
red : compressed file
flashing red : wrong symbolic link
green : executable file
light blue : link
yellow : device file
white : text file
gray : other files

Item table of Contents Description
1 boot Start the file. All files related to system startup are saved here
1.2 boot/grub System Boot Manager
2 dev Store the device files under Linx, accessing this directory is equivalent to accessing a certain device, usually used for mounting
3 etc Global configuration files for system programs and most applications
3.1 etc/init.d SystemV-style startup scripts, generally start some ancient services
3.2 etc/rcX.d Link to start script, define run level
3.3 etc/network Network profile
3.4 etc/X11 Graphical interface configuration file
4 usr Application storage directory, including self-installed software
4.1 usr/bin Store application program execution instructions
4.2 usr/share Store shared data
4.3 usr/share/doc System description file storage directory
4.4 usr/share/man Program description file storage directory
4.5 usr/lib Function library file, cannot run directly
4.6 usr/local Store software upgrade package
5 where Dynamic data: place files that change frequently during the execution of the system
5.1 var / log Dynamic log
5.2 var / spool / mail Mail storage directory
5.3 have / run After the program or service is started, its PID is stored in this directory
6 temp Temporary files: The directory where files are temporarily stored by general users or programs being executed, which can be accessed by anyone. Important data cannot be placed in this directory
7 mnt Temporarily mount, generally use mount
8 media Mount media devices, U disk hard drives, etc.
9 root The root directory of the system administrator
10 home System account directory, when a new account is added, it will exist in this directory
11 proc The data in this directory is in the memory, such as the system core, external devices, network status, because the data is stored in the memory, it does not take up disk space, which is more important file
12 srv The data directory that needs to be accessed after the service is started, such as the web page data that the www service needs to access is stored in /srv/www
13 opt Directory for third-party software
14 bin The directory of executable binary files, such as commonly used commands ls, tar, mv, cat, etc.
15 lib System use function library directory

3. Commonly used basic commands:

The command format is generally:

command [-options] [parameter]

command : command name
options : options
parameter : parameters passed to the command

3.1 Common commands are as follows:

1. sudo xxxx
allows users to use administrator privileges. If you continue to use it, you need to start the administrator root. The
startup method: su, the password will be prompted to switch
back to the user: su user name

2. sudo apt install software package
Installation software: such as vim installation sudo apt install vim

3. sudo apt remove software package
uninstall software

4. man command
View command instructions.
If in Server, press key instructions

Operation buttons Features
Space Show next page
Carriage return Show next line
b back, display the previous page
q quit, exit

5.ls
list, the list displays the contents of the current directory

Options Features
ls -a all,显示所有内容 包含隐藏文件
ls -l 显示文件详细信息
ls -h human-readable,阅读方便

ls通配符号

通配符 功能
* 代表任意多个字符,可以没有字符,ls * 表示目录下所有文件及子文件
代表一个任意字符,至少一个字符,ls ?ib 表示目录下以ib结尾的文件及列举所有子文件
[1234] 匹配1,2,3,4中的任意一个
[a-g] 匹配a到g范围的任意一个

6.pwd
print wrok directory 查看当前所在路径

7.cd

命令 说明
cd+空格+路径名称 change directory,跳转到指定路径
cd+空格+… 跳转到上一级目录
cd+空格+ /. 切换到最初根目录
cd+空格+ - 在最近两个目录来回切换

8.touch +空格+文件名称
创建这个文件

9.mkdir+空格+文件夹名称

命令 说明
mkdir a 创建一个文件夹a
mkdir -p a/b/c 创建一个递归目录

10.rm+空格+文件名
remove 删除指定文件

命令 说明
rm -f a 强制删除a,忽略不存在文件,不提示
rm -r a 删除 文件夹a

11.clear
清屏

12.cp拷贝
cp+空格+源文件路径及名称+空格+目标文件路径及名称

命令 说明
cp a /home/kml/Desktop 复制A文件到桌面
cp -i a /home/kml/Desktop 复制A文件到桌面,若覆盖文件时有提示
cp -r a /home/kml/Desktop 复制文件夹A到桌面

13.mv 移动move
mv+空格+移动文件+空格+移动目录

命令 说明
mv -i a /home/kml/Desktop 复制A文件或文件夹到桌面,若覆盖文件时有提示

14.tree 树状显示

命令 说明
tree 显示该当前目录下(文件夹下)的所有文件,按树状图排列
tree -d directory,只显示文件夹

15.cat 查看文件内容
cat+空格+文件

16.grep 查找
global search regular expression(RE) and print out the line

17.重定向

符号 说明
> 输出重定向到一个文件或者设备,覆盖原来内容或文件
>> 输出重定向到一个文件或者设备,追加原来内容或文件

如:cat a.py >a.text

18.管道符号|
一个命令的输出+空格+|+空格+另外一个命令的输入

注:
往往16、18都是一起使用,如:cat a.py | grep xx 对文件内容进行查找

19.关机重启
shutdown可以安全关闭或者重启,默认一分钟

参数 说明
shutdown now 立刻关机
shutdown -r now 立刻重新启动,与reboot一样
shutdown -c 取消关机计划

举例:

  • 一分钟以后关机
shutdown
  • 今天21:30分关机
shutdown 21:30
  • 10分钟后关机
shutdown +10
  • 10分钟以后关机,同时发出警告信息
shutdown +10 "System will shutdown after 10 minutes"

四、网络配置

1.Ifconfig
查看和配置当前计算机信息

  • 快速定位IP地址
ifconfig | grep inet
  • 查看网卡信息
ifconfig

2.
ping The ping command is used to test the network connectivity between hosts. The ping command will use the ICMP transmission protocol to send out a response request message. Generally used to detect whether the network communication between computers is normal.

  • ping target host IP
ping 192.168.0.1
  • Check whether the local network card is normal
ping 127.0.0.1
  • How to set IP
#1、查看网卡编号(如下附图1)
ip a
#记录网卡编号
#2、切到根目录,编辑interfaces文件
sudo vi /etc/network/interfaces
#3、编辑内容如下:
auto 网卡编号			//系统启动时自动启动网卡
iface 网卡编号 inet static	//static表示固定IP,dhcp表示自动获取IP
address 192.168.1.2		//IP地址
gateway 192.168.1.1		//网关
network 255.255.255.0		//掩码
#4、完成上述内容后,同网段应该可以ping通,如果无法ping通得检查是否编辑内容错误
#但ping 百度还是ping不通,此时可以添加DNS,让百度可以通过DNS快速查找
sudo vi /etc/systemd/resolved.conf
#5、打开文件后,将DNS前得#去掉,加上通用DNS服务器即可,如8.8.8.8
#6、加载网络配置文件,重启网络服务
sudo /etc/init.d/networking force-reload
sudo /etc/init.d/networking restart
#7、重启计算机
shutdown -r now

#注意:如果还是不行,重新启停以太网卡:
sudo ifconfig 网卡编号 down
sudo ifconfig 网卡编号 up

Figure 1
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_37697566/article/details/105294493