FreeBSD includes several benchmarking suites in the ports collection. One of these suites is netperf, developed by HP. It allows measuring several network parameters using two programs: the server and the client.
First things first: let us install netperf.
% cd /usr/ports/benchmarks/netperf && make install clean
Once the software has been successfully compiled (it does not take long) we can bring the server up:
$ netserver
Starting netserver at port 12865
Starting netserver at hostname 0.0.0.0 port 12865 and family AF_UNSPEC
Notice that you can launch the server as a regular user. Now, we are ready to run our test:
$ netperf -t TCP_STREAM
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to localhost (127.0.0.1) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
65536 32768 32768 10.07 3842.31
This test is just a first step as it just shows how your network performs right now. After this, you should tune your system and run the test(s) again to compare the results. A list of tests can be found in the man page.
Enjoy!
PS: I’m not an HP employee. XD
$ smbclient -L //melchor -U username
Shows all the available shares at melchor. Asks for a password if needed. The -U option may be unnecessary if shares are browseable. The snippet is useful if you have forgotten a share name, for instance.
portsclean cleans garbage from the directory tree of the ports collection. It is a utility of the base system that should be run from time to time to keep one’s ports infrastructure as sane as possible.
portsclean wipes old package files, unneeded libraries and such. There are several interesting option flags described in the man page. This is how I run portsclean from time to time:
% portsclean -DD
The command above cleans all the distfiles that are not referenced by any installed package in the system. I usually run this after rebuilding the complete userland from a new ports fetch.
Enjoy!
Here you are: your first vim lesson!
First off, start vim with a named empty file:
$ vim myfile
Once you have done this, you get a screen similar to this one (I’ve removed some of the blank lines for the sake of clarity):
~
~
~
~
~
~
~
~
"myfile" [New File] 0,0-1 All
Vim opens a new empty file. At the bottom (if this option is set…) you see some information, like the name of the file, whether it is a new one created by vim, and the location of the cursor (line and character).
Now type “i” without the quotes and look at the bottom of the screen. The name of the file has disappeared and instead vim indicates it is in insert mode. From now on, what you type will be shown on the screen. Let us write something:
This is a test
~
~
~
-- INSERT -- 1,15 All
And now, write the contents and exit vim. In order to do that, we need to enter command line mode. Type “ESC” (the escape key) once or several times just to be sure until you hear “the bell”. And now type “:wq” (without the quotes) and press enter. This stands for “write” and “quit”. The “:” tells vim to go to command line mode and execute the commands (write, quit, set options, replace text, etc)
~
~
:wq
After writing the file, vim informs you how many lines and characteres were written:
~
~
"myfile" 1L, 15C written
Now, you can check the contents of the file:
$ cat myfile
This is a test
$
Though this has been a short session, the basics of a common vim session have been shown. Within the next chapters, I plan to show you more aspects of the vim editor. Till then,
Enjoy!
The pw command is used to add and modify system users and groups. The following is an easy way to add a new member to a group:
% pw groupmod operator -M n0str0m0
It adds n0str0m0 to the operators group.
Bye!
One of the most important aspects of *BSD systems is security. Knowing which installed packages have exploitable vulnerabilities is one of the admin’s tasks.
Here, the portaudit utility comes in handy. It is not part of the base system, so it must be installed first:
% cd /usr/ports/ports-mgmt/portaudit; make install clean
To run a simple check:
% portaudit
Affected package: XXX
Type of problem: XXX -- embedded GD library Use-After-Free vulnerability.
Reference: <http://www.FreeBSD.org/ports/portaudit/6XXxf31-4254-11de-bXX-0030843d3802.html>
Affected package: YYY-0.2.8.4_2
Type of problem: YYY -- integer overflow vulnerability.
Reference: <http://www.FreeBSD.org/ports/portaudit/48aab1d0-YYY-YYYYYYY-0030843d3802.html>
Affected package: ZZZ-1.10.2_2
Type of problem: ZZZ -- integer overflow.
Reference: <http://www.FreeBSD.org/ports/portaudit/4b17ZZZZZZbecb-001cc0377035.html>
I have omitted the details of the vulnerable packages of my own machine. I’m sure you understand :)
Enjoy!
:1,$d
This
vi command blanks out the file being edited.
Updated:
javisantana suggested another way to emptying a file. Type:
ggdG
in command mode.
systat is a base system utility that displays system statistics.
Information is updated automatically and shown in a pseudo-graphical way (based on ncurses).
$ systat
/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10
Load Average ||
/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100
root idle XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
n0str0m0 firefox-bi XXXXXXX
root gnome-pty- XXX
n0str0m0 gnome-term XXX
n0str0m0 gnome-term XXX
n0str0m0 bash XXX
n0str0m0 gnome-pane XX
root Xorg X
Sometimes you need split a file. For example, to send them attached to an email. For this, you can use the split command.
$ split -b 1m big_file file_part_
In the example, the big_file size is 10MB, the -b option split the file in 1MB pieces, and the file_part_ is the name given to the different parts.
$ ls file_part_*
file_part_aa file_part_ac file_part_ae file_part_ag file_part_ai
file_part_ab file_part_ad file_part_af file_part_ah file_part_aj
All the files are 1MB long.
For joining all the parts you can use the cat command.
cat file_part_* >> new_file
And new_file will be the same file as big_file.
man ascii
Prints octal, hexadecimal and decimal listings of the ASCII character set.