August 3, 2022

Upgrade perl or python to newer versions on FreeBSD

The default versions languages like perl or python often get updated in FreeBSD ports as the language versions get updated upstream. The default version of the language mostly lags the upstream version because many other ports depend on it. If you run the default version you have a much better chance that other ports that use perl or python will work correctly. There is however nothing stopping you to run a a newer or older version if it is available in the ports. Read more

October 13, 2021

A Few Thoughts on Using FreeBSD Packages and Ports

FreeBSD s a complete operating system with a large collection of tools in the base system. FreeBSD also provides two ways for installing third-party software: the FreeBSD Ports Collection, for installing from source, and packages, for installing from pre-built binaries. I am not going to go into how to set up packages or ports, this is well documented at About FreeBSD ports and Installing Applications: Packages and Ports. When you start installing third party applications on FreeBSD you must decide if you will use ports or packages. Read more

May 27, 2021

Examples of using find in Unix like systems

find is one of the Unix utilities that is most often used. As the name says it is used to find something i.e. files. It has many options you can use to specify which files to look for. One of the simplest uses is find . -name somefile that will look for the file named somefile in the current directory. If you use find . -iname somefile a case insensitive search will be done for somefile. Read more

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

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 If you want the output to be more “human” readable use: du -ah |sort -rh|less This is useful if you want to cleanup your files, or when a disk is filling up.

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

© Arnold Greyling 2023