Monday, June 25, 2018

Linux CLI Networking

Working from a terminal interface sometimes is the only option. For example, when something has gone horribly wrong with an update and the system won't boot and you find yourself staring at a terminal while in recovery mode. In this example, the recovery mode does not have any networking enabled by default. Consequently, you may need the means to make that connection. Fortunately, this is fairly easy to perform.

First you'll need to know the name of the interface that you intend to enable. The following commend will give the name of all of the interfaces, so you'll need to pick the one that you want to enable.

ifconfig -a

For this example, we'll say that on the list is eth0. You'll then do something along the lines of the following command to turn it on.

ifconfig eth0 192.168.1.42 netmask 255.255.255.0 up

This will turn on the network interface, set the IP address, and the netmask. You may also need to identify your gateway, which the following command will do for you.

route add default gw 192.168.1.1 eth0

At this point, you should have a working network interface. A quick verification would be to ping a known IP address, like a Google server 8.8.8.8.

Monday, June 18, 2018

Linux CLI USB Mounting

To mount a USB device in the command line in Linux, you will need to know what the device is called.  There are many ways to fetch this information if you don't have it already.
lsusb
blkid
fdisk -l
udiskctl
I typically just use the top one, and the bottom one doesn't work on all systems. Once you have the name of the device, then you will need to decide where to mount it. One potential location is shown below.
/mnt
With the location, you can then mount your USB storage device.
mount /dev/sdj1 /mnt
When done, you can unmount it just as easily.
umount /mnt

That pretty much covers it.