headphone jack not working with Dell XPS 13 bought in 2014

First I reinstalled everything from scratch nicely by following Ubuntu sound troubleshooting step 1: https://help.ubuntu.com/community/SoundTroubleshootingProcedure and ran:

sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install pavucontrol linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; killall pulseaudio; rm -r ~/.pulse*; ubuntu-support-status; sudo usermod -aG `cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'` `whoami`

then I managed to turn the volume on in the headphones with solution from Headphones is not working in 15.04 Dell XPS 13 answer:

after every boot and perhaps every suspend, I have to open the terminal and run alsamixer, which is a CLI app for volume adjustments. Use the arrow keys to select the "Headphone" column. Press "M" to unmute it, if it says "M" at the bottom. Press the up arrow to turn the volume all the way up in the headphone column. Then use the arrow keys to move to the "Speaker" column. You probably want to turn it all the way down unless you want sound to come out of the speakers and the headphone jack.

[UPDATE] I found a one command line to do that you can execute whenever I plug in my headphones:

amixer -c 1 set Headphone on;amixer -c 1 set Headphone 100%

so to get get to that, I had

to find the right card to use:

amixer controls

to use first card and see which controls are available on that card

amixer -c 1

to turn it on

amixer -c 1 set Headphone on

to set volume

amixer -c 1 set Headphone 100%

I went to pulse audio volume control, input devices, and UNMUTED the INTERNAL MIC and my headphones worked again.

2016 XPS 13 Ubuntu 18.04


After trying various different solutions on my Dell XPS 15 headphones still weren't detected, only got to use analog internal speakers (which weren't functioning before too).

I then tried the amixer commands from @Jeremy's answer, but nothing happened and right after I executed the following from a Launchpad's user suggestion:

rm -r ~/.config/pulse/
pulseaudio -k && sudo alsa force-reload
sudo reboot

I let the headphones connected to the jackport all the time while executing the commands and while laptop was rebooting.

After the reboot headphones were reproducing sound though they are still not listed in the output devices, only internal analog speakers are listed, but the sound actually comes through the headphones. I haven't plugged off my headphones nor restarted the system ever since.

Credit goes to user Camilo Prieto on this Launchpad bug comment.