Any Dell's service tag can be read from the system using the ever-so-handy dmidecode
tool.
The service tag is stored in the BIOS as a DMI/SMBIOS string, namely system-serial-number
. It can be read using the below command:
sudo dmidecode -s system-serial-number
This command will output the service tag as just itself, so it can be passed into a script or similar without much worry.
$ sudo dmidecode -s system-serial-number
1ABC123
If the Express Service Code is needed, that's easily retrievable using a similar command:
echo $((36#$(sudo dmidecode -s system-serial-number)))
This command will output the Express Service Code to the terminal, much in the same way the Service Tag is outputted. It works by converting the Base36 Service Tag to the Base10 Express Service Code using Bash's $((base#number))
notation.