freebsd命令汇总

合集下载

FreeBSD上配置FTP

FreeBSD上配置FTP

FTP 服务器FTP (File Transfer Protocol) 是常用的网络协议,主要的功能是用来传输档案,我们时常从 FTP 站台下载档案。

本章将介绍如何使用 FreeBSD 架设 FTP 服务器,并说明各种 FTP 服务器的管理技巧。

本章除了FreeBSD 内附的 FTP 服务器软件外,并将介绍笔者开发的 SmbFTPD。

读完本章后,您将进一步了解下列主题:∙FTP 协定的运作方法。

∙如何使用 FreeBSD FTP。

∙加强权限控制以建立安全的 FTP 服务器。

∙安装设定 SmbFTPD。

∙如何使用具 SSL 加密的 FTP。

∙如何进行流量控制。

15.1 FTP 概论FTP 是一个历史悠久的网络通讯协议,和大多数的网络协议一样,它采用 Client/Server 架构,各地的使用者可以经由网络连到服务器上传或下载档案。

FTP 协议比较特别的地方在于它在使用时必须建立二个联机:一个用来传输指令、一个用来传输档案。

图 15-1当我们使用 FTP 软件连到 FTP 服务器时,客户端会先连到服务器的连接埠 21,并建立一条「控制联机」(Control Stream)。

接下来,您会输入账号、密码等指令,这些指令及 FTP 的响应都是使用都是使用「控制联机」。

当您要下载档案时,或者是执行 ls 以列出目录中的档案时,档案或目录列表的下载是经另一个联机「数据联机」(Data Stream)。

「数据联机」和「控制联机」不同的是数据联机所传输的数据比较大,而控制联机只是用来传输指令及简单的响应。

基本上,一个完整的 FTP 联机建立过程为:∙客户端打开自已机器大于 1024 的连接埠,并连到服务器的连接埠 21,建立「控制联机」。

∙客户端开始对服务器下指令,告诉服务器客户端用来传输档案的连接埠为何。

∙服务器从连接埠 20 连到客户端所开放的埠号 (大于 1024),以建立「数据联机」。

上述这种联机建立的方式是由服务器主动建立「数据联机」,我们称之为「主动模式」(Active Mode)。

FreeBSD 系统安装和 检点的iscsi 多路径共享配置

FreeBSD 系统安装和 检点的iscsi 多路径共享配置

FreeBSD-8.3.1-x64安装配置1.安装系统:(为实验需要,添加了两块网卡,和三块磁盘,系统盘为2GB,1G可能会出错,内存默认即可)安装系统过程中注意系统安装在哪块磁盘上。

其他保持默认即可!8.3.1版本的全自动安装!安装完毕自动获得ip.2.配置服务通过http://192.168.4.149访问free1)更改语言为中文或者english ,然后刷新便可2)设置管理员密码:更改完毕登出,然后再登陆(没设置前alert 闪红灯,设置后成绿色)3.配置iscsi磁盘1)查看当前磁盘状态:2)配置iscsi server我们在此先不设置严格的认证程序,允许所有的可连接源允许任何主机使用3260端口连接添加连接的目标名称:ubu8设置连接目标设备:da3 (* 注意da3 需在系统中使用mkfs.ext3 /dev/da3 进行文件系统创建,否则在此不可用)设置目标和设备关联到此,iscsi 共享磁盘已经创建完毕!接下来,我们在远处客户端进行连接测试!我们使用ubuntu作为客户端:1)客户端需要安装iscsi 服务软件安装open-iscsi 和open-iscsi-utils查看软件包安装是否成功并设置iscsid 自动启动2)安装multipath多路径选择功能3)发现iscsi 目标:Ubuntu 默认没有iscsiadm 命令需要使用apt-get install iscsiadm 进行安装连接iscsi目标:使用fdisk /dev/sdc 便可对iscsi映射过来的磁盘进行分区创建!本实验是采用了多路径,使用multipath –Fmultipath –v2multipath –ll查看映射状态,创建分区后在/dev/mapper/下回出现,两个设备文件(如下图),而xxxxx-part1 是在创建分区后出现的,使用mkfs.ext3 便可将其创建为文件系统,挂载使用便可!当然也可直接使用/dev/sdc 进行分区并创建文件系统后使用。

FreeBSD 自由BSD操作系统使用说明说明书

FreeBSD 自由BSD操作系统使用说明说明书

