FreeBSD is an important branch of UNIX systems, and its commands are mostly common to Linux, and few of them are unique.

Source: Internet
Author: User
Tags disk usage nameserver ssh server dmesg

FreeBSD is an important branch of UNIX systems, and its commands are mostly common to Linux, and few of them are unique.

1:man online query man ls
2:ls Viewing directories and Archives Ls-la
3:ln creating a linked file ln-fs/usr/local/apache/etc/httpd.conf/etc/httpd.conf
4:more page show more file names
5:CD Switch Directory Cd/usr/local/apache
6:mkdir creating a new directory Mkdir/usr/temp
7:rmdir Deleting a directory rmdir/usr/temp
8:RM Delete the directory or archive rm-f file name if you want to delete the directory. Need to add-R)
9:CP copy directory or file CP source file target file
10:pwd shows the current working directory
11:MV directory or file name or move MV source file target file
12:find Find directory or archive find/etc-name file name

Fetch FTP Get file fetch ftp://ftp.center.kl.edu.tw/pub/FreeBSD/test.tgz
chmod change the file usage rights chmod-r 755/USR/LOCAL/ETC
Chown Change file owner Chown-r lin.wheel/usr/local/etc
fsck Repair File System fsck-y
Gzip/tar Compress or unzip the file or directory TAR-CZVF compressed file name. tar.gz Directory Name
Mount the file system or equipment Mount/cdrom
Umount Remove the file system or device Umount/cdrom
The available file space DF of the DF query system
DU displays the disk space that the directory or archive occupies du-a file name (Du-sh can get the disk usage space under the current folder)
PS Query System process State Ps-aux|grep apach*
Kill a process kill PID
Su Transform Identity Su–root
AddUser new users
Rmuser Delete User
VIPW Edit user Account
passwd Change Password
Ping to detect the online status of the computer ping 210.240.6.9
Ifconfig network interface settings and management ifconfig-a
The route can be set routing table
Traceroute list the route traceroute 210.240.8.1
Netstat can query the use of the network and online situation
Pkg_add installation package Pkg_add bash-2.04.tgz
Pkg_delete Remove the installed package Pkg_delete bash-2.04
Pkg_info Query Installation Record
PNS Sync forces System to write cache data back to hard drive
Reboot reboot System
Halt shutdown system
Shutdown notifies the user that the system will be closed
0 Init Direct shutdown
Chown chown-r owner. Group profile or directory
-R: The owner and group of all files in this directory are followed by changes

chmod
Drwxrwxrwx
Lr–rwxr-x
1 2 3 4
D: Table Directory
R: Table Read
W: Table Write
X: Table Executable
-: Table Off function

L: Table-Link files
2: Read permission of the file or directory owner
3: Read permission for the same group as the file or directory owner
4: Read access for people on the network
-r: The Read permission of all files in this directory is changed after

Gzip/tar
Tar czvf compressed file name. tar.gz Directory Name
Z: With gzip compression
C: Create a new compression file
V: Watch the compression process using the Verbose method
F: Forced

Tar zxvf compressed file name. tar.gz
Z: Uncompressed with gzip
X: Unzip
V: Watch the compression process using the Verbose method
F: Forced

Ifconfig
Querying for all network interface scenarios
Ifconfig-a

Setting parameters for network interfaces
Ifconfig de0 192.168.1.10 netmask 255.255.255.0

Stop network interface
Ifconfig de0 Down

Start the network interface
Ifconfig de0 up

Route
Change the gateway of routing path
Route change default 192.168.1.254

Netstat
Query routing Table
Netstat-rn

Querying network Interface Traffic statistics
Netstat-i
Querying TCP Network online scenarios
Netstat-t
Querying all network online scenarios
Netstat-a

Shutdown
Notify the user how long after the shutdown, managers need to reboot or halt
Shutdown-k Time Message
Notify the user how long after the system restarts
Shutdown-r Time Message
Notifies the user how long it takes to shut down the system
Shutdown-h Time Message

Time: Now or +3 table three minutes later or YYMMDDHHMM
Message: Enclose with double quotation marks or start with a number.

Some other common combinations of commands:
Shift+g the end key with win, so that the cursor is at the end of the document.
:/ function is to search for text within a document
: Find this is a search for files

==============================================

