To create the standard directories such as Downloads, Documents, Desktop, etc., in a user’s home directory on Arch Linux, you can use the xdg-user-dirs-update command. This command creates the default directories specified by the XDG Base Directory specification.
Here are the steps to create these directories:
Install
xdg-user-dirspackage:First, you need to ensure that the
xdg-user-dirspackage is installed. This package contains the necessary tools to manage user directories according to the XDG Base Directory specification.sudo pacman -S xdg-user-dirsUpdate user directories:
Once the package is installed, you can run the
xdg-user-dirs-updatecommand to create the default directories in your home directory. This command will create directories such asDesktop,Documents,Downloads,Music,Pictures,Public,Templates, andVideos.xdg-user-dirs-updateThis command reads the configuration file at
~/.config/user-dirs.dirsand creates the specified directories.Verify the directories:
After running the command, you can check your home directory to see if the directories have been created.
ls ~/
Example
Here is an example step-by-step process:
Install
xdg-user-dirs:sudo pacman -S xdg-user-dirsUpdate user directories for the current user:
xdg-user-dirs-updateVerify the directories:
ls ~/
You should see the standard directories (Desktop, Documents, Downloads, Music, Pictures, Public, Templates, Videos) created in your home directory.
Automating for New Users
To ensure that new users have these directories created automatically, you can add the xdg-user-dirs-update command to their login scripts. For example, you can add it to the global profile script:
Edit the global profile script:
sudo nano /etc/profileAdd the following line at the end of the file:
xdg-user-dirs-update
This will ensure that the xdg-user-dirs-update command is run whenever a user logs in, creating the necessary directories if they do not already exist.