Table of ContentsAbout1 Chapter 1: Getting started with FreeBSD2 Remarks2 Versions2 Examples4 Installation or Setup4 Chapter 2: Build from source5 Introduction5 Remarks5 Overview of the whole process5 Get the number of processors5 Examples5 Download the latest source code5 SVN5 Get Current6 Get Releases6 Tarball (http & ftp)6 http6 ftp6 Git6 GitHub6 Configure the kernel6 Build the world and the kernel7 Build the world7 Estimated time7 Build the kernel7 Estimated time7 Configure the root filesystem of your new FreeBSD7 Install the world and the kernel8Install the world8 Install the kernel8 Chapter 3: FreeBSD Jails9 Examples9 Deploying jail9 Simple jail deployment from binaries9 Simple jail deployment from source9 Simple thin jail deployment10 Initializing our environment10 downloading sources10 Initializing our thin jail10 Networking and Jails11 Removing network support11 Allowing only IPv4 networking11 Allowing only IPv6 networking11 Dedicated network stack (VNET)11 Chapter 4: Packages and Ports management13 Remarks13 Examples13 Getting Ports tree13 Portsnap13 updating ports tree with portsnap13 schedule cron job for daily updates13 SVN13 head13 quaterly13 Tarball (http or ftp)14 Git14 Searching software14 keyword search14name search14 Using fresports14 Building and installing software14 Simple build and install with manual configuration14 Simple build and install with automatic configuration15 Configuring software sources15 Configuring www/apache2415 Packaging15 Manual packaging15 Using poudriere15 Installing poudriere15 Configuring poudriere16 Deploying poudriere jail16 Updating poudriere jail16 Deploying poudriere ports tree16 Updating poudriere ports tree16 Bulk build16 Chapter 5: Set up the FreeBSD development environment17 Examples17 ctags17 Build exctags(1) using ports17 Download and install a prebuilt binary of Exuberant Ctags:17 Create the tag file17 Credits18AboutYou can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: freebsdIt is an unofficial and free FreeBSD ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official FreeBSD.The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to ********************Chapter 1: Getting started with FreeBSD RemarksThis section provides an overview of what freebsd is, and why a developer might want to use it.It should also mention any large subjects within freebsd, and link out to the related topics. Since the Documentation for freebsd is new, you may need to create initial versions of those related topics.VersionsSome versions were omitted since the exact release date is unknown. See the source of this post to view the list of the omitted versions.ExamplesInstallation or SetupFreeBSD is known of its well-written handbook (link). The installation process is described in detail in the Chapter 2. Installing FreeBSD.Read Getting started with FreeBSD online: https:///freebsd/topic/5708/getting-started-with-freebsdChapter 2: Build from sourceIntroductionExamples below are not necessarily in the correct order. See the Remarks section below for more information on the whole process.RemarksOverview of the whole processDownload the latest source code.1.2.Configure the kernel.3.Build the world and the kernel.4.Configure the root filesystem of your new FreeBSD.5.Install the world and the kernel.Get the number of processorsAn easy way to speed up the process of building and installing the new system is to use more processors to increase the computational power.To find out what's the number of the processors you have to speed up the process:sysctl hw.ncpuFor example:hw.ncpu: 1Let's set the $NUMBER_OF_PROCESSORS environmental variable then:export $NUMBER_OF_PROCESSORS=$(sysctl hw.ncpu | tr -d 'a-z.: ')ExamplesDownload the latest source codeSVNFreeBSD project use SVN as default SCM. Source could be download with svnlite software. Get Currentcd /usr/srcsvnlite checkout https:///base/head .Get Releasescd /usr/srcsvnlite checkout https:///base/release/11.0.0 .Tarball (http & ftp)You can also get source from frozen tarball with fetch commandhttpcd /tmpfetch /pub/FreeBSD/releases/amd64/11.0-RELEASE/src.txzcd /usr/srctar xJvf /tmp/src.txzftpcd /tmpfetch ftp:///pub/FreeBSD/releases/amd64/11.0-RELEASE/src.txzcd /usr/srctar xJvf /tmp/src.txzGitGitHubgit clone https:///freebsd/freebsd freebsdsrcConfigure the kernelGo to the directory with the source code:1.cd freebsdsrc2.Go to the directory with the kernel's configuration code:# If your system is 32-bit.cd sys/i386/conf/# If your system is 64-bit.cd sys/amd64/conf/3.Get a copy of the GENERIC kernel (let's call it MODEDKERNEL). It will be the base of your customisations.cp GENERIC MODEDKERNEL4.Modify the MODEDKERNEL file at your will.Build the world and the kernelBuild the worldGo to the freebsdsrc/ (the root directory of the FreeBSD source tree you've already downloaded) and build the world:sudo make -j${NUMBER_OF_PROCESSORS} buildworld KERNCONF=MODEDKERNEL -DNO_CLEAN Estimated time•Estimated time on Hasee Q540S running on a one processor: 8 hours.•Estimated time on Dell L702X running on 8 processors: 98 minutes.Build the kernelTo build the kernel run:sudo make -j${NUMBER_OF_PROCCESORS} buildkernel KERNCONF=UFFIE -DNO_CLEANEstimated time•Estimated time on Hasee Q540S running on a one processor: 2 hours.•Estimated time on Dell L702X running on 8 processors: 19 minutes.Configure the root filesystem of your new FreeBSDLet's configure the destination directory for the root filesystem of your new FreeBSD (for exampleAdd the following lines to /etc/src.conf to set it up:.if ${KERNCONF} == "MODEDKERNEL"DESTDIR?=/usr/home/beastie/MODEDKERNELMODULES_OVERRIDE=md ufs.endifRemember to use spaces not tabs if you wish to indent the code.1. Create the root file system now:Make distribution directories:sudo make distrib-dirs KERNCONF=MODEDKERNELEstimated time on Hasee Q540S: a few seconds.•Make the distribution:sudo make distribution KERNCONF=UFFIEEstimated time on Hasee Q540S: 3 minutes.•2. Install the world and the kernel Install the worldsudo make installworld KERNCONF=MODEDKERNEL Estimated time on Hasee Q540S: 5 minutes.Install the kernelsudo make installkernel KERNCONF=MODEDKERNELEstimated time on Hasee Q540S: a few seconds.Read Build from source online: https:///freebsd/topic/7062/build-from-sourceChapter 3: FreeBSD JailsExamplesDeploying jailA jail is simply a chroot with strong isolation. So, if you want to create jail, you simply need to create an alternative root and starting a new jail in it.Simple jail deployment from binaries# create our alternative root pathJAILROOT="/path/to/my/jail"mkdir -p "${JAILROOT}"cd "${JAILROOT}"# get distribution from freebsd repositoryfetch /pub/FreeBSD/releases/amd64/11.0-RELEASE/base.txz# extract it in our alternative roottar xJvf base.txz# now we can launch our jailjail -c name=simplejail path=${JAILROOT}# to check if jail is up and running we use jlsjls# now we can enter in our new jailjexec simplejail shSimple jail deployment from source# create our alternative root pathJAILROOT="/path/to/my/jail"mkdir -p "${JAILROOT}"# we need to build binaries from source...cd /usr/srcmake buildworld# ... and install it in our alternative pathmake installworld DESTDIR=${JAILROOT}# now we can launch our jailjail -c name=simplejail path=${JAILROOT}# to check if jail is up and running we use jls# now we can enter in our new jailjexec simplejail shSimple thin jail deploymentThin jail is simply a jail with shared read-only alternative root mounted with nullfs. Initializing our environment# making our shared alternative rootSHARED_ROOT=/path/to/your/shared/rootmkdir -p "${SHARED_ROOT}"# making our jail rootJAIL_ROOT=/path/to/your/jail/rootmkdir -p "${JAIL_ROOT}"downloading sources# to initialize our shared root, we can use# all method described above. Here, we will use# simple binary initialization from official# repositorycd "${SHARED_ROOT}"# get distribution from freebsd repositoryfetch /pub/FreeBSD/releases/amd64/11.0-RELEASE/base.txz# extract it in our alternative roottar xJvf base.txzInitializing our thin jail# now we need to initialize our dedicated# jail rootcd "${JAIL_ROOT}"mkdir base# we make symbolic link pointing to# files stored in read-only directoryfor link in bin boot lib libexec rescue sbindoln -s ${link} /base/${link}done# we do same thing with directory in /usrfor link in bin include lib lib32 libdata libexec sbin sharedoln -s usr/${link} /base/usr/${link}# now we are ready to start our jail!jail -c name=thinjail path="${JAIL_ROOT}" \mount="${SHARED_ROOT} ${JAIL_ROOT} nullfs ro 0 0"# check if our thin jail is ok...jls# we can now grab in it!jexec thinjail shNetworking and JailsFreeBSD jails can have fine grained networking configuration. By default, every jails use the same network configuration than host.Removing network supportjail -c name="nonetwork" path="/path/to/your/jail" ip4=disable ip6=disableAllowing only IPv4 networkingjail -c name="onlyipv4" path="/path/to/your/jail" ip4=inherit ip6=disableAllowing only IPv6 networkingjail -c name="onlyipv6" path="/path/to/your/jail" ip4=disable ip6=inherit Dedicated network stack (VNET)VNET is recent feature allowing jail to have its own network stack. Doing this configuration need to add routing feature to the host. VIMAGE option is required in host kernel.# starting our own jail with vnetjail -c name="vnetjail" path="/path/to/your/jail" vnet=new# we need a bridge...ifconfig bridge0 create# a pair of ethernet interface...ifconfig epair0 create# and interconnecting epair, jail and bridgeifconfig epair0b vnet vnetjailRead FreeBSD Jails online: https:///freebsd/topic/7070/freebsd-jailsChapter 4: Packages and Ports management RemarksTips:Remember to always check the /usr/ports/UPDATING file before upgrading. There might be •some significant changes in programs you use or in their configuration which will break your current setup.ExamplesGetting Ports treePortsnapportsnap fetchportsnap extractupdating ports tree with portsnapportsnap updateschedule cron job for daily updates0 3 * * * root /usr/sbin/portsnap cronSVNheadcd /usr/portssvnlite checkout https:///ports/head .quaterlyFreeBSD Ports team freeze ports tree every 3 months. To get this ports tree you can use ports branches:cd /usr/portssvnlite checkout https:///ports/branches/2016Q4 .Tarball (http or ftp)cd /usr/portsfetch /pub/FreeBSD/releases/amd64/11.0-RELEASE/ports.txztar xJvf ports.txzGitgit clone https:///freebsd/freebsd-portsSearching softwarekeyword searchcd /usr/portsmake search key=apachename searchcd /usr/portsmake search name=apache24Using fresportsOfficial FreeBSD ports website (/) give you a nice way to find ports and all information concerning it.Building and installing softwareIf you have found your software in the ports tree, now its the time to build it.Simple build and install with manual configurationcd /usr/ports/www/apache24makemake installSimple build and install with automatic configurationcd /usr/ports/www/apache24make BATCH=yesmake installConfiguring software sourcesIf you want custom configuration from ports, you can configure it before building it make config. All ports configuration are stored in /var/db/ports/${CATEGORY_NAME}/options as makefile. Configuring www/apache24cd /usr/ports/www/apache24make configmakemake installThis configuration will be saved in /var/db/ports/www_apache24/options.PackagingManual packagingYou can make your own package based on ports.cd /usr/ports/www/apache24make package BATCH=yesThis command will store your package in /usr/ports/packages/All.Using poudrierepoudriere is currently the official package builder for FreeBSD.pkg install poudriere# orcd /usr/ports/ports-mgmt/poudrieremakemake installConfiguring poudrierepoudriere configuration is stored in /usr/local/etc/poudriere.conf and /usr/local/etc/poudriere.d Deploying poudriere jailpoudriere jail -c -j myjailUpdating poudriere jailpoudriere jail -u -j myjailDeploying poudriere ports treepoudriere ports -c -p myportsUpdating poudriere ports treepoudriere ports -u -p myportsBulk buildpoudriere bulk -j myjail -p myports www/apache24Read Packages and Ports management online:https:///freebsd/topic/7069/packages-and-ports-managementChapter 5: Set up the FreeBSD development environmentExamplesctagsctags is a useful utility you can use to read and move around the source code more efficiently. The built-in ctags(1) however is not the Exuberant Ctags utility you might expect.You can install Exuberant Ctags (exctags(1)) using either ports or pkg:Build exctags(1) using portscd /usr/ports/devel/ctags/ && make install cleanDownload and install a prebuilt binary of Exuberant Ctags: pkg install ctagsCreate the tag fileexctags -RRead Set up the FreeBSD development environment online:https:///freebsd/topic/6136/set-up-the-freebsd-development-environmentCredits。