1. View the relevant catalogue description
#man hier
2. Manage user information with PW
#pw groupadd group1 Add Group
#pw useradd-n user1-g group1-m-s/bin/csh
-n username/Specify user name
-g groupname/Specify group name
-M/auto-Create user Directory
-S/Specify user shell
#echo |pw useradd-n username-g group-m-s/bin/csh-h 0
The main parameter-h-0/can create the user's password directly when creating users;
#pw userdel-n username-r/delete change user
-R also delete home directory related data
#pw groupshow Wheel View members of this group
#pw groupmod wheel-m user1 Add the User1 user to the wheel group
-M set this user to be the only member of this group
-M add users to this group
2.1 Interactively adding users with commands
AddUser adding users
Rmuser Deleting a user
Chpass tools for modifying user database information
passwd tools to modify user passwords
PW Modify the User account tool
2.2 Using the ID command to display change user information
#id username
# ID Root
Uid=0 (Root) gid=0 (wheel) groups=0 (wheel), 5 (operator)
3. Screensaver Program
Add the following information in the/etc/rc.conf file
Blanktime= "900" Enable time is 15 minutes, in seconds
saver= "logo" graphic Interface (graphics), daemon (text).
4. Please empty a file
#true > FileName
5. Print the man's file, for example, to convert the SSH2 's help information into a ssh2.txt file;
#man Find |col-b > Find. Txt
6. Forget the FreeBSD password solution
To restart FreeBSD, select 4 when the rewind occurs, run ' #/sbin/mount-a ' after entering the system, and now you can change the root password with ' passwd '.
7. In FreeBSD want to use the SU command, switch to root, your user should be the wheel group Ah, so that su to root go ah
8. Mount the DOS/NTFS partition with Mount
#mount-t msdosfs/dev/ad0s1/mnt
#mount-t mount_ntfs/dev/ad0s1/mnt
9. When the user logged in using single user mode is also prompted to enter the password operation, modify the/etc/ttys file
Console none unknown off secure
Change the secure to insecure so that you also provide account information when you log in as a single user.
10. Directory Architecture for FreeBSD
/etc/defaults system default boot configuration and script directory
/etc/periodic directory where the script is scheduled to execute
11. Using the Pkg_add command to install a BREEBSD package from a local or network server, a single package must be used. Tgz or. TBZ two different formats.
#pkg_add xxx-1.11.1.tgz
12. Use Pkg_info to list all installed package lists and descriptions.
#pkg_info
13. Use Pkg_version to count all the installation packages
14. Use Pkg_dalete to remove the previous installation instead of the software, you must provide the full package name.
#pkg_dalete XXX-1.11.1
15. Use the Pciconf tool to display detailed hardware output
#pciconf
16. View CPU:
Sysctl Hw.model HW.NCPU
DMESG | grep "CPU:"

17. View Memory:
DMESG | grep "Real Memory" | Awk-f ' [()] ' {print $2,$4,$7,$8} '
18. Check the hard drive:
DMESG | grep "Sector" | awk ' {print $1,$2} '
19. Mount File System:
Mount_msdosfs/dev/ad0s1/mnt
Mount_ntfs/dev/ad0s1/mnt
20. Add or disable the system Forbidden flag (directory not applicable) to the file:
Chflags Sunlink File1
Chflags Nosunlink File1
21. Initialize the disk:
Fdisk-bi AD1
22, the establishment of the FreeBSD partition:
Disklabel-b-w-r AD1S1 Auto
23. Establish logical partition:
DISKLABEL-E AD1S1
24. Format the partition and create the file system:
newfs/dev/ad1s1e
25. Display PCI Hardware information:
Pciconf-lv
26. Turn on Linux binary Compatibility support (the simplest way to enable this feature is to load the Linux KLD module):
Kldload Linux
27. Check if the KLD module is loaded:
Kldstat
28, in the kernel statically linked into the Linux binary compatibility mode, in the kernel configuration file added:
Options Compat_linux
29. If you want Linix compatibility support to be expected to start during the initial system, modify the/etc/rc.conf
Linux_enable= "Yes"
30. View Server Branding
#dmegs | grep ACPI
============== System Management Section ======================
1. NIC and Nic chipset information
/usr/scr/sys/conf/notes or/usr/src/sys/arch/conf/notes
Information about the NIC and chipset will be available in both directories
2. Load the corresponding module of the NIC
#kldoad
3. Using the Windowsndis driver to load the NIC driver, if you want to take advantage of ndisulator, you need three things, kernel source code/binary form of windowsxp driver (extension. SYS)/windows XP driver configuration file ( extension. inf); In the following example we use W32driver.sys and W32driver.inf to represent these files
A. Using the root user to execute the ndisgen command to load a binary form driver into a kernel module
#ndisgen/path/to/w32driver. Inf/path/to/w32driver. SYS
At the end of this interactive program, he will prompt you to enter some additional information, which will generate the Ygie kernel module file in the current directory when finished.
B. Loading a newly generated kernel module file
#kldload./w32driver.ko
C. In addition to loading the new module, there are two kernel modules loaded Ndis.ko and If_ndis.ko
#kldoad Ndis.ko Loading NDIS driver Encapsulation module
#kldoad If_ndis.ko load the actual network interface
D. Automatically load the module, copy W32driver.ko to/boot/modules directory, modify/boot/loader.conf to add
W32driver_load= "YES
4. Binding multiple IP addresses on a network card, mainly modifying the/etc/rc.conf file, but the network card alias must be starting from alias0 and ascending sequentially, the general description is as follows:
Ifconfig_ Network card name _alias0= "inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"
Like my own.
ifocnfig_lnc0_alias0= "inet 192.168.137.1 netmask 255.255.255.0″
ifconfig_lnc0_alias1= "inet 192.168.138.1 netmake 255.255.255.0″
5. Change the operating mode of the NIC command:
Full-duplex
#ifconfig lnc0 Media 100baseTX mediaopt Full-duplex
Half Duplex
#ifconfig LNC0 Media 100base
6. Set the client DNS file/etc/resolv.conf, the format of the record is as follows:
nameserver query DNS server IP address in sequence, up to three
Search searches the list of machine names, usually with local domain name decisions
Domin local domain name
Search example.com
NameServer 202.96.0.133
NameServer 202.97.16.195
Format of 7./etc/hosts file
[Internet address] [Official hostname] [ALIAS1] [ALIAS2] ...

