3

I noticed there's default tilde + alias exist:

[root@xiaobai ~]# cd ~[press Tab]
~abrt/                ~dbus/                ~lp/                  ~openvpn/             ~root/                ~systemd-network/
~adm/                 ~ftp/                 ~mail/                ~operator/            ~rpc/                 ~systemd-resolve/
~apache/              ~games/               ~mpd/                 ~pkg-build/           ~rpcuser/             ~systemd-timesync/
~avahi/               ~gdm/                 ~mysql/               ~polkitd/             ~rtkit/               ~tcpdump/
~avahi-autoipd        ~geoclue/             ~nfs4user/            ~postfix/             ~saslauth/            ~toranon/
~bin/                 ~gnome-initial-setup  ~nfsnobody/           ~postgres/            ~shutdown/            ~tss
~chrony/              ~halt/                ~nm-openconnect/      ~pulse                ~sshd/                ~unbound/
~colord/              ~iguanair/            ~nobody/              ~qemu/                ~sync/                ~usbmuxd/
~daemon/              ~ldap/                ~ntop/                ~radvd/               ~systemd-bus-proxy/   ~xiaobai/
[root@xiaobai ~]# cd ~halt
[root@xiaobai sbin]# pwd
/sbin
[root@xiaobai sbin]# l ~halt
14 lrwxrwxrwx. 1 root root 8 Nov 18  2014 /sbin -> usr/sbin
[root@xiaobai sbin]# cd ~nobody/
[root@xiaobai //]# pwd
//
[root@xiaobai //]# 
[root@xiaobai //]# realpath ~nobody/
/
[root@xiaobai //]# 

Where can i set this tilde+alias (i'm not talking about ~/.bashrc) ? Any reference/documentation about this combination ?

My platform is Fedora 21.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
林果皞
  • 4,946
  • 2
  • 29
  • 45

2 Answers2

5
  1. It's called tilde, not 'tidle'.
  2. They're not aliases, they're usernames on the system, when you press tab the shell is offering to auto-complete ~ to one of the user's home directories for you.
cas
  • 1
  • 7
  • 119
  • 185
4

Very easy,

Create dummy entries in the /etc/passwd file with directory names, as new user names, and append the right directory you want it to point to. That's it.

NOTE: Use different/unused UID, GID values

Ex:

tomsawyer:x:402733:5762:tomsawyer,,,:/home/tomsawyer:/bin/bash
Desktop:x:999:999::/home/tomsawyer/Desktop/:/bin/bash
Downloads:x:999:999::/home/tomsawyer/Downloads/:/bin/bash

Here "tomsawyer" is an example real username, where as "Downloads" and "Desktop" are dummy usernames, and will be pointing to respective directories upon accessing with "tilde notation"

Sun
  • 181
  • 4