ls命令选项详解

ls命令选项详解

ls命令选项详解ls 命令可以说是Linux下最常用的命令之一。

它有众多的选项,其中有很多是很有用的,你是否熟悉呢?下面列出了 ls 命令的绝大多数选项。

-a 列出目录下的所有文件,包括以 . 开头的隐含文件。

-b 把文件名中不可输出的字符用反斜杠加字符编号(就象在C语言里一样)的形式列出。

-c 输出文件的 i 节点的修改时间,并以此排序。

-d 将目录象文件一样显示,而不是显示其下的文件。

-e 输出时间的全部信息,而不是输出简略信息。

-f -U 对输出的文件不排序。

-g 无用。

-i 输出文件的 i 节点的索引信息。

-k 以 k 字节的形式表示文件的大小。

-l 列出文件的详细信息。

-m 横向输出文件名,并以“,”作分格符。

-n 用数字的 UID,GID 代替名称。

-o 显示文件的除组信息外的详细信息。

-p -F 在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;“/”表示目录;“@”表示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)。

-q 用?代替不可输出的字符。

-r 对目录反向排序。

-s 在每个文件名后输出该文件的大小。

-t 以时间排序。

-u 以文件上次被访问的时间排序。

-x 按列输出,横向排序。

-A 显示除“.”和“..”外的所有文件。

