Navigation

Friday, 13 September 2019

C++整数类型的范围如何看??


以下代码用来看电脑编译器,整数类型的范围。



#include <iostream>
#include "Sales_item.h"
int main() {
unsigned long long a;
a = 18446744073709551615;
std::cout << a + 1 << std::endl;
std::cout << "char contains " << sizeof(char) << "bytes" << std::endl;
std::cout << "unsigned char contains " << sizeof(unsigned char) << "bytes" << std::endl;
std::cout << "short contains " << sizeof(short) << "bytes" << std::endl;
std::cout << "unsigned short contains " << sizeof(unsigned short) << "bytes" << std::endl;
std::cout << "int contains " << sizeof(int) << "bytes" << std::endl;
std::cout << "unsigned contains " << sizeof(unsigned) << "bytes" << std::endl;
std::cout << "long contains " << sizeof(long) << "bytes" << std::endl;
std::cout << "unsigned long contains " << sizeof(unsigned long) << "bytes" << std::endl;
std::cout << "long long contains " << sizeof(long long) << "bytes" << std::endl;
std::cout << "unsigned long long contains " << sizeof(unsigned long long) << "bytes" << std::endl;
std::cout << "float " << sizeof(float) << "bytes" << std::endl;
std::cout << "double " << sizeof(double) << "bytes" << std::endl;
std::cout << "long double " << sizeof(long double) << "bytes" << std::endl;
getchar();
return 0;
}

Friday, 6 September 2019

192.168.和10.0.开头的IP、内网IP段、IP简介、分类——(IP观止)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/superit401/article/details/78246298

在这三类地址中,绝大多数的IP地址都是公有地址,需要向国际互联网信息中心申请注册。但是在IPv4地址协议中预留了3个IP地址段,作为私有地址,供组织机构内部使用。
这三个地址段分别位于A、B、C三类地址内:
A类地址:10.0.0.0--10.255.255.255
B类地址:172.16.0.0--172.31.255.255 

