Warm tip: This article is reproduced from serverfault.com, please click

Unable to create directory in /usr/share

发布于 2020-12-01 04:03:18

I have heard its a conventional practice to store program dependent files in /usr/share/application-folder in linux. So I'm trying to do it in my c program in a function called load_interface_files() for example. I am not sure if this is a good practice or not, I've heard about creating configuration files for this kind of issues.

Anyways, here's the the code I wrote to make a directory in /usr/share.

if (mkdir("/usr/share/test", S_IRUSR) == -1)
     printf("no");

After running the code I don't see the error message nor the created directory. But when I try the same thing for my project directory path for example, it works fine. I am not sure but I think it has to do with root privilege in order to write to /usr/share but I don't know how to work around this.

Some debugging info:

$ ls -ld /usr/share
drwxr-xr-x 314 root root 12288 Dec  1 07:39 /usr/share
$ ls -l /usr/share
total 1448
drwxr-xr-x   5 root root  4096 Nov 10 19:35 accerciser
drwxr-xr-x   3 root root  4096 Nov 10 19:35 accountsservice
drwxr-xr-x   2 root root 36864 Nov 24 21:56 aclocal
drwxr-xr-x   3 root root  4096 Nov 10 20:15 aclocal-1.16
drwxr-xr-x   2 root root  4096 Oct 19 15:59 alacarte
drwxr-xr-x  10 root root  4096 Nov 10 20:00 alsa
drwxr-xr-x   3 root root  4096 Oct 19 15:59 alsa-card-profile
drwxr-xr-x   3 root root  4096 Oct 19 15:59 apparmor
drwxr-xr-x   2 root root  4096 Nov 23 06:01 appdata
drwxr-xr-x   4 root root  4096 Oct 19 16:00 app-info
drwxr-xr-x   3 root root 12288 Nov 24 21:56 applications
drwxr-xr-x   2 root root  4096 Nov 23 06:01 application-utility
drwxr-xr-x   3 root root  4096 Oct 19 16:00 apr-1
drwxr-xr-x   3 root root  4096 Nov 10 19:35 augeas
drwxr-xr-x   7 root root  4096 Nov 10 19:35 autoconf
drwxr-xr-x   4 root root  4096 Nov 10 20:15 automake-1.16
drwxr-xr-x   3 root root  4096 Oct 19 15:59 avahi
drwxr-xr-x   2 root root  4096 Oct 19 15:57 awk
drwxr-xr-x   9 root root  4096 Oct 19 16:00 backgrounds
drwxr-xr-x   4 root root  4096 Oct 19 15:59 bash-completion
drwxr-xr-x   5 root root  4096 Nov 10 20:15 bison
drwxr-xr-x   7 root root  4096 Nov 10 19:35 brltty
drwxr-xr-x   3 root root  4096 Oct 19 15:57 ca-certificates
drwxr-xr-x   4 root root  4096 Oct 19 16:00 caffeine
drwxr-xr-x   3 root root  4096 Oct 19 16:00 caja
drwxr-xr-x   3 root root  4096 Nov 23 06:01 clang
drwxr-xr-x   3 root root  4096 Oct 19 15:59 clutter-1.0
drwxr-xr-x   3 root root  4096 Nov 23 06:01 cmake
drwxr-xr-x   2 root root  4096 Oct 19 16:00 cmus
drwxr-xr-x   3 root root  4096 Oct 19 15:59 cogl
drwxr-xr-x   4 root root  4096 Oct 19 15:59 color
drwxr-xr-x   7 root root  4096 Oct 19 15:59 colord
drwxr-xr-x   2 root root  4096 Nov 10 20:00 color-schemes
drwxr-xr-x   3 root root  4096 Oct 19 15:57 common-lisp
drwxr-xr-x   2 root root  4096 Oct 19 15:59 cracklib
drwxr-xr-x   3 root root  4096 Nov 10 19:35 cryptui
drwxr-xr-x  16 root root  4096 Oct 19 16:00 cups
drwxr-xr-x   2 root root  4096 Nov 10 20:00 daxctl
drwxr-xr-x   8 root root  4096 Oct 19 15:59 dbus-1
drwxr-xr-x   3 root root  4096 Oct 19 15:59 dconf
drwxr-xr-x   3 root root  4096 Oct 19 15:59 defaults
drwxr-xr-x   2 root root  4096 Nov 10 20:01 desktop-directories
drwxr-xr-x   4 root root  4096 Nov 10 19:35 devhelp
drwxr-xr-x   2 root root  4096 Oct 19 15:57 dhclient
drwxr-xr-x   3 root root  4096 Oct 19 15:57 dhcpcd
drwxr-xr-x   2 root root  4096 Oct 19 15:59 dict
drwxr-xr-x   4 root root  4096 Oct 19 15:59 djvu
drwxr-xr-x   2 root root  4096 Oct 19 15:57 dnsmasq
drwxr-xr-x 237 root root 12288 Nov 24 21:56 doc
drwxr-xr-x   2 root root  4096 Nov 23 06:01 drirc.d
drwxr-xr-x   3 root root  4096 Oct 19 16:00 dynamic-wallpaper-editor
drwxr-xr-x   2 root root  4096 Oct 19 15:57 ecryptfs-utils
drwxr-xr-x   4 root root  4096 Nov 10 20:00 edk2-ovmf
drwxr-xr-x   3 root root  4096 Oct 19 15:57 emacs
drwxr-xr-x   2 root root  4096 Nov 23 06:01 enchant
drwxr-xr-x   4 root root  4096 Nov 10 19:35 eog
drwxr-xr-x   2 root root  4096 Nov 23 06:01 epiphany
drwxr-xr-x   2 root root  4096 Oct 19 15:57 et
drwxr-xr-x   3 root root  4096 Nov 10 20:00 evince
drwxr-xr-x  12 root root  4096 Nov 10 20:00 evolution
drwxr-xr-x   2 root root  4096 Nov 10 20:00 evolution-data-server
drwxr-xr-x   3 root root  4096 Oct 19 15:57 factory
drwxr-xr-x   3 root root  4096 Oct 19 15:59 ffmpeg
drwxr-xr-x   3 root root  4096 Oct 19 15:57 file
drwxr-xr-x   2 root root  4096 Nov 10 20:00 file-roller
drwxr-xr-x   5 root root  4096 Oct 19 16:00 fish
drwxr-xr-x   3 root root  4096 Nov 10 19:35 five-or-more
drwxr-xr-x   3 root root  4096 Oct 19 16:00 flatpak
drwxr-xr-x  12 root root  4096 Oct 19 16:00 fonts
drwxr-xr-x   5 root root  4096 Oct 19 16:00 foomatic
drwxr-xr-x   3 root root  4096 Nov 10 19:35 four-in-a-row
drwxr-xr-x  35 root root  4096 Nov 23 06:01 freeoffice
drwxr-xr-x   2 root root  4096 Nov 23 06:01 fzf
drwxr-xr-x   3 root root  4096 Nov 10 20:00 gcc-10.2.0
drwxr-xr-x   3 root root  4096 Oct 19 15:59 GConf
drwxr-xr-x   3 root root  4096 Oct 19 15:57 gdb
drwxr-xr-x   3 root root  4096 Nov 10 20:00 gdm
drwxr-xr-x   3 root root  4096 Oct 19 16:00 geary
drwxr-xr-x   4 root root  4096 Oct 19 15:59 gedit
drwxr-xr-x   3 root root  4096 Nov 10 19:35 gegl-0.4
drwxr-xr-x   6 root root  4096 Oct 19 15:57 gettext
drwxr-xr-x   3 root root  4096 Oct 19 15:57 gettext-0.21
drwxr-xr-x   3 root root  4096 Nov 10 20:00 ghostscript
drwxr-xr-x   2 root root 12288 Nov 23 06:01 gir-1.0
drwxr-xr-x  25 root root  4096 Nov 11 15:57 git
drwxr-xr-x   3 root root  4096 Oct 19 16:00 git-core
drwxr-xr-x   3 root root  4096 Oct 19 16:00 git-gui
drwxr-xr-x   3 root root  4096 Oct 19 16:00 gitk
drwxr-xr-x   3 root root  4096 Nov 11 15:57 gitweb
drwxr-xr-x   4 root root  4096 Oct 19 15:59 gjs-1.0
drwxr-xr-x   4 root root  4096 Oct 19 16:00 glade
drwxr-xr-x   7 root root  4096 Oct 19 15:57 glib-2.0
drwxr-xr-x   3 root root  4096 Oct 19 16:00 gls
drwxr-xr-x   3 root root  4096 Oct 19 15:58 glvnd
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-background-properties
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-bluetooth
drwxr-xr-x   3 root root  4096 Nov 10 19:35 gnome-books
drwxr-xr-x   7 root root  4096 Nov 10 19:35 gnome-boxes
drwxr-xr-x   5 root root  4096 Nov 10 19:35 gnome-builder
drwxr-xr-x   3 root root  4096 Nov 10 19:35 gnome-chess
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gnome-color-manager
drwxr-xr-x   5 root root  4096 Nov 10 20:16 gnome-control-center
drwxr-xr-x   4 root root  4096 Nov 10 19:35 gnome-documents
drwxr-xr-x   2 root root  4096 Nov 10 19:35 gnome-logs
drwxr-xr-x   4 root root  4096 Nov 10 19:35 gnome-mahjongg
drwxr-xr-x   4 root root  4096 Nov 10 20:00 gnome-maps
drwxr-xr-x   3 root root  4096 Nov 10 19:35 gnome-mines
drwxr-xr-x   4 root root  4096 Nov 10 19:35 gnome-nettool
drwxr-xr-x   5 root root  4096 Nov 10 20:00 gnome-nibbles
drwxr-xr-x   4 root root  4096 Nov 10 19:35 gnome-recipes
drwxr-xr-x   6 root root  4096 Nov 10 19:35 gnome-robots
drwxr-xr-x   3 root root  4096 Nov 10 20:00 gnome-session
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gnome-settings-daemon
drwxr-xr-x   7 root root  4096 Nov 23 06:01 gnome-shell
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-software
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-system-monitor
drwxr-xr-x   4 root root  4096 Nov 10 19:35 gnome-taquin
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-todo
drwxr-xr-x   2 root root  4096 Nov 10 20:00 gnome-tweaks
drwxr-xr-x   2 root root  4096 Nov 10 19:35 gnome-user-share
drwxr-xr-x   2 root root  4096 Nov 10 19:35 gnome-video-effects
drwxr-xr-x   4 root root  4096 Oct 19 16:00 gnome-vpn-properties
drwxr-xr-x   2 root root  4096 Oct 19 15:58 gnupg
drwxr-xr-x   2 root root  4096 Oct 19 15:57 graphite2
drwxr-xr-x   8 root root  4096 Nov 10 19:35 graphviz
drwxr-xr-x   3 root root  4096 Oct 19 16:00 grilo-plugins
drwxr-xr-x   4 root root  4096 Oct 19 15:58 groff
drwxr-xr-x   3 root root  4096 Nov 23 06:01 grub
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gst-plugins-base
drwxr-xr-x   6 root root  4096 Nov 10 20:01 gstreamer-1.0
drwxr-xr-x   6 root root  4096 Oct 19 15:59 gthumb
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gtk-2.0
drwxr-xr-x   3 root root  4096 Nov 10 20:00 gtk-3.0
drwxr-xr-x   5 root root  4096 Nov 10 19:35 gtk-doc
drwxr-xr-x   2 root root  4096 Oct 19 15:59 gtk-engines
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gtksourceview-2.0
drwxr-xr-x   3 root root  4096 Nov 10 20:00 gtksourceview-3.0
drwxr-xr-x   4 root root  4096 Oct 19 15:59 gtksourceview-4
drwxr-xr-x   4 root root  4096 Oct 19 16:00 gufw
drwxr-xr-x   3 root root  4096 Nov 10 20:15 guile
drwxr-xr-x   2 root root  4096 Oct 19 15:59 gupnp-av
drwxr-xr-x   3 root root  4096 Oct 19 15:59 gupnp-dlna-2.0
drwxr-xr-x   5 root root  4096 Oct 19 16:00 gutenprint
drwxr-xr-x   4 root root  4096 Oct 19 16:00 gvfs
drwxr-xr-x  69 root root  4096 Nov 10 19:35 help
drwxr-xr-x   5 root root  4096 Oct 19 16:00 highlight
drwxr-xr-x  12 root root  4096 Nov 23 06:01 hplip
drwxr-xr-x   4 root root  4096 Oct 19 16:00 httpd
drwxr-xr-x   2 root root  4096 Oct 19 15:57 hwdata
drwxr-xr-x   2 root root  4096 Oct 19 15:58 hwinfo
drwxr-xr-x   3 root root  4096 Oct 19 15:59 hwloc
drwxr-xr-x   4 root root  4096 Oct 19 15:57 i18n
drwxr-xr-x   4 root root  4096 Nov 10 19:35 iagno
drwxr-xr-x   2 root root  4096 Nov 10 20:00 iana-etc
drwxr-xr-x   6 root root  4096 Oct 19 16:00 ibus
drwxr-xr-x  20 root root  4096 Oct 19 16:00 icons
drwxr-xr-x   3 root root  4096 Oct 19 15:57 icu
drwxr-xr-x   2 root root  4096 Nov 23 06:01 ImageMagick-7
drwxr-xr-x   3 root root  4096 Oct 19 15:59 imlib2
drwxr-xr-x   2 root root 12288 Nov 23 06:01 info
drwxr-xr-x   5 root root  4096 Oct 19 16:00 installed-tests
drwxr-xr-x   2 root root  4096 Nov 23 06:01 iptables
drwxr-xr-x   3 root root  4096 Oct 19 15:59 iso-codes
drwxr-xr-x   3 root root  4096 Oct 19 15:59 jack-audio-connection-kit
drwxr-xr-x   2 root root  4096 Nov 10 20:00 java
drwxr-xr-x   6 root root  4096 Oct 19 15:57 kbd
drwxr-xr-x   2 root root  4096 Oct 19 15:57 keyutils
drwxr-xr-x   4 root root  4096 Oct 19 16:00 kf5
drwxr-xr-x  46 root root  4096 Oct 19 16:00 Kvantum
drwxr-xr-x   3 root root  4096 Oct 19 16:00 kvantummanager
drwxr-xr-x   3 root root  4096 Oct 19 16:00 kvantumpreview
drwxr-xr-x   3 root root  4096 Oct 19 15:59 ladspa
drwxr-xr-x   3 root root  4096 Nov 10 19:35 lensfun
drwxr-xr-x   4 root root  4096 Oct 19 15:57 libalpm
drwxr-xr-x   2 root root  4096 Oct 19 15:59 libcaca
drwxr-xr-x   2 root root  4096 Nov 23 06:01 libdrm
drwxr-xr-x   3 root root  4096 Oct 19 16:00 libftdi
drwxr-xr-x   4 root root  4096 Oct 19 15:59 libgnomekbd
drwxr-xr-x   2 root root  4096 Oct 19 15:57 libgpg-error
drwxr-xr-x   3 root root  4096 Nov 10 20:00 libgphoto2
drwxr-xr-x   3 root root  4096 Oct 19 16:00 libgphoto2_port
drwxr-xr-x   2 root root  4096 Oct 19 15:59 libgweather
drwxr-xr-x   2 root root  4096 Nov 23 06:01 libinput
drwxr-xr-x   3 root root  4096 Oct 19 16:00 liblouis
drwxr-xr-x   3 root root  4096 Oct 19 15:59 libquvi-scripts
drwxr-xr-x   2 root root  4096 Oct 19 15:59 libthai
drwxr-xr-x   5 root root  4096 Oct 19 15:59 libtool
drwxr-xr-x   5 root root  4096 Nov 10 20:00 libvirt
drwxr-xr-x   3 root root 16384 Nov 23 06:01 libwacom
drwxr-xr-x 453 root root 20480 Nov 24 21:56 licenses
drwxr-xr-x   2 root root  4096 Nov 10 20:00 lightsoff
drwxr-xr-x   3 root root  4096 Nov 10 19:02 lintian
drwxr-xr-x   5 root root  4096 Oct 19 16:00 lirc
drwxr-xr-x 302 root root 12288 Nov 10 20:00 locale
drwxr-xr-x   2 root root  4096 Nov 10 20:00 lollypop
drwxr-xr-x   4 root root  4096 Oct 19 16:00 lshw
drwxr-xr-x   4 root root  4096 Nov 10 19:35 lua
drwxr-xr-x   3 root root  4096 Nov 10 19:35 luajit-2.0.5
drwxr-xr-x  11 root root  4096 Nov 10 20:00 makepkg
drwxr-xr-x   2 root root  4096 Jul 31 02:06 makepkg-template
drwxr-xr-x  37 root root  4096 Nov 23 06:31 man
drwxr-xr-x   4 root root  4096 Oct 19 16:00 manjaro-hello
drwxr-xr-x   2 root root  4096 Oct 19 16:00 mate-background-properties
drwxr-xr-x   3 root root  4096 Oct 19 15:59 mate-panel
drwxr-xr-x   7 root root  4096 Nov 10 20:01 mc
drwxr-xr-x   2 root root  4096 Nov 10 20:16 menu
drwxr-xr-x   2 root root  4096 Oct 19 16:00 mesa-demos
drwxr-xr-x   2 root root 12288 Nov 23 06:31 metainfo
drwxr-xr-x  15 root root  4096 Nov 24 21:56 mime
drwxr-xr-x   2 root root  4096 Nov 24 21:56 mime-info
drwxr-xr-x   2 root root  4096 Sep 26 16:06 misc
drwxr-xr-x   2 root root  4096 Nov 10 20:00 mkinitcpio
drwxr-xr-x   2 root root  4096 Oct 19 15:59 mobile-broadband-provider-info
drwxr-xr-x   7 root root  4096 Oct 19 15:59 model
drwxr-xr-x   2 root root  4096 Nov 23 06:01 ModemManager
drwxr-xr-x   2 root root  4096 Oct 19 16:00 mousetweaks
drwxr-xr-x  12 root root  4096 Nov 24 21:56 mysql-workbench
drwxr-xr-x   3 root root  4096 Nov 10 20:01 nano
drwxr-xr-x   3 root root  4096 Nov 10 20:01 nautilus
drwxr-xr-x   3 root root  4096 Oct 19 16:00 nautilus-python
drwxr-xr-x   2 root root  4096 Nov 10 20:00 netpbm
drwxr-xr-x   3 root root  4096 Oct 19 16:00 ntp
drwxr-xr-x   4 root root  4096 Nov 23 06:01 openal
drwxr-xr-x   3 root root  4096 Nov 10 20:00 openmpi
drwxr-xr-x   4 root root  4096 Oct 19 16:00 openvpn
drwxr-xr-x   3 root root  4096 Nov 10 19:35 orca
drwxr-xr-x   3 root root  4096 Nov 10 20:00 org.gnome.Characters
drwxr-xr-x   3 root root  4096 Nov 10 20:00 org.gnome.Music
drwxr-xr-x   2 root root  4096 Nov 10 20:00 org.gnome.SoundRecorder
drwxr-xr-x   2 root root  4096 Nov 10 19:35 org.gnome.Weather
drwxr-xr-x   8 root root  4096 Nov 10 20:00 osinfo
drwxr-xr-x   2 root root  4096 Oct 19 15:58 os-prober
drwxr-xr-x   3 root root  4096 Oct 19 16:00 ostree
lrwxrwxrwx   1 root root    20 Oct 22 01:46 ovmf -> /usr/share/edk2-ovmf
lrwxrwxrwx   1 root root    20 Oct 22 01:46 OVMF -> /usr/share/edk2-ovmf
drwxr-xr-x   3 root root  4096 Oct 19 15:57 p11-kit
drwxr-xr-x   3 root root  4096 Nov 10 20:00 pacman
drwxr-xr-x   2 root root  4096 Oct 19 15:58 pacman-mirrors
drwxr-xr-x   2 root root  4096 Oct 19 15:59 pastebin.d
drwxr-xr-x   5 root root  4096 Oct 19 15:58 perl5
drwxr-xr-x   5 root root  4096 Oct 19 16:00 perl-image-exiftool
drwxr-xr-x   5 root root  4096 Nov 23 06:01 pixmaps
drwxr-xr-x   3 root root  4096 Nov 24 21:56 pkgconfig
drwxr-xr-x   2 root root  4096 Nov 10 20:00 pmix
drwxr-xr-x   3 root root  4096 Nov 10 20:01 polari
drwxr-xr-x   4 root root  4096 Oct 19 15:57 polkit-1
drwxr-xr-x   4 root root  4096 Oct 19 16:00 ppd
drwxr-xr-x   2 root root  4096 Nov 24 21:56 proj
drwxr-xr-x   2 root root  4096 Oct 19 16:00 pulseaudio-ctl
drwxr-xr-x   4 root root  4096 Oct 19 16:00 pygobject
drwxr-xr-x   5 root root  4096 Nov 23 06:01 qemu
drwxr-xr-x   2 root root  4096 Nov 23 06:01 qlogging-categories5
drwxr-xr-x   3 root root  4096 Oct 19 16:00 qt
drwxr-xr-x   3 root root  4096 Nov 10 19:35 quadrapassel
drwxr-xr-x   2 root root  4096 Oct 19 15:57 readline
drwxr-xr-x   5 root root  4096 Nov 10 20:01 rygel
drwxr-xr-x   6 root root  4096 Oct 19 16:00 sane
drwxr-xr-x   2 root root  4096 Nov 23 06:01 scan-build
drwxr-xr-x   3 root root  4096 Nov 23 06:01 scan-view
drwxr-xr-x   3 root root  4096 Oct 19 16:00 seahorse
drwxr-xr-x   3 root root  4096 Oct 19 15:59 shared-color-targets
drwxr-xr-x   3 root root  4096 Oct 19 16:00 sip
drwxr-xr-x   8 root root  4096 Oct 19 16:00 slsh
drwxr-xr-x   5 root root  4096 Nov 23 06:01 snmp
drwxr-xr-x   6 root root  4096 Nov 10 19:35 sounds
drwxr-xr-x   4 root root  4096 Nov 10 19:35 speech-dispatcher
drwxr-xr-x   2 root root  4096 Oct 19 15:57 ss
drwxr-xr-x   2 root root  4096 Oct 19 16:00 stoken
drwxr-xr-x   4 root root  4096 Nov 10 20:01 sushi
drwxr-xr-x   3 root root  4096 Nov 10 19:35 swell-foop
drwxr-xr-x   4 root root  4096 Oct 19 15:57 systemd
drwxr-xr-x   3 root root  4096 Oct 19 15:59 t1lib
drwxr-xr-x   2 root root  4096 Oct 19 15:57 tabset
drwxr-xr-x   2 root root  4096 Nov 10 20:01 tali
drwxr-xr-x   2 root root  4096 Nov 10 20:00 tc
drwxr-xr-x   4 root root  4096 Nov 10 19:35 telepathy
drwxr-xr-x  44 root root  4096 Oct 19 15:57 terminfo
drwxr-xr-x   7 root root  4096 Oct 19 15:58 texinfo
drwxr-xr-x  48 root root  4096 Nov 10 20:00 themes
drwxr-xr-x   2 root root  4096 Nov 23 06:01 thumbnailers
drwxr-xr-x   3 root root  4096 Oct 19 16:00 timeshift
drwxr-xr-x   3 root root  4096 Oct 19 15:58 tlp
drwxr-xr-x   2 root root  4096 Nov 10 20:01 totem
drwxr-xr-x   6 root root  4096 Nov 10 20:00 tracker
drwxr-xr-x   5 root root  4096 Nov 10 20:01 tracker3
drwxr-xr-x   5 root root  4096 Nov 10 20:00 tracker3-miners
drwxr-xr-x   3 root root  4096 Oct 19 16:00 tracker-miners
drwxr-xr-x   4 root root  4096 Oct 19 16:00 ufw
drwxr-xr-x   2 root root 20480 Oct 19 16:00 usb_modeswitch
drwxr-xr-x   3 root root  4096 Nov 10 20:00 vala
drwxr-xr-x   3 root root  4096 Nov 10 20:00 vala-0.50
drwxr-xr-x   3 root root  4096 Nov 10 20:00 valadoc-0.50
drwxr-xr-x   2 root root  4096 Nov 10 19:35 vde2
drwxr-xr-x   3 root root  4096 Oct 19 15:58 vim
drwxr-xr-x   3 root root  4096 Nov 10 19:02 vulkan
drwxr-xr-x   2 root root  4096 Oct 19 15:58 wayland
drwxr-xr-x   4 root root  4096 Oct 19 15:59 wayland-protocols
drwxr-xr-x   2 root root  4096 Nov 10 20:00 wayland-sessions
drwxr-xr-x   3 root root  4096 Nov 10 20:01 webapp-manager
drwxr-xr-x   3 root root  4096 Nov 23 06:01 webapps
drwxr-xr-x   6 root root  4096 Nov 23 06:31 wine
drwxr-xr-x   7 root root  4096 Oct 19 16:00 X11
drwxr-xr-x   2 root root  4096 Nov 10 20:00 xcb
drwxr-xr-x   3 root root  4096 Oct 19 15:59 xdg-desktop-portal
drwxr-xr-x   6 root root  4096 Nov 10 19:35 xml
drwxr-xr-x   2 root root  4096 Nov 10 20:00 xsessions
drwxr-xr-x   2 root root  4096 Nov 23 06:01 xtables
drwxr-xr-x   6 root root  4096 Oct 19 15:59 yelp
drwxr-xr-x   4 root root  4096 Oct 19 15:59 yelp-xsl
drwxr-xr-x   3 root root  4096 Nov 10 20:00 zenity
drwxr-xr-x  20 root root  4096 Nov 10 20:00 zoneinfo
drwxr-xr-x  18 root root  4096 Nov 10 20:00 zoneinfo-leaps
lrwxrwxrwx   1 root root     8 Oct 25 18:43 zoneinfo-posix -> zoneinfo
drwxr-xr-x   7 root root  4096 Oct 19 15:58 zsh
Questioner
Vahan
Viewed
0
Chris Dodd 2020-12-01 12:25:31

use ls -ld /usr/share to see what the permissions on the directory are (without -d, you get the contents and their permissions).

Use code like:

if (mkdir("/usr/share/test", S_IRWXU) != 0) {
    perror("mkdir");
    exit(1); }

to test the success/failure of the mkdir call and print the reason it failed (and exit) when it fails. Most likely, you'll see

mkdir: Permission denied

meaning you don't have write permission to the containing directory.