-B 不输出以“~”结尾的备份文件。

-C 按列输出,纵向排序。

-G 输出文件的组的信息。

-L 列出链接文件名而不是链接到的文件。

-N 不限制文件长度。

-Q 把输出的文件名用双引号括起来。

-R 列出所有子目录下的文件。

-S 以文件大小排序。

-X 以文件的扩展名(最后一个 . 后的字符)排序。

-1 一行只输出一个文件。

--color=no 不显示彩色文件名--help 在标准输出上显示帮助信息。

--version 在标准输出上输出版本信息并退出。

Linux ls命令 -l 列表信息详解我们平时用ls -l 命令查看一个目录下的文件和子目录的详悉信息时,会得到一个详细的文件和目录名列表.这个列表包含了文件的属性,所属用户,所属组,创建时间,文件大小等等信息.这些信息到底是什么意思呢?有很多初学者对这些不太了解,因此想详悉讲解一下用ls -l命令得到的文件列表每一个字段的意思以笔者电脑的/root目录为例: [root@gucuiwen root]# ll总用量 4055-rw-r--r-- 1 root root 1581 11月 24 18:14 anaconda-ks.cfg drwxr-xr-x 2 root root 208 12月 1 13:50 babylinuxlrwxrwxrwx 1 root root 9 1月 4 11:06 disk1.link.png -> disk1.png -rwxr-xr-x 1 root root 13695 11月 30 16:51 fangkuai.sh drwxr-xr-x 2 root root 208 12月 28 12:06 FreeBSD -rw-r--r-- 1 root root 2315 11月 25 17:19 getMBR.png brw-r----- 1 root root 3, 1 1月 4 11:06 hda1 drwxr-xr-x 2 root root 296 12月 31 11:53 htmls-rw-r--r-- 1 root root 21369 11月 24 18:12 install.log -rw-r--r-- 1 root root 0 12月 18 10:44 tset crw-r----- 1 root root 4, 65 1月 4 11:08 ttyS1 -rw-r--r-- 1 root root 9754 12月 1 11:25 X.sxw-rw-r--r-- 1 root root 8704 11月 29 12:22 员工信息.xls 可以看到,用ls -l命令查看某一个目录会得到一个9个字段的列表. ####################### 第1行:总用量(total) #######################这个数值是该目录下所有文件及目录列表第5个字段的和(以k为单位),也就是该目录的大小.请注意和该目录下的文件和子目录下文件的总合做区分.这个数字和du /root 得到的数字的大小是不一样的.可以用awk命令来验证. 用awk累加第5字段得到的数值:[root@gucuiwen root]# ls -l |awk 'BEGIN{sum=0}{sum+=$5}END{print sum}' 4104092转化成以K为单位:[root@gucuiwen root]# ls -l |awk 'BEGIN{sum=0}{sum+=$5}END{print sum/1024}' 4007.9用ls -l得到的数值: 总用量 4055用du -sh /root得到的数值:[root@gucuiwen root]# du -sh /root 127M /root可以看到累加第5个字段得到的值和total显示的是一样的(因为具体算法的不同,略微有差别).得到的数值实际上是root目录的大小(把root目录看成是一个特殊的文件,就可以理解什么是目录的大小).而用du得到的数值是root目录下所由文件和子目录下全部文件的大小的总合.######################## 第1字段: 文件属性字段########################文件属性字段总共有10个字母组成,第一个字母表示文件类型,如果这个字母是一个减号"-",则说明该文件是一个普通文件.字母"d"表示该文件是一个目录,字母"d",是dirtectory(目录)的缩写.请注意,一个目录或者说一个文件夹是一个特殊文件,这个特殊文件存放的是其他文件和文件夹的相关信息.如果该字母是"l",表示该文件是一个符号链接.符号链接的概念类似于windows里的快捷方式.字母"l"是link(链接)的缩写.在UNIX类系统中,一个文件可以有多个文件名,一个文件的多个文件名之间互称为硬链接(hard link).这些文件头可以指向同一个文件,删除其中一个文件名并不能删除该文件,只有把指向该文件的所有硬链接都删除,这个文件所占用的空间才真正被释放,该文件才真正被删除.这和windows是有很大区别的,windows中不允许一个文件有两个以上文件名,如果存在这中情况,则被认为是文件系统错误.如果你以前在windows下玩过DEBUG就知道,可以用DEBUG修改一张软盘上的根目录,使一个文件同时具有两个文件名.但是修改好后用 scandisk监测的时候会被认为是交叉链接错误.开头为b的表示块设备文件(block),,设备文件是普通文件和程序访问硬件设备的入口,是很特殊的文件.它的没有文件大小,只有一个主设备号和一个辅设备号.上面的hda1就是一个设备文件,具有主设备号3和辅设备号1.表示第一个硬盘第一个分区.另外,如果第一个字母为c表示该文件是一个字符设备文件(character),一次传输一个字节的设备被称为字符设备,比如键盘,字符终端等,传输数据的最小单位为一个字节.一次传输数据为一整块的被称为块设备,比如硬盘,光盘等.最小数据传输单位为一个数据块(通常一个数据块的大小是512字节).第一字段的后面9个字母表示文件的权限. r表是读 (Read) w表示写 (Write) x表示执行 (eXecute)其中前三个表示文件属主的权限,中间三个表示组用户权限,最后三个表示其他用户权限. 比如:-rw-r--r-- 1 root root 1581 11月 24 18:14 anaconda-ks.cfg表示文件的拥有者root对文件有读写权限,其他人(同组用户和其他用户只有读的权限) 另外,权限组还有一些特殊的表示法.比如/usr/X11R6/bin/XFree86具有如下权限: [root@gucuiwen root]# ll /usr/X11R6/bin/XFree86-rws--x--x 1 root root 1960262 2003-02-28 /usr/X11R6/bin/XFree86其中的s表示这个是网络接口程序"s"是socket的缩写.该程序在运行过程中会打开一个网络接口.其他UNIX类系统如FreeBSD中还有t权限,表示一个临时(temporary)文件在freeBSD中用ls -l /tmp 可以看到这样的权限: drwxrwxrwt它的最后一位是字母"t"############################### 第2字段文件硬链接数或目录子目录数 ###############################如果一个文件不是目录那么这一字段表示,这个文件所具有的硬链接数,即这个文件总共有多少个文件名.查看第一个文件:-rw-r--r-- 1 root root 1581 11月 24 18:14 anaconda-ks.cfg第2字段的值为1,说明这个文件只有anaconda-ks.cfg这一个文件名.即只有一个指向该链接的硬链接.如果我用ln,做一个指向该文件的硬链接再查看该文件,该文件的第2字段就会变成2: [root@gucuiwen root]# ln anaconda-ks.cfg anaconda-ks.cfg.hardlink [root@gucuiwen root]# ls -l 总用量 4071-rw-r--r-- 2 root root 1581 11月 24 18:14 anaconda-ks.cfg-rw-r--r-- 2 root root 1581 11月 24 18:14 anaconda-ks.cfg.hardlink此时,anaconda-ks.cfg 和anaconda-ks.cfg.hardlink 称为互为硬链接.他们指向同一个文件,无论是修改哪一个文件,另一个里也做相应的变化,因为实际上他们指向同一个文件. 用ls -i anaconda-ks.cfg可以查看它的文件节点(inode) 互为硬链接的文件具有相同的文件节点. 以下是验证实验: [root@gucuiwen root]# ls -i anaconda-ks.cfg 18102 anaconda-ks.cfg [root@gucuiwen root]# ls -i anaconda-ks.cfg.hardlink 18102 anaconda-ks.cfg.hardlink可以看到,这两个文件具有相同的文件节点号:18102如果你知道一个文件有多个文件名,如何查找他的其他文件名分布在什么地方呢?可以先用ls -i 获得它的节点号,然后用find查找,如/etc/sysconfig/networking/devices/ifcfg-eth0就具有多个文件名,我要查找与它互为硬链接的文件:[root@gucuiwen devices]# ls -i /etc/sysconfig/networking/devices/ifcfg-eth0 147181 /etc/syscon fig/networking/devices/ifcfg-eth0 得到它的节点号为 147181 再用find查找:[root@gucuiwen devices]# find /etc -inum 147181 /etc/sysconfig/networking/devices/ifcfg-eth0/etc/sysconfig/networking/profiles/default/ifcfg-eth0 这样就得到了同一个文件的不同文件名的位置. ************************************* 如果是一个目录,第2字段的含义: **************************************如果是一个目录,则第2字段表示该目录所含子目录的个数.新建一个空目录,这个目录的第二字段就是2,表示该目录下有两个子目录.为什么新建的目录下面会有两个子目录呢?因为每一个目录都有一个指向它本身的子目录"." 和指向它上级目录的子目录"..",这两个默认子目录是隐藏的.用ls -a可以看到.每次在目录下新建一个子目录,该目录第2字段的值就增1,但是新建一个普通文件该字段值不增加.############################### 第3字段: 文件拥有者###############################该字段表示这个文件是属于哪个用户的.UNIX类系统都是多用户系统,每个文件都有它的拥有者.只有文件的拥有者才具有改动文件属性的权利.当然, root用户具有改动任何文件属性的权利.对于一个目录来说,只有拥有该目录的用户,或者具有写权限的用户才有在目录下创建文件的权利.如果某一个用户因为某种原因,被删除,而该用户的文件还存在,那么用ls -l 查看该文件将显示一个代表用户存在前ID号的数字. 以下是演示:先创建一个用户并用su过去:[root@gucuiwen root]# useradd gucuiwen -g users [root@gucuiwen root]# su - gucuiwen 用新建的用户创建一个测试文件:[gucuiwen@gucuiwen gucuiwen]$ touch testfile [gucuiwen@gucuiwen gucuiwen]$ ls -l testfile -rw-r--r-- 1 gucuiwen users 0 1月 4 16:31 testfile 最后用ls -l 看到第三字段的文件拥有者为gucuiwen 然后我将gucuiwen用户删除:[root@gucuiwen root]# userdel gucuiwen [root@gucuiwen root]# cd /home/gucuiwen/ [root@ gucuiwen gucuiwen]# ls -l 总用量 0-rw-r--r-- 1 501 users 0 1月 4 16:31 testfile可以看到,第三字段成了一个数字,这个数字是原gucuiwen用户的ID号.因为文件系统对每个文件记录文件所有者的ID,而非用户名. ############################### 第4字段:文件拥有者所在的组###############################组的概念可以想像成是一个共同完成一个项目的团队.通过组的概念,可以控制文件让特定的用户查看,修改或运行.而不是一棍子打死,要么全不让看,要么全让看.一个用户可以加入很多个组,但是其中有一个是主组,就是显示在第4字段的明称. 可以在adduser的时候用-g指定该用户所在的主组,用-G指定其他组. ############################### 第5字段:文件文件大小(以字节为单位) ###############################第5字段表示文件大小,如果是一个文件夹,则表示该文件夹的大小.请注意是文件夹本身的大小,而不是文件夹以及它下面的文件的总大小!很多人不能理解文件夹是一个特殊的文件的含义,这样的话理解文件夹大小的含义就比较困难了.###############################第6字段: 文件创建月份############################### 这个不必多说了.############################### 第7字段: 文件创建日期############################### ############################### 第8字段: 文件创建时间###############################文件创建的时间可以通过touch命令来修改.如: #touch testfile可以把testfile的创建时间修改为当前时间. touch的详细用法请看链接文档. #man touch 另外,一个文件还有最后访问时间,最后修改时间等属性. 这些属性可以用ls 的其它参数显示出来. ############################### 第9字段: 文件名###############################如果是一个符号链接,那么会有一个 "->" 箭头符号,后面根一个它指向的文件名.。

