August 25, 2018

Collection of FreeBSD tips

This is a collection of FreeBSD tips that comes with the fortune programe included in the system. Many of these will work on any Unix system. Any user that is a member of the wheel group can use “su -” to simulate a root login. You can add a user to the wheel group by editing /etc/group. By pressing “Scroll Lock” you can use the arrow keys to scroll backwardthrough the console output. Read more

July 12, 2018

Outlook is rubbish!

Microsoft Outlook especially older versions is junk, but you probably knew that already. For some reason Outlook often sends out a message with incorrect syntax e.g. “[email protected]”. Mail servers like postfix will reject these messages but Outlook will not warn its user that there is a problem. Instead it will keep the message in the outbox and continously retry sending. If you are a postfix admin you can strip the apostrophes with a command filter. Read more

October 23, 2017

Change vim 8.0 .vimrc behaviour back to sanity

When a user doesn’t have a /.vimrc file in vim 8.0 (and possibly later) vim loads the default configuration file after the systemwide vimrc file created by the system administrator. This overides any settings the system administrator made. This is of course totally unexpected and frustrating especially when you upgrade from earlier versions. Some may even call it insane and it is definitely not expected behaviour. Anyway below is a way to prevent that from happening. Read more

August 26, 2017

UNIX - Use sed to edit files

sed is one of the commands that have been around forever on Unix systems. sed is a stream editor that you can use to perform basic text transformations on an input stream (a file or input from a pipeline). Want to use sed to edit a file in place? Well, to replace every ‘e’ with an ‘o’, in a file named ‘foo’, you can do: sed -i.bak s/e/o/g foo And you’ll get a backup of the original in a file named ‘foo. Read more

August 26, 2017

FREEBSD - Show open sockets

Most people know the netstat command to show you everything about the state of the network on your machine. You can also use sockstat to list all the open sockets on your system. Below are the sockstat options. sockstat -4 Show AF_INET (IPv4) sockets. sockstat -6 Show AF_INET6 (IPv6) sockets. sockstat -c Show connected sockets. sockstat -j jid Show only sockets belonging to the specified jail ID. sockstat -L Only show Internet sockets if the local and foreign addresses are not in the loopback network prefix 127. Read more

August 26, 2017

UNIX - Specify file and disk size output

If you want df, ls or du and other commands to display disk sizes in kilobytes instead of 512 byte blocks, set BLOCKSIZE in your environment to ‘K’. You can also use ‘M’ for Megabytes or ‘G’ for Gigabytes. If you want them to automatically select the best size then use df -h for example.

June 27, 2017

Do you need to find large files?

Use the following command to get a list of files sorted from large to small on your unix machine. du -ak |sort -rn |less This is useful if you want to cleanup your files, or when a disk is filling up.

January 1, 2017

Firewalls -block rather than scan

If you run a so called “New Generation Firewall” it will probably have an IDS/IPS system that scans all traffic. This eats a lot of CPU and slows down your firewall. There are lots of reliable lists (blocklists) of IP addresses out there that you can use to drop traffic from the bad guys before scanning, saving lots of CPU and increasing your throughput. Research the lists you plan to use, here is a good place to start your research: FireHOL IP Lists. Read more

December 12, 2016

CPU info in FreeBSD

There are various methods to get CPU information on FreeBSD sysctl -a | grep -i cpu | less sysctl -a | egrep -i 'hw.machine|hw.ncpu|hw.model' “sysctl” retrieves the kernel state. You can also use dmesg to get the information: dmesg | grep -i cpu grep -i cpu /var/run/dmesg.boot

November 3, 2016

Change your Unix login shell

If you don’t like the default shell on your system you can easily change it with the chsh command e.g. chsh -s /opt/local/bin/bash You will be asked to enter your password to make the change.

© Arnold Greyling 2020

Powered by Hugo & Kiss.