8.syslog.conf is a configuration file for the SYSLOGD program that stores a specific log file, newsyslog.conf is a profile that is scheduled to run, Newsyslog points out when the log files need to be packaged or re-organized. For example, logfile was moved to logfile.0,logfile.0 move to logfile.1 and so on, the log can also be compressed with gzip, His naming format is logfile.0.gz.<301 page >
9.sysctl.conf and rc.conf's file style is similar, wherein the configuration is variable = value form, the configuration of this file will be in the system into multi-user mode after the actual modification operation, not all variables are in the multi- Modified in user mode. For example, you want to close a record that received a fatal signal exit and prevent a normal user from seeing another user's process
A. Do not log process exits caused by a fatal signal
Kern.logsigexit=0
B. Preventing a user from seeing a process that executes as a different UID
Seurity.bsd.see_other_uids=0
10.sysctl is capable of changing the running FreeBSD system interface, which contains some advanced options for the TCP/IP stack and virtual memory system, while he can read set 500 system variables, where the SYSCTL variable setting is usually a string, numeric or Boolean (Boolean with 1 means " Yes ", 0 means" no ")
#sysctl-a view all variables;
#sysctl Kern.maxproc to read a specified variable;
#sysctl kern.maxfiles=5000 set a specified variable directly with the Variable=value syntax;
11. Create a swap file in FreeBSD
1. First create a swap file (SWAP0)
#dd If=/dev/zero of=/mnt/swap0 bs=1024k count=64
2. Give this file the appropriate permissions
#chmod 0600/mnt/swap0
3. Enable swap files in/etc/rc.conf love you
Swapfile= "/mnt/swap0″ #set to name Ofswapfile
4. Effective when restarting the machine
#mdconfig-t vnode-f/mnt/swap0-u o && swapon/dev/md0
12. Create a tunnel using OpenSSH, example using SSH to create a tunnel for Telnet
#ssh-2-n-f-l 5023:localhost:23 [email protected]
Parameter description:
-2 forced SSH to use the second version of the Protocol
-n means not using the command line, only using tunneling
-F force SSH to execute in the background
-L indicates a local port: remote host: Tunnel in the form of a remote port
[Email protected] Remote SSH server
13. Restrict SSH Login
1. Only allow root users to log in to the server from 192.168.1.2:
Modify the/etc/ssh/sshd_conf file to add a parameter to the file:
allowusers [email protected]
2. Allow admin users to log in from anywhere
Allowusers Admin
You can also specify multiple users on the same line
allowusers [email protected] Admin
14. Setting ACLs on files
#getfacl filename to view ACL information for a file
ACL information for #setfacl filename settings file
#setfacl-K filename-k Remove all defined ACLs from the file or file system
-B keep the ACL from getting something normal.
15. Using dump to back up data via SSH
#/sbin/dump-0uan-f–/usr |gzip-2 |ssh-c blowfish [email protected] DD of=/mydatefiles/dump-user-10.gz
16. Using pipelines and rsh to send data to a remote tape drive
#tar cf–. | rsh hostname dd Of=tape-device obs=20b
17. Use the script command to output information from the executed or compiled process to a file for easy querying of error messages.
#script/var/tmp/mw.out
18. See if the kernel supports serial ports
#dmesg | grep ' Sio '

FreeBSD is an important branch of UNIX systems, and its commands are mostly common to Linux, and few of them are unique.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.