UNIX操作系统命令大全

UNIX操作系统命令大全

UNIX操作系统命令大全1. ls:列出当前目录中的文件和目录。

2. cd:切换当前工作目录。

3. pwd:显示当前工作目录的路径。

4. mkdir:创建一个新目录。

5. rmdir:删除一个空目录。

6. cp:复制文件或目录。

7. mv:移动或重命名文件或目录。

8. rm:删除文件或目录。

9. touch:创建一个新文件。

10. cat:连接文件并打印到标准输出设备上。

11. less:逐页显示文件内容。

12. head:显示文件的开头几行。

13. tail:显示文件的末尾几行。

14. grep:在文件中查找匹配的字符串。

15. find:从指定目录开始递归地查找文件。

16. tar:打包和压缩文件。

17. unzip:解压缩文件。

18. chmod:更改文件的权限。

19. chown:更改文件的所有者。

20. chgrp:更改文件的所属组。

21. ps:显示当前运行的进程。

22. top:动态显示系统资源使用情况。

23. kill:终止一个进程。

24. ssh:使用安全外壳协议远程登录到另一台计算机。

25. scp:通过安全外壳协议在本地计算机和远程计算机之间传输文件。

26. ping:测试与另一台计算机的网络连接。

27. ifconfig:显示和配置网络接口。

