Debian post installation – Initial setup

A couple of things that needs to be done on the host when you first setup it up.

In my case I use Debian most of the time these days.

Install vim

First thing I usually end up changing is the default text client to vim.

That means I need to install vim, default editor in Debian these days is Nano.

This is easily accomplished.

sudo apt install vim -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,494 kB of archives.
After this operation, 3,365 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 vim amd64 2:8.2.2434-3+deb11u1 [1,494 kB]
Fetched 1,494 kB in 0s (6,833 kB/s)
Selecting previously unselected package vim.
(Reading database ... 143297 files and directories currently installed.)
Preparing to unpack .../vim_2%3a8.2.2434-3+deb11u1_amd64.deb ...
Unpacking vim (2:8.2.2434-3+deb11u1) ...
Setting up vim (2:8.2.2434-3+deb11u1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode

Change editor

Then to change the default editor run this command: “update-alternatives –config editor

update-alternatives --config editor
There are 3 choices for the alternative editor (providing /usr/bin/editor).

Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/nano 40 manual mode
2 /usr/bin/vim.basic 30 manual mode
3 /usr/bin/vim.tiny 15 manual mode

Press <enter> to keep the current choice[*], or type selection number: 2

That takes care of editor choice if you don’t like nano.

Updates

Next I tend to run updates, which in Debian can turn into one command with three options: “sudo apt-get update && sudo apt upgrade -y && sudo apt autoremove -y

sudo apt-get update && sudo apt upgrade -y && sudo apt autoremove -y
[sudo] password for user: 
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Additional useful packages

There are a few other packages that may be useful to install on a Debian box in case you install on a basic non-gui box:

Openssh server and sudoers. This can easily be done by running this command:

apt-get install -y openssh-server sudo

These two will allow remote connection via ssh  and to enable sudo use so you don’t have to use the su function to switch user (to root).

Changing IP to static

Once this is done it is easy to check the current network config by running “cat /etc/network/interfaces”. If you make use of the allow-hotplug as I have below in static IP example you will need a restart to reflect the changes. If you do not want that you can use “auto” instead of “allow-hotplug” and this will then update the IP with just a restart of the networking service.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

ip a” will tell you the name of your nic (and configuration)

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d2:2c:e7 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.226.12/24 brd 192.168.226.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fed2:2ce7/64 scope link 
valid_lft forever preferred_lft forever

In this case it ends on 12 and is static because I already changed the file:

cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug ens33
iface ens33 inet static
address 192.168.226.12
netmask 255.255.255.0
gateway 192.168.226.2

dns-server 1.1.1.1

So above is how a static config looks. Once this is done I find that you need to reboot the host for it to take effect. In older times it may have been possible by doing a restart of the Networking.

systemctl restart Networking

 

Tips and Troubleshooting

A few troubleshooting things for Network cards

with “ip -s link” you can see the RX/TX errors of a nic:

ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped missed mcast 
3208 33 0 0 0 0 
TX: bytes packets errors dropped carrier collsns 
3208 33 0 0 0 0 
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:d2:2c:e7 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast 
2116980 4812 0 0 0 0 
TX: bytes packets errors dropped carrier collsns 
65347 721 0 0 0 0 
altname enp2s1

To get it more specific you can use “ip -s link show ens33” (note after show you can hit tab to see interface names), this shows you specifically for one nic only.

ip -s link show ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:d2:2c:e7 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast 
2347305 5373 0 2 0 0 
TX: bytes packets errors dropped carrier collsns 
81127 854 0 0 0 0 
altname enp2s1

To set a link down (needs root or sudo) you can use:”ip link set ens33 down” and “ip link set ens33 up” to enable it again.

ip link set mtu <number> dev <interface>” changes the MTU of an interface.

Here you can see I change the MTU to 9000:

ip -s link show ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:d2:2c:e7 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast 
2336103 5341 0 2 0 0 
TX: bytes packets errors dropped carrier collsns 
80907 852 0 0 0 0 
altname enp2s1