https://wiki.archlinux.org/api.php?action=feedcontributions&user=Luolimao&feedformat=atomArchWiki - User contributions [en]2024-03-29T08:24:57ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=MATLAB&diff=303246MATLAB2014-03-05T16:41:53Z<p>Luolimao: /* Create Desktop and Menu Shortcuts */ fixed grammar</p>
<hr />
<div>[[Category:Mathematics and science]]<br />
{{Related articles start}}<br />
{{Related|Octave}}<br />
{{Related|Sage-mathematics}}<br />
{{Related|Mathematica}}<br />
{{Related articles end}}<br />
From the [http://www.mathworks.com/products/matlab/ official website]:<br />
<br />
:''MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, you can analyze data, develop algorithms, and create models and applications. The language, tools, and built-in math functions enable you to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java.''<br />
<br />
== General installation ==<br />
{{Note|Versions earlier than MATLAB R2013a are not compatible with Java 7. When installing an older version, first install {{Pkg|libxp}} and {{AUR|jre6}}.}}<br />
<br />
MATLAB 2013a+ should install fine with the install script provided by MATLAB, without any additional packages.<br />
<br />
To install from an iso file:<br />
# modprobe loop<br />
# mount -o loop matlab.iso /mnt/<br />
# /mnt/install<br />
<br />
Additionally, install {{Pkg|xorg-fonts-100dpi}}, {{Pkg|xorg-fonts-75dpi}}, and {{Pkg|xorg-fonts-type1}} so fonts are displayed properly in figures.<br />
<br />
=== Create Desktop and Menu Shortcuts ===<br />
If you choose Custom in Installation Type, the symlink will be created automatically. Otherwise, you may need to manually create a symlink in {{ic|/usr/local/bin}} to make it easier to launch in terminal:<br />
<br />
# ln -s /{MATLAB}/bin/matlab /usr/local/bin<br />
<br />
To create a menu item, we need to get a icon first:<br />
<br />
# curl http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -o /usr/share/icons/matlab.png<br />
<br />
Then create a new .desktop file in {{ic|/usr/share/applications}} with following lines:<br />
<br />
{{hc|/usr/share/applications/matlab.desktop|<nowiki><br />
#!/usr/bin/env xdg-open<br />
[Desktop Entry]<br />
Type=Application<br />
Icon=/usr/share/icons/matlab.png<br />
Name=MATLAB<br />
Comment=Start MATLAB - The Language of Technical Computing<br />
Exec=env -u _JAVA_OPTIONS matlab -desktop -nosplash -r "cd('%d'); edit '%f'"<br />
Categories=Development;<br />
MimeType=text/x-matlab;<br />
</nowiki><br />
}}<br />
<br />
The {{ic|Exec}} command line is composed as follows:<br />
<br />
* {{ic|-desktop}} is a flag needed to run Matlab without a terminal.<br />
* {{ic|-nosplash}} is a flag preventing the splash screen from showing and taking up a temporary space in your task bar.<br />
* {{ic|env -u _JAVA_OPTIONS}} prevents the creation of a .java.log-file in your home directory by unsetting {{ic|$_JAVA_OPTIONS}}. Java prints all options set this way to stdout, and Matlab treats everything in stdout as an error worth logging.<br />
* {{ic|-r '...'}} executes Matlab code on startup:<br />
*# {{ic|cd('%d')}} This changes the working directory of Matlab to the opened file’s directory.<br />
*# {{ic|edit '%f'}} This spawns an editor tab for the file.<br />
<br />
You can also put this .desktop file in the ~/Desktop directory to create a shortcut.<br />
<br />
More details see [https://help.ubuntu.com/community/MATLAB MATLAB - Community Ubuntu Documents]<br />
<br />
=== Install supported compiler ===<br />
<br />
In order for Matlab to work with C code (needed for simulink) it is necessary to install a [http://www.mathworks.ch/support/compilers/?sec=glnxa64 supported compiler]. For example, if using Matlab r2013a, install {{AUR|gcc44}} from the AUR.<br />
<br />
Then edit {{ic|${MATLAB}/bin/mexopts.sh}} and replace all occurances of CC='gcc' with CC='gcc-4.4' and CXX='g++' with CXX='g++-4.4'. Afterwards run <br />
mex -setup<br />
in Matlab and select the {{ic|mexopts.sh}} file.<br />
<br />
== Troubleshooting ==<br />
As one installs Matlab, it might complain that it cannot find a package, for the most part just look at the package name and then install it with [[Pacman]], or in the case of x86_64 there are some libraries only in [[AUR]].<br />
<br />
=== Install-Time Library Errors ===<br />
* Make sure that the symlink {{ic|bin/glnx64/libstdc++.so.6}} is pointing to the correct version of {{ic|libstdc++.so.xx}} (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').<br />
<br />
* Make sure the device you're installing from is not mounted as {{ic|noexec}}<br />
<br />
* If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.<br />
<br />
=== License: invalid machine id ===<br />
The installer may complain about an invalid machine id, because it is looking for a network interface named eth0 to get a MAC address for activation, while new Arch Linux setups do not have a network interface called eth0 (systemd uses [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names]). <br />
<br />
The optimal solution is to create a dummy network interface named eth0 with the MAC address of the network device in use (wireless or wired) when you activated MATLAB. First, get that MAC address using {{ic|ip link}} Next, create the following file:<br />
<br />
{{hc|/etc/systemd/system/matlab.licensing.service|<nowiki><br />
[Unit]<br />
Description=Dummy network interface for MATLAB<br />
Requires=systemd-modules-load.service<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/sbin/ip link set dev dummy0 name eth0<br />
ExecStart=/sbin/ip link set dev eth0 address 00:00:00:00:00:00<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki><br />
}}<br />
<br />
Replace 00:00:00:00:00:00 with your MAC address.<br />
<br />
Then make the script run on boot:<br />
<br />
# systemctl enable matlab.licensing<br />
<br />
Finally, set the dummy module to load on boot by creating the following file:<br />
<br />
{{hc|/etc/modules-load.d/dummy.conf|<nowiki>dummy</nowiki><br />
}}<br />
<br />
==== Rename Interfaces ====<br />
<br />
A less preferable option is to [[rename network interfaces|change the name of the interface]].<br />
<br />
The machine id should now be different than 000000000000 and you should be able to install and activate MATLAB without problems.<br />
<br />
=== Resolving start warnings/errors ===<br />
<br />
* Even if all needed libraries are installed, Matlab when starting can still report some missing libraries. This is resolved by symbolic linking of needed libraries to directories that Matlab checks at start-up. For example, if Matlab triggers error/warning about missing {{ic|/lib64/libc.so.6}} library, this can be resolved by:<br />
<br />
# ln -s /lib/libc.so.6 /lib64<br />
<br />
* Matlab R2011b with an up-to-date Arch Linux (as of March 12, 2012) fails on startup with the familiar "Failure loading desktop class." A solution is to point Matlab to the system JVM (confirmed to work with the {{Pkg|jdk7-openjdk}} package):<br />
<br />
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre<br />
<br />
=== MATLAB crashes when displaying graphics ===<br />
<br />
To identify this error, start MATLAB with<br />
<br />
LIBGL_DEBUG=verbose matlab<br />
<br />
from the terminal and try to collect OpenGL information with {{ic|opengl info}} from the MATLAB command prompt. If it crashes again and there is an output line like <br />
<br />
libGL error: dlopen /usr/lib/xorg/modules/dri/swrast_dri.so failed <br />
(/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: <br />
version `GLIBCXX_3.4.15' not found (required by /usr/lib/xorg/modules/dri/swrast_dri.so))<br />
<br />
then the problem is that MATLAB uses its own GNU C++ library, which is an older version than the up-to-date version on your Archlinux system. Make MATLAB use the current C++ library for your system by<br />
<br />
cd /usr/local/MATLAB/R(your release)/sys/os/glnxa64<br />
sudo unlink libstdc++.so.6<br />
sudo ln -s /usr/lib/libstdc++.so.6<br />
<br />
=== Blank/grey UI when using DWM/Awesome ===<br />
<br />
wmname LG3D<br />
<br />
== OpenGL Acceleration ==<br />
<br />
Once Matlab is installed type the following in the interpreter:<br />
<br />
>> opengl info<br />
<br />
The output should be similar to the following:<br />
<br />
{{bc|<nowiki><br />
Version = 2.0 Mesa 7.8.2<br />
Vendor = Advanced Micro Devices, Inc.<br />
Renderer = Mesa DRI R600 (RV710 9552) 20090101 x86/MMX/SSE2 TCL DRI2<br />
MaxTextureSize = 4096<br />
Visual = 0xcb (TrueColor, depth 24, RGB mask 0xff0000 0xff00 0x00ff)<br />
Software = false<br />
# of Extensions = 107<br />
<br />
Driver Bug Workarounds:<br />
OpenGLBitmapZbufferBug = 0<br />
OpenGLWobbleTesselatorBug = 0<br />
OpenGLLineSmoothingBug = 0<br />
OpenGLClippedImageBug = 0<br />
OpenGLEraseModeBug = 0<br />
</nowiki>}}<br />
This will vary with card you are using, but the important part is "Software = false". If it's not "false" for you, then there is a problem with your hardware acceleration.<br />
<br />
=== NVIDIA ===<br />
<br />
With an [[Nvidia|NVIDIA]] card, the output should be similar to this:<br />
{{bc|<nowiki><br />
>> opengl info<br />
Version = 2.1.2 NVIDIA 177.82<br />
Vendor = NVIDIA Corporation<br />
Renderer = Quadro NVS 140M/PCI/SSE2<br />
MaxTextureSize = 8192<br />
Visual = 0x21 (TrueColor, depth 16, RGB mask 0xf800 0x07e0 0x001f)<br />
Software = false<br />
# of Extensions = 144<br />
<br />
Driver Bug Workarounds:<br />
OpenGLBitmapZbufferBug = 0<br />
OpenGLWobbleTesselatorBug = 0<br />
OpenGLLineSmoothingBug = 0<br />
OpenGLClippedImageBug = 1<br />
OpenGLEraseModeBug = 0<br />
</nowiki>}}<br />
<br />
With the NVIDIA card all it required to start working was to copy the {{ic|libGLU.so}} from the Matlab installed library {{ic|${MATLAB}/sys/opengl/lib/glnx86/libGLU.so}} to {{ic|/usr/lib directory}}. Note that in x86_64 this might be a different directory.<br />
<br />
{{Note|Although, not thoroughly tested, using {{Pkg|lib32-nvidia-utils}} seems to work as well.}}</div>Luolimaohttps://wiki.archlinux.org/index.php?title=MATLAB&diff=303245MATLAB2014-03-05T16:38:02Z<p>Luolimao: /* Install supported compiler */ fixed spelling, added clarification</p>
<hr />
<div>[[Category:Mathematics and science]]<br />
{{Related articles start}}<br />
{{Related|Octave}}<br />
{{Related|Sage-mathematics}}<br />
{{Related|Mathematica}}<br />
{{Related articles end}}<br />
From the [http://www.mathworks.com/products/matlab/ official website]:<br />
<br />
:''MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, you can analyze data, develop algorithms, and create models and applications. The language, tools, and built-in math functions enable you to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java.''<br />
<br />
== General installation ==<br />
{{Note|Versions earlier than MATLAB R2013a are not compatible with Java 7. When installing an older version, first install {{Pkg|libxp}} and {{AUR|jre6}}.}}<br />
<br />
MATLAB 2013a+ should install fine with the install script provided by MATLAB, without any additional packages.<br />
<br />
To install from an iso file:<br />
# modprobe loop<br />
# mount -o loop matlab.iso /mnt/<br />
# /mnt/install<br />
<br />
Additionally, install {{Pkg|xorg-fonts-100dpi}}, {{Pkg|xorg-fonts-75dpi}}, and {{Pkg|xorg-fonts-type1}} so fonts are displayed properly in figures.<br />
<br />
=== Create Desktop and Menu Shortcuts ===<br />
If you choose Custom in Installation Type, the symlink will be created automatically. Otherwise, you may need to manually create a symlink in {{ic|/usr/local/bin}} to make it easier to launch in terminal:<br />
<br />
# ln -s /{MATLAB}/bin/matlab /usr/local/bin<br />
<br />
To create a menu item, we need to get a icon first:<br />
<br />
# curl http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -o /usr/share/icons/matlab.png<br />
<br />
Then create a new .desktop file in {{ic|/usr/share/applications}} with following lines:<br />
<br />
{{hc|/usr/share/applications/matlab.desktop|<nowiki><br />
#!/usr/bin/env xdg-open<br />
[Desktop Entry]<br />
Type=Application<br />
Icon=/usr/share/icons/matlab.png<br />
Name=MATLAB<br />
Comment=Start MATLAB - The Language of Technical Computing<br />
Exec=env -u _JAVA_OPTIONS matlab -desktop -nosplash -r "cd('%d'); edit '%f'"<br />
Categories=Development;<br />
MimeType=text/x-matlab;<br />
</nowiki><br />
}}<br />
<br />
The {{ic|Exec}} command line is composed as follows:<br />
<br />
* {{ic|-desktop}} is a flag needed to run matlab without a terminal.<br />
* {{ic|-nosplash}} is a flag preventing the splash screen from showing and taking up a temporary space in your task bar.<br />
* {{ic|env -u _JAVA_OPTIONS}} prevents the creation of a .java.log-file in your home directory by unsetting {{ic|$_JAVA_OPTIONS}}. Java prints all options set this way to stdout, and matlab treats everything in stdout as error worth a log.<br />
* {{ic|-r '...'}} executes matlab code on startup:<br />
*# {{ic|cd('%d')}} This changes the working directory of matlab to the opened file’s directory.<br />
*# {{ic|edit '%f'}} This spawns an editor tab for the file.<br />
<br />
You can also put this .desktop file in the ~/Desktop directory to create a shortcut.<br />
<br />
More details see [https://help.ubuntu.com/community/MATLAB MATLAB - Community Ubuntu Documents]<br />
<br />
=== Install supported compiler ===<br />
<br />
In order for Matlab to work with C code (needed for simulink) it is necessary to install a [http://www.mathworks.ch/support/compilers/?sec=glnxa64 supported compiler]. For example, if using Matlab r2013a, install {{AUR|gcc44}} from the AUR.<br />
<br />
Then edit {{ic|${MATLAB}/bin/mexopts.sh}} and replace all occurances of CC='gcc' with CC='gcc-4.4' and CXX='g++' with CXX='g++-4.4'. Afterwards run <br />
mex -setup<br />
in Matlab and select the {{ic|mexopts.sh}} file.<br />
<br />
== Troubleshooting ==<br />
As one installs Matlab, it might complain that it cannot find a package, for the most part just look at the package name and then install it with [[Pacman]], or in the case of x86_64 there are some libraries only in [[AUR]].<br />
<br />
=== Install-Time Library Errors ===<br />
* Make sure that the symlink {{ic|bin/glnx64/libstdc++.so.6}} is pointing to the correct version of {{ic|libstdc++.so.xx}} (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').<br />
<br />
* Make sure the device you're installing from is not mounted as {{ic|noexec}}<br />
<br />
* If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.<br />
<br />
=== License: invalid machine id ===<br />
The installer may complain about an invalid machine id, because it is looking for a network interface named eth0 to get a MAC address for activation, while new Arch Linux setups do not have a network interface called eth0 (systemd uses [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names]). <br />
<br />
The optimal solution is to create a dummy network interface named eth0 with the MAC address of the network device in use (wireless or wired) when you activated MATLAB. First, get that MAC address using {{ic|ip link}} Next, create the following file:<br />
<br />
{{hc|/etc/systemd/system/matlab.licensing.service|<nowiki><br />
[Unit]<br />
Description=Dummy network interface for MATLAB<br />
Requires=systemd-modules-load.service<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/sbin/ip link set dev dummy0 name eth0<br />
ExecStart=/sbin/ip link set dev eth0 address 00:00:00:00:00:00<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki><br />
}}<br />
<br />
Replace 00:00:00:00:00:00 with your MAC address.<br />
<br />
Then make the script run on boot:<br />
<br />
# systemctl enable matlab.licensing<br />
<br />
Finally, set the dummy module to load on boot by creating the following file:<br />
<br />
{{hc|/etc/modules-load.d/dummy.conf|<nowiki>dummy</nowiki><br />
}}<br />
<br />
==== Rename Interfaces ====<br />
<br />
A less preferable option is to [[rename network interfaces|change the name of the interface]].<br />
<br />
The machine id should now be different than 000000000000 and you should be able to install and activate MATLAB without problems.<br />
<br />
=== Resolving start warnings/errors ===<br />
<br />
* Even if all needed libraries are installed, Matlab when starting can still report some missing libraries. This is resolved by symbolic linking of needed libraries to directories that Matlab checks at start-up. For example, if Matlab triggers error/warning about missing {{ic|/lib64/libc.so.6}} library, this can be resolved by:<br />
<br />
# ln -s /lib/libc.so.6 /lib64<br />
<br />
* Matlab R2011b with an up-to-date Arch Linux (as of March 12, 2012) fails on startup with the familiar "Failure loading desktop class." A solution is to point Matlab to the system JVM (confirmed to work with the {{Pkg|jdk7-openjdk}} package):<br />
<br />
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre<br />
<br />
=== MATLAB crashes when displaying graphics ===<br />
<br />
To identify this error, start MATLAB with<br />
<br />
LIBGL_DEBUG=verbose matlab<br />
<br />
from the terminal and try to collect OpenGL information with {{ic|opengl info}} from the MATLAB command prompt. If it crashes again and there is an output line like <br />
<br />
libGL error: dlopen /usr/lib/xorg/modules/dri/swrast_dri.so failed <br />
(/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: <br />
version `GLIBCXX_3.4.15' not found (required by /usr/lib/xorg/modules/dri/swrast_dri.so))<br />
<br />
then the problem is that MATLAB uses its own GNU C++ library, which is an older version than the up-to-date version on your Archlinux system. Make MATLAB use the current C++ library for your system by<br />
<br />
cd /usr/local/MATLAB/R(your release)/sys/os/glnxa64<br />
sudo unlink libstdc++.so.6<br />
sudo ln -s /usr/lib/libstdc++.so.6<br />
<br />
=== Blank/grey UI when using DWM/Awesome ===<br />
<br />
wmname LG3D<br />
<br />
== OpenGL Acceleration ==<br />
<br />
Once Matlab is installed type the following in the interpreter:<br />
<br />
>> opengl info<br />
<br />
The output should be similar to the following:<br />
<br />
{{bc|<nowiki><br />
Version = 2.0 Mesa 7.8.2<br />
Vendor = Advanced Micro Devices, Inc.<br />
Renderer = Mesa DRI R600 (RV710 9552) 20090101 x86/MMX/SSE2 TCL DRI2<br />
MaxTextureSize = 4096<br />
Visual = 0xcb (TrueColor, depth 24, RGB mask 0xff0000 0xff00 0x00ff)<br />
Software = false<br />
# of Extensions = 107<br />
<br />
Driver Bug Workarounds:<br />
OpenGLBitmapZbufferBug = 0<br />
OpenGLWobbleTesselatorBug = 0<br />
OpenGLLineSmoothingBug = 0<br />
OpenGLClippedImageBug = 0<br />
OpenGLEraseModeBug = 0<br />
</nowiki>}}<br />
This will vary with card you are using, but the important part is "Software = false". If it's not "false" for you, then there is a problem with your hardware acceleration.<br />
<br />
=== NVIDIA ===<br />
<br />
With an [[Nvidia|NVIDIA]] card, the output should be similar to this:<br />
{{bc|<nowiki><br />
>> opengl info<br />
Version = 2.1.2 NVIDIA 177.82<br />
Vendor = NVIDIA Corporation<br />
Renderer = Quadro NVS 140M/PCI/SSE2<br />
MaxTextureSize = 8192<br />
Visual = 0x21 (TrueColor, depth 16, RGB mask 0xf800 0x07e0 0x001f)<br />
Software = false<br />
# of Extensions = 144<br />
<br />
Driver Bug Workarounds:<br />
OpenGLBitmapZbufferBug = 0<br />
OpenGLWobbleTesselatorBug = 0<br />
OpenGLLineSmoothingBug = 0<br />
OpenGLClippedImageBug = 1<br />
OpenGLEraseModeBug = 0<br />
</nowiki>}}<br />
<br />
With the NVIDIA card all it required to start working was to copy the {{ic|libGLU.so}} from the Matlab installed library {{ic|${MATLAB}/sys/opengl/lib/glnx86/libGLU.so}} to {{ic|/usr/lib directory}}. Note that in x86_64 this might be a different directory.<br />
<br />
{{Note|Although, not thoroughly tested, using {{Pkg|lib32-nvidia-utils}} seems to work as well.}}</div>Luolimaohttps://wiki.archlinux.org/index.php?title=KDE_package_guidelines&diff=252314KDE package guidelines2013-03-29T22:54:32Z<p>Luolimao: /* Install prefix */ replaced backticks</p>
<hr />
<div>[[Category:Package development]]<br />
{{Package Guidelines}}<br />
<br />
The [[KDE]] packages on Arch Linux follow a certain schema.<br />
<br />
== Build dir ==<br />
A good way of building [[Wikipedia:CMake|CMake]] packages is to make a build directory outside the root of the project and run cmake from that dir. So, the build function in the [[PKGBUILD]] should start with the following lines:<br />
mkdir build<br />
cd build<br />
cmake ../${pkgname}-${pkgver}<br />
<br />
== Install prefix ==<br />
Every packages must set the {{Ic|CMAKE_INSTALL_PREFIX}} variable, but also we have to respect custom built versions of KDE, so please use:<br />
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)<br />
When a package is moved to [extra] or [community] that line must be changed to:<br />
-DCMAKE_INSTALL_PREFIX=/usr<br />
<br />
== Build type ==<br />
Please specify the build type; this makes it really simple to rebuild a package with debug symbols by just using a sed rule.<br />
-DCMAKE_BUILD_TYPE=Release<br />
<br />
== Force Qt4 ==<br />
On systems where both {{Pkg|qt4}} and {{Pkg|qt5-base}} are installed, `qmake` refers to the 5.x version, so force cmake to use Qt4 this way:<br />
-DQT_QMAKE_EXECUTABLE=qmake-qt4<br />
<br />
== Package naming ==<br />
<br />
=== KDE Config Module ===<br />
KDE Config Module packages should be named {{Ic|kcm-''module''}}.<br />
<br />
=== Plasmoids ===<br />
Plasmoids packages should be named {{Ic|kdeplasma-applets-''plasmoidname''}} so that they are recognizable as [[KDE]]-related packages; this also distinguishes them from the official packages.<br />
<br />
=== Runners ===<br />
Plasma runners packages should be named {{Ic|kdeplasma-runners-''runnername''}} so that they are recognizable as [[KDE]]-related packages; this also distinguishes them from the official packages.<br />
<br />
=== Service Menus ===<br />
Service menus packages should be named {{Ic|kde-servicemenus-''servicename''}} so that they are recognizable as [[KDE]]-related packages<br />
<br />
=== Themes ===<br />
Plasma themes packages should be named {{Ic|kdeplasma-themes-''themename''}} so that they are recognizable as [[KDE]]-related packages.<br />
<br />
== .install files ==<br />
For many [[KDE]] packages, all {{Ic|.install}} files look almost exactly the same.<br />
Some packages install icons in the hicolor icon theme; use the {{Ic|xdg-icon-resource}} utility provided by the {{Pkg|xdg-utils}} package, which is a dependency of the {{Pkg|qt4}} package. So use this line:<br />
xdg-icon-resource forceupdate --theme hicolor &> /dev/null<br />
<br />
Many packages install Freedesktop.org compatible {{Ic|.desktop}} files and register MimeType entries in them. Running {{Ic|update-desktop-database}} in {{Ic|post_install}} is recommended as that tool is provided by the {{Pkg|desktop-file-utils}} package which is a dependency of the {{Pkg|qt4}} package. So use this line:<br />
update-desktop-database -q</div>Luolimaohttps://wiki.archlinux.org/index.php?title=PKGBUILD&diff=227482PKGBUILD2012-10-07T20:17:43Z<p>Luolimao: /* options */ removed extra apostrophe</p>
<hr />
<div>[[Category:Package development]]<br />
[[cs:PKGBUILD]]<br />
[[el:PKGBUILD]]<br />
[[es:PKGBUILD]]<br />
[[fa:PKGBUILD]]<br />
[[fr:PKGBUILD]]<br />
[[it:PKGBUILD]]<br />
[[pl:PKGBUILD]]<br />
[[pt:PKGBUILD]]<br />
[[sr:PKGBUILD]]<br />
[[zh-CN:PKGBUILD]]<br />
[[zh-TW:PKGBUILD]]<br />
{{Article summary start}}<br />
{{Article summary text|This article provides an explanation of PKGBUILD variables used when [[Creating Packages|creating packages]]. A PKGBUILD is a script that describes how software is to be compiled and packaged. Writing installation functions and general packaging information is covered in [[Creating Packages]] and other [[:Category:Package development|package development]] articles}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Package management overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Arch Packaging Standards}}<br />
{{Article summary wiki|Creating Packages}}<br />
{{Article summary wiki|Custom local repository}}<br />
{{Article summary wiki|pacman Tips}}<br />
{{Article summary wiki|PKGBUILD Templates}}<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|PKGBUILD(5) Manual Page|https://www.archlinux.org/pacman/PKGBUILD.5.html}}<br />
{{Article summary end}}<br />
<br />
A '''PKGBUILD''' is an [[Arch Linux]] package build description file used when [[Creating Packages|creating packages]].<br />
<br />
Packages in Arch Linux are built using the [[makepkg]] utility and information stored in PKGBUILDs. When '''makepkg''' is run, it searches for a {{Ic|PKGBUILD}} in the current directory and follows the instructions therein to either compile or otherwise acquire the files to build a package file ({{ic|''pkgname''.pkg.tar.xz}}). The resulting package contains binary files and installation instructions, readily installed with [[pacman]].<br />
<br />
== Variables ==<br />
The following are variables that can be filled out in the PKGBUILD file.<br />
<br />
It is common practice to define the variables in the PKGBUILD in same order as given here. However, this is not mandatory, as long as correct [[Bash]] syntax is used.<br />
<br />
=== pkgname ===<br />
The name of the package. It should consist of ''alphanumeric and any of the following characters @ . _ + - (at symbol, dot, underscore, plus, hyphen)''. All letters should be ''lowercase'' and ''names are not allowed to start with hyphens''. For the sake of consistency, {{ic|pkgname}} should match the name of the source tarball of the software you are packaging. For instance, if the software is in {{ic|foobar-2.5.tar.gz}}, the {{ic|pkgname}} value should be {{Ic|foobar}}. The present working directory the PKGBUILD file is in should also match the {{ic|pkgname}}.<br />
<br />
=== pkgver ===<br />
The version of the package. The value should be the same as the version released by the author of the package. It can contain letters, numbers, periods and underscore but CANNOT contain a hyphen. If the author of the package uses a hyphen in their version numbering scheme, replace it with an underscore. For instance, if the version is ''0.99-10'', it should be changed to ''0.99_10''. If the {{ic|pkgver}} variable is used later in the PKGBUILD then the underscore can easily be substituted for a dash on usage e.g.:<br />
source=($pkgname-${pkgver//_/-}.tar.gz)<br />
<br />
=== pkgrel ===<br />
The release number of the package specific to Arch Linux. This value allows users to differentiate between consecutive builds of the same version of a package. When a new package version is first released, the '''release number starts at 1'''. As fixes and optimizations are made to the {{ic|PKGBUILD}} file, the package will be '''re-released''' and the '''release number''' will increment by 1. When a new version of the package comes out, the release number resets to 1.<br />
<br />
=== epoch ===<br />
An integer value, specific to Arch Linux, representing what 'lifetime' to compare version numbers against. This value allows overrides of the normal version comparison rules for packages that have inconsistent version numbering, require a downgrade, change numbering schemes, etc. By default, packages are assumed to have an epoch value of ''0''. Do not use this unless you know what you are doing.<br />
<br />
=== pkgdesc ===<br />
The description of the package. The description should be about 80 characters or less and should not include the package name in a self-referencing way. For instance, "Nedit is a text editor for X11" should be written as "A text editor for X11."<br />
<br />
{{Note|Do not follow this rule thoughtlessly when submitting packages to [[AUR]]. If package name differs from application name for some reason, inclusion of full name into description can be the only way to ensure that package can be found during search.}}<br />
<br />
=== arch ===<br />
An array of architectures that the {{ic|PKGBUILD}} file is known to build and work on. Currently, it should contain {{ic|i686}} and/or {{ic|x86_64}}, {{ic|1=arch=('i686' 'x86_64')}}. The value {{ic|any}} can also be used for architecture-independent packages.<br />
<br />
You can access the target architecture with the variable {{ic|$CARCH}} during a build, and even when defining variables. See also {{bug|16352}}. Example:<br />
<br />
depends=(foobar)<br />
if test "$CARCH" == x86_64; then<br />
depends+=(lib32-glibc)<br />
fi<br />
<br />
=== url ===<br />
The URL of the official site of the software being packaged.<br />
<br />
=== license ===<br />
The license under which the software is distributed. A {{pkg|licenses}} package has been created in {{ic|[core]}} that stores common licenses in {{ic|/usr/share/licenses/common}}, e.g. {{ic|/usr/share/licenses/common/GPL}}. If a package is licensed under one of these licenses, the value should be set to the directory name, e.g. {{ic|1=license=('GPL')}}. If the appropriate license is not included in the official {{Pkg|licenses}} package, several things must be done:<br />
<br />
# The license file(s) should be included in: {{ic|/usr/share/licenses/''pkgname''/}}, e.g. {{ic|/usr/share/licenses/foobar/LICENSE}}.<br />
# If the source tarball does NOT contain the license details and the license is only displayed elsewhere, e.g. a website, then you need to copy the license to a file and include it.<br />
# Add {{ic|custom}} to the {{ic|license}} array. Optionally, you can replace {{ic|custom}} with {{ic|custom:name of license}}. Once a license is used in two or more packages in an official repository (including {{ic|[community]}}), it becomes a part of the {{Pkg|licenses}} package.<br />
* The [[Wikipedia:BSD License|BSD]], [[Wikipedia:MIT License|MIT]], [[Wikipedia:ZLIB license|zlib/png]] and [[Wikipedia:Python License|Python]] licenses are special cases and could not be included in the {{pkg|licenses}} package. For the sake of the {{ic|license}} array, it is treated as a common license ({{ic|1=license=('BSD')}}, {{ic|1=license=('MIT')}}, {{ic|1=license=('ZLIB')}} and {{ic|1=license=('Python')}}) but technically each one is a custom license because each one has its own copyright line. Any packages licensed under these four should have its own unique license stored in {{ic|/usr/share/licenses/''pkgname''}}. Some packages may not be covered by a single license. In these cases, multiple entries may be made in the license array, e.g. {{ic|1=license=('GPL' 'custom:name of license')}}.<br />
* Additionally, the (L)GPL has many versions and permutations of those versions. For (L)GPL software, the convention is:<br />
** (L)GPL - (L)GPLv2 or any later version<br />
** (L)GPL2 - (L)GPL2 only<br />
** (L)GPL3 - (L)GPL3 or any later version<br />
* If after researching the issue no license can be determined, {{ic|PKGBUILD.proto}} suggests using {{ic|unknown}}. However, upstream should be contacted about the conditions under which the software is (and is not) available.<br />
<br />
{{Tip|Some software authors do not provide separate license file and describe distribution rules in section of common ReadMe.txt. This information can be extracted in separate file during {{Ic|build}} phase with something like this: {{Ic|sed -n '/'''This software'''/,/''' thereof.'''/p' ReadMe.txt > LICENSE}}.}}<br />
<br />
=== groups ===<br />
The group the package belongs in. For instance, when you install the {{Pkg|kdebase}} package, it installs all packages that belong in the {{Grp|kde}} group.<br />
<br />
=== depends ===<br />
An array of package names that must be installed before this software can be run. If a software requires a minimum version of a dependency, the {{ic|1=>=}} operator should be used to point this out, e.g. {{ic|1=depends=('foobar>=1.8.0')}}. You do not need to list packages that your software depends on if other packages your software depends on already have those packages listed in their dependency. For instance, {{pkg|gtk2}} depends on {{pkg|glib2}} and {{pkg|glibc}}. However, {{pkg|glibc}} does not need to be listed as a dependency for {{pkg|gtk2}} because it is a dependency for {{pkg|glib2}}.<br />
<br />
===makedepends===<br />
An array of package names that must be installed to build the software but unnecessary for using the software after installation. You can specify the minimum version dependency of the packages in the same format as the {{ic|depends}} array.<br />
<br />
{{Warning|The group {{Grp|base-devel}} is assumed already installed when building with makepkg . Members of "base-devel" '''should not''' be included in {{ic|makedepends}} arrays.}}<br />
<br />
=== checkdepends ===<br />
An array of packages this package depends on to run its test suite but are not needed at runtime. Packages in this list follow the same format as depends. These dependencies are only considered when the [[Creating Packages#The check() function|check()]] function is present and is to be run by makepkg.<br />
<br />
=== optdepends ===<br />
An array of package names that are not needed for the software to function but provides additional features. A short description of what each package provides should also be noted. An {{ic|optdepends}} may look like this:<br />
optdepends=('cups: printing support'<br />
'sane: scanners support'<br />
'libgphoto2: digital cameras support'<br />
'alsa-lib: sound support'<br />
'giflib: GIF images support'<br />
'libjpeg: JPEG images support'<br />
'libpng: PNG images support')<br />
<br />
=== provides ===<br />
An array of package names that this package provides the features of (or a virtual package such as {{Ic|cron}} or {{Ic|sh}}). Packages that provide the same things can be installed at the same time unless conflict with each other (see below). If you use this variable, you should add the version ({{ic|pkgver}} and perhaps the {{ic|pkgrel}}) that this package will provide if dependencies may be affected by it. For instance, if you are providing a modified ''qt'' package named ''qt-foobar'' version 3.3.8 which provides ''qt'' then the {{ic|provides}} array should look like {{ic|1=provides=('qt=3.3.8')}}. Putting {{ic|1=provides=('qt')}} will cause to fail those dependencies that require a specific version of ''qt''. Do not add {{ic|pkgname}} to your provides array, this is done automatically.<br />
<br />
=== conflicts ===<br />
An array of package names that may cause problems with this package if installed. Package with this name and all packages which {{Ic|provides}} virtual packages with this name will be removed. You can also specify the version properties of the conflicting packages in the same format as the {{ic|depends}} array.<br />
<br />
=== replaces ===<br />
An array of obsolete package names that are replaced by this package, e.g. {{ic|1=replaces=('ethereal')}} for the {{pkg|wireshark}} package. After syncing with {{ic|pacman -Sy}}, it will immediately replace an installed package upon encountering another package with the matching {{ic|replaces}} in the repositories. If you are providing an alternate version of an already existing package, use the {{ic|conflicts}} variable which is only evaluated when actually installing the conflicting package.<br />
<br />
=== backup ===<br />
An array of files that can contain user-made changes and should be preserved during upgrade or removal of a package, primarily intended for configuration files in {{ic|/etc}}.<br />
<br />
When updating, new version may be saved as {{ic|file.pacnew}} to avoid overwriting a file which already exists and was previously modified by the user. Similarly, when the package is removed, user-modified file will be preserved as {{ic|file.pacsave}} unless the package was removed with {{ic|pacman -Rn}} command. <br />
<br />
The file paths in this array should be relative paths (e.g. {{ic|etc/pacman.conf}}) not absolute paths (e.g. {{ic|/etc/pacman.conf}}). See also [[Pacnew and Pacsave Files]].<br />
<br />
=== options ===<br />
This array allows you to override some of the default behavior of {{ic|makepkg}}, defined in {{Ic|/etc/makepkg.conf}}. To set an option, include the option name in the array. To reverse the default behavior, place an '''{{ic|!}}''' at the front of the option. The following options may be placed in the array:<br />
<br />
* '''''strip''''' - Strips symbols from binaries and libraries. If you frequently use a debugger on programs or libraries, it may be helpful to disable this option.<br />
* '''''docs''''' - Save {{ic|/doc}} directories.<br />
* '''''libtool''''' - Leave ''libtool'' ({{ic|.la}}) files in packages.<br />
* '''''emptydirs''''' - Leave empty directories in packages.<br />
* '''''zipman''''' - Compress ''man'' and ''info'' pages with ''gzip''.<br />
* '''''purge''''' - Remove files specified by the {{ic|PURGE_TARGETS}} variable from the package.<br />
* '''''upx''''' - Compress binary executable files using UPX. Additional options can be passed to UPX by specifying the {{ic|UPXFLAGS}} variable.<br />
* '''''ccache''''' - Allow the use of {{ic|ccache}} during build. More useful in its negative form {{ic|!ccache}} with select packages that have problems building with {{ic|ccache}}.<br />
* '''''distcc''''' - Allow the use of {{ic|distcc}} during build. More useful in its negative form {{ic|!distcc}} with select packages that have problems building with {{ic|distcc}}.<br />
* '''''buildflags''''' - Allow the use of user-specific {{ic|buildflags}} (CFLAGS, CXXFLAGS, LDFLAGS) during build. More useful in its negative form {{ic|!buildflags}} with select packages that have problems building with custom {{ic|buildflags}}.<br />
* '''''makeflags''''' - Allow the use of user-specific {{ic|makeflags}} during build. More useful in its negative form {{ic|!makeflags}} with select packages that have problems building with custom {{ic|makeflags}}.<br />
<br />
=== install ===<br />
The name of the {{ic|.install}} script to be included in the package. pacman has the ability to store and execute a package-specific script when it installs, removes or upgrades a package. The script contains the following functions which run at different times:<br />
<br />
* '''''pre_install''''' - The script is run right before files are extracted. One argument is passed: new package version.<br />
* '''''post_install''''' - The script is run right after files are extracted. One argument is passed: new package version.<br />
* '''''pre_upgrade''''' - The script is run right before files are extracted. Two arguments are passed in the following order: new package version, old package version.<br />
* '''''post_upgrade''''' - The script is run after files are extracted. Two arguments are passed in the following order: new package version, old package version.<br />
* '''''pre_remove''''' - The script is run right before files are removed. One argument is passed: old package version.<br />
* '''''post_remove''''' - The script is run right after files are removed. One argument is passed: old package version.<br />
<br />
Each function is run chrooted inside the pacman install directory. See [https://bbs.archlinux.org/viewtopic.php?pid=913891 this thread].<br />
<br />
{{Tip|A prototype {{ic|.install}} is provided at {{ic|/usr/share/pacman/proto.install}}.}}<br />
<br />
=== changelog ===<br />
The name of the package changelog. To view changelogs for installed packages (that have this file):<br />
pacman -Qc ''pkgname''<br />
<br />
{{Tip|A prototype changelog file is provided at {{ic|/usr/share/pacman/ChangeLog.proto}}.}}<br />
<br />
=== source ===<br />
An array of files which are needed to build the package. It must contain the location of the software source, which in most cases is a full HTTP or FTP URL. The previously set variables {{ic|pkgname}} and {{ic|pkgver}} can be used effectively here (e.g. {{ic|<nowiki>source=(http://example.com/$pkgname-$pkgver.tar.gz)</nowiki>}})<br />
<br />
{{Note|If you need to supply files which are not downloadable on the fly, e.g. self-made patches, you simply put those into the same directory where your {{ic|PKGBUILD}} file is in and add the filename to this array. Any paths you add here are resolved relative to the directory where the {{ic|PKGBUILD}} lies. Before the actual build process is started, all of the files referenced in this array will be downloaded or checked for existence, and {{ic|makepkg}} will not proceed if any are missing.}}<br />
<br />
{{Tip|You can specify a different name for the downloaded file - if the downloaded file has a different name for some reason like the URL had a GET parameter - using the following syntax: {{Ic|''filename''::''fileuri''}}, for example {{Ic|$pkgname-$pkgver.zip::<nowiki>http://199.91.152.193/7pd0l2tpkidg/jg2e1cynwii/Warez_collection_16.4.exe</nowiki>}}}}<br />
<br />
=== noextract ===<br />
An array of files listed under the {{ic|source}} array which should not be extracted from their archive format by {{ic|makepkg}}. This most commonly applies to certain zip files which cannot be handled by {{ic|/usr/bin/bsdtar}} because {{Pkg|libarchive}} processes all files as streams rather than random access as {{Pkg|unzip}} does. In these situations {{ic|unzip}} should be added in the {{ic|makedepends}} array and the first line of the [[Creating Packages#The build() function|build()]] function should contain:<br />
<br />
cd "$srcdir/$pkgname-$pkgver"<br />
unzip [source].zip<br />
<br />
Note that while the {{ic|source}} array accepts URLs, {{ic|noextract}} is '''just''' the file name portion. So, for example, you would do something like this (simplified from [https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/grub2&id=f054e33a0b5cbdfe7d81e91a8c4c807a9bfaa124 grub2's PKGBUILD]):<br />
<br />
source=(<nowiki>"http://ftp.archlinux.org/other/grub2/grub2_extras_lua_r20.tar.xz"</nowiki>)<br />
noextract=("grub2_extras_lua_r20.tar.xz")<br />
<br />
To extract ''nothing'', you can do something fancy like this (taken from [https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/firefox-i18n&id=cb10a40aeda9b444285d1ae6959c344110b4c936 firefox-i18n]):<br />
<br />
noextract=(${source[@]##*/})<br />
<br />
{{Note|More conservative Bash substitution would include quotes, or possibly even a loop that calls {{ic|basename}}. If you have read this far, you should get the idea.}}<br />
<br />
=== md5sums ===<br />
An array of MD5 checksums of the files listed in the {{ic|source}} array. Once all files in the {{ic|source}} array are available, an MD5 hash of each file will be automatically generated and compared with the values of this array in the same order they appear in the {{ic|source}} array. While the order of the source files itself does not matter, it is important that it matches the order of this array since {{ic|makepkg}} cannot guess which checksum belongs to what source file. You can generate this array quickly and easily using the command {{ic|makepkg -g}} in the directory that contains the {{ic|PKGBUILD}} file. Note that the MD5 algorithm is known to have weaknesses, so you should consider using a stronger alternative.<br />
<br />
=== sha1sums ===<br />
An array of SHA-1 160-bit checksums. This is an alternative to {{ic|md5sums}} described above, but it is also known to have weaknesses, so you should consider using a stronger alternative. To enable use and generation of these checksums, be sure to set up the {{ic|INTEGRITY_CHECK}} option in {{ic|/etc/makepkg.conf}}. See {{ic|man makepkg.conf}}.<br />
<br />
=== sha256sums, sha384sums, sha512sums ===<br />
An array of SHA-2 checksums with digest sizes 256, 384 and 512 bits respectively. These are alternatives to {{ic|md5sums}} described above and are generally believed to be stronger. To enable use and generation of these checksums, be sure to set up the {{ic|INTEGRITY_CHECK}} option in {{ic|/etc/makepkg.conf}}. See {{ic|man makepkg.conf}}.<br />
<br />
== See also ==<br />
*[http://pastebin.com/MeXiLDV9 Example PKGBUILD file]<br />
*[http://seberm.pastebin.com/gP0tBqvs Example .install file]</div>Luolimaohttps://wiki.archlinux.org/index.php?title=Users_and_groups&diff=167221Users and groups2011-10-23T19:24:12Z<p>Luolimao: /* Groups */ clarification regarding "bin" group</p>
<hr />
<div>[[Category:Security (English)]]<br />
[[fr:Utilisateurs et Groupes]]<br />
{{i18n|Users and Groups}}<br />
<br />
{{Article summary start}}<br />
{{Article summary text|This article describes how to add, delete, and manage user and group accounts using essential system administration utilities. Whilst certain [[desktop environment]]s provide graphical user/group management tools, they are not discussed here.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Access control overview}}}}<br />
{{Article summary end}}<br />
<br />
Users and groups are used on GNU/Linux for [[Wikipedia:access control#Computer security|access control]] — that is, to control access to the system's files, directories, and peripherals. Linux offers relatively simple/coarse access control mechanisms by default. For more advanced options, see [[ACL]] and [[LDAP Authentication]].<br />
<br />
== Overview ==<br />
<br />
A ''user'' is anyone who uses a computer. In this case, we are describing the names which represent those users. It may be Mary or Bill, and they may use the names Dragonlady or Pirate in place of their real name. All that matters is that the computer has a name for each account it creates, and it is this name by which a person gains access to use the computer. Some system services also run using restricted or privileged user accounts.<br />
<br />
Managing users is done for the purpose of security by limiting access in certain specific ways.<br />
<br />
Any individual may have more than one account, as long as they use a different name for each account they create. Further, there are some reserved names which may not be used such as "root".<br />
<br />
Users may be grouped together into a "group," and users may choose to join an existing group to utilize the privileged access it grants.<br />
<br />
{{Note|The beginner should use these tools carefully and stay away from having anything to do with any other ''existing'' user account, other than their own.}}<br />
<br />
== Permissions and ownership ==<br />
<br />
From [http://ph7spot.com/musings/in-unix-everything-is-a-file In UNIX Everything is a File]:<br />
<br />
:''The UNIX operating system crystallizes a couple of unifying ideas and concepts that shaped its design, user interface, culture and evolution. One of the most important of these is probably the mantra: "everything is a file," widely regarded as one of the defining points of UNIX.''<br />
<br />
:''This key design principle consists of providing a unified paradigm for accessing a wide range of input/output resources: documents, directories, hard-drives, CD-ROMs, modems, keyboards, printers, monitors, terminals and even some inter-process and network communications. The trick is to provide a common abstraction for all of these resources, each of which the UNIX fathers called a "file." Since every "file" is exposed through the same API, you can use the same set of basic commands to read/write to a disk, keyboard, document or network device.''<br />
<br />
From [http://www.intel-research.net/Publications/Pittsburgh/101220041324_277.pdf Extending UNIX File Abstraction for General-Purpose Networking]:<br />
<br />
:''A fundamental and very powerful, consistent abstraction provided in UNIX and compatible operating systems is the file abstraction. Many OS services and device interfaces are implemented to provide a file or file system metaphor to applications. This enables new uses for, and greatly increases the power of, existing applications — simple tools designed with specific uses in mind can, with UNIX file abstractions, be used in novel ways. A simple tool, such as cat, designed to read one or more files and output the contents to standard output, can be used to read from I/O devices through special device files, typically found under the {{Filename|/dev}} directory. On many systems, audio recording and playback can be done simply with the commands, "{{Codeline|cat /dev/audio > myfile}}" and "{{Codeline|cat myfile > /dev/audio}}," respectively.''<br />
<br />
Every file on a GNU/Linux system is owned by a user and a group. In addition, there are three types of access permissions: read, write, and execute. Different access permissions can be applied to a file's owning user, owning group, and others (those without ownership). One can determine a file's owners and permissions by viewing the long listing format of the {{Codeline|ls}} command:<br />
<br />
{{Command|ls /boot/ -l|total 13740<br />
drwxr-xr-x 2 root root 4096 Jan 12 00:33 grub<br />
-rw-r--r-- 1 root root 8570335 Jan 12 00:33 kernel26-fallback.img<br />
-rw-r--r-- 1 root root 1821573 Jan 12 00:31 kernel26.img<br />
-rw-r--r-- 1 root root 1457315 Jan 8 08:19 System.map26<br />
-rw-r--r-- 1 root root 2209920 Jan 8 08:19 vmlinuz26}}<br />
<br />
The first column displays the file's permissions (for example, the file {{Filename|kernel26.img}} has permissions {{Codeline|-rw-r--r--}}). The third and fourth columns display the file's owning user and group, respectively. In this example, all files are owned by the ''root'' user and the ''root'' group.<br />
<br />
{{Command|ls /media/ -l|total 16<br />
drwxrwx--- 1 root vboxsf 16384 Jan 29 11:02 sf_Shared}}<br />
<br />
In this example, the {{Filename|sf_Shared}} directory is owned by the ''root'' user and the ''vboxsf'' group. It is also possible to determine a file's owners and permissions using the stat command:<br />
<br />
Owning user:<br />
<br />
{{Command|stat -c %U /media/sf_Shared/|root}}<br />
<br />
Owning group:<br />
<br />
{{Command|stat -c %G /media/sf_Shared/|vboxsf}}<br />
<br />
Access rights:<br />
<br />
{{Command|stat -c %A /media/sf_Shared/|drwxrwx---}}<br />
<br />
Access permissions are displayed in three groups of characters, representing the permissions of the owning user, owning group, and others, respectively. For example, the characters {{Codeline|-rw-r--r--}} indicate that the file's owner has read and write permission, but not execute ({{Codeline|rw-}}), whilst users belonging to the owning group and other users have only read permission ({{Codeline|r--}} and {{Codeline|r--}}). Meanwhile, the characters {{Codeline|drwxrwx---}} indicate that the file's owner and users belonging to the owning group all have read, write, and execute permissions ({{Codeline|rwx}} and {{Codeline|rwx}}), whilst other users are denied access ({{Codeline|---}}). The first character represents the file's type.<br />
<br />
List files owned by a user or group with the {{Codeline|find}} command:<br />
<br />
# find / -group [group]<br />
<br />
# find / -user [user]<br />
<br />
A file's owning user and group can be changed with the {{Codeline|chown}} (change owner) command. A file's access permissions can be changed with the {{Codeline|chmod}} (change mode) command.<br />
<br />
See [http://linux.die.net/man/1/chown man chown], [http://linux.die.net/man/1/chmod man chmod], and [http://www.tuxfiles.org/linuxhelp/filepermissions.html Linux file permissions] for additional detail.<br />
<br />
{{Expansion}}<br />
<br />
== User management ==<br />
<br />
Local user information is stored in the {{Filename|/etc/passwd}} file. To list all user accounts on the system:<br />
<br />
$ cat /etc/passwd<br />
<br />
There is one line per account, and each is of the format:<br />
<br />
account:password:UID:GID:GECOS:directory:shell<br />
<br />
where:<br />
*{{Codeline|account}} is the user name<br />
*{{Codeline|password}} is the user password<br />
*{{Codeline|UID}} is the numerical user ID<br />
*{{Codeline|GID}} is the numerical primary group ID for the user<br />
*{{Codeline|GECOS}} is an optional field used for informational purposes; usually it contains the full user name<br />
*{{Codeline|directory}} is the user's {{Codeline|$HOME}} directory<br />
*{{Codeline|shell}} is the user command interpreter (defaults to {{Filename|/bin/sh}})<br />
<br />
{{Note|1=Arch Linux uses ''shadowed'' passwords. The {{Filename|passwd}} file is world-readable, so storing passwords (hashed or otherwise) in this file would be insecure. Instead, the {{Codeline|password}} field will contain a placeholder character ({{Codeline|x}}) indicating that the hashed password is saved in the access-restricted file {{Filename|/etc/shadow}}.}}<br />
<br />
To list users currently logged on the system, the {{Codeline|who}} command can be used.<br />
<br />
To add a new user, use the {{Codeline|useradd}} command:<br />
<br />
# useradd -m -g [initial_group] -G [additional_groups] -s [login_shell] [username]<br />
<br />
* '''{{Codeline|-m}}''' creates the user home directory as {{Filename|/home/[username]}}; within his home directory, a non-root user can write files, delete them, install programs, and so on.<br />
* '''{{Codeline|-g}}''' defines the group name or number of the user's initial login group; the group name must exist; if a group number is provided, it must refer to an already existing group; if not specified, the behavior of useradd will depend on the USERGROUPS_ENAB variable contained in {{Filename|/etc/login.defs}}.<br />
* '''{{Codeline|-G}}''' introduces a list of supplementary groups which the user is also a member of; each group is separated from the next by a comma, with no intervening spaces; the default is for the user to belong only to the initial group.<br />
* '''{{Codeline|-s}}''' defines the path and filename of the user's default login shell; Arch Linux init scripts use Bash; after the boot process is complete, the default login shell is the one specified here; ensure the chosen shell package is installed if choosing something other than Bash.<br />
<br />
A typical desktop system example, adding a user named ''archie'' specifying bash as the login shell:<br />
# useradd -m -g users -G audio,lp,optical,storage,video,wheel,games,power,scanner -s /bin/bash archie<br />
<br />
For more advanced uses of useradd, type:<br />
<br />
$ man useradd<br />
<br />
To enter user information for the ''GECOS'' field (e.g. the full user name), type:<br />
<br />
# chfn [username]<br />
<br />
(this way {{Codeline|chfn}} runs in interactive mode).<br />
<br />
To specify the user's password, type:<br />
<br />
# passwd [username]<br />
<br />
An interactive tool is available for adding users:<br />
<br />
# adduser<br />
<br />
{{Codeline|adduser}} asks common questions about the user with sane defaults and constructs a {{Codeline|useradd}} command to run. It also changes ''finger'' information and sets the password, thus carrying out also the job of {{Codeline|chfn}} and {{Codeline|passwd}}.<br />
<br />
User accounts may be deleted with the {{Codeline|userdel}} command.<br />
<br />
# userdel -r [username]<br />
<br />
The {{Codeline|-r}} option specifies that the user's home directory and mail spool should also be deleted.<br />
<br />
== Group management ==<br />
<br />
{{Filename|/etc/group}} is the file that defines the groups on the system ({{Codeline|man group}} for details).<br />
<br />
Display group membership with the {{Codeline|groups}} command:<br />
<br />
$ groups [user]<br />
<br />
If {{Codeline|user}} is omitted, the current user's group names are displayed.<br />
<br />
The {{Codeline|id}} command provides additional detail, such as the user's UID and associated GIDs:<br />
<br />
$ id [user]<br />
<br />
To list all groups on the system:<br />
<br />
$ cat /etc/group<br />
<br />
Create new groups with the {{Codeline|groupadd}} command:<br />
<br />
# groupadd [group]<br />
<br />
Add users to a group with the {{Codeline|gpasswd}} command:<br />
<br />
# gpasswd -a [user] [group]<br />
<br />
To delete existing groups:<br />
<br />
# groupdel [group]<br />
<br />
To remove users from a group:<br />
<br />
# gpasswd -d [user] [group]<br />
<br />
If the user is currently logged in, he/she must log out and in again for the change to have effect.<br />
<br />
== Groups ==<br />
<br />
Workstation/desktop users often add their non-root user to the following groups to allow access to peripherals and other hardware and facilitate system administration:<br />
<br />
* audio<br />
* floppy<br />
* lp<br />
* network<br />
* optical<br />
* power<br />
* storage<br />
* video<br />
* wheel<br />
<br />
{| border="1" <br />
|+ A list of groups and their function (sorted alphabetically)<br />
! Group || Affected files || Purpose<br />
|-<br />
| adm || {{Filename|/var/log/*}} || Read access to log files.<br />
|-<br />
| audio || {{Filename|/dev/audio}}, {{Filename|/dev/snd/*}}, {{Filename|/dev/rtc0}} || Access to sound hardware.<br />
|-<br />
| avahi || ||<br />
|-<br />
| bin || {{Filename|/usr/bin/*}} || Read-only access to the binary files in /usr/bin/<br />
|-<br />
| camera || || Access to [[Digital Cameras]].<br />
|-<br />
| clamav || {{Filename|/var/lib/clamav/*}}, {{Filename|/var/log/clamav/*}} || Used by [[Clam AntiVirus]].<br />
|-<br />
| daemon || ||<br />
|-<br />
| dbus || {{Filename|/var/run/dbus/*}} ||<br />
|-<br />
| disk || {{Filename|/dev/sda[1-9]}}, {{Filename|/dev/sdb[1-9]}}, {{Filename|/dev/hda[1-9]}} || Access to block devices not affected by other groups such as optical, floppy, and storage.<br />
|-<br />
| floppy || {{Filename|/dev/fd[0-9]}} || Access to floppy drives.<br />
|-<br />
| ftp || {{Filename|/srv/ftp}} ||<br />
|-<br />
| games || {{Filename|/var/games}} || Access to some game software.<br />
|-<br />
| gdm || ||<br />
|-<br />
| hal || {{Filename|/var/run/hald}}, {{Filename|/var/cache/hald}} ||<br />
|-<br />
| http || ||<br />
|-<br />
| kmem || {{Filename|/dev/port}}, {{Filename|/dev/mem}}, {{Filename|/dev/kmem}} ||<br />
|-<br />
| locate || {{Filename|/usr/bin/locate}}, {{Filename|/var/lib/locate}}, {{Filename|/var/lib/mlocate}}, {{Filename|/var/lib/slocate}} || Right to use {{Codeline|updatedb}} command.<br />
|-<br />
| log || {{Filename|/var/log/*}} || Access to log files in {{Filename|/var/log}},<br />
|-<br />
| lp || {{Filename|/etc/cups}}, {{Filename|/var/log/cups}}, {{Filename|/var/cache/cups}}, {{Filename|/var/spool/cups}} || Access to printer hardware; enables the user to manage print jobs.<br />
|-<br />
| mem || || <br />
|-<br />
| mail || {{Filename|/usr/bin/mail}} ||<br />
|-<br />
| network || || Right to change network settings such as when using [[NetworkManager]]. <br />
|-<br />
| networkmanager || || Requirement for your user to connect wirelessly with [[NetworkManager]]. This group is not included with Arch by default so it must be added manually.<br />
|-<br />
| nobody || || Unprivileged group.<br />
|-<br />
| ntp || || <br />
|-<br />
| optical || {{Filename|/dev/sr[0-9]}}, {{Filename|/dev/sg[0-9]}} || Access to optical devices such as CD and DVD drives.<br />
|-<br />
| policykit || || <br />
|-<br />
| power || || Right to use [[Pm-utils]] (suspend, hibernate...) and power management controls.<br />
|-<br />
| rfkill || || <br />
|-<br />
| root || {{Filename|/*}} || Complete system administration and control (root, admin).<br />
|-<br />
| scanner || {{Filename|/var/lock/sane}} || Access to scanner hardware.<br />
|-<br />
| smmsp || || {{Codeline|sendmail}} group<br />
|-<br />
| storage || || Access to removable drives such as USB hard drives, flash/jump drives, MP3 players; enables the user to mount storage devices through [[HAL]] and [[D-Bus]].<br />
|-<br />
| stb-admin || || <br />
|-<br />
| sys || || Right to admin printers in [[CUPS]].<br />
|-<br />
| thinkpad || {{Filename|/dev/misc/nvram}} || Used by ThinkPad users for access to tools such as [[tpb]].<br />
|-<br />
| tty || {{Filename|/dev/tty}}, {{Filename|/dev/vcc}}, {{Filename|/dev/vc}}, {{Filename|/dev/ptmx}} || Eg. to acces /dev/ACMx<br />
|-<br />
| users || || Standard users group.<br />
|-<br />
| uucp || {{Filename|/dev/ttyS[0-9]}}, {{Filename|/dev/tts/[0-9]}} || Serial and USB devices such as modems, handhelds, RS-232/serial ports.<br />
|-<br />
| vboxusers || {{Filename|/dev/vboxdrv}} || Right to use [[VirtualBox]] software.<br />
|-<br />
| video || {{Filename|/dev/fb/0}}, {{Filename|/dev/misc/agpgart}} || Access to video capture devices, DRI/3D hardware acceleration ([[Xorg|X]] can be used ''without'' belonging to this group).<br />
|-<br />
| vmware || || Right to use [[VMware]] software.<br />
|-<br />
| wheel || || Right to use [[sudo]] (setup with {{Codeline|visudo}}), also affected by PAM.<br />
|}</div>Luolimao