28. netstat:显示网络连接、路由表和网络接口统计信息。

29. hostname:显示或设置主机名。

30. whoami:显示当前登录的用户。

31. su:切换到另一个用户身份。

32. sudo:以超级用户的身份执行命令。

33. date:显示或设置系统日期和时间。

35. df:显示文件系统的磁盘使用情况。

36. du:显示目录或文件的磁盘使用情况。

37. tar:创建备份文件或将备份文件释放到系统中。

38. gzip:使用GNU的zip压缩程序压缩文件。

39. gunzip:解压文件。

40. zip:创建一个zip文件。

41. uname:显示系统信息。

freebsd-syslog配置日志服务器

freebsd-syslog配置日志服务器

在比较大规模的网络应用或者对安全有一定要求的应用中,通常需要对系统的日志进行记录分类并审核,默认情况下,每个系统会在本地硬盘上记录自己的日志,这样虽然也能有日志记录,但是有很多缺点:首先是管理不便,当服务器数量比较多的时候,登陆每台服务器去管理分析日志会十分不便,其次是安全问题,一旦有入侵者登陆系统,他可以轻松的删除所有日志,系统安全分析人员不能得到任何入侵信息。

因此,在网络中安排一台专用的日志服务器来记录系统日志是一个比较理想的方案。

本文以FreeBSD下的syslog为例,介绍如何利用freebsd的syslogd来记录来自UNIX和windows的log信息。

一,记录UNIX类主机的log信息:首先需要对Freebsd的syslog进行配置,使它允许接收来自其他服务器的log信息。

在/etc/rc.conf中加入:syslogd_flags="-4 -a 0/0:*"说明:freebsd的syslogd参数设置放在/etc/rc.conf文件的syslogd_flags变量中Freebsd对syslogd的默认设置参数是syslogd_flags="-s",(可以在/etc/defaults/rc.conf中看到)默认的参数-s表示打开UDP端口监听,但是只监听本机的UDP端口,拒绝接收来自其他主机的log信息。

如果是两个ss,即-ss,表示不打开任何UDP端口,只在本机用/dev/log设备来记录log.修改后的参数说明:-4 只监听IPv4端口,如果你的网络是IPv6协议,可以换成-6-a 0/0:* 接受来自所有网段所有端口发送过来的log信息。

如果只希望syslogd接收来自某特定网段的log信息可以这样写:-a 192.168.1.0/24:*-a 192.168.1.0/24:514或者-a 192.168.1.0/24表示仅接收来自该网段514端口的log信息,这也是freebsd的syslogd进程默认设置,也就是说freebsd 在接收来自其他主机的log信息的时候会判断对方发送信息的端口,如果对方不是用514端口发送的信息,那么freebsd的syslogd会拒绝接收信息。

硬盘完全安装版FreeBSD安装panabit的基本配置手册

硬盘完全安装版FreeBSD安装panabit的基本配置手册

硬盘完全安装版FreeBSD安装panabit的基本配置手册看到这篇文档时朋友们需要确认三点:1.你是使用FreeBSD系统ISO安装版的,不是精简版、也不是LIVE CD转的硬盘版2.你已经下载了ssh等必要的工具3.你需要的只是panabit标准版,专业版请咨询专业售后工程师如果你确认好了上述问题,那么我们开始。

登陆root用户。

第一登陆没有密码,所以我们要执行passwd并回车。

在出现的提示符后面输入新的密码并确认一次。

如果想空密码的话就直接敲两次回车。

