Linux Cheat Sheet

I’m not a Linux guy. I don’t use Linux machines at work or at home as my personal computers.

But I do use Linux on my Network Streamers. Because that’s the only way to get great audio.

So I don’t use Linux machines often enough so as to memorize the commands that I need to know, yet I need to tinker with my Linux machines often enough so as to need to know said commands. The solution is pretty obvious.. I keep notes. But I’ve realized that it’s easier to access my notes when I keep them on this blog. So that is what this is about. Linux commands / ways of doing things, with a heavy bias towards audio streamers.

Also, keep in mind that my Linux distribution of choice is Arch Linux, and in particular Arch Linux Arm, since my favorite audio distribution (Archphile, no longer maintained) was based on that.

So some commands that I use either come with Arch Linux or are easy to install using Arch Linux’s package installer, pacman.

But before we start, a word on security. It is not a concern. Not at all. These systems are not meant to be internet-facing and store no useful files whatsoever, so the idea is to just use root for everything. None of that sudo rubbish here! 😛

I will update this post when I deem it necessary.

Installing applications and updating the system:

Arch Linux uses the Pacman package manager to install and update packages. Packages refer to binary files, either system components or applications.

Perform a full system update:

It is prudent once in a while to do a full system update. This method of updating will include system files (including kernel, bootloader, etc) as well as all of the installed packages.

pacman -Syu

Perform a mirror list update:

When you want to update pacman’s mirror list without doing a full system update.

pacman -Syy

Install a new package:

Some of the commands mentioned below require the relevant applications / packages to be installed, for example iftop or iptraf-ng. In order to do that you use the following command:

pacman -S name_of_package

System Tuning:

Change the name of the machine:

nano /etc/hostname

Error logs:

dmesg: boot messages generated by the kernel
nano /var/log/daemon.log: messages generated by daemons
nano /var/log/kernel.log: messages generated by the kernel

View Measured System Temperatures:

View temperatures: vcgencmd measure_temp

View voltages: vcgencmd measure_volts <id>

Where <id> is:

  • core for core voltage
  • sdram_c for sdram Core voltage
  • sdram_i for sdram I/O voltage
  • sdram_p for sdram PHY voltage

Manage services:

Enable a service: systemctl enable name_of_service

Disable a service: systemctl disable name_of_service

Start a service: systemctl start name_of_service

Stop and restart a service: systemctl restart name_of_service

Stop a service: systemctl stop name_of_service

Synchronize clock with NTP server:

ntpdate 1.ro.pool.ntp.org

Find ports bound to services:

lsof -Pnl +M -i4

Working with files:

Find a file:

find . -name filename.extension

wildcards are supported, so this is also valid:

find . -name *.extension

Find out how much space is taken by a directory:

du -sh /name_of_directory/

List directories by space taken:

du -sk * | sort -n

System Monitoring:

Monitor CPU:

htop

Monitor network:

iftop

iptraf-ng

See network link status:

ifconfig dev_name

or

networkctl status dev_name

See WiFi link quality:

iwconfig wlan0 | grep -i --color quality

or for a continuous display:

watch -n 1 cat /proc/net/wireless

See available WiFi APs:

nmcli dev wifi

List available USB devices, with IDs:

lsusb

Audio Subsystem Management:

See selected Sound card:

amixer

or

aplay -l

or

aplay -L

Sound card output mode:

See the format of the audio that the sound card / USB interface / whatever is outputting:

cat /proc/asound/card*/pcm0p/sub0/hw_params

Sound card supported output modes:

See the audio formats that the sound card / USB interface / whatever supports:

cat /proc/asound/card*/stream0

My personal favorite software: alsacap

This one is very practical, but is not easy to come by as it is not supported by pacman. I had to download the sources and compile it myself. No big deal..:

This is a sample output:

Mounting a USB drive:

First we need to make a mount point, in other words a folder under which we will see the contents of our USB drive:

mkdir /mnt/sd

Now, we need to find the USB file systems. Look for /dev/sd* disk:

ls /dev/sd*

Or to get better info, do fdisk -l

Finally, we need to actually mount the file system. So, assuming sda1 is the desired file system:

mount /dev/sda1 /mnt/sd

When we are done with the USB drive and need to disconnect it, we need to unmount it first. So do:

umount /mnt/sd