In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the arrangement of instructions commonly used in FreeBSD". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "FreeBSD commonly used instructions collation" bar!
As one of the main branches of BSD, FreeBSD has the advantages of robustness and stability, so some system administrators especially like FreeBSD. This article summarizes some common FreeBSD instructions that readers can use to do a search.
1. View CPU:
Sysctlhw.modelhw.ncpudmesg | grep "CPU:"
2. View memory:
Dmesg | grep "real memory" | awk-F'[()]'{print$2,$4,$7,$8}'
View swap:
Top | grep "Swap:" | awk' {print$1,$2}'
3. View the hard disk:
Diskinfo-vt/dev/ad0disklable/dev/ad0s2# to view partition information
Look at the hard disk size:
Dmesg | grep "sector" | awk' {print$1,$2} 'diskinfo-v/dev/da0 | grep "inbytes" | awk-F' [()]' {print$2}'
4. Check the server brand:
Dmesg | grep "ACPIAPIC"
5. Mount the file system:
Fat32:mount_msdosfs-Lzh_CN.eucCN/dev/ad0s1/mntntfs:mount_ntfs-CeucCn/dev/ad0s1/mntcdrom:mount_cd9660/dev/acd0/mnt
Note: ntfs can only be read but not written in FreeBSD
6. Add or disable the system forbidden deletion flag to the file (directory is not applicable):
Chflagssunlinkfile1chflagsnosunlinkfile1
7. Initialize the disk:
Fdisk-BIad1
8. Create a FreeBSD partition:
Disklabel-B-w-rad1s1auto
9. Establish a logical partition:
Disklabel-ead1s1
10. Format the partition and create a file system:
Newfs/dev/ad1s1e
11. Display PCI hardware information:
Pciconf-lv
12. Enable Linux binary compatibility support (the easiest way to enable this feature is to load the linuxKLD module):
Kldloadlinux
Let Linux compatibility be enabled automatically at system initialization, enter in / etc/rc.conf:
Linux_enable= "YES"
13. Check whether the KLD module is loaded:
Kldstat
14. Statically link into Linux binary compatibility mode in the kernel, and add:
OptionsCOMPAT_LINUX
15. Set the IP address of the Nic em0:
Ifconfigem0inet192.0.2.10netmask255.255.255.0
16. Add an alias IP address to the Nic em0 setting:
Ifconfigem0inet192.168.51.45/24add
17. Delete the alias IP address of Nic:
Ifconfigem0inet192.168.51.45-alias
18. Set the working mode of the network card em0 to 100baseTX:
Ifconfigem0media100baseTXmediaoptfull-duplex
19. When the script under / usr/local/etc/rc.d cannot start automatically, try adding a line to / etc/rc.conf:
Local_startup= "/ usr/local/etc/rc.d"
20. Find the required software in ports and go to the / usr/ports directory to execute:
Makesearchname=lsof
Or
Echo/usr/ports/*/*lsof*
Or
Whereislsof
Makesearchkey= keyword # search for keywords in name, comment, description
21. Use package to install the management software, using the following command:
Pkg_addlsof-4.56.4.tgz# installation package pkg_info# lists all installed software packages pkg_version# counts all installed software versions, compares the local package version with the current version in the ports directory, and pkg_deletelsof-4.56.4# deletes the package, you need to provide the full package name
22. Update the local ports using the CVSup protocol: (change the cvsup.FreeBSD.org to a closer CVSup server)
Csup-L2-hcvsup.FreeBSD.org/usr/share/examples/cvsup/ports-supfile
23. Some shell cache executables in the directory specified in the environment variable PATH to speed up the lookup, which will prevent some newly installed commands from running. Execute the following commands before you can run the newly installed commands:
Rehash
Or
Hash-r
24. When the Internet is not available all the time, execute the following command under / usr/ports, and all required files will be downloaded: (this command can be executed in a lower directory, such as / usr/ports/comms/nmp)
Makefetch# only downloads the required files, not the dependency package makefetch-recursive# along with the dependency package.
25. Change the default Ports directory:
MakeWRKDIRPREFIX=/usr/home/example/portsinstall# compiles port in / usr/home/example/ports, installs in / usr/localmakePREFIX=/usr/home/example/localinstall#, compiles port in / usr/ports, installs in / usr/home/example/localmakeWRKDIRPREFIX=../portsPREFIX=../localinstall# and compiles port in.. / ports Install to.. / local 26, use the portsclean tool to clear the temporary directory and the distfiles directory: portsclean-C# clear the temporary directory during installation portsclean-D# clear the files that are not referenced by all port in the distfiles directory portsclean-DD# delete the source package files that are not used by the currently installed port
27. Force manual detection of SCSI devices, SCSI bus scanning:
Camcontrolrescanall
28. Display a list of SCSI devices:
Camcontroldevlist
29. Use the pipeline to change the user's password:
Echo "password" | pwusermodroot-h0
30. Sed insert row:
Sed-i-E'/serviceport/a\\ apexport:18306\\ / home/xiyou/config
31. Overwrite the existing MBR with freebsd's MBR:
Fdisk-B-b/boot/boot0device
32. Rebuild the user list based on a new file:
Pwd_mkdb-p/etc/master.passwd.new#-p is to generate a new / etc/passwd
33. Take the time:
Date-v-1d+%Y%m%d#Freebsd take yesterday date method date-v-1w+%Y%m%d#Freebsd take last week today method date-v-1m+%Y%m%d#Freebsd take last month today method date-v-1y+%Y%m%d#Freebsd take last year today method
34. Execute a command or script as xiyou:
Su-xiyou-c "cd/home/xiyou/script;./start_apex.sh&"
35. Exclude a subdirectory when tar is packaged:
TarzcvfApex09010702.tgz--exclude=ApexItemServer/hook_logApexItemServer
Note: the above example uses the tar program format of the GUN version, otherwise-- the exclude parameter should be placed in * *
36. Lock the terminal:
Lock-np#-n never times out.-p uses the system password as the key to open the terminal.
37. Display the list of ATA devices:
Atacontrollist
38. View network traffic:
Systat-if1#1 indicates that the screen is refreshed every second, and the peak peak of Traffic traffic and the average of average are netstat1.
39. Check the real-time read and write status of the detailed partition of the hard disk:
Gstat
40. Password is also required to enter single user mode:
A.vi/etc/ttys found whengoingtosingle-usermode.
b. Change the secure after consolenoneunknownoff to insecure
c. Save and exit
41. Load above FreeBSD5.X and uninstall the ISO file:
The mount:mdconfig-a-tvnode-fmyisofile.iso# screen outputs the number after the md0 or similar device name mount-tcd9660/dev/md0/mntumount:umount/mntmdconfig-d-u0#-u and the preceding md? The numbers in the consistent mdconfig-l# can be listed about configuring md? 42. Update the configuration file, such as editing. cshrc, you need to use the source command: source.cshrc
43. Repair the UFS file system partition:
Fsck_ufs/dev/ad1
44. Pf Firewall
Pfctl-e# starts pf Firewall pfctl-d# stops pf Firewall pfctl-sa | grepStatus# View status pfctl-f/etc/pf.conf# loads pf.conf file pfctl-nf/etc/pf.conf# checks configuration file error But do not load pfctl-Nf/etc/pf.conf# only load NAT rules in the file pfctl-Rf/etc/pf.conf# load only filter rules in the file pfctl-sn# display current NAT rules pfctl-sr# display current filtering rules pfctl-ss# display current state table pfctl-si# display filter status and count pfctl-sa# display any displayable pfctl-thttp_table-Tshow# view dynamic table Pfctl-thttp_table-Tadd192.168.1.X# add an IP to the table pfctl-thttp_table-Tdel192.168.1.X# remove IP from the table
45. System optimization + prevention of ddos
Load file modification
# vi/boot/loader.conf# add the following text kern.dfldsiz= "2147483648" # Settheinitialdatasizelimitkern.maxdsiz= "2147483648" # Setthemaxdatasize kern.ipc.nmbclusters= "0" # Setthenumberofmbufclusterskern.ipc.nsfbufs= "66560" # Setthenumberofsendfile (2) bufs
# # explanation:
The second line is mainly designed to break through the 1G memory setting.
B. The third line is actually a bug of bsd. When the system concurrency reaches an order of magnitude, the system will crash, which is a very bad thing. Fortunately, after changing this parameter, there can be no similar situation in the case of high concurrency. Of course, in the case of very bt, we have to find a further way.
C. the fourth line is the number of files read. If you download a large number of files, it is not always cool to increase this parameter.
Sysctl modification
# vi/etc/rc.localsysctlkern.ipc.maxsockets=100000## adds concurrent socket, which is very useful for ddos. Number of files opened by sysctlkern.ipc.somaxconn=65535## sysctlnet.inet.tcp.msl=2500##timeout time
Accelerate ports installation
# vi / etc/make.conf## add the following MASTER_SITE_OVERRIDE?= http://ports.hshh.org/${DIST_SUBDIR}/MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/
Freebsd color display
SecureCRT settings: emulation: terminal-> linux > check ANSI color-- > OK
# vi/etc/csh.cshrc## add the following setenvLSCOLORSExGxFxdxCxegedabagExExsetenvCLICOLORyes#cd/usr/ports/edit/vim;makeinstall#echo "syntaxon" > / root/.vimrc#echo "aliasvivim" > > / root/.cshrc # # colors are mainly displayed by vim, so you need to install vim, and then change vialias to vim.
46. View system status
Fstat# reports information about opening files in the system
Pstat-T# displays the status of these system tables, including the currently used and available system tablespaces, so it can be used to check how many system tables the system uses under the current load to help optimize system performance.
Systat# by default systat reports processor utilization, including total utilization status, idle utilization, and utilization of individual processes
By specifying parameters, systat can also carry out the statistics of I iostat,-vmstat,-mbufs,-netstat,-ip,-icmp,-tcp,-swap O, virtual memory, network, etc., these parameters include-TCP and so on.
Kldstat-v# displays the module loaded by the kernel klsdstat-mipfilter# displays the IRQ and memory address occupied by the specified module pnpinfo# plug and play device devinfo-u# display device
Use the directory tree of portsnap student port, which is recommended; I did not do this step, use port to install vim system to report an error.
① configuration portsnap:
To use portsnap, first set its configuration file, which is located at / etc/portsnap.conf:
[root@bsd01/usr/ports] # vi/etc/portsnap.conf
Put
SERVERNAME=portsnap.freebsd.org
Modified to:
SERVERNAME=portsnap.hshh.org
To use portsnap in your freebsd * *, you must perform the following 2 steps:
[root@bsd01~] # portsnap fetch [root@bsd01~] # portsnap extract
# these two steps can be combined to use:
[root@bsd01~] # portsnap fetch extract # portsnapfecth is a * compressed package for obtaining portsnap snapshots on the Internet. I have heard that this compressed package is updated every hour.
# portsnapextract creates this package to / usr/ports. Even if you have manually installed ports before, it will re-create it.
③ uses portsnap to update ports later:
For future updates, you only need to perform the following 2 steps:
[root@bsd01~] # portsnap fetch [root@bsd01~] # portsnap update
These two steps can be combined to use:
[root@bsd01~] # portsnap fetch update
It may take a while for portsnap * to run the extract command, but it will be much faster when update is used in future updates.
At this point, I believe that everyone on the "FreeBSD commonly used instructions collation" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.