Linux / UNIX List User Dot-Files

How do I list only user dot-files from $HOME under UNIX and Linux operating systems? How do I ensure that user Dot-Files are not World-writable?

Use the ls command and shell GLOB characters to list only user Dot-Files, enter:

ADVERTISEMENTS

ls -ld /root/.[A-Za-z0-9]*
ls -ld $HOME/.[A-Za-z0-9]*

Sample Outputs:

-rw-r--r--  2 root  wheel  1455 Jun 12 18:47 /root/.cshrc
-rw-------  1 root  wheel  2650 Jul 28 06:26 /root/.history
-rw-r--r--  1 root  wheel   299 Jun 12 18:40 /root/.login
-rw-------  1 root  wheel    57 Jun 12 22:07 /root/.mysql_history
-rw-r--r--  2 root  wheel   260 Jun 12 18:40 /root/.profile

Run chmod command on misconfigured file to remove group- or world-writable permissions, enter:

# chmod go-w $HOME/.dot-file-name

Owners can run the same command to fix permission issue.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
7 comments… add one
  • Alexei Aug 26, 2009 @ 18:11

    Why not just this command?

    ls -ld \.* 

    And this?

    find ~ -name \.\* -exec chmod go-w {} \;
    • silvio Jan 30, 2014 @ 14:47

      ls -ld \.*
      lists ‘.’ and ‘..’ as well. The point here is avoid including these two.

      The find command works.

      • silvio Jan 30, 2014 @ 14:50

        ls -ld .[^.]*

        think it works

  • 🐧 nixCraft Aug 26, 2009 @ 18:21

    @ Alexei,

    Nice. I almost forgot about find, pipes and xargs :(

  • oll Aug 26, 2009 @ 19:28

    find ~ -name \.\* -exec chmod go-w {} \;
    Since I don’t know any dot file or dot directory that contains less than 2 letters, what I do is :
    chmod -R go-w ~/.??*
    But in a script, Alexei find’s syntax is smarter indeed.

  • Juan Giordana Sep 1, 2009 @ 9:36

    find $HOME -maxdepth 1 -iname '.*'
    find ~ -maxdepth 1 -iname '.*'

  • BOUAZIZ MOURAD Sep 28, 2009 @ 19:50

    HELLO;I WANT SOME HELPE ABOUT THE SOLARIS COMMANDS

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.