1. awk trick: Find duplicate User IDs (UIDs), from the /etc/passwd file.
This command will display only the duplicate UID, and nothing more:

- awk -F: ‘{print $3}’ /etc/passwd | sort | uniq -d
$ sudo useradd -u 999 mike7
$ sudo useradd -o -u 999 mike8
$ awk -F: '{print $3}' /etc/passwd | sort | uniq -d
999
2. dpkg trick: Find the package a command belongs to in Debian based Linux distros.
This will display package and the command’s binary:
- dpkg -S $(which command_here)
$ dpkg -S $(which ls)
coreutils: /bin/ls
$ dpkg -S $(which ifconfig)
net-tools: /sbin/ifconfig
$ dpkg -S $(which skill)
procps: /usr/bin/skill
3. Create a function to mkdir and cd to the directory:
To make the mkd function persistent, add this line in your ~/.bashrc file:
- mkd () { mkdir -p “$@” && cd “$@”; }
$ echo 'mkd () { mkdir -p "$@" && cd "$@"; }' >> ~/.bashrc
$ bash
$ mkd ~/1/2
$ pwd
/home/razvan/1/2
If you liked this article, read the other oneliner articles here.