在讲述配置之前我要先说明几个常识性的问题:1.FreeBSD的配置文件修改后需要重启后才生效2.FreeBSD使用shutdown作为电源管理命令,关机格式是shutdown –p now ,重启格式是shutdown –r now。

reboot也能重启但貌似效果不好,建议还是用shutdown的参数。

3.手册后面使用的ee 是个FreeBSD里很好用的文本编辑命令,个人感觉比vi上手好些;esc+enter选a是保存所编辑文档的命令开关,如果你没有编辑打开的文档选a这步就不需要做了。

FreeBSD的本机命令行感觉很压抑,我们一般都是用ssh作为管理工具,首先我们在压抑的本机命令行下配置开启sshFreeBSD中打开sshee /etc/rc.confhostname="yes"sshd_enable="yes"ifconfig_管理网卡号="inet IP netmask 子网掩码"defaultrouter=网管IPesc+enter 选a在下面编辑的文档中需要把所编辑的选项前的#号去掉并将no修改为yes,不要添加那两行。

ee /etc/ssh/sshd_configPermitRootLogin yesPermitEmptyPasswords yesesc+enter 选a执行shutdown –r now重启然后是用ssh连接FreeBSD并上传panabit包到/tmp目录下,然后执行tar vxzf panabit包名.tar.gz(注意大小写)cd panabit包名.tar.gz./ipeinstall在所有提示路径的地方回车,在提示yes/no的地方打y在提示填写管理网卡的地方填写管理网卡名填写管理用的IP填写子网掩码填写网关地址在提示填写数据网卡的地方填上数据网卡名(做一个桥需要2块数据网卡,做监控需要一块数据网卡)安装好panabit后设置开机启动服务ee /etc/rc.local/usr/panabit/bin/ipectrl startesc+enter 选a都配置好了再次执行shutdown –r now重启登陆panabit的web界面的操作是:打开IE,填入https://ip回车初始用户名密码为:admin/panabit现在基本的panabit就可以登陆使用了,后续的使用问题可以参见论坛上的《V8.05管理配置手册》内容,我就不做赘述了。

FreeBSD11系列1:FreeBSD11.0 的安装

FreeBSD11系列1:FreeBSD11.0 的安装

FreeBSD11 安装(FreeBSD11.0 amd64)一、硬件最低配置安装 FreeBSD 所需的最低配置,随版本及硬件架构而有所不同。

● 1.FreeBSD/i386FreeBSD/i386 需要 486 或更快的处理器,最小 64 MB 的内存,以及至少 1.1 GB 的硬盘空间。

● 2.FreeBSD/amd64FreeBSD/amd64 支持两种处理器。

第一种是 AMD64 处理器,包括AMD Athlon™64、AMD Athlon™64-FX、AMD Opteron™ 以及更高级别的处理器。

第二种是采用了Intel®EM64 架构的处理器。

这类处理器包括Intel®Core™ 2 Duo、Quad 和 Extreme 家族,还包括Intel®Xeon™ 3000、 5000 和 7000 系列,以及Intel®Core™ i3、 i5 和 i7。

对于使用了 nVidia nForce3 Pro-150 的机器,必须在 BIOS 设置中禁用 IO APIC,如果没有这样的选项就只能转而禁用 ACPI。

因为 Pro-150 芯片组存在 bug,而目前还没有能够规避此问题的方法。

● 3.FreeBSD/powerpc Apple®Macintosh®支持所有内建 USB 的 New World Apple®Macintosh® 系统,同时也为配置多 CPU 的机器提供 SMP 支持。

注意 32 位的内核只能使用内存的前 2 GB,而 PowerMac G3 蓝白机上的FireWire® 也不被支持。

● 4.FreeBSD/sparc64FreeBSD/sparc64 需要独占一块磁盘。

目前还不支持与其他操作系统共享同一块磁盘。

二、获取安装镜像FreeBSD 9.0-RELEASE 及更高版本的镜像文件可以在ftp:///pub/FreeBSD/releases/arch/arch/ISO-IMAGES/version/FreeBSD -version-RELEASE-arch-memstick.img 中的ISO-IMAGES/目录中找到,其中,arch是指要安装的架构,而version则是指要安装的版本号。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

freebsd命令汇总 查询命令 find / -name adc.rar abc.rar为你要查询的文件名

---------------------------- find / \! -name “*.c” -print 列出所有不是以.c结尾的文件 Print out a list of all the files whose names do not end in .c.

find / -newer ttt -user wnj -print 列出所有比文件ttt新并且owner是wnj的文件

find / \! \( -newer ttt -user wnj \) -print 列出所有比文件ttt旧并且owner不是是wnj的文件

find / \( -newer ttt -or -user wnj \) -print 列出所有比文件ttt新或者owner是wnj的文件

find / -newerct „1 minute ago‟ -print 列出所有一分钟之前改变的文件

find / -type f -exec rm {} \; 删除所有文件,除非你疯了

find -L /usr/bin/ -type l -delete 删除/usr/bin目录下所有连接错误的连接符号 find / -name “[a-z].*” 还有几个参数会经常用到 -amin n 表示最后n分钟访问的文件 -atime n 表示最后n小时访问的文件 -cmin n 表示最后n分钟改变状态的文件 -ctime n 表示最后n小时改变状态的文件 -mmin n 表示最后n分钟里修改过的文件 -mtime n 表示最后24*n小时里修改过的文件 -empty 表示空白的文件,或空白的文件目录,或目录中没有子目录的文件夹 -nouser 属于作废用户的文件 -size +nc 长度大于n字节的文件 几个参数之间可以用-and,-or连接,某个参数取反可用!,可以用括号分隔条件 -exec command; 并执行命令 chown 命令

功能:更改某个文件或目录的属主和属组。这个命令也很常用。例如root用户把自己的一个文件拷贝给用户xu,为了让用户xu能够存取这个文件,root用户应该把这个文件的属主设为xu,否则,用户xu无法存取这个文件。