C类地址:192.168.0.0--192.168.255.255
IP地址范围:1.0.0.1——255.255.255.254
(参考:https://zhidao.baidu.com/question/1756686766672478628.html)
在公网(连Internet的)是看不到这些IP的,使用这些IP一定是你在公司或学校内网中,比如公司路由下。这些私有地址在公司(组织)内网中,可重复出现在不同公司组织内部。比如你在公司内部的使用分配到的内网ip192.168.1.12和另一家公司的朋友QQ聊天,碰巧他的内网ip也是192.168.1.12,但是你俩不会ip冲突,因为你们处于不同组织内部,也就是不同公网IP下的内网IP,是可以重复的。不同的是你们俩通过网关对应公网的IP,即不能重复。但是这IP(已分配为私有地址)不会出现在公网Internet中,因为公网IP全球唯一,否则就冲突了。公网是不会使用者三类地址的,即使用者三类IP的一定在公司或者学校(组织)内网中,公网是看不到的。  
理论上每个公网IP(公网地址)下都可以在其内网(如学校、公司内部网络或者你宿舍宽带分配的内网ip)分配私网地址(如下图),即公网地址全球唯一不可重复,但是每个公网地址下的私网地址可以重复,因为这些私网地址,就是分配给内网使用的,一般公网上是访问不到这些内网地址的。


这些地址是不会被Internet分配的,它们在Internet上也不会被路由,虽然它们不能直接和Internet网连接,但通过技术手段仍旧可以和Internet通讯。我们可以根据需要来选择适当的地址类,在内部局域网中将这些地址像公用IP地址一样地使用。在Internet上,有些不需要与Internet通讯的设备,如打印机、可管理集线器等也可以使用这些地址,以节省IP地址资源。机器比较少的话用A B 类地址肯定是不理智的,价格也会很昂贵的。

内网一般也就几十台 到几百台机器  用c类地址每段都可以容纳254台主机 是比较理智的选择。


但内网要想和外部Internet链接就需要转换成公网唯一IP与外部链接,需要使用路由NAT转换。
NAT(Network Address Translation,网络地址转换)是1994年提出的。当在专用网内部的一些主机本来已经分配到了本地IP地址(即仅在本专用网内使用的专用地址),但现在又想和因特网上的主机通信(并不需要加密)时,可使用NAT方法。
这种方法需要在专用网连接到因特网的路由器上安装NAT软件。装有NAT软件的路由器叫做NAT路由器,它至少有一个有效的外部全球IP地址。这样,所有使用本地地址的主机在和外界通信时,都要在NAT路由器上将其本地地址转换成全球IP地址,才能和因特网连接。
另外,这种通过使用少量的公有IP 地址代表较多的私有IP 地址的方式,将有助于减缓可用的IP地址空间的枯竭。

(参考:NAT百度百科https://baike.baidu.com/item/nat/320024)


NAT 之内的 PC 联机到 Internet 上面时,他所显示的 IP 是 NAT 主机的公共 IP,所以 Client 端的 PC 当然就具有一定程度的安全了,外界在进行 portscan(端口扫描) 的时候,就侦测不到源Client 端的 PC 。
AT的主要作用,是解决IP地址数量紧缺。当大量的内部主机只能使用少量的合法的外部地址,就可以使用NAT把内部地址转化成外部地址。
NAT还可以防止外部主机攻击内部主机(或服务器)。


IP地址(0.0.0.0——255.255.255.254)分类:
A类:
0.0.0.0---127.255.255.255 (其中私有:10.0.0.0---10.255.255.255,保留:0.0.0.0,127.0.0.0---127.255.255.255)
B类:
128.0.0.1---191.255.255.254(其中私有:172.16.0.0---172.31.255.255,保留:169.254.0.0-169.254.255.255,191.255.255.255是广播地址,不能分配)
C类:
192.0.0.1---223.255.255.254(其中:私有:192.168.0.0---192.168.255.255)
D类:
224.0.0.1---239.255.255.254
E类:
240.0.0.1---255.255.255.254
(参考:https://jingyan.baidu.com/article/ea24bc3985f7b3da62b33188.html
https://zhidao.baidu.com/question/1756686766672478628.html)
参考:



Thursday, 5 September 2019

Arch Linux终于和cuteftp和vs 2019 tmd连起来了

cuteftp一直他妈大连不上
socket10030什么的,我也记不清。

vs2019也不行

关键是arch linux 狗屁不是,什么都没有装,自然不是ftp服务器

vsftpd也装好并且设置好,就可以来

当然ssh,没有用ssh2
还有很多不懂了,慢慢来

https://wiki.archlinux.org/index.php/Very_Secure_FTP_Daemon


https://wiki.archlinux.org/index.php/Talk:Very_Secure_FTP_Daemon


当然再connect vs2019的时候,要注意rsync要装

arch linux 的pacman要比centos大软件新了多了去了

Wednesday, 4 September 2019

How to fix corrupted ps command

ps has been replaced by other stuff, that is ps is corrupted.
how to recover

easy

RUN apt-get update && apt-get install -y procps


Procps - The /proc file system utilities

procps is the package that has a bunch of small useful utilities that give information about processes using the /proc filesystem. The package includes the programs ps, top, vmstat, w, kill, free, slabtop, and skill.

Tuesday, 3 September 2019

7个可以查看linux分区是什么格式大办法

7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)

A file system is the way in which files are named, stored, retrieved as well as updated on a storage disk or partition; the way files are organized on the disk.
A file system is divided in two segments called: User Data and Metadata (file name, time it was created, modified time, it’s size and location in the directory hierarchy etc).
In this guide, we will explain seven ways to identify your Linux file system type such as Ext2, Ext3, Ext4, BtrFS, GlusterFS plus many more.

1. Using df Command

df command reports file system disk space usage, to include the file system type on a particular disk partition, use the -T flag as below:
$ df -Th
OR
$ df -Th | grep "^/dev"
df Command - Find Filesystem Type
df Command – Find Filesystem Type
For a comprehensive guide for df command usage go through our articles:
  1. 12 Useful “df” Commands to Check Disk Space in Linux
  2. Pydf – An Alternative ‘df’ Command That Shows Disk Usage in Colours

2. Using fsck Command

fsck is used to check and optionally repair Linux file systems, it can also print the file system type on specified disk partitions.
The flag -N disables checking of file system for errors, it just shows what would be done (but all we need is the file system type):
$ fsck -N /dev/sda3
$ fsck -N /dev/sdb1
fsck - Print Linux Filesystem Type
fsck – Print Linux Filesystem Type

3. Using lsblk Command

lsblk displays block devices, when used with the -f option, it prints file system type on partitions as well:
$ lsblk -f
lsblk - Shows Linux Filesystem Type
lsblk – Shows Linux Filesystem Type

4. Using mount Command

mount command is used to mount a file system in Linux, it can also be used to mount an ISO imagemount remote Linux filesystem and so much more.
When run without any arguments, it prints info about disk partitions including the file system type as below:
$ mount | grep "^/dev"
Mount - Show Filesystem Type in Linux
Mount – Show Filesystem Type in Linux

5. Using blkid Command

blkid command is used to find or print block device properties, simply specify the disk partition as an argument like so:
$ blkid /dev/sda3
blkid - Find Filesystem Type
blkid – Find Filesystem Type

6. Using file Command

file command identifies file type, the -s flag enables reading of block or character files and -L enables following of symlinks:
$ sudo file -sL /dev/sda3
file - Identifies Filesystem Type
file – Identifies Filesystem Type

7. Using fstab File

The /etc/fstab is a static file system info (such as mount point, file system type, mount options etc) file:
$ cat /etc/fstab
Fstab - Shows Linux Filesystem Type
Fstab – Shows Linux Filesystem Type
That’s it! In this guide, we explained seven ways to identify your Linux file system type. Do you know of any method not mentioned here? Share it with us in the comments.

7 Essential Things To Do After Installing Arch Linux

Brief: This tutorial shows you a few essential things to do after installing Arch Linux. This will help you get started with Arch Linux so that you can explore it further.
Earlier I showed you how to install Arch Linux. Today, I am going to list a few basic and yet important things to do after installing Arch Linux.
By this time, you probably already know that Arch Linux comes with a minimal installation and lets you build your own system on top of it. From installing desktop environments to media codecs and your favorite applications, everything has to be done by you.
This do-it-yourself (DIY) approach is what many Arch Linux users prefer. If you want things running out of the box, you should use Manjaro Linux. Manjaro is based on Arch minus the hassle.
Cutting down the chit-chat, let’s see what to do after installing Arch Linux.

Must to do things after installing Arch Linux

Things to do after installing Arch Linux
While at It’s FOSS, we focus on beginner centric approach and hence we suggest plenty of GUI based approach, this won’t be the case here.
Arch Linux is sort of expert domain and we believe if you use Arch, you are not afraid of using the terminal. This is why the steps mentioned here are command line based.

0. Update your system

You might already have used the latest release, but it’s advisable to check for the latest update for your Arch System:
sudo pacman -Syu

1. Installing X server, Desktop Environment and Display Manager

Before installing a desktop environment (DE), you will need to install the X server.
sudo pacman -S xorg
Once it’s completed, use any of the below commands to install your favorite desktop environment.
To install GNOME:
sudo pacman -S gnome gnome-extra
To install Cinnamon:
sudo pacman -S cinnamon nemo-fileroller
To install XFCE:
sudo pacman -S xfce4 xfce4-goodies
To install KDE:
sudo pacman -S plasma
To install MATE:
sudo pacman -S mate mate-extra
You will also need a display manager to log in to your desktop environment. For the ease, you can install LXDM.
pacman -S lxdm
Once installed, you can enable to start each time you reboot your system.
systemctl enable lxdm.service
Reboot your system and you will see the LXDM login screen, select your desktop environment from the list and login.
This is how my system looks like with LXDM and GNOME.
Arch Linux with GNOME and LXDM

2. Install an LTS kernel

Why should you install LTS kernel in Arch Linux when it is supposed to be cutting edge?
Installing an LTS kernel means you have a more stable kernel with better support to older hardware. Also, the LTS kernels are supported for at least 2 years with bug fixes and performance enhancements.
If you rather choose to use the latest Linux kernel, you may find regression and bugs introduced by the latest kernel updates to your existing software and system. It’s not a certainty but it is definitely a possibility. For example, a Kernel update broke GNOME in Arch based Linux some time back.
This is why it is advisable to use an LTS kernel if you prefer a more stable system and/or have an older one. But the decision is yours to make.
Before you install an LTS kernel, check the Linux kernel version you are using.
uname -r
To install the LTS kernel and Linux LTS headers, type the below command:
sudo pacman -S linux-lts
sudo pacman install linux-lts-headers
At this point, the LTS version is the default one.
Once done, you can remove the older kernels by typing the below command. However, I prefer to keep it in “case” something goes wrong, I can boot into the other Linux kernel version.
sudo pacman -Rs linux

3. Installing Yaourt

Yaourt stands for Yet AnOther User Repository Tool which can be used to search, download and install packages from the official repository as well as AUR.
Arch User Repository or AUR is a community-driven repository for Arch users and contains package descriptions to compile a package from source and install it. Most of the packages that make to the official repository start in the AUR first. Users contribute their own applications which are voted for or against and once it becomes popular enough, they are included in the official repository.
AUR contains lots of useful applications that are not found in the main repo can be installed from AUR with help of Yaourt. Yaourt is similar to what Synaptic Package Manager does, and can be installed by following these steps:
Open /etc/pacman.conf file and add these lines at the bottom:
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
Save the change. Install Yaourt with the below command
sudo pacman -Syu yaourt
Use the command below to sync Yaourt with AUR:
yaourt -Syy
To install AUR packages, you can the below commands :
yaourt -S package-name

4. Install GUI Package Manager Pamac

The default package manager for Arch Linux is Pacman (Package Manager) and using Pacman is quite easy to install or remove a software.
However, it’s sometimes difficult to talk in commands. Pamac provides a GUI option for Pacman and works like Synaptic Package Manager or GNOME Software.
Pamac serves as a GUI tool for installing or updating packages and works well with Arch User Repository AUR.
How to install Pamac
Before you can use Pamac, you will need to have Yaourt (or Packer) installed first. Once done, type the below command in terminal to install Pamac.
yaourt -S pamac-aur
You can launch the GUI by searching for Add/Remove Software. It will show different packages that are available and installed and which all updates are needed.
Pamac Package Manager
However, by default, the AUR packages are not enabled. To enable it, click on the options just beside the search option) and choose Preferences. Under the AUR tab, Enable AUR support.
Enable AUR support in Pamac
Installing software through Pamac is as easier as searching it through the GUI (which searches the community and AUR) and installing it with a click.

5. Installing Codecs and plugins

Of course, you are going to use your personal system for recreational works like watching videos and listening to your favorite song. But before that, you will have to install codecs for these audio and video files.
Type the below command in the terminal:
sudo pacman -S a52dec faac faad2 flac jasper lame libdca libdv libmad libmpeg2 libtheora libvorbis libxv wavpack x264 xvidcore gstreamer0.10-plugins
However, installing a media player like VLC imports all the necessary codecs and installs it.
sudo pacman -S vlc
You may add a music player too:
sudo pacman -S amarok

6. Installing productive software

For day to day use and setting up your Arch system for productive use, you need some basic applications like an office suite, email client, a web browser etc.
sudo pacman -S libreoffice thunderbird firefox gedit flashplugin skype dropbox aria2
Aria2 is a download manager, LibreOffice is the most popular open source office suite, Thunderbird is a cross-platform mail and chat client, Firefox is an open source and free web browser, Gedit is an editor, flashplugin installs flash, Skype is a popular messaging and video calling software and Dropbox – to store your file for anytime access.
Along with these, you will need archive managers
sudo pacman -S p7zip p7zip-plugins unrar tar rsync
This is of course just a suggestion. You can install essential Linux applications of your choice and your requirement.

7. Customizing the looks of your Arch Linux desktop

You can customize your Arch Linux by installing some nice flat themes or the conky monitoring tool.
Installing themes
Some of the most liked themes are Arc GTK, flatplat, Vertex and Numix, which can be installed by below command:
yaourt -S arc-gtk-theme flatplat-theme-git vertex-themes
sudo pacman -S numix-themes
Go to settings > Appearance and change the default theme from there.
Installing Conky
Conky is a free system manager application which can monitor and display memory usage, CPU statistics, disk storage, swap, CPU temperature and more.
To install conky, use below command :
sudo pacman -S conky
You can configure conky yourself which will need some digging into the ~/.conkyrc file or you can download your favorite one from web and replace the default conkyrc file. There is a detailed tutorial about conky and its configuration on the Arch Linux website.

Additional tip:

At any point in time, if you feel like removing any application (and its dependencies), you can use these commands:
sudo pacman -R package-name
It removes the package without removing the dependencies. If you want to remove the dependencies but leaving out the ones which are being used by some other application, below command will help:
sudo pacman -Rs package-name

Final Words

Arch Linux is a great distribution if you want to take control of everything, from setting up your favorite desktop environment to the tools you want to use. The Arch Wiki is a great place to learn these things and in itself more than sufficient.
In this article, we have just listed out the most important things to do after installing Arch Linux. The rest is up to you to explore.
By the way, what are the things you do after installing Arch Linux?