语法:chown [选项] 用户或组 文件 说明:chown将指定文件的拥有者改为指定的用户或组。用户可以是用户名或用户ID。组可以是组名或组ID。文件是以空格分开的要改变权限的文件列表,支持通配符。

------------------ 例子:

chown -R deserts:apache phpMyAdmin-2.8.1-rc1 pkg_info 查找已安装软件 可以看到mod_xml的模块

如果是port安装,我建议你去安装一下子port里面的pkg_tree 然后用这个就可以得到列表了。 FREEBSD中查看硬件信息

在FREEBSD中查看硬件信息和LINUX有所不同 cat /var/run/dmesg.boot可以查看各种硬件的信息 如: cat /var/run/dmesg.boot |grep CPU //可以用来查CPU的信息 cat /var/run/dmesg.boot |grep net //可以用来查网卡的信息 FreeBSD 常用命令以及VI 命令 ls 命令详解 ls 显示本目录下的文件及目录 ls -a 显示本目录下的所有文件及目录(包括隐藏目录和文件) ls -l 显示本目录下所有文件的属性 ls -l | grep ^d 只显示目录名 ls -l | grep ^f 只显示文件名 ls -G 以颜色显示目录名和文件名 ls -l | grep ^d 只显示子目录 ls -l | grep ^- 只显示文件 ls -l | grep ^d | wc –l 统计当能目录下的子目录数 ls -l | grep ^- | wc –l 统计当能目录下的文件数 (注:可以修改/root/.cshrc 增加 alias ls=ls -G 这样以后只要敲入ls 命令系统就会以颜色显 示目录和文件了,前提是你用的是FreeBSD 的默认shell。如果是其它的shell 请根据需要修 改对应的配置文件。) cd 命令详解 cd .. 返回上级目录 cd ../.. 进入上二级目录 cd - 返回上一次进入的目录 cd 进入用户自己的主目录 cd ~ 进入用户自己的主目录 cd /进入/你想要/进入的/目录 col 命令概解 man ls | col -b > outfile 要将 ls 的 man 手册转为文本文件 more 命令概解:用于查看文件中的内容 more files 查看文件的内容 mkdir 命令概解:用于创建目录 mkdir directory 在本目录下建立新目录 mkdir -p directory 创建多级目录 touch 命令概解:用于创建新文件 touch files 创建新文件 chmod 命令概解:chmod 命令用于改变文件的运行级别(读=4、写=2 执行=1) chmod 400 files 给某文件以只读权限 chmod 600 files 给某文件以只读、写权限 chmod 700 files 给某文件以只读、写、执行权限 chmod -R 400 directory 改变某目录下所有文件的运行权限为只读权限 chmod -R 600 directory 改变某目录下所有文件的运行权限为以只读、写权限 chmod -R 700 directory 改变某目录下所有文件的运行权限为只读、写、执行权限 以chmod 700 为例解释下数字及数字所在位置的意义 第一位数字代表用户自身对文件的运行权限 第二位数字代表用户本组对文件的运行权限 第三位数字代表其它组及用户对文件的运行权限 数字“7”代表文件具有读、写、执行的运行全部权限 7=读+写+执行 要想改变其他运行权限,请参考第一种做法。 chown 概解:改变文件及文件夹的用户所属 chown root:wheel files 改变文件的用户为root 用户组为wheel 组 chown -R root:wheel directory 改变目录的用户为root 用户组为wheel 组 rm -fr ./files rm -fr [!s]* 删除当前目录下所有不以s 开头的文件(含文件夹) cp -fr oldpath newpath mkdir newdir rmdir olddir mv file newpath 既可移动文件,又可用来重命名 uname -a, --all print all information, in the following order, except omit -p and -i if unknown: -s, --kernel-name print the kernel name -n, --nodename print the network node hostname -r, --kernel-release print the kernel release -v, --kernel-version print the kernel version mount mount /dev/hda5 /mnt/hda5 挂载硬盘 mount -t iso9660 /dev/cdrom /mnt/cdrom 挂载光盘 mount -t vfat /dev/sdb1 /mnt/usb 挂载U 盘 mount -o loop /mnt/hda5/fedora/FC-5-i386-disc1.iso /mnt/cdrom 挂载硬盘上的ISO 文件 umount /mnt/XXX eject 弹出光盘 eject -t 关闭光盘 rpm -ivh 安装 -Uvh 升级 -e 卸载 -q 查询 tar tar -jxvf tmp.tar.bz2 解压 tar -jcvf tmp.tar.bz2 /tmp/ 将/tmp/目录下的所有文件压缩成tmp.tar.bz2 文件 tar -zxvf tmp.tar.gz 解压 tar -zcvf tmp.tar.gz /tmp/ 将/tmp 目录下的所有文件压缩成tmp.tar.gz 文件 rar rar a tmp.rar /tmp/ 将/tmp 目录下的所有文件压缩成tmp.rar 文件 rar e tmp.rar 解压 远程登录linux 主机(from linux to linux) #ssh -l root IP #password: #... #exit 远程拷贝文件 #scp -fr [email=root@IP1:/home/programs]root@IP1:/home/programs[/email] [email=root@IP2:/home/]root@IP2:/home/[/email] ln ln -s /etc/init.d/smb /bin/ 符号链接 硬链接没有-s,少用。 shutdown -r now 重启(reboot) -h now 关机 chmod chmod u+x file 给属主用户加执行权限,u,g,o 三组,每组有rwx date date +%Y%m%d 输出20070330 locate locate smb* 在文件系统中查找以smb 开头的所有文件 find find ./ -name smb* 在当前目录下查找以smb 开头的所有文件 find ./ -name "[^s]*" -exec rm {} \; 查找当前目录下所有不以s 开头的文件并删除之

相关文档
最新文档