https://wiki.archlinux.org/api.php?action=feedcontributions&user=TPXP&feedformat=atomArchWiki - User contributions [en]2024-03-28T22:12:16ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=User:TPXP&diff=788909User:TPXP2023-10-01T19:11:20Z<p>TPXP: </p>
<hr />
<div>Hi, I'm TPXP ! :-)<br />
<br />
I started to use ArchLinux on a Dell XPS 17 (L701X) - pretty old model, big and heavy. Then I got a [[Dell XPS 13 2-in-1 (9365)]] and kept on playing with ArchLinux on it. It was starting to get old, so I've switched to a Macbook Pro in 2023.<br />
<br />
I still run ArchLinux on two Raspberry Pi 4Bs, and regularily come back to the Arch Wiki whenever I need help with a Linux tool. I also do my best to contribute whenever I find something missing on the wiki (which is pretty rare - great job!).<br />
<br />
Languages:<br />
* '''French''': Native speaker<br />
* '''English''': Good level<br />
* '''Spanish''': Average level<br />
<br />
[https://github.com/TPXP Github] - [https://gitlab.com/TPXP/ Gitlab] - [https://aur.archlinux.org/packages/?SeB=m&K=TPXP AUR] - [https://tpxp.ddns.net Personal website (in French)]</div>TPXPhttps://wiki.archlinux.org/index.php?title=User:TPXP&diff=788908User:TPXP2023-10-01T19:10:50Z<p>TPXP: </p>
<hr />
<div>Hi, I'm TPXP ! :-)<br />
<br />
I started to use ArchLinux on a Dell XPS 17 (L701X) - pretty old model, big and heavy. Then I got a [[Dell XPS 13 2-in-1 (9365)]] and kept on playing with ArchLinux on it. It was starting to get old, I've switched to a Macbook Pro in 2023.<br />
<br />
I still run ArchLinux on two Raspberry Pi 4Bs, and regularily come back to the Arch Wiki whenever I need help with a Linux tool. I also do my best to contribute whenever I find something missing on the wiki (which is pretty rare - great job!).<br />
<br />
Languages:<br />
* '''French''': Native speaker<br />
* '''English''': Good level<br />
* '''Spanish''': Average level<br />
<br />
[https://github.com/TPXP Github] - [https://gitlab.com/TPXP/ Gitlab] - [https://aur.archlinux.org/packages/?SeB=m&K=TPXP AUR] - [https://tpxp.ddns.net Personal website (in French)]</div>TPXPhttps://wiki.archlinux.org/index.php?title=User:TPXP&diff=788907User:TPXP2023-10-01T19:10:35Z<p>TPXP: </p>
<hr />
<div>Hi, I'm TPXP ! :-)<br />
<br />
I started to used ArchLinux on a Dell XPS 17 (L701X) - pretty old model, big and heavy. Then I got a [[Dell XPS 13 2-in-1 (9365)]] and kept on playing with ArchLinux on it. It was starting to get old, I've switched to a Macbook Pro in 2023.<br />
<br />
I still run ArchLinux on two Raspberry Pi 4Bs, and regularily come back to the Arch Wiki whenever I need help with a Linux tool. I also do my best to contribute whenever I find something missing on the wiki (which is pretty rare - great job!).<br />
<br />
Languages:<br />
* '''French''': Native speaker<br />
* '''English''': Good level<br />
* '''Spanish''': Average level<br />
<br />
[https://github.com/TPXP Github] - [https://gitlab.com/TPXP/ Gitlab] - [https://aur.archlinux.org/packages/?SeB=m&K=TPXP AUR] - [https://tpxp.ddns.net Personal website (in French)]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Systemd/Timers&diff=788906Systemd/Timers2023-10-01T19:06:28Z<p>TPXP: Add timezone documentation to the calendar example and a note about WakeSystem</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:System administration]]<br />
[[de:Systemd/Timers]]<br />
[[es:Systemd (Español)/Timers]]<br />
[[fr:Systemd (Français)/Timers]]<br />
[[ja:Systemd/タイマー]]<br />
[[pt:Systemd (Português)/Timers]]<br />
[[ru:Systemd (Русский)/Timers]]<br />
[[zh-hans:Systemd/Timers]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|systemd/User}}<br />
{{Related|systemd FAQ}}<br />
{{Related|cron}}<br />
{{Related articles end}}<br />
<br />
Timers are [[systemd]] unit files whose name ends in ''.timer'' that control ''.service'' files or events. Timers can be used as an alternative to [[cron]] (read [[#As a cron replacement]]). Timers have built-in support for calendar time events, monotonic time events, and can be run asynchronously.<br />
<br />
== Timer units ==<br />
<br />
Timers are ''systemd'' unit files with a suffix of ''.timer''. Timers are like other [[systemd#Writing unit files|unit configuration files]] and are loaded from the same paths but include a {{ic|[Timer]}} section which defines when and how the timer activates. Timers are defined as one of two types:<br />
<br />
* '''Realtime timers''' (a.k.a. wallclock timers) activate on a calendar event, the same way that cronjobs do. The option {{ic|OnCalendar{{=}}}} is used to define them.<br />
* '''Monotonic timers''' activate after a time span relative to a varying starting point. They stop if the computer is temporarily suspended or shut down. There are number of different monotonic timers but all have the form: {{ic|On''Type''Sec{{=}}}}. Common monotonic timers include {{ic|OnBootSec}} and {{ic|OnUnitActiveSec}}.<br />
<br />
For a full explanation of timer options, see the {{man|5|systemd.timer}}. The argument syntax for calendar events and time spans is defined in {{man|7|systemd.time}}.<br />
<br />
{{Note|''systemd'' offers the target {{ic|timers.target}} which sets up all timers that should be active after boot (see {{man|7|systemd.special}} for details). To use it, add {{ic|WantedBy{{=}}timers.target}} to the {{ic|[Install]}} section of your timer and [[enable]] the timer unit.}}<br />
<br />
== Service units ==<br />
<br />
For each ''.timer'' file, a matching ''.service'' file exists (e.g. {{ic|foo.timer}} and {{ic|foo.service}}). The ''.timer'' file activates and controls the ''.service'' file. The ''.service'' does not require an {{ic|[Install]}} section as it is the ''timer'' units that are enabled. If necessary, it is possible to control a differently-named unit using the {{ic|Unit{{=}}}} option in the timer's {{ic|[Timer]}} section.<br />
<br />
== Management ==<br />
<br />
To use a ''timer'' unit [[enable]] and [[start]] it like any other unit (remember to add the ''.timer'' suffix). To view all started timers, run:<br />
<br />
{{hc|$ systemctl list-timers|<br />
NEXT LEFT LAST PASSED UNIT ACTIVATES<br />
Thu 2014-07-10 19:37:03 CEST 11h left Wed 2014-07-09 19:37:03 CEST 12h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service<br />
Fri 2014-07-11 00:00:00 CEST 15h left Thu 2014-07-10 00:00:13 CEST 8h ago logrotate.timer logrotate.service<br />
}}<br />
<br />
{{Note|<br />
* To list all timers (including inactive), use {{ic|systemctl list-timers --all}}.<br />
* The status of a service started by a timer will likely be inactive unless it is currently being triggered.<br />
* If a timer gets out of sync, it may help to delete its {{ic|stamp-*}} file in {{ic|/var/lib/systemd/timers}} (or {{ic|~/.local/share/systemd/}} in case of user timers). These are zero length files which mark the last time each timer was run. If deleted, they will be reconstructed on the next start of their timer.}}<br />
<br />
== Examples ==<br />
<br />
A service unit file can be scheduled with a timer out-of-the-box. The following examples schedule {{ic|foo.service}} to be run with a corresponding timer called {{ic|foo.timer}}.<br />
<br />
=== Monotonic timer ===<br />
<br />
A timer which will start 15 minutes after boot and again every week while the system is running.<br />
<br />
{{hc|/etc/systemd/system/foo.timer|<nowiki><br />
[Unit]<br />
Description=Run foo weekly and on boot<br />
<br />
[Timer]<br />
OnBootSec=15min<br />
OnUnitActiveSec=1w<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
=== Realtime timer ===<br />
<br />
A timer which starts once a week (at 12:00am on Monday). When activated, it triggers the service immediately if it missed the last start time (option {{ic|Persistent{{=}}true}}), for example due to the system being powered off:<br />
<br />
{{hc|/etc/systemd/system/foo.timer|2=<br />
[Unit]<br />
Description=Run foo weekly<br />
<br />
[Timer]<br />
OnCalendar=weekly<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
}}<br />
<br />
When more specific dates and times are required, {{ic|OnCalendar}} events uses the following format:<br />
<br />
DayOfWeek Year-Month-Day Hour:Minute:Second<br />
<br />
An asterisk may be used to specify any value and commas may be used to list possible values. Two values separated by {{ic|..}} indicate a contiguous range.<br />
<br />
In the below example the service is run the first four days of each month at 12:00 PM, but ''only'' if that day is a Monday or a Tuesday.<br />
<br />
OnCalendar=Mon,Tue *-*-01..04 12:00:00<br />
<br />
To run a service on the first Saturday of every month, use:<br />
<br />
OnCalendar=Sat *-*-1..7 18:00:00<br />
<br />
When using the {{ic|DayOfWeek}} part, at least one weekday has to be specified. If you want something to run every day at 4am, use:<br />
<br />
OnCalendar=*-*-* 4:00:00<br />
<br />
To run a service at different times, {{ic|OnCalendar}} may be specified more than once. In the example below, the service runs at 22:30 on weekdays and at 20:00 on weekends.<br />
<br />
OnCalendar=Mon..Fri 22:30<br />
OnCalendar=Sat,Sun 20:00<br />
<br />
You can also specify a timezone at the end of the directive (use <code>timedatectl list-timezones</code> to list accepted values)<br />
<br />
OnCalendar=*-*-* 02:00:00 Europe/Paris<br />
<br />
More information is available in {{man|7|systemd.time}}.<br />
<br />
{{Tip|<br />
* {{ic|OnCalendar}} time specifications can be tested in order to verify their validity and to calculate the next time the condition would elapse when used on a timer unit file with the {{ic|calendar}} option of the ''systemd-analyze'' utility. For example, one can use {{ic|systemd-analyze calendar weekly}} or {{ic|systemd-analyze calendar "Mon,Tue *-*-01..04 12:00:00"}}. Add {{ic|--iterations{{=}}N}}</code> to ask for more iterations to be printed.<br />
* The {{ic|faketime}} command is especially useful to test various scenarios with the above command; it comes with the {{Pkg|libfaketime}} package.<br />
* Special event expressions like {{ic|daily}} and {{ic|weekly}} refer to ''specific start times'' and thus any timers sharing such calendar events will start simultaneously. Timers sharing start events can cause poor system performance if the timers' services compete for system resources. The {{ic|RandomizedDelaySec}} option in the {{ic|[Timer]}} section avoids this problem by randomly staggering the start time of each timer. See {{man|5|systemd.timer}}.<br />
* Add the option {{ic|AccuracySec{{=}}1us}} to the {{ic|[Timer]}} section, to avoid the inaccuracy of the ''1m'' default value of {{ic|AccuracySec}}. Also see {{man|5|systemd.timer}}.<br />
* Some options ({{ic|WakeSystem}}) may require specific system capabilities and prevent a timer from starting, resulting in the following error messages: "Failed to enter waiting state: Operation not supported" and "Failed with result 'resources'.".<br />
}}<br />
<br />
== Transient timer units ==<br />
<br />
One can use {{ic|systemd-run}} to create transient ''.timer'' units. That is, one can set a command to run at a specified time without having a service file. For example the following command touches a file after 30 seconds:<br />
<br />
# systemd-run --on-active=30 /bin/touch /tmp/foo<br />
<br />
One can also specify a pre-existing service file that does not have a timer file. For example, the following starts the systemd unit named {{ic|''someunit''.service}} after 12.5 hours have elapsed:<br />
<br />
# systemd-run --on-active="12h 30m" --unit ''someunit''.service<br />
<br />
See {{man|1|systemd-run}} for more information and examples.<br />
<br />
== As a cron replacement ==<br />
<br />
Although [[cron]] is arguably the most well-known job scheduler, ''systemd'' timers can be an alternative.<br />
<br />
=== Benefits ===<br />
<br />
The main benefits of using timers come from each job having its own ''systemd'' service. Some of these benefits are:<br />
<br />
* Jobs can be easily started independently of their timers. This simplifies debugging.<br />
* Each job can be configured to run in a specific environment (see {{man|5|systemd.exec}}).<br />
* Jobs can be attached to [[cgroups]].<br />
* Jobs can be set up to depend on other ''systemd'' units.<br />
* Jobs are logged in the ''systemd'' journal for easy debugging.<br />
<br />
=== Caveats ===<br />
<br />
Some things that are easy to do with cron are difficult to do with timer units alone:<br />
<br />
* Creation: to set up a timed job with ''systemd'' you need to create two files and run {{ic|systemctl}} commands, compared to adding a single line to a crontab.<br />
* Emails: there is no built-in equivalent to cron's {{ic|MAILTO}} for sending emails on job failure. See the next section for an example of setting up a similar functionality using {{ic|OnFailure{{=}}}}.<br />
<br />
Also note that [[systemd/User|user]] timer units will only run during an active user login session by default. However, [[Systemd/User#Automatic start-up of systemd user instances|lingering]] can enable services to run at boot even when the user has no active login session.<br />
<br />
=== MAILTO ===<br />
<br />
{{Merge|systemd#Notifying about failed services|Same topic, different solution.}}<br />
<br />
You can set up systemd to send an e-mail when a unit fails. Cron sends mail to {{ic|MAILTO}} if the job outputs to stdout or stderr, but many jobs are setup to only output on error. First you need two files: an executable for sending the mail and a ''.service'' for starting the executable. For this example, the executable is just a shell script using {{ic|sendmail}}, which is in packages that provide {{ic|smtp-forwarder}}.<br />
<br />
{{hc|/usr/local/bin/systemd-email|<nowiki><br />
#!/bin/sh<br />
<br />
/usr/bin/sendmail -t <<ERRMAIL<br />
To: $1<br />
From: systemd <root@$HOSTNAME><br />
Subject: $2<br />
Content-Transfer-Encoding: 8bit<br />
Content-Type: text/plain; charset=UTF-8<br />
<br />
$(systemctl status --full "$2")<br />
ERRMAIL<br />
</nowiki>}}<br />
<br />
Whatever executable you use, it should probably take at least two arguments as this shell script does: the address to send to and the unit file to get the status of. The ''.service'' we create will pass these arguments:<br />
<br />
{{hc|/etc/systemd/system/status_email_''user''@.service|2=<br />
[Unit]<br />
Description=status email for %i to ''user''<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/local/bin/systemd-email ''address'' %i<br />
User=nobody<br />
Group=systemd-journal<br />
}}<br />
<br />
Where {{ic|''user''}} is the user being emailed and {{ic|''address''}} is that user's email address. Although the recipient is hard-coded, the unit file to report on is passed as an instance parameter, so this one service can send email for many other units. At this point you can [[start]] {{ic|status_email_''user''@dbus.service}} to verify that you can receive the emails.<br />
<br />
Then simply [[edit]] the service you want emails for and add {{ic|OnFailure{{=}}status_email_''user''@%n.service}} to the {{ic|[Unit]}} section. {{ic|%n}} passes the unit's name to the template.<br />
<br />
{{Note|<br />
* If you set up sSMTP security according to [[sSMTP#Security]] the user {{ic|nobody}} will not have access to {{ic|/etc/ssmtp/ssmtp.conf}}, and the {{ic|systemctl start status_email_''user''@dbus.service}} command will fail. One solution is to use {{ic|root}} as the User in the {{ic|status_email_''user''@.service}} unit.<br />
* If you try to use {{ic|mail -s somelogs ''address''}} in your email script, {{ic|mail}} will fork and systemd will kill the mail process when it sees your script exit. Make the mail non-forking by doing {{ic|mail -Ssendwait -s somelogs ''address''}}.<br />
}}<br />
<br />
{{Tip|Newer versions of systemd recommend using {{ic|1=DynamicUser=true}} as a replacement for {{ic|1=User=nobody}} which is now discouraged. See [https://github.com/v2fly/v2ray-core/issues/428 GitHub issue 428] for more details.}}<br />
<br />
{{Merge|drop-in snippet|This is a great tip that would benefit more people on the dedicated page.}}<br />
<br />
Note that systemd also allows to set top level per-type drop-ins, to change some aspect of all units of a given type (e.g. {{ic|service}}) by creating a file like {{ic|/etc/systemd/system/service.d/someName.conf}}, which could set {{ic|OnFailure}} for e.g. all services.<br />
<br />
=== Using a crontab ===<br />
<br />
Several of the caveats can be worked around by installing a package that parses a traditional crontab to configure the timers, like {{AUR|systemd-cron}}. It can provide the missing {{ic|MAILTO}} feature.<br />
<br />
Also, like with crontabs, a unified view of all scheduled jobs can be obtained with {{ic|systemctl}}. See [[#Management]].<br />
<br />
=== Manually ===<br />
<br />
Outside of migrating from an existing crontab, using the same periodicity as cron can be desired. To avoid the tedious task of creating a timer for each service to start periodically, use a [[Systemd#Using units|template unit]], for example: <br />
<br />
{{hc|/etc/systemd/system/monthly@.timer|2=<br />
[Unit]<br />
Description=Monthly Timer for %i service<br />
<br />
[Timer]<br />
OnCalendar=*-*-1 02:00:00<br />
AccuracySec=6h<br />
RandomizedDelaySec=1h<br />
Persistent=true<br />
Unit=%i.service<br />
<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
<br />
{{Note|See {{man|5|systemd.timer|OPTIONS}} for the importance of using {{ic|RandomizedDelaySec}} and not only {{ic|AccuracySec}} to avoid all units started by the timer firing at once.}}<br />
<br />
Then one only needs to [[enable/start]] {{ic|monthly@''unit_name''.timer}}.<br />
<br />
{{Tip|The template units can be nested, e.g. one could [[enable/start]] {{ic|monthly@btrfs-scrub@mnt-$(systemd-escape bbb76c63-e4ac-4e39-8897-a120c5d30686).timer}}.}}<br />
<br />
== Handling "time to live" ==<br />
<br />
Some software will track the time elapsed since they last ran, for example blocking the update of a database if the last download ended less than 24 hours ago. <br />
<br />
By default, timers do not track when the task they launched has ended. To work around this, we can use {{ic|OnUnitInactiveSeconds}}: <br />
<br />
{{hc|/etc/systemd/system/daily-inactive@.timer|2=<br />
[Unit]<br />
Description=Launch %i service 24hours after it deactivated<br />
<br />
[Timer]<br />
'''OnUnitInactiveSec=1day1sec'''<br />
Unit=%i.service<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
<br />
{{Tip|With {{ic|1=Restart=on-failure}} along with {{ic|RestartSec}}, it is possible to have a unit rerun after failure and success according to different schedules, see {{man|5|systemd.service|OPTIONS}}.}}<br />
<br />
== See also ==<br />
<br />
* {{man|5|systemd.timer}}<br />
* [[Fedora:Features/SystemdCalendarTimers]]<br />
* [[Gentoo:Systemd#Timer services]]<br />
* {{App|systemd-cron|provides systemd units to run cron scripts; using ''systemd-crontab-generator'' to convert crontabs|https://github.com/systemd-cron/systemd-cron|{{AUR|systemd-cron}}}}<br />
* [https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/ Systemd Timers for Scheduling Tasks]</div>TPXPhttps://wiki.archlinux.org/index.php?title=DVB-T&diff=787740DVB-T2023-09-16T11:50:36Z<p>TPXP: /* ffmpeg */ formatting</p>
<hr />
<div>[[Category:TV cards]]<br />
[[ja:DVB-T]]<br />
{{Related articles start}}<br />
{{Related|DVB-S}}<br />
{{Related|LIRC}}<br />
{{Related|RTL-SDR}}<br />
{{Related articles end}}<br />
<br />
[[wikipedia:DVB-T|DVB-T]] is a standard for transmitting terrestrial digital video broadcast, which is used in the majority of Africa, Asia, Australia and Europe. It is possible to receive DVB-T using several different hardware setups, however this article will focus on DVB-T USB dongles based on the RTL2832U chipset (which are also very popular as cheap software defined radios using [[RTL-SDR]]).<br />
<br />
== Driver ==<br />
<br />
The main driver in use is {{ic|dvb_usb_rtl28xxu}}, and exists in the latest kernels. If it is not [[Kernel modules|loaded]], do so manually:<br />
<br />
# modprobe dvb_usb_rtl28xxu<br />
<br />
You might also need to load {{ic|rtl2832}} or {{ic|rtl2830}}:<br />
<br />
# modprobe rtl2830<br />
# modprobe rtl2832<br />
<br />
{{Note|If you have [[RTL-SDR]] installed, note that it conflicts with this driver, and therefore blacklists it. Make sure to remove any necessary blacklists before loading the driver. The default location for the blacklist file is in {{ic|/etc/modprobe.d/rtlsdr.conf}}.}}<br />
<br />
After plugging the device in, the output of [[dmesg]] should show something like this:<br />
<br />
[ 4009.326338] usb 7-5: new high-speed USB device number 4 using ehci-pci<br />
[ 4009.466712] usb 7-5: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state<br />
[ 4009.531594] usb 7-5: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer<br />
[ 4009.531613] DVB: registering new adapter (Realtek RTL2832U reference design)<br />
[ 4009.534554] usb 7-5: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...<br />
[ 4009.534627] r820t 4-001a: creating new instance<br />
[ 4009.546177] r820t 4-001a: Rafael Micro r820t successfully identified<br />
[ 4009.552681] Registered IR keymap rc-empty<br />
[ 4009.552783] input: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb7/7-5/rc/rc1/input20<br />
[ 4009.552854] rc1: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb7/7-5/rc/rc1<br />
[ 4009.553275] input: MCE IR Keyboard/Mouse (dvb_usb_rtl28xxu) as /devices/virtual/input/input21<br />
[ 4009.554466] rc rc1: lirc_dev: driver ir-lirc-codec (dvb_usb_rtl28xxu) registered at minor = 0<br />
[ 4009.554474] usb 7-5: dvb_usb_v2: schedule remote query interval to 400 msecs<br />
[ 4009.565930] usb 7-5: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected<br />
<br />
{{Note|in this case we see that the dongle has a R820T tuner, but there are several other popular tuners that you might run into. Also note the IR sensor device that was recognized that, properly configured, can be used with the device remote control. See [[LIRC]] for more information.}}<br />
<br />
Additionally, you should now see the adapter device under {{ic|/dev/dvb/adapter0}}. Some cards need additional firmwares that are not distributed for various reasons. Usually you will find an explicit message about that from ''dmesg''. Look for the name of the file(s) you see with your favorite search engine, and once you have them, put the required firmware(s) in /usr/lib/firmware. Possibly a package might exist in the AUR.<br />
<br />
== Utilities ==<br />
<br />
Various DVB utilities can be found in the {{AUR|linuxtv-dvb-apps}} package.<br />
<br />
=== Scanning ===<br />
<br />
{{AUR|w_scan_cpp}} allows for automatic scanning of channels without configuration. Install it then issue:<br />
<br />
# w_scan_cpp -ft -c [country_code] --output-mplayer > ~/channels.conf<br />
<br />
If you do not know your country code, enter the following to get a list of codes.<br />
<br />
# w_scan_cpp -c "?"<br />
<br />
The application now provides help. Use {{ic|w_scan_cpp --help}} for more information.<br />
<br />
More advanced scanning options can be found under [[DVB-S#Scanning channels]].<br />
<br />
When {{ic|w_scan_cpp}} fails to find all expected channels you could try {{AUR|w_scan2}}. It is a fork of the original ''w_scan'' and can be found on [https://github.com/stefantalpalaru/w_scan2 GitHub].<br />
<br />
== Clients ==<br />
<br />
See also [[XScreenSaver|how to disable screensaver when playing video/TV]] by using configuration files or use {{ic|xset}} command before and after player starts to enable/disable it. If you have installed {{Pkg|xscreensaver}} then you will need to use {{ic|xscreensaver-command}} instead of {{ic|xset}} to activate/deactivate screensaver from command line.<br />
<br />
=== Kaffeine ===<br />
<br />
Kaffeine [https://bugs.kde.org/show_bug.cgi?id=397594 does not work] on [[Wayland]]. On [[X11]], DVB-T works out-of-the box in [[Kaffeine]], including management of multpile DVB-T devices, channel tuning, channel selection, EPG and recording. No external playlist generation is needed. Multiple DVB-T devices can be used at once (e.g. for recording from a multiplex while watching another one). Many single-tuner DVB-T devices can even provide two different TV channels, as long as they share the same multiplex; this feature is also readily available in Kaffeine.<br />
<br />
=== Smplayer ===<br />
<br />
[[Smplayer]] Can play DVB-T with [[tvheadend]]<br />
<br />
=== VLC ===<br />
<br />
The simplest way to watch DVB-T channels with [[VLC]] is to first generate a playlist:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -L > dvb.xspf<br />
$ vlc dvb.xspf<br />
<br />
You can also specify the frequency and programs by hand. This can be done using:<br />
<br />
$ vlc dvb://frequency=543000000<br />
<br />
where the frequency is set in Hz, and should match the base frequency for the transmissions in your area. You can also explicitly specify which demodulation you would like to use, so instead of {{ic|dvb}} you can use {{ic|dvb-t}}, {{ic|dvb-t2}}, etc.<br />
<br />
VLC also accepts various command line arguments, for example if you want to tune into a different program:<br />
<br />
$ vlc dvb://frequency=543000000 :program=3<br />
<br />
If some [[VLC media player#Media does not load|DVB-T streams do not work]], [[install]] {{Pkg|aribb24}}.<br />
<br />
=== MPlayer / mpv ===<br />
<br />
For DVB streaming, [[MPlayer]] (or [[mpv]]) requires a channels configuration file at {{ic|~/.mplayer/channels.conf}}. Follow [[#Scanning]] for instructions on how to generate it, but make sure to use the {{ic|-M}} flag to generate the proper format for MPlayer, if you are using {{ic|w_scan_cpp}}:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -M > ~/.mplayer/channels.conf<br />
<br />
For ''mpv'', use:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -M > ~/.config/mpv/channels.conf<br />
<br />
Try the configuration with {{ic|mplayer dvb://}}, which should start to play the first channel. If it does not, you might need to use {{ic|-demuxer lavf}} or {{ic|-demuxer mpegts}} in order to properly receive the stream.<br />
<br />
If the configuration works, you can simply run:<br />
<br />
$ mplayer dvb://"STREAM NAME"<br />
<br />
with a valid {{ic|STREAM NAME}} from the channels configuration file. <br />
<br />
{{Note|MPlayer cannot handle and play channels from a command line that contains some of Linux special symbols like {{ic|/}} in their names, but you can manually rename them by editing {{ic|~/.mplayer/channels.conf}}.}}<br />
<br />
==== Channel selector ====<br />
<br />
Here is a {{AUR|lstv}} script that will show a numbered list of channels by reading data from a {{ic|~/.mplayer/channels.conf}} file. You will be able to watch a channel by using a number associated to it by the script instead of having to type the whole channel name on the command line, e.g. {{ic|lstv 3}}. The channel number associated by the script equals to the line number with tuning configuration for it. The script disables display power saving and a screen saver before starting ''mplayer'' and enables both again after you close it to disable screensaver management in this script remove {{ic|xset ...;}} before and after [[MPlayer]].<br />
<br />
{{hc|/usr/local/bin/lstv|<nowiki><br />
#!/bin/bash<br />
if [ "$1" ];then<br />
CC='^[0-9]+$';<br />
if ! [[ "$@" =~ $CC ]];then echo Is not a channel number!;<br />
else<br />
##<br />
awk -F':' -v AA="$1" '//{ZZ++;<br />
if(AA == ZZ)system("xset -dpms s off;mplayer dvb://""\""$1"\";xset +dpms s on")}<br />
END{if(AA > ZZ)printf "The highest channel number is: "ZZ"\n"}' "$HOME/.mplayer/channels.conf"<br />
##<br />
fi;<br />
else<br />
awk -F':' '// { ZZ++; printf ZZ " | " $1 "\n"}' "$HOME/.mplayer/channels.conf"<br />
fi;<br />
</nowiki>}}<br />
<br />
{{Note|1=<nowiki></nowiki><br />
* It is assumed that the {{ic|channels.conf}} file has been created with: {{ic|w_scan_cpp -ft -c ''country_code'' -C UTF-8 -M -E 0 -O 0 > ~/.mplayer/channels.conf}}<br />
* If the list of channels is too long then you can use something like {{ic|<nowiki>lstv | less</nowiki>}} and search for channels name by pressing {{ic|/}} and writing its name. When found press {{ic|q}} for exiting of [http://unixhelp.ed.ac.uk/CGI/man-cgi?less less]{{Dead link|2023|05|07|status=domain name not resolved}} and use the channel associated number with {{AUR|lstv}}.<br />
* If you have a problem with playing of video see [https://bbs.archlinux.org/viewtopic.php?id=57650 Arch Linux Forum].<br />
}}<br />
<br />
{{Warning|If there is more than one channel with the same name, ''mplayer'' will play only the closest one in the list.}}<br />
<br />
=== ffmpeg ===<br />
<br />
[[FFmpeg]] can take DVB-T MPEG streams as input, but requires {{ic|tzap}} (in {{AUR|linuxtv-dvb-apps}}) to do so.<br />
<br />
{{Note|This might not necessarily be the case, if a better method is known, please update.}}<br />
<br />
First, generate a tzap-compatible {{ic|channels.conf}} file, using {{ic|w_scan_cpp}}:<br />
<br />
$ w_scan_cpp -ft -A1 -X > ~/.tzap/channels.conf<br />
<br />
Then, you can run:<br />
<br />
$ tzap -r "CHANNEL NAME"<br />
<br />
which, if setup correctly should yield an output similar to:<br />
<br />
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'<br />
reading channels from file '/home/user/.tzap/channels.conf'<br />
Version: 5.10 FE_CAN { DVB-T }<br />
tuning to 506000000 Hz<br />
video pid 0x0a21, audio pid 0x0a22<br />
status 00 | signal 0000 | snr 0000 | ber 0000ffff | unc 00007fbd | <br />
status 1f | signal 0000 | snr 0126 | ber 00000000 | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0129 | ber 0000000f | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0120 | ber 00000003 | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0125 | ber 00000011 | unc 00007fbd | FE_HAS_LOCK<br />
# ....<br />
<br />
More information on {{ic|tzap}} is available on the [https://www.linuxtv.org/wiki/index.php/Zap zap wiki page].<br />
<br />
Once {{ic|tzap}} is encoding the stream, {{ic|/dev/dvb/adapter0/dvr0}} should be available to {{ic|ffmpeg}} (or any other program).<br />
<br />
A simple command to stream a program, without additional encoding might look like so:<br />
<br />
$ ffmpeg -f mpegts -i /dev/dvb/adapter0/dvr0 out.mp4<br />
<br />
(Note: the above command will not generate output if the card requires to setup the frontend and/or the demuxer).<br />
<br />
You may also wish to simply record the stream with tzap, and re-encode it with ffmpeg later<br />
<br />
$ tzap -t <recording duration in seconds> -o foo.ts "<channel name>"<br />
<br />
=== dvbjet ===<br />
<br />
DVB cards receive several simultaneous programs multiplexed.<br />
The command-line [https://github.com/lightful/DVBdirect/ dvbjet] standalone tool (has no dependencies) <br />
tunes the TV card by selecting the frequency, as with a radio, and saves the ''full MPEG-TS stream''.<br />
To play or extract a separate program from it (with all its audio, video and subtitle tracks) its companion python script lists the programs and invokes ffmpeg.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Multiple frontends ===<br />
<br />
Many DVB dongles may register more than 1 frontend. This can be spotted in {{ic|dmesg}}:<br />
[ 9080.196561] usb 1-6: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...<br />
[ 9080.196567] dvbdev: dvb_create_media_entity: media entity 'Realtek RTL2832 (DVB-T)' registered.<br />
[ 9080.196626] usb 1-6: DVB: registering adapter 0 frontend 1 (Sony CXD2837ER DVB-T/T2/C demodulator)...<br />
[ 9080.196630] dvbdev: dvb_create_media_entity: media entity 'Sony CXD2837ER DVB-T/T2/C demodulator' registered.<br />
They can be listed by doing:<br />
$ ls /dev/dvb/adapter0/frontend*<br />
<br />
Each frontend may have a specific purpose and may only support decoding specific DVB standards. <br />
Some software may not have an ability or proper documentation on selecting which frontend to use and will default to {{ic|frontend0}}, <br />
which will cause problems if the broadcast is in a standard that {{ic|frontend0}} does not support <br />
(in above example, if the broadcast is in DVB-T2, but the frontend can only do DVB-T, it will not work)<br />
<br />
=== Other ===<br />
<br />
If you run into problems, these tools can help debug problems:<br />
<br />
* {{AUR|dvbsnoop}} is an advanced tool that can show all the necessary data regarding the bandwidth, signal, frontend, etc.<br />
* {{ic|femon -H}} shows signal statistics</div>TPXPhttps://wiki.archlinux.org/index.php?title=DVB-T&diff=787739DVB-T2023-09-16T11:50:05Z<p>TPXP: Add more details about tzap and its recording capabilities</p>
<hr />
<div>[[Category:TV cards]]<br />
[[ja:DVB-T]]<br />
{{Related articles start}}<br />
{{Related|DVB-S}}<br />
{{Related|LIRC}}<br />
{{Related|RTL-SDR}}<br />
{{Related articles end}}<br />
<br />
[[wikipedia:DVB-T|DVB-T]] is a standard for transmitting terrestrial digital video broadcast, which is used in the majority of Africa, Asia, Australia and Europe. It is possible to receive DVB-T using several different hardware setups, however this article will focus on DVB-T USB dongles based on the RTL2832U chipset (which are also very popular as cheap software defined radios using [[RTL-SDR]]).<br />
<br />
== Driver ==<br />
<br />
The main driver in use is {{ic|dvb_usb_rtl28xxu}}, and exists in the latest kernels. If it is not [[Kernel modules|loaded]], do so manually:<br />
<br />
# modprobe dvb_usb_rtl28xxu<br />
<br />
You might also need to load {{ic|rtl2832}} or {{ic|rtl2830}}:<br />
<br />
# modprobe rtl2830<br />
# modprobe rtl2832<br />
<br />
{{Note|If you have [[RTL-SDR]] installed, note that it conflicts with this driver, and therefore blacklists it. Make sure to remove any necessary blacklists before loading the driver. The default location for the blacklist file is in {{ic|/etc/modprobe.d/rtlsdr.conf}}.}}<br />
<br />
After plugging the device in, the output of [[dmesg]] should show something like this:<br />
<br />
[ 4009.326338] usb 7-5: new high-speed USB device number 4 using ehci-pci<br />
[ 4009.466712] usb 7-5: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state<br />
[ 4009.531594] usb 7-5: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer<br />
[ 4009.531613] DVB: registering new adapter (Realtek RTL2832U reference design)<br />
[ 4009.534554] usb 7-5: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...<br />
[ 4009.534627] r820t 4-001a: creating new instance<br />
[ 4009.546177] r820t 4-001a: Rafael Micro r820t successfully identified<br />
[ 4009.552681] Registered IR keymap rc-empty<br />
[ 4009.552783] input: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb7/7-5/rc/rc1/input20<br />
[ 4009.552854] rc1: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:1d.7/usb7/7-5/rc/rc1<br />
[ 4009.553275] input: MCE IR Keyboard/Mouse (dvb_usb_rtl28xxu) as /devices/virtual/input/input21<br />
[ 4009.554466] rc rc1: lirc_dev: driver ir-lirc-codec (dvb_usb_rtl28xxu) registered at minor = 0<br />
[ 4009.554474] usb 7-5: dvb_usb_v2: schedule remote query interval to 400 msecs<br />
[ 4009.565930] usb 7-5: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected<br />
<br />
{{Note|in this case we see that the dongle has a R820T tuner, but there are several other popular tuners that you might run into. Also note the IR sensor device that was recognized that, properly configured, can be used with the device remote control. See [[LIRC]] for more information.}}<br />
<br />
Additionally, you should now see the adapter device under {{ic|/dev/dvb/adapter0}}. Some cards need additional firmwares that are not distributed for various reasons. Usually you will find an explicit message about that from ''dmesg''. Look for the name of the file(s) you see with your favorite search engine, and once you have them, put the required firmware(s) in /usr/lib/firmware. Possibly a package might exist in the AUR.<br />
<br />
== Utilities ==<br />
<br />
Various DVB utilities can be found in the {{AUR|linuxtv-dvb-apps}} package.<br />
<br />
=== Scanning ===<br />
<br />
{{AUR|w_scan_cpp}} allows for automatic scanning of channels without configuration. Install it then issue:<br />
<br />
# w_scan_cpp -ft -c [country_code] --output-mplayer > ~/channels.conf<br />
<br />
If you do not know your country code, enter the following to get a list of codes.<br />
<br />
# w_scan_cpp -c "?"<br />
<br />
The application now provides help. Use {{ic|w_scan_cpp --help}} for more information.<br />
<br />
More advanced scanning options can be found under [[DVB-S#Scanning channels]].<br />
<br />
When {{ic|w_scan_cpp}} fails to find all expected channels you could try {{AUR|w_scan2}}. It is a fork of the original ''w_scan'' and can be found on [https://github.com/stefantalpalaru/w_scan2 GitHub].<br />
<br />
== Clients ==<br />
<br />
See also [[XScreenSaver|how to disable screensaver when playing video/TV]] by using configuration files or use {{ic|xset}} command before and after player starts to enable/disable it. If you have installed {{Pkg|xscreensaver}} then you will need to use {{ic|xscreensaver-command}} instead of {{ic|xset}} to activate/deactivate screensaver from command line.<br />
<br />
=== Kaffeine ===<br />
<br />
Kaffeine [https://bugs.kde.org/show_bug.cgi?id=397594 does not work] on [[Wayland]]. On [[X11]], DVB-T works out-of-the box in [[Kaffeine]], including management of multpile DVB-T devices, channel tuning, channel selection, EPG and recording. No external playlist generation is needed. Multiple DVB-T devices can be used at once (e.g. for recording from a multiplex while watching another one). Many single-tuner DVB-T devices can even provide two different TV channels, as long as they share the same multiplex; this feature is also readily available in Kaffeine.<br />
<br />
=== Smplayer ===<br />
<br />
[[Smplayer]] Can play DVB-T with [[tvheadend]]<br />
<br />
=== VLC ===<br />
<br />
The simplest way to watch DVB-T channels with [[VLC]] is to first generate a playlist:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -L > dvb.xspf<br />
$ vlc dvb.xspf<br />
<br />
You can also specify the frequency and programs by hand. This can be done using:<br />
<br />
$ vlc dvb://frequency=543000000<br />
<br />
where the frequency is set in Hz, and should match the base frequency for the transmissions in your area. You can also explicitly specify which demodulation you would like to use, so instead of {{ic|dvb}} you can use {{ic|dvb-t}}, {{ic|dvb-t2}}, etc.<br />
<br />
VLC also accepts various command line arguments, for example if you want to tune into a different program:<br />
<br />
$ vlc dvb://frequency=543000000 :program=3<br />
<br />
If some [[VLC media player#Media does not load|DVB-T streams do not work]], [[install]] {{Pkg|aribb24}}.<br />
<br />
=== MPlayer / mpv ===<br />
<br />
For DVB streaming, [[MPlayer]] (or [[mpv]]) requires a channels configuration file at {{ic|~/.mplayer/channels.conf}}. Follow [[#Scanning]] for instructions on how to generate it, but make sure to use the {{ic|-M}} flag to generate the proper format for MPlayer, if you are using {{ic|w_scan_cpp}}:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -M > ~/.mplayer/channels.conf<br />
<br />
For ''mpv'', use:<br />
<br />
$ w_scan_cpp -ft -c [country_code] -M > ~/.config/mpv/channels.conf<br />
<br />
Try the configuration with {{ic|mplayer dvb://}}, which should start to play the first channel. If it does not, you might need to use {{ic|-demuxer lavf}} or {{ic|-demuxer mpegts}} in order to properly receive the stream.<br />
<br />
If the configuration works, you can simply run:<br />
<br />
$ mplayer dvb://"STREAM NAME"<br />
<br />
with a valid {{ic|STREAM NAME}} from the channels configuration file. <br />
<br />
{{Note|MPlayer cannot handle and play channels from a command line that contains some of Linux special symbols like {{ic|/}} in their names, but you can manually rename them by editing {{ic|~/.mplayer/channels.conf}}.}}<br />
<br />
==== Channel selector ====<br />
<br />
Here is a {{AUR|lstv}} script that will show a numbered list of channels by reading data from a {{ic|~/.mplayer/channels.conf}} file. You will be able to watch a channel by using a number associated to it by the script instead of having to type the whole channel name on the command line, e.g. {{ic|lstv 3}}. The channel number associated by the script equals to the line number with tuning configuration for it. The script disables display power saving and a screen saver before starting ''mplayer'' and enables both again after you close it to disable screensaver management in this script remove {{ic|xset ...;}} before and after [[MPlayer]].<br />
<br />
{{hc|/usr/local/bin/lstv|<nowiki><br />
#!/bin/bash<br />
if [ "$1" ];then<br />
CC='^[0-9]+$';<br />
if ! [[ "$@" =~ $CC ]];then echo Is not a channel number!;<br />
else<br />
##<br />
awk -F':' -v AA="$1" '//{ZZ++;<br />
if(AA == ZZ)system("xset -dpms s off;mplayer dvb://""\""$1"\";xset +dpms s on")}<br />
END{if(AA > ZZ)printf "The highest channel number is: "ZZ"\n"}' "$HOME/.mplayer/channels.conf"<br />
##<br />
fi;<br />
else<br />
awk -F':' '// { ZZ++; printf ZZ " | " $1 "\n"}' "$HOME/.mplayer/channels.conf"<br />
fi;<br />
</nowiki>}}<br />
<br />
{{Note|1=<nowiki></nowiki><br />
* It is assumed that the {{ic|channels.conf}} file has been created with: {{ic|w_scan_cpp -ft -c ''country_code'' -C UTF-8 -M -E 0 -O 0 > ~/.mplayer/channels.conf}}<br />
* If the list of channels is too long then you can use something like {{ic|<nowiki>lstv | less</nowiki>}} and search for channels name by pressing {{ic|/}} and writing its name. When found press {{ic|q}} for exiting of [http://unixhelp.ed.ac.uk/CGI/man-cgi?less less]{{Dead link|2023|05|07|status=domain name not resolved}} and use the channel associated number with {{AUR|lstv}}.<br />
* If you have a problem with playing of video see [https://bbs.archlinux.org/viewtopic.php?id=57650 Arch Linux Forum].<br />
}}<br />
<br />
{{Warning|If there is more than one channel with the same name, ''mplayer'' will play only the closest one in the list.}}<br />
<br />
=== ffmpeg ===<br />
<br />
[[FFmpeg]] can take DVB-T MPEG streams as input, but requires {{ic|tzap}} (in {{AUR|linuxtv-dvb-apps}}) to do so.<br />
<br />
{{Note|This might not necessarily be the case, if a better method is known, please update.}}<br />
<br />
First, generate a tzap-compatible {{ic|channels.conf}} file, using {{ic|w_scan_cpp}}:<br />
<br />
$ w_scan_cpp -ft -A1 -X > ~/.tzap/channels.conf<br />
<br />
Then, you can run:<br />
<br />
$ tzap -r "CHANNEL NAME"<br />
<br />
which, if setup correctly should yield an output similar to:<br />
<br />
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'<br />
reading channels from file '/home/user/.tzap/channels.conf'<br />
Version: 5.10 FE_CAN { DVB-T }<br />
tuning to 506000000 Hz<br />
video pid 0x0a21, audio pid 0x0a22<br />
status 00 | signal 0000 | snr 0000 | ber 0000ffff | unc 00007fbd | <br />
status 1f | signal 0000 | snr 0126 | ber 00000000 | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0129 | ber 0000000f | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0120 | ber 00000003 | unc 00007fbd | FE_HAS_LOCK<br />
status 1f | signal 0000 | snr 0125 | ber 00000011 | unc 00007fbd | FE_HAS_LOCK<br />
# ....<br />
<br />
More information on {{ic|tzap}} is available on the [https://www.linuxtv.org/wiki/index.php/Zap zap wiki page].<br />
<br />
Once {{ic|tzap}} is encoding the stream, {{ic|/dev/dvb/adapter0/dvr0}} should be available to {{ic|ffmpeg}} (or any other program).<br />
<br />
A simple command to stream a program, without additional encoding might look like so:<br />
<br />
$ ffmpeg -f mpegts -i /dev/dvb/adapter0/dvr0 out.mp4<br />
<br />
(Note: the above command will not generate output if the card requires to setup the frontend and/or the demuxer).<br />
<br />
You may also wish to simply record the stream with tzap, and re-encode it with ffmpeg later<br />
<br />
$ tzap -t <recording duration in seconds> -o foo.ts "<channel name>"<br />
<br />
=== dvbjet ===<br />
<br />
DVB cards receive several simultaneous programs multiplexed.<br />
The command-line [https://github.com/lightful/DVBdirect/ dvbjet] standalone tool (has no dependencies) <br />
tunes the TV card by selecting the frequency, as with a radio, and saves the ''full MPEG-TS stream''.<br />
To play or extract a separate program from it (with all its audio, video and subtitle tracks) its companion python script lists the programs and invokes ffmpeg.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Multiple frontends ===<br />
<br />
Many DVB dongles may register more than 1 frontend. This can be spotted in {{ic|dmesg}}:<br />
[ 9080.196561] usb 1-6: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...<br />
[ 9080.196567] dvbdev: dvb_create_media_entity: media entity 'Realtek RTL2832 (DVB-T)' registered.<br />
[ 9080.196626] usb 1-6: DVB: registering adapter 0 frontend 1 (Sony CXD2837ER DVB-T/T2/C demodulator)...<br />
[ 9080.196630] dvbdev: dvb_create_media_entity: media entity 'Sony CXD2837ER DVB-T/T2/C demodulator' registered.<br />
They can be listed by doing:<br />
$ ls /dev/dvb/adapter0/frontend*<br />
<br />
Each frontend may have a specific purpose and may only support decoding specific DVB standards. <br />
Some software may not have an ability or proper documentation on selecting which frontend to use and will default to {{ic|frontend0}}, <br />
which will cause problems if the broadcast is in a standard that {{ic|frontend0}} does not support <br />
(in above example, if the broadcast is in DVB-T2, but the frontend can only do DVB-T, it will not work)<br />
<br />
=== Other ===<br />
<br />
If you run into problems, these tools can help debug problems:<br />
<br />
* {{AUR|dvbsnoop}} is an advanced tool that can show all the necessary data regarding the bandwidth, signal, frontend, etc.<br />
* {{ic|femon -H}} shows signal statistics</div>TPXPhttps://wiki.archlinux.org/index.php?title=Samba&diff=714063Samba2022-01-27T21:31:37Z<p>TPXP: /* Enabling and starting services */ Add a note about WSD next to nmb</p>
<hr />
<div>[[Category:Network sharing]]<br />
[[Category:Servers]]<br />
[[de:Samba]]<br />
[[fr:Samba]]<br />
[[ja:Samba]]<br />
[[ru:Samba]]<br />
[[zh-hans:Samba]]<br />
[[zh-hant:Samba]]<br />
{{Related articles start}}<br />
{{Related|Active Directory Integration}}<br />
{{Related|Samba/Active Directory domain controller}}<br />
{{Related|NFS}}<br />
{{Related articles end}}<br />
[https://www.samba.org/ Samba] is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the [[wikipedia:Server_Message_Block|SMB/CIFS]] protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.<br />
<br />
To share files through Samba, see [[#Server]] section; to access files shared through Samba on other machines, please see [[#Client]] section.<br />
<br />
== Server ==<br />
<br />
=== Installation ===<br />
<br />
[[Install]] the {{Pkg|samba}} package.<br />
<br />
Samba is configured in the {{ic|/etc/samba/smb.conf}} configuration file, which is extensively documented in {{man|5|smb.conf}}.<br />
<br />
Because the {{Pkg|samba}} package does not provide this file, one needs to create it '''before''' starting {{ic|smb.service}}.<br />
<br />
A documented example as in {{ic|smb.conf.default}} from the [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD Samba git repository] may be used to setup {{ic|/etc/samba/smb.conf}}. <br />
<br />
{{Note|<br />
* The default configuration sets {{ic|log file}} to a non-writable location, which will cause errors - apply one of the following workarounds:<br />
** Change the log file location to a writable path: {{ic|1=log file = /var/log/samba/%m.log}}<br />
** Change logging to a non-file backend solution: {{ic|1=logging = syslog}} with {{ic|1=syslog only = yes}}, or use {{ic|1=logging = systemd}}<br />
* If required; the {{ic|workgroup}} specified in the {{ic|[global]}} section has to match the Windows workgroup (default {{ic|WORKGROUP}}).<br />
}}<br />
<br />
{{Tip|Whenever you modify the {{ic|smb.conf}} file, run the {{man|1|testparm}} command to check for syntactic errors.}}<br />
<br />
==== Enabling and starting services ====<br />
<br />
To provide basic file sharing through SMB, [[enable/start]] {{ic|smb.service}} and {{ic|nmb.service}}. See {{man|8|smbd}} and {{man|8|nmbd}} for details.<br />
<br />
{{Note|{{ic|nmb.service}} is not required. However, it is needed to access Samba servers by hostname (e.g. {{ic|smb://hostname/}}) for some hosts. If your network is only composed of machines running Windows 10 or later, consider [[#Windows_1709_or_up_does_not_discover_the_samba_server_in_Network_view|installing a WSD daemon as well]] for your server to appear in the "Network" view.}}<br />
<br />
==== Configure firewall ====<br />
<br />
If you are using a [[firewall]], do not forget to open required ports (usually 137-139 + 445). For a complete list, see [https://www.samba.org/~tpot/articles/firewall.html Samba port usage].<br />
<br />
===== UFW Rule =====<br />
<br />
A [[Ufw]] App Profile for SMB/CIFS is included by default with the default installation of UFW in {{ic|ufw-fileserver}}.<br />
<br />
Allow Samba by running {{ic|ufw allow CIFS}} as root.<br />
<br />
If you deleted the profile, create/edit {{ic|/etc/ufw/applications.d/samba}} and add the following content:<br />
<br />
[Samba]<br />
title=LanManager-like file and printer server for Unix<br />
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.<br />
ports=137,138/udp|139,445/tcp<br />
<br />
Then load the profile into UFW run {{ic|ufw app update Samba}} as root.<br />
<br />
Then finally, allow Samba by running {{ic|ufw allow Samba}} as root.<br />
<br />
===== firewalld service =====<br />
<br />
To configure [[firewalld]] to allow Samba in the '''home''' zone, run:<br />
<br />
# firewall-cmd --permanent --add-service={samba,samba-client,samba-dc} --zone=home<br />
<br />
The three service listed are:<br />
<br />
* {{ic|samba}}: for sharing files with others.<br />
* {{ic|samba-client}}: to browse shares on other machines on the network.<br />
* {{ic|samba-dc}}: for [[Samba/Active Directory domain controller]].<br />
<br />
{{ic|--permanent}} ensures the changes remain after {{ic|firewalld.service}} is [[restart]]ed.<br />
<br />
=== Usage ===<br />
<br />
==== User management ====<br />
<br />
The following section describes creating a local (tdbsam) database of Samba users. For user authentication and other purposes, Samba can also be bound to an Active Directory domain, can itself serve as an Active Directory domain controller, or can be used with an LDAP server.<br />
<br />
===== Adding a user =====<br />
<br />
Samba requires a Linux user account - you may use an existing user account or create a [[Users and groups#User management|new one]].<br />
<br />
{{Note|The [[user]]/[[user group]] ''nobody'' should already exist on the system, it's used as the default {{ic|guest account}} and may be used for shares containing {{ic|1=guest ok = yes}}, thus preventing the need of user login on that share.}}<br />
<br />
Although the user name is shared with Linux system, Samba uses a password separate from that of the Linux user accounts. Replace {{ic|samba_user}} with the chosen Samba user account:<br />
<br />
# smbpasswd -a ''samba_user''<br />
<br />
Depending on the [https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#SERVERROLE server role], existing [[File permissions and attributes]] may need to be altered for the Samba user account.<br />
<br />
If you want the new user only to be allowed to remotely access the file server shares through Samba, you can restrict other login options:<br />
<br />
* disabling shell - {{ic|usermod --shell /usr/bin/nologin --lock ''samba_user''}}<br />
* disabling SSH logons - edit {{ic|/etc/ssh/sshd_config}}, change option {{ic|AllowUsers}}<br />
<br />
Also see [[Security]] for hardening your system.<br />
<br />
===== Listing users =====<br />
<br />
Samba users can be listed using the {{man|8|pdbedit}} command:<br />
<br />
# pdbedit -L -v<br />
<br />
===== Changing user password =====<br />
<br />
To change a user password, use {{ic|smbpasswd}}:<br />
<br />
# smbpasswd ''samba_user''<br />
<br />
==== Creating an anonymous share ====<br />
<br />
1. Create a Linux user which anonymous Samba users will be mapped to.<br />
<br />
# useradd guest -s /bin/nologin<br />
<br />
{{Note|The username can be any valid Linux username, not just "guest". This user does not need to be a Samba user.}}<br />
<br />
2. Add the following to {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[global]<br />
security = user<br />
map to guest = bad user<br />
guest account = guest<br />
<br />
[guest]<br />
comment = guest<br />
path = /tmp/<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
Any anonymous users will now be mapped to the Linux user {{ic|guest}} and have the ability to access any directories defined in {{ic|guest.path}}, for example, {{ic|/tmp/}} in the configuration above.<br />
<br />
Make sure shares have been properly defined as per the ''Share Definitions'' section of [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD smb.conf.default].<br />
<br />
=== Enable symlink following ===<br />
<br />
{{Warning|Enabling the {{ic|follow symlinks}} option can be a security risk.}}<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[global]<br />
follow symlinks = yes<br />
wide links = yes<br />
unix extensions = no<br />
}}<br />
<br />
Then, [[restart]] {{ic|smb.service}}.<br />
<br />
{{Note|When using [[AppArmor]], if the symlink points to a directory outside the user's home or the [[#Enable Usershares|usershare]] directory, then you need to [[#Permission issues on AppArmor|modify the AppArmor profile permissions]].}}<br />
<br />
=== Advanced Configuration ===<br />
<br />
==== Enable Usershares ====<br />
<br />
{{Note|This is an optional feature. Skip this section if you do not need it.}}<br />
<br />
[https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html Usershares]<br />
is a feature that gives non-root users the capability to add, modify, and delete their own share definitions. <br />
<br />
# Create a directory for usershares: {{bc|# mkdir /var/lib/samba/usershares}}<br />
# Create a [[user group]]: {{bc|# groupadd -r sambashare}}<br />
# Change the owner of the directory to {{ic|root}} and the group to {{ic|sambashare}}: {{bc|# chown root:sambashare /var/lib/samba/usershares}}<br />
# Change the permissions of the {{ic|usershares}} directory so that users in the group {{ic|sambashare}} can read, write and execute files: {{bc|# chmod 1770 /var/lib/samba/usershares}}<br />
<br />
Set the following parameters in the {{ic|smb.conf}} configuration file: <br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
usershare path = /var/lib/samba/usershares<br />
usershare max shares = 100<br />
usershare allow guests = yes<br />
usershare owner only = yes<br />
}}<br />
<br />
Add the user to the ''sambashare'' group. Replace {{ic|''your_username''}} with the name of your user:<br />
<br />
# gpasswd sambashare -a ''your_username''<br />
<br />
[[Restart]] {{ic|smb.service}} and {{ic|nmb.service}} services.<br />
<br />
Log out and log back in.<br />
<br />
If you want to share paths inside your home directory you must make it accessible for the group ''others''.<br />
<br />
In the GUI, you can use [[Thunar]] or [[Dolphin]] - right click on any directory and share it on the network. <br />
<br />
In the CLI, use one of the following commands, replacing italic ''sharename'', ''user'', ... :<br />
<br />
# net usershare add ''sharename'' ''abspath'' [''comment''] [''user'':{R|D|F}] [guest_ok={y|n}]<br />
# net usershare delete ''sharename''<br />
# net usershare list ''wildcard-sharename''<br />
# net usershare info ''wildcard-sharename''<br />
<br />
==== Set and forcing permissions ====<br />
<br />
Permissions may be applied to both the server and shares:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
;inherit owner = unix only ; Inherit ownership of the parent directory for new files and directories<br />
;inherit permissions = yes ; Inherit permissions of the parent directory for new files and directories<br />
create mask = 0664<br />
directory mask = 2755<br />
force create mode = 0644<br />
force directory mode = 2755<br />
...<br />
<br />
[media]<br />
comment = Media share accessible by ''greg'' and ''pcusers''<br />
path = ''/path/to/media''<br />
valid users = ''greg @pcusers''<br />
force group = ''+pcusers''<br />
public = no<br />
writable = yes<br />
create mask = 0664<br />
directory mask = 2775<br />
force create mode = 0664<br />
force directory mode = 2775<br />
<br />
[public]<br />
comment = Public share where ''archie'' has write access<br />
path = ''/path/to/public''<br />
public = yes<br />
read only = yes<br />
write list = ''archie''<br />
printable = no<br />
<br />
[guests]<br />
comment = Allow all users to read/write<br />
path = ''/path/to/guests''<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
See {{man|5|smb.conf}} for a full overview of possible permission flags and settings.<br />
<br />
==== Restrict protocols for better security ====<br />
<br />
{{Warning|By default, Samba versions prior to 4.11 allow connections using the outdated and insecure SMB1 protocol. When using one these Samba versions, it is highly recommended to set {{ic|1=server min protocol = SMB2_02}} to protect yourself from ransomware attacks. In Samba 4.11 and newer, SMB2 is the default min protocol, so no changes are required there.}}<br />
<br />
[[Append]] {{ic|server min protocol}} and {{ic|server max protocol}} in {{ic|/etc/samba/smb.conf}} to force usage of a minimum and maximum protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server min protocol = SMB2_02<br />
; server max protocol = SMB3<br />
}}<br />
<br />
See {{ic|server max protocol}} in {{man|5|smb.conf}} for an overview of supported protocols.<br />
<br />
For compatibility with older clients and/or servers, you might need to set {{ic|1=client min protocol = CORE}} or {{ic|1=server min protocol = CORE}}, but please note that this makes you vulnerable to exploits in SMB1 including ransomware attacks.<br />
<br />
{{Tip|Use {{ic|1=server min protocol = SMB3_00}} when clients should only connect using the latest SMB3 protocol, e.g. on clients running Windows 8 and later.}}<br />
<br />
[[#Manual mounting|Clients]] using {{ic|mount.cifs}} may need to specify the correct {{ic|1=vers=*}}, e.g.:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',iocharset=''utf8'',vers=''3.1.1''<br />
<br />
See {{man|8|mount.cifs}} for more information.<br />
<br />
==== Use native SMB transport encryption ====<br />
<br />
Native SMB transport encryption is available in SMB version 3.0 or newer. Clients supporting this type of encryption include Windows 8 and newer, Windows server 2012 and newer, and smbclient of Samba 4.1 and newer.<br />
<br />
To use native SMB transport encryption by default, set the {{ic|server smb encrypt}} parameter globally and/or by share. Possible values are {{ic|off}}, {{ic|enabled}} (default value), {{ic|desired}}, or {{ic|required}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server smb encrypt = desired<br />
}}<br />
<br />
To configure encryption for on the client side, use the option {{ic|client smb encrypt}}.<br />
<br />
See {{man|5|smb.conf}} for more information, especially the paragraphs ''Effects for SMB1'' and ''Effects for SMB2''.<br />
<br />
{{Tip|When [[#Manual mounting|mounting]] a share, specify the {{ic|seal}} mount option to force usage of encryption.}}<br />
<br />
==== Disable printer sharing ====<br />
<br />
By default Samba shares printers configured using [[CUPS]].<br />
<br />
If you do not want printers to be shared, use the following settings:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = no<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = yes<br />
show add printer wizard = no<br />
}}<br />
<br />
==== Block certain file extensions on Samba share ====<br />
<br />
{{Note|Setting this parameter will affect the performance of Samba, as it will be forced to check all files and directories for a match as they are scanned.}}<br />
<br />
Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files. More information about this option can be found in {{man|5|smb.conf}}.<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[myshare]<br />
comment = Private<br />
path = /mnt/data<br />
read only = no<br />
veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/<br />
}}<br />
<br />
==== Improve throughput ====<br />
<br />
{{Warning|Beware this may lead to corruption/connection issues and potentially cripple your TCP/IP stack.}}<br />
<br />
The default settings should be sufficient for most users. However setting the 'socket options' correct can improve performance, but getting them wrong can degrade it by just as much. Test the effect before making any large changes.<br />
<br />
Read the {{man|5|smb.conf}} man page before applying any of the options listed below.<br />
<br />
The following settings should be [[Append|appended]] to the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}.<br />
<br />
SMB3 multi-channel may improve performance, however it may result in data corruption under some rare conditions. Future releases may improve this situation:<br />
<br />
server multi channel support = yes<br />
<br />
Setting a deadtime is useful to stop a server's resources from being exhausted by a large number of inactive connections:<br />
<br />
deadtime = 30<br />
<br />
The usage of sendfile may make more efficient use of the system CPU's and cause Samba to be faster:<br />
<br />
use sendfile = yes<br />
<br />
Setting min receivefile size allows zero-copy writes directly from network socket buffers into the filesystem buffer cache (if available). It may improve performance but user testing is recommended:<br />
<br />
min receivefile size = 16384<br />
<br />
Reading/writing files asynchronously may improve performance instead of using synchronous writes:<br />
<br />
aio read size = 1<br />
aio write size = 1<br />
<br />
Increasing the receive/send buffers size and socket optimize flags might be useful to improve throughput. It is recommended to test each flag separately as it may cause issues on some networks:<br />
<br />
socket options = IPTOS_LOWDELAY TCP_NODELAY IPTOS_THROUGHPUT SO_RCVBUF=131072 SO_SNDBUF=131072<br />
<br />
{{Note|Network-interface adjustments may be needed for some options to work, see [[Sysctl#Networking]].}}<br />
<br />
==== Enable access for old clients/devices ====<br />
<br />
Latest versions of Samba no longer offer older authentication methods and protocols which are still used by some older clients (IP cameras, etc). These devices usually require Samba server to allow NTMLv1 authentication and NT1 version of the protocol, known as CIFS. For these devices to work with latest Samba, you need to add these two configuration parameters into {{ic|[global]}} section:<br />
<br />
server min protocol = NT1<br />
ntlm auth = yes<br />
<br />
Anonymous/guest access to a share requires just the first parameter. If the old device will access with username and password, you also need the add the second line too.<br />
<br />
==== Enable Spotlight searching ====<br />
<br />
Spotlight allows supporting clients (e.g. MacOS Finder) to quickly search shared files.<br />
<br />
Install and start/enable [[OpenSearch]]. Install {{aur|fs2es-indexer}}, configure the directories you want to index in {{ic|/etc/fs2es-indexer/config.yml}}, and start/enable {{ic|fs2es-indexer.service}} for periodic indexing.<br />
<br />
Edit {{ic|smb.conf}} as described in the [https://wiki.samba.org/index.php/Spotlight_with_Elasticsearch_Backend#Samba Samba wiki] to enable Spotlight per share, and restart {{ic|smb.service}} to apply the changes.<br />
<br />
== Client ==<br />
<br />
Install {{Pkg|smbclient}} for an {{ic|ftp}}-like command line interface. See {{man|1|smbclient}} for commonly used commands.<br />
<br />
For a lightweight alternative (without support for listing public shares, etc.), [[install]] {{Pkg|cifs-utils}} that provides {{ic|/usr/bin/mount.cifs}}.<br />
<br />
Depending on the [[desktop environment]], GUI methods may be available. See [[#File manager configuration]] for use with a file manager.<br />
<br />
{{Note|<br />
* {{Pkg|smbclient}} requires a {{ic|/etc/samba/smb.conf}} file (see [[#Installation]]), which you can create as an empty file using the {{ic|touch}} utility.<br />
* After installing {{Pkg|cifs-utils}} or {{Pkg|smbclient}}, load the {{ic|cifs}} [[kernel module]] or reboot to prevent mount fails.<br />
}}<br />
<br />
=== List public shares ===<br />
<br />
The following command lists public shares on a server:<br />
<br />
$ smbclient -L ''hostname'' -U%<br />
<br />
Alternatively, running {{ic|$ smbtree -N}} will show a tree diagram of all the shares. It uses broadcast queries and is therefore not advisable on a network with a lot of computers, but can be helpful for diagnosing if you have the correct sharename. The {{ic|-N}} ({{ic|-no-pass}}) option suppresses the password prompt.<br />
<br />
=== NetBIOS/WINS host names ===<br />
<br />
Samba clients handle NetBIOS host names automatically by default (the behavior is controlled by the {{ic|name resolve order}} option in {{ic|smb.conf}}). Other programs (including {{ic|mount.cifs}}) typically use [[Domain name resolution#Name Service Switch|Name Service Switch]], which does not handle NetBIOS by default.<br />
<br />
The {{Pkg|smbclient}} package provides a libnss driver to resolve NetBIOS host names. To use it, [[install]] it along with the {{Pkg|samba}} package (which provides the ''winbindd'' daemon), [[start/enable]] {{ic|winbind.service}} and add {{ic|wins}} to the {{ic|hosts}} line in {{man|5|nsswitch.conf}}:<br />
<br />
{{hc|/etc/nsswitch.conf|2=<br />
...<br />
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns '''wins'''<br />
...<br />
}}<br />
<br />
{{Note|Due to a current mistake in {{ic|winbind.service}}, you may have to modify the unit file as described in this [https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1789097 bug-report]}}<br />
<br />
Now, during host resolving (e.g. when using {{ic|mount.cifs}} or just {{ic|ping ''netbios-name''}}), ''winbindd'' will resolve the host name by sending queries using NetBIOS Name Service (NBNS, also known as WINS) protocol.<br />
<br />
By default it sends a broadcast query to your local network. If you have a WINS server, you can add {{ic|1=wins server = ''wins-server-ip''}} to {{ic|smb.conf}} and [[restart]] {{ic|winbind.service}}, then ''winbindd'' and other Samba clients will send unicast queries to the specified IP.<br />
<br />
If you want to resolve your local host name (specified in the {{ic|netbios name}} option in {{ic|smb.conf}}), [[start/enable]] {{ic|nmb.service}}, which will handle incoming queries.<br />
<br />
You can test WINS resolution with {{ic|nmblookup}}. By default it sends broadcast queries to your local network regardless of the {{ic|wins server}} option.<br />
<br />
Note that WINS resolution requires incoming traffic originating from port 137.<br />
<br />
==== Disable NetBIOS/WINS support ====<br />
<br />
When not using NetBIOS/WINS host name resolution, it may be preferred to disable this protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
disable netbios = yes<br />
dns proxy = no<br />
}}<br />
<br />
Finally [[disable]]/[[stop]] {{ic|winbind.service}}.<br />
<br />
=== Manual mounting ===<br />
<br />
Create a mount point for the share:<br />
<br />
# mkdir /mnt/''mountpoint''<br />
<br />
Mount the share using {{ic|mount.cifs}} as {{ic|type}}. Not all the options listed below are needed or desirable:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',workgroup=''workgroup'',iocharset=''utf8'',uid=''username'',gid=''group''<br />
<br />
The options {{ic|uid}} and {{ic|gid}} corresponds to the local (e.g. client) [[user]]/[[user group]] to have read/write access on the given path.<br />
<br />
{{Note|<br />
* If the {{ic|uid}} and {{ic|gid}} being used does not match the user of the server, the {{ic|forceuid}} and {{ic|forcegid}} options may be helpful. However note permissions assigned to a file when {{ic|forceuid}} or {{ic|forcegid}} are in effect may not reflect the the real (server) permissions. See the ''File And Directory Ownership And Permissions'' section in {{man|8|mount.cifs|FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS}} for more information.<br />
* To allow users to mount it as long as the mount point resides in a directory controllable by the user; i.e. the user's home, append the {{ic|users}} mount option. The option is user'''s''' (plural). For other filesystem types handled by mount, this option is usually ''user''; sans the "'''s'''".<br />
* To mount a Windows share without authentication, use {{ic|1="username=*"}}.<br />
}}<br />
<br />
{{Warning|Using {{ic|uid}} and/or {{ic|gid}} as mount options may cause I/O errors, it is recommended to set/check correct [[File permissions and attributes]] instead.}}<br />
<br />
* {{ic|''SERVER''}} — The server name.<br />
* {{ic|''sharename''}} — The shared directory.<br />
* {{ic|''mountpoint''}} — The local directory where the share will be mounted.<br />
* {{ic|[-o ''options'']}} — See {{man|8|mount.cifs}} for more information.<br />
<br />
{{Note|<br />
* Abstain from using a trailing {{ic|/}}. {{ic|//''SERVER''/''sharename'''''/'''}} will not work.<br />
* If your mount does not work stable, stutters or freezes, try to enable different SMB protocol version with {{ic|1=vers=}} option. For example, {{ic|1=vers=2.0}} for Windows Vista mount.<br />
* If having timeouts on a mounted network share with cifs on a shutdown, see [[wpa_supplicant#Problem with mounted network shares (cifs) and shutdown]].<br />
}}<br />
<br />
==== Storing share passwords ====<br />
<br />
Storing passwords in a world readable file is not recommended. A safer method is to use a credentials file instead, e.g. inside {{ic|/etc/samba/credentials}}:<br />
<br />
{{hc|/etc/samba/credentials/share|2=<br />
username=''myuser''<br />
password=''mypass''<br />
}}<br />
<br />
For the mount command replace {{ic|1=username=myuser,password=mypass}} with {{ic|1=credentials=/etc/samba/credentials/share}}.<br />
<br />
The credential file should explicitly readable/writeable to root:<br />
<br />
# chown root:root /etc/samba/credentials<br />
# chmod 700 /etc/samba/credentials<br />
# chmod 600 /etc/samba/credentials/share<br />
<br />
=== Automatic mounting ===<br />
<br />
{{Note|You may need to [[enable]] {{ic|systemd-networkd-wait-online.service}} or {{ic| NetworkManager-wait-online.service}} (depending on your setup) to proper enable booting on start-up.}}<br />
<br />
==== Using NetworkManager and GIO/gvfs ====<br />
<br />
[[NetworkManager#Network services with NetworkManager dispatcher|NetworkManager]] can be configured to run a script on network status change. This script uses the ''gio'' command so that it mounts the Samba shares automatically, the same way your file manager does, as explained [[#File manager configuration|below]]. The script also safely unmounts the Samba shares before the relevant network connection is disabled by listening for the {{ic|pre-down}} and {{ic|vpn-pre-down}} events. Make the script is [[executable]] after creating it.<br />
<br />
{{hc|/etc/NetworkManager/dispatcher.d/30-samba.sh|<nowiki><br />
#!/bin/bash<br />
<br />
# Find the connection UUID with "nmcli con show" in terminal.<br />
# All NetworkManager connection types are supported: wireless, VPN, wired...<br />
WANTED_CON_UUID="CHANGE-ME-NOW-9c7eff15-010a-4b1c-a786-9b4efa218ba9"<br />
<br />
# The user the share will be mounted under<br />
USER="yourusername"<br />
# The path that appears in your file manager when you manually mount the share you want<br />
SMB_URL="smb://servername/share"<br />
<br />
if [[ "$CONNECTION_UUID" == "$WANTED_CON_UUID" ]]; then<br />
<br />
# Script parameter $1: NetworkManager connection name, not used<br />
# Script parameter $2: dispatched event<br />
<br />
case "$2" in<br />
"up")<br />
su $USER -c "DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus gio mount $SMB_URL"<br />
;;<br />
"pre-down");&<br />
"vpn-pre-down")<br />
su $USER -c "DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus gio mount -uf $SMB_URL"<br />
;;<br />
esac<br />
fi<br />
</nowiki>}}<br />
<br />
Create a symlink inside {{ic|/etc/NetworkManager/dispatcher.d/pre-down}} to catch the {{ic|pre-down}} events:<br />
<br />
# ln -s /etc/NetworkManager/dispatcher.d/30-samba.sh /etc/NetworkManager/dispatcher.d/pre-down.d/30-samba.sh<br />
<br />
==== As mount entry ====<br />
<br />
This is a simple example of a {{ic|cifs}} [[fstab|mount entry]] that requires authentication:<br />
<br />
{{hc|/etc/fstab|2=<br />
//''SERVER''/''sharename'' /mnt/''mountpoint'' cifs _netdev,nofail,username=''myuser'',password=''mypass'' 0 0<br />
}}<br />
<br />
{{Note|Spaces in sharename should be replaced by {{ic|\040}} (ASCII code for space in octal). For example, {{ic|//''SERVER''/share name}} on the command line should be {{ic|//''SERVER''/share\040name}} in {{ic|/etc/fstab}}.}}<br />
<br />
{{Tip|Use {{ic|x-systemd.automount}} if you want them to be mounted only upon access. See [[Fstab#Remote file system]] for details.}}<br />
<br />
==== As systemd unit ====<br />
<br />
Create a new {{ic|.mount}} file inside {{ic|/etc/systemd/system}}, e.g. {{ic|mnt-myshare.mount}}. See {{man|5|systemd.mount}} for details.<br />
<br />
{{Note|Make sure the filename corresponds to the mountpoint you want to use.<br />
E.g. the unit name {{ic|mnt-myshare.mount}} can only be used if are going to mount the share under {{ic|/mnt/myshare}}. Otherwise the following error might occur: {{ic|1=systemd[1]: mnt-myshare.mount: Where= setting does not match unit name. Refusing.}}.}}<br />
<br />
{{ic|1=What=}} path to share<br />
<br />
{{ic|1=Where=}} path to mount the share<br />
<br />
{{ic|1=Options=}} share mounting options<br />
<br />
{{Note|<br />
* Network mount units automatically acquire {{ic|After}} dependencies on {{ic|remote-fs-pre.target}}, {{ic|network.target}} and {{ic|network-online.target}}, and gain a {{ic|Before}} dependency on {{ic|remote-fs.target}} unless {{ic|nofail}} mount option is set. Towards the latter a {{ic|Wants}} unit is added as well.<br />
* [[Append]] {{ic|noauto}} to {{ic|Options}} preventing automatically mount during boot (unless it is pulled in by some other unit).<br />
* If you want to use a hostname for the server you want to share (instead of an IP address), add {{ic|1=nss-lookup.target}} to {{ic|1=After}}. This might avoid mount errors at boot time that do not arise when testing the unit.<br />
}} <br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.mount|2=<br />
[Unit]<br />
Description=Mount Share at boot<br />
<br />
[Mount]<br />
What=//server/share<br />
Where=/mnt/myshare<br />
Options=_netdev,credentials=/etc/samba/credentials/myshare,iocharset=utf8,rw<br />
Type=cifs<br />
TimeoutSec=30<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
{{Tip|<br />
* In case of an unreachable system, [[append]] {{ic|1=ForceUnmount=true}} to {{ic|[Mount]}}, allowing the share to be (force-)unmounted.<br />
* If your share has groups with read-only access, [[append]] {{ic|1=uid=''username''}} or {{ic|1=gid=''group''}} to {{ic|1=Options=}}, to specify your user / group allowing writing to the share.<br />
}}<br />
<br />
To use {{ic|mnt-myshare.mount}}, [[start]] the unit and [[enable]] it to run on system boot.<br />
<br />
===== automount =====<br />
<br />
To automatically mount a share (when accessed, like autofs), one may use the following automount unit:<br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.automount|2=<br />
[Unit]<br />
Description=Automount myshare<br />
<br />
[Automount]<br />
Where=/mnt/myshare<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
[[Disable]]/[[stop]] the {{ic|mnt-myshare.mount}} unit, and [[enable]]/[[start]] {{ic|mnt-myshare.automount}} to automount the share when the mount path is being accessed.<br />
<br />
{{Tip|[[Append]] {{ic|TimeoutIdleSec}} to enable auto unmount. See {{man|5|systemd.automount}} for details.}}<br />
<br />
==== smbnetfs ====<br />
<br />
{{Note|1=smbnetfs needs an intact Samba server setup.<br />
<br />
See above on how to do that.}}<br />
<br />
First, check if you can see all the shares you are interested in mounting:<br />
<br />
$ smbtree -U ''remote_user''<br />
<br />
If that does not work, find and modify the following line<br />
in {{ic|/etc/samba/smb.conf}} accordingly:<br />
<br />
domain master = auto<br />
<br />
Now [[restart]] {{ic|smb.service}} and {{ic|nmb.service}}.<br />
<br />
If everything works as expected, [[pacman#Installing specific packages|install]] {{Pkg|smbnetfs}} from the official repositories.<br />
<br />
Then, add the following line to {{ic|/etc/fuse.conf}}:<br />
<br />
user_allow_other<br />
<br />
Now copy the directory {{ic|/etc/smbnetfs/.smb}} to your home directory:<br />
<br />
$ cp -a /etc/smbnetfs/.smb ~<br />
<br />
Then create a link to {{ic|smb.conf}}:<br />
<br />
$ ln -sf /etc/samba/smb.conf ~/.smb/smb.conf<br />
<br />
If a username and a password are required to access some of the shared folders, edit {{ic|~/.smb/smbnetfs.auth}}<br />
to include one or more entries like this:<br />
<br />
{{hc|~/.smb/smbnetfs.auth|<br />
auth "hostname" "username" "password"<br />
}}<br />
<br />
It is also possible to add entries for specific hosts to be mounted by smbnetfs, if necessary.<br />
More details can be found in {{ic|~/.smb/smbnetfs.conf}}.<br />
<br />
If you are using the [[Dolphin]] or [[GNOME Files]], you may want to add the following to {{ic|~/.smb/smbnetfs.conf}} to avoid "Disk full" errors as smbnetfs by default will report 0 bytes of free space:<br />
<br />
{{hc|~/.smb/smbnetfs.conf|<br />
free_space_size 1073741824<br />
}}<br />
<br />
When you are done with the configuration, you need to run<br />
<br />
$ chmod 600 ~/.smb/smbnetfs.*<br />
<br />
Otherwise, smbnetfs complains about 'insecure config file permissions'.<br />
<br />
Finally, to mount your Samba network neighbourhood to a directory of your choice, call<br />
<br />
$ smbnetfs ''mount_point''<br />
<br />
===== Daemon =====<br />
<br />
The Arch Linux package also maintains an additional system-wide operation mode for smbnetfs. To enable it, you need to make the<br />
said modifications in the directory {{ic|/etc/smbnetfs/.smb}}.<br />
<br />
Then, you can start and/or enable the {{ic|smbnetfs}} [[daemon]] as usual. The system-wide mount point is at {{ic|/mnt/smbnet/}}.<br />
<br />
==== autofs ====<br />
<br />
See [[Autofs]] for information on the kernel-based automounter for Linux.<br />
<br />
=== File manager configuration ===<br />
<br />
==== GNOME Files, Nemo, Caja, Thunar and PCManFM ====<br />
<br />
In order to access samba shares through GNOME Files, Nemo, Caja, Thunar or PCManFM, install the {{Pkg|gvfs-smb}} package, available in the [[official repositories]].<br />
<br />
Press {{ic|Ctrl+l}} and enter {{ic|smb://''servername''/''share''}} in the location bar to access your share.<br />
<br />
The mounted share is likely to be present at {{ic|/run/user/''your_UID''/gvfs}} or {{ic|~/.gvfs}} in the filesystem.<br />
<br />
==== KDE ====<br />
<br />
KDE applications (like Dolphin) has the ability to browse Samba shares built in. Use the path {{ic|smb://''servername''/''share''}} to browse the files. If you want to access files from on non-KDE application, you can install {{Pkg|kio-fuse}}.<br />
<br />
To use a GUI in the KDE System Settings, you will need to install the {{Pkg|kdenetwork-filesharing}} package.<br />
<br />
==== Other graphical environments ====<br />
<br />
There are a number of useful programs, but they may need to have packages created for them. This can be done with the Arch package build system. The good thing about these others is that they do not require a particular environment to be installed to support them, and so they bring along less baggage.<br />
<br />
* {{AUR|pyneighborhood}} is available in the official repositories.<br />
* LinNeighborhood, RUmba, xffm-samba plugin for Xffm are not available in the official repositories or the AUR. As they are not officially (or even unofficially supported), they may be obsolete and may not work at all.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Discovering network shares ===<br />
<br />
If nothing is known about other systems on the local network, and automated tools such as [[#smbnetfs|smbnetfs]] are not available, the following methods allow one to manually probe for Samba shares.<br />
<br />
1. First, [[install]] the {{Pkg|nmap}} and {{Pkg|smbclient}} packages.<br />
<br />
2. {{ic|nmap}} checks which ports are open:<br />
<br />
# nmap -p 139 -sT "192.168.1.*"<br />
<br />
In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:<br />
<br />
{{hc|$ nmap -sT "192.168.1.*"|<nowiki><br />
Starting nmap 3.78 ( http://www.insecure.org/nmap/ ) at 2005-02-15 11:45 PHT<br />
Interesting ports on 192.168.1.1:<br />
(The 1661 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
'''139/tcp open netbios-ssn'''<br />
5000/tcp open UPnP<br />
<br />
Interesting ports on 192.168.1.5:<br />
(The 1662 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
6000/tcp open X11<br />
<br />
Nmap run completed -- 256 IP addresses (2 hosts up) scanned in 7.255 seconds<br />
</nowiki>}}<br />
<br />
The first result is another system; the second happens to be the client from where this scan was performed.<br />
<br />
3. Now that systems with port 139 open are revealed, use {{man|1|nmblookup}} to check for NetBIOS names: <br />
<br />
{{hc|$ nmblookup -A 192.168.1.1|<br />
Looking up status of 192.168.1.1<br />
PUTER <00> - B <ACTIVE><br />
HOMENET <00> - <GROUP> B <ACTIVE><br />
PUTER <03> - B <ACTIVE><br />
'''PUTER <20> - B <ACTIVE>'''<br />
HOMENET <1e> - <GROUP> B <ACTIVE><br />
USERNAME <03> - B <ACTIVE><br />
HOMENET <1d> - B <ACTIVE><br />
MSBROWSE <01> - <GROUP> B <ACTIVE><br />
}}<br />
<br />
Regardless of the output, look for '''<20>''', which shows the host with open services.<br />
<br />
4. Use {{ic|smbclient}} to list which services are shared on ''PUTER''. If prompted for a password, pressing enter should still display the list:<br />
<br />
{{hc|$ smbclient -L \\PUTER|<nowiki><br />
Sharename Type Comment<br />
--------- ---- -------<br />
MY_MUSIC Disk<br />
SHAREDDOCS Disk<br />
PRINTER$ Disk<br />
PRINTER Printer<br />
IPC$ IPC Remote Inter Process Communication<br />
<br />
Server Comment<br />
--------- -------<br />
PUTER<br />
<br />
Workgroup Master<br />
--------- -------<br />
HOMENET PUTER<br />
</nowiki>}}<br />
<br />
=== Remote control of Windows computer ===<br />
<br />
Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.<br />
<br />
Send shutdown command with a comment:<br />
<br />
$ net rpc shutdown -C "comment" -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.<br />
<br />
Stop and start services:<br />
<br />
$ net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
To see all possible net rpc command:<br />
<br />
$ net rpc<br />
<br />
== Troubleshooting ==<br />
<br />
=== Failed to start Samba SMB/CIFS server ===<br />
<br />
Possible solutions:<br />
<br />
* Check {{ic|smb.conf}} on syntactic errors with {{man|1|testparm}}.<br />
* Set correct permissions for {{ic|/var/cache/samba/}} and [[restart]] {{ic|smb.service}}:<br />
<br />
# chmod 0755 /var/cache/samba/msg<br />
<br />
=== Permission issues on SELinux ===<br />
<br />
[[SELinux]] not allow samba to access user home directories by default, to solve this, run:<br />
<br />
# setsebool -P samba_enable_home_dirs 1<br />
<br />
Similarly, {{ic|samba_export_all_ro}} and {{ic|samba_export_all_rw}} make [[Samba]] has the ability to read or "read and write" all files.<br />
<br />
=== Permission issues on AppArmor ===<br />
<br />
If using a [[#Creating an anonymous share|share path]] located outside of a home or usershares directory, whitelist it in {{ic|/etc/apparmor.d/local/usr.sbin.smbd}}. E.g.:<br />
<br />
{{hc|/etc/apparmor.d/local/usr.sbin.smbd|<br />
"/data/" rk,<br />
"/data/**" lrwk,<br />
}}<br />
<br />
=== No dialect specified on mount ===<br />
<br />
The client is using an unsupported SMB/CIFS version that is required by the server.<br />
<br />
See [[#Restrict protocols for better security]] for more information.<br />
<br />
=== Unable to overwrite files, permissions errors ===<br />
<br />
{{Accuracy|An user should set/check for server/client permissions, instead of using incorrect/possible insecure flags.}}<br />
<br />
Possible solutions:<br />
<br />
* Append the mount option {{ic|nodfs}} to the {{ic|/etc/fstab}} [[#As mount entry|entry]].<br />
* Add {{ic|1=msdfs root = no}} to the {{ic|[global]}} section of the server's {{ic|/etc/samba/smb.conf}}.<br />
<br />
=== Windows clients keep asking for password even if Samba shares are created with guest permissions ===<br />
<br />
Set {{ic|map to guest}} inside the {{ic|global}} section of {{ic|/etc/samba/smb.conf}}:<br />
<br />
map to guest = Bad User<br />
<br />
From Samba 4.10.10 you should use {{ic|Bad Password}} instead {{ic|Bad User}}.<br />
<br />
=== Windows 7 connectivity problems - mount error(12): cannot allocate memory ===<br />
<br />
A known Windows 7 bug that causes "mount error(12): cannot allocate memory" on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:<br />
<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache}} (set to {{ic|1}})<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size}} (set to {{ic|3}})<br />
<br />
Alternatively, start Command Prompt in Admin Mode and execute the following:<br />
<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f<br />
<br />
Do one of the following for the settings to take effect:<br />
<br />
* Restart Windows<br />
* Restart the Server service via services.msc<br />
* From the Command Prompt run: 'net stop lanmanserver' and 'net start lanmanserver' - The server may automatically restart after stopping it.<br />
<br />
{{Note|Googling will reveal another tweak recommending users to add a key modifying the "IRPStackSize" size. This is incorrect for fixing this issue under Windows 7. Do not attempt it.}}<br />
<br />
[https://web.archive.org/web/20150819153712/http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017/ Original article].<br />
<br />
=== Windows 10 1709 and up connectivity problems - "Windows cannot access" 0x80004005 ===<br />
<br />
This error affects some machines running Windows 10 version 1709 and later. It is not related to SMB1 being disabled in this version but to the fact that Microsoft disabled insecure logons for guests on this version for some, but not others.<br />
<br />
To fix, open Group Policy Editor ({{ic|gpedit.msc}}). Navigate to ''Computer configuration\administrative templates\network\Lanman Workstation > Enable insecure guest logons'' and enable it.<br />
Alternatively,change the following value in the registry:<br />
<br />
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]<br />
"AllowInsecureGuestAuth"=dword:1<br />
<br />
=== Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL ===<br />
<br />
If you are a home user and using samba purely for file sharing from a server or NAS, you are probably not interested in sharing printers through it. If so, you can prevent this error from occurring by adding the following lines to your {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = No<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = Yes<br />
}}<br />
<br />
[[Restart]] the samba service, {{ic|smb.service}}, and then check your logs:<br />
<br />
# cat /var/log/samba/smbd.log<br />
<br />
and the error should now no longer be appearing.<br />
<br />
=== Sharing a folder fails ===<br />
<br />
It means that while you are sharing a folder from ''Dolphin'' (file manager) and everything seems ok at first, after restarting ''Dolphin'' the share icon is gone from the shared folder, and also some output like this in terminal (''Konsole'') output:<br />
<br />
‘net usershare’ returned error 255: net usershare: usershares are currently disabled<br />
<br />
To fix it, enable usershare as described in [[#Enable Usershares]].<br />
<br />
=== "Browsing" network fails with "Failed to retrieve share list from server" ===<br />
<br />
And you are using a firewall (iptables) because you do not trust your local (school, university, hotel) network. This may be due to the following: When the smbclient is browsing the local network it sends out a broadcast request on udp port 137. The servers on the network then reply to your client but as the source address of this reply is different from the destination address iptables saw when sending the request for the listing out, iptables will not recognize the reply as being "ESTABLISHED" or "RELATED", and hence the packet is dropped. A possible solution is to add:<br />
<br />
iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns<br />
<br />
to your iptables setup.<br />
<br />
For [[Uncomplicated Firewall]], you need to add {{ic|nf_conntrack_netbios_ns}} to the end of the following line in {{ic|/etc/default/ufw}}<br />
<br />
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc"<br />
<br />
and then run the following commands as root:<br />
<br />
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper<br />
ufw allow CIFS<br />
ufw reload<br />
<br />
To make this change persistent across reboots, add the following line at the end of {{ic|/etc/ufw/sysctl.conf}}:<br />
<br />
net.netfilter.nf_conntrack_helper=1<br />
<br />
=== Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE ===<br />
<br />
The client probably does not have access to shares. Make sure clients' IP address is in {{ic|1=hosts allow =}} line in {{ic|/etc/samba/smb.conf}}.<br />
<br />
Another problem could be, that the client uses an invalid protocol version. To check this try to connect with the {{ic|smbclient}} where you specify the maximum protocol version manually:<br />
<br />
$ smbclient -U <user name> -L //<server name> -m <protocol version: e. g. SMB2> -W <domain name><br />
<br />
If the command was successful then create a configuration file:<br />
<br />
{{hc|~/.smb/smb.conf|output=<br />
[global]<br />
workgroup = <domain name><br />
client max protocol = SMB2<br />
}}<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL) ===<br />
<br />
You are probably passing a wrong server name to {{ic|smbclient}}. To find out the server name, run {{ic|hostnamectl}} on the server and look at "Transient hostname" line<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED) ===<br />
<br />
Make sure that the server has started. The shared directories should exist and be accessible.<br />
<br />
=== Protocol negotiation failed: NT_STATUS_CONNECTION_RESET ===<br />
<br />
Probably the server is configured not to accept protocol SMB1. Add option {{ic|1=client max protocol = SMB2}} in {{ic|/etc/samba/smb.conf}}.<br />
Or just pass argument {{ic|-m SMB2}} to {{ic|smbclient}}.<br />
<br />
=== Password Error when correct credentials are given (error 1326) ===<br />
<br />
[https://www.samba.org/samba/history/samba-4.5.0.html Samba 4.5] has NTLMv1 authentication disabled by default. It is recommend to install the latest available upgrades on clients and deny access for unsupported clients.<br />
<br />
If you still need support for very old clients without NTLMv2 support (e.g. Windows XP), it is possible force enable NTLMv1, although this is '''not recommend''' for security reasons:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
lanman auth = yes<br />
ntlm auth = yes<br />
}}<br />
<br />
If NTLMv2 clients are unable to authenticate when NTLMv1 has been enabled, create the following file on the client:<br />
{{hc|/home/user/.smb/smb.conf|2=<br />
[global]<br />
sec = ntlmv2<br />
client ntlmv2 auth = yes<br />
}}<br />
<br />
This change also affects samba shares mounted with '''mount.cifs'''. If after upgrade to Samba 4.5 your mount fails, add the '''sec=ntlmssp''' option to your mount command, e.g.<br />
<br />
mount.cifs //server/share /mnt/point -o sec=ntlmssp,...<br />
<br />
See the {{man|8|mount.cifs}} man page: '''ntlmssp''' - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message. The default in mainline kernel versions prior to v3.8 was '''sec=ntlm'''. In v3.8, the default was changed to '''sec=ntlmssp'''.<br />
<br />
=== Mapping reserved Windows characters ===<br />
<br />
Starting with kernel 3.18, the cifs module uses the [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2baa2682531ff02928e2d3904800696d9e7193db "mapposix" option by default].<br />
When mounting a share using unix extensions and a default Samba configuration, files and directories containing one of the seven reserved Windows characters {{ic|: \ * < > ? |}} are listed but cannot be accessed.<br />
<br />
Possible solutions are:<br />
<br />
* Use the undocumented {{ic|nomapposix}} mount option for cifs<br />
<br />
# mount.cifs //server/share /mnt/point -o nomapposix<br />
<br />
* Configure Samba to remap {{ic|mapposix}} ("SFM", Services for Mac) style characters to the correct native ones using [https://www.mankier.com/8/vfs_fruit fruit]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia fruit<br />
fruit:encoding = native<br />
}}<br />
<br />
* Manually remap forbidden characters using [https://www.mankier.com/8/vfs_catia catia]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia<br />
catia:mappings = 0x22:0xf022, 0x2a:0xf02a, 0x2f:0xf02f, 0x3a:0xf03a, 0x3c:0xf03c, 0x3e:0xf03e, 0x3f:0xf03f, 0x5c:0xf05c, 0x7c:0xf07c, 0x20:0xf020<br />
}}<br />
<br />
The latter approach (using catia or fruit) has the drawback of filtering files with unprintable characters.<br />
<br />
=== Folder shared inside graphical environment is not available to guests ===<br />
<br />
This section presupposes:<br />
<br />
# Usershares are configured following [[#Enable Usershares|previous section]]<br />
# A shared folder has been created as a non-root user from GUI<br />
# Guests access has been set to shared folder during creation<br />
# Samba service has been restarted at least once since last {{ic|/etc/samba/smb.conf}} file modification<br />
<br />
For clarification purpose only, in the following sub-sections is assumed:<br />
<br />
* Shared folder is located inside user home directory path ({{ic|/home/yourUser/Shared}})<br />
* Shared folder name is ''MySharedFiles''<br />
* Guest access is read-only.<br />
* Windows users will access shared folder content without login prompt<br />
<br />
==== Verify correct samba configuration ====<br />
<br />
Run the following command from a terminal to test configuration file correctness:<br />
<br />
$ testparm<br />
<br />
==== Verify correct shared folder creation ====<br />
<br />
Run the following commands from a terminal:<br />
<br />
$ cd /var/lib/samba/usershare<br />
$ ls<br />
<br />
If everything is fine, you will notice a file named {{ic|mysharedfiles}}<br />
<br />
Read the file contents using the following command:<br />
<br />
$ cat mysharedfiles<br />
<br />
The terminal output should display something like this:<br />
<br />
{{hc|/var/lib/samba/usershare/mysharedfiles|2=<br />
path=/home/yourUser/Shared<br />
comment=<br />
usershare_acl=S-1-1-0:r<br />
guest_ok=y<br />
sharename=MySharedFiles<br />
}}<br />
<br />
==== Verify folder access by guest ====<br />
<br />
Run the following command from a terminal. If prompted for a password, just press Enter:<br />
<br />
$ smbclient -L localhost<br />
<br />
If everything is fine, MySharedFiles should be displayed under {{ic|Sharename}} column<br />
<br />
Run the following command in order to access the shared folder as guest (anonymous login)<br />
<br />
$ smbclient -N //localhost/MySharedFiles<br />
<br />
If everything is fine samba client prompt will be displayed:<br />
<br />
smb: \><br />
<br />
From samba prompt verify guest can list directory contents:<br />
<br />
smb: \> ls<br />
<br />
If the {{ic|NTFS_STATUS_ACCESS_DENIED}} error is displayed, the issue is likely to be with Unix directory permissions. Ensure that your samba user has access to the folder and all parent folders. You can test this by sudoing to the user and attempting to list the mount directory, and all of its parents.<br />
<br />
=== Mount error: Host is down ===<br />
<br />
This error might be seen when mounting shares of Synology NAS servers. Use the mount option {{ic|1=vers=1.0}} to solve it.<br />
<br />
{{Note|SMB version 1 is known to have security vulnerabilities and was used in successful ransomware attacks.}}<br />
<br />
=== Software caused connection abort ===<br />
<br />
File managers that utilizes {{Pkg|gvfs-smb}} can show the error {{ic|Software caused connection abort}} when writing a file to a share/server. This may be due to the server running SMB/CIFS version 1, which many routers use for USB drive sharing (e.g. Belkin routers). To write to these shares specify the CIFS version with the option {{ic|1=vers=1.0}}. E.g.:<br />
<br />
{{hc|/etc/fstab|2=<br />
//SERVER/sharename /mnt/mountpoint cifs _netdev,guest,file_mode=0777,dir_mode=0777,vers=1.0 0 0<br />
}}<br />
<br />
This can also happen after updating Samba to version 4.11, which deactivates SMB1 as default, and accessing any Samba share. You can reenable it by adding<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
client min protocol = CORE<br />
}}<br />
<br />
=== Connection problem (due to authentification error) ===<br />
<br />
Be sure that you do not leave any space characters before your username in Samba client configuration file as follows:<br />
<br />
{{hc|~/.samba|2=<br />
username= user<br />
password=pass<br />
}}<br />
<br />
The correct format is:<br />
<br />
{{hc|~/.samba|2=<br />
username=user<br />
password=pass<br />
}}<br />
<br />
=== Windows 1709 or up does not discover the samba server in Network view ===<br />
<br />
With Windows 10 version 1511, support for SMBv1 and thus NetBIOS device discovery was disabled by default. Depending on the actual edition, later versions of Windows starting from version 1709 ("Fall Creators Update") do not allow the installation of the SMBv1 client anymore. This causes hosts running Samba not to be listed in the Explorer's "Network (Neighborhood)" views. While there is no connectivity problem and Samba will still run fine, users might want to have their Samba hosts to be listed by Windows automatically. {{AUR|wsdd}} implements a Web Service Discovery host daemon. This enables (Samba) hosts, like your local NAS device, to be found by Web Service Discovery Clients like Windows. The default settings should work for most installations, all you need to do is start enable {{ic|wsdd.service}}.<br />
<br />
If the default configuration (advertise itself as the machine hostname in group "WORKGROUP") should be all you need in most cases. If you need, you can change configuration options by passing additional arguments to wsdd by adding them in <code>/etc/conf.d/wsdd</code> (see the manual page for wsdd for details).<br />
<br />
{{AUR|wsdd2}} does the same thing, but is written in C instead of Python. By default, it will look for the <code>netbios name</code> and <code>workgroup</code> values in <code>smb.conf</code>.<br />
<br />
== See also ==<br />
<br />
* [https://www.samba.org/ Official website]<br />
* [https://www.samba.org/samba/docs/SambaIntro.html Samba: An Introduction]<br />
* [https://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf Samba 3.2.x HOWTO and Reference Guide] (outdated but still most extensive documentation)<br />
* [[Wikipedia:Samba (software)|Wikipedia]]<br />
* [[Gentoo:Samba/Guide]]<br />
* [[Debian:Samba/ServerSimple]]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Samba&diff=714062Samba2022-01-27T21:26:12Z<p>TPXP: /* Windows 1709 or up does not discover the samba server in Network view */ Mention wsdd2 and configuration options for wsdd</p>
<hr />
<div>[[Category:Network sharing]]<br />
[[Category:Servers]]<br />
[[de:Samba]]<br />
[[fr:Samba]]<br />
[[ja:Samba]]<br />
[[ru:Samba]]<br />
[[zh-hans:Samba]]<br />
[[zh-hant:Samba]]<br />
{{Related articles start}}<br />
{{Related|Active Directory Integration}}<br />
{{Related|Samba/Active Directory domain controller}}<br />
{{Related|NFS}}<br />
{{Related articles end}}<br />
[https://www.samba.org/ Samba] is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the [[wikipedia:Server_Message_Block|SMB/CIFS]] protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.<br />
<br />
To share files through Samba, see [[#Server]] section; to access files shared through Samba on other machines, please see [[#Client]] section.<br />
<br />
== Server ==<br />
<br />
=== Installation ===<br />
<br />
[[Install]] the {{Pkg|samba}} package.<br />
<br />
Samba is configured in the {{ic|/etc/samba/smb.conf}} configuration file, which is extensively documented in {{man|5|smb.conf}}.<br />
<br />
Because the {{Pkg|samba}} package does not provide this file, one needs to create it '''before''' starting {{ic|smb.service}}.<br />
<br />
A documented example as in {{ic|smb.conf.default}} from the [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD Samba git repository] may be used to setup {{ic|/etc/samba/smb.conf}}. <br />
<br />
{{Note|<br />
* The default configuration sets {{ic|log file}} to a non-writable location, which will cause errors - apply one of the following workarounds:<br />
** Change the log file location to a writable path: {{ic|1=log file = /var/log/samba/%m.log}}<br />
** Change logging to a non-file backend solution: {{ic|1=logging = syslog}} with {{ic|1=syslog only = yes}}, or use {{ic|1=logging = systemd}}<br />
* If required; the {{ic|workgroup}} specified in the {{ic|[global]}} section has to match the Windows workgroup (default {{ic|WORKGROUP}}).<br />
}}<br />
<br />
{{Tip|Whenever you modify the {{ic|smb.conf}} file, run the {{man|1|testparm}} command to check for syntactic errors.}}<br />
<br />
==== Enabling and starting services ====<br />
<br />
To provide basic file sharing through SMB, [[enable/start]] {{ic|smb.service}} and {{ic|nmb.service}}. See {{man|8|smbd}} and {{man|8|nmbd}} for details.<br />
<br />
{{Note|{{ic|nmb.service}} is not required. However, it is needed to access Samba servers by hostname (e.g. {{ic|smb://hostname/}}).}}<br />
<br />
==== Configure firewall ====<br />
<br />
If you are using a [[firewall]], do not forget to open required ports (usually 137-139 + 445). For a complete list, see [https://www.samba.org/~tpot/articles/firewall.html Samba port usage].<br />
<br />
===== UFW Rule =====<br />
<br />
A [[Ufw]] App Profile for SMB/CIFS is included by default with the default installation of UFW in {{ic|ufw-fileserver}}.<br />
<br />
Allow Samba by running {{ic|ufw allow CIFS}} as root.<br />
<br />
If you deleted the profile, create/edit {{ic|/etc/ufw/applications.d/samba}} and add the following content:<br />
<br />
[Samba]<br />
title=LanManager-like file and printer server for Unix<br />
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.<br />
ports=137,138/udp|139,445/tcp<br />
<br />
Then load the profile into UFW run {{ic|ufw app update Samba}} as root.<br />
<br />
Then finally, allow Samba by running {{ic|ufw allow Samba}} as root.<br />
<br />
===== firewalld service =====<br />
<br />
To configure [[firewalld]] to allow Samba in the '''home''' zone, run:<br />
<br />
# firewall-cmd --permanent --add-service={samba,samba-client,samba-dc} --zone=home<br />
<br />
The three service listed are:<br />
<br />
* {{ic|samba}}: for sharing files with others.<br />
* {{ic|samba-client}}: to browse shares on other machines on the network.<br />
* {{ic|samba-dc}}: for [[Samba/Active Directory domain controller]].<br />
<br />
{{ic|--permanent}} ensures the changes remain after {{ic|firewalld.service}} is [[restart]]ed.<br />
<br />
=== Usage ===<br />
<br />
==== User management ====<br />
<br />
The following section describes creating a local (tdbsam) database of Samba users. For user authentication and other purposes, Samba can also be bound to an Active Directory domain, can itself serve as an Active Directory domain controller, or can be used with an LDAP server.<br />
<br />
===== Adding a user =====<br />
<br />
Samba requires a Linux user account - you may use an existing user account or create a [[Users and groups#User management|new one]].<br />
<br />
{{Note|The [[user]]/[[user group]] ''nobody'' should already exist on the system, it's used as the default {{ic|guest account}} and may be used for shares containing {{ic|1=guest ok = yes}}, thus preventing the need of user login on that share.}}<br />
<br />
Although the user name is shared with Linux system, Samba uses a password separate from that of the Linux user accounts. Replace {{ic|samba_user}} with the chosen Samba user account:<br />
<br />
# smbpasswd -a ''samba_user''<br />
<br />
Depending on the [https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#SERVERROLE server role], existing [[File permissions and attributes]] may need to be altered for the Samba user account.<br />
<br />
If you want the new user only to be allowed to remotely access the file server shares through Samba, you can restrict other login options:<br />
<br />
* disabling shell - {{ic|usermod --shell /usr/bin/nologin --lock ''samba_user''}}<br />
* disabling SSH logons - edit {{ic|/etc/ssh/sshd_config}}, change option {{ic|AllowUsers}}<br />
<br />
Also see [[Security]] for hardening your system.<br />
<br />
===== Listing users =====<br />
<br />
Samba users can be listed using the {{man|8|pdbedit}} command:<br />
<br />
# pdbedit -L -v<br />
<br />
===== Changing user password =====<br />
<br />
To change a user password, use {{ic|smbpasswd}}:<br />
<br />
# smbpasswd ''samba_user''<br />
<br />
==== Creating an anonymous share ====<br />
<br />
1. Create a Linux user which anonymous Samba users will be mapped to.<br />
<br />
# useradd guest -s /bin/nologin<br />
<br />
{{Note|The username can be any valid Linux username, not just "guest". This user does not need to be a Samba user.}}<br />
<br />
2. Add the following to {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[global]<br />
security = user<br />
map to guest = bad user<br />
guest account = guest<br />
<br />
[guest]<br />
comment = guest<br />
path = /tmp/<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
Any anonymous users will now be mapped to the Linux user {{ic|guest}} and have the ability to access any directories defined in {{ic|guest.path}}, for example, {{ic|/tmp/}} in the configuration above.<br />
<br />
Make sure shares have been properly defined as per the ''Share Definitions'' section of [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD smb.conf.default].<br />
<br />
=== Enable symlink following ===<br />
<br />
{{Warning|Enabling the {{ic|follow symlinks}} option can be a security risk.}}<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[global]<br />
follow symlinks = yes<br />
wide links = yes<br />
unix extensions = no<br />
}}<br />
<br />
Then, [[restart]] {{ic|smb.service}}.<br />
<br />
{{Note|When using [[AppArmor]], if the symlink points to a directory outside the user's home or the [[#Enable Usershares|usershare]] directory, then you need to [[#Permission issues on AppArmor|modify the AppArmor profile permissions]].}}<br />
<br />
=== Advanced Configuration ===<br />
<br />
==== Enable Usershares ====<br />
<br />
{{Note|This is an optional feature. Skip this section if you do not need it.}}<br />
<br />
[https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html Usershares]<br />
is a feature that gives non-root users the capability to add, modify, and delete their own share definitions. <br />
<br />
# Create a directory for usershares: {{bc|# mkdir /var/lib/samba/usershares}}<br />
# Create a [[user group]]: {{bc|# groupadd -r sambashare}}<br />
# Change the owner of the directory to {{ic|root}} and the group to {{ic|sambashare}}: {{bc|# chown root:sambashare /var/lib/samba/usershares}}<br />
# Change the permissions of the {{ic|usershares}} directory so that users in the group {{ic|sambashare}} can read, write and execute files: {{bc|# chmod 1770 /var/lib/samba/usershares}}<br />
<br />
Set the following parameters in the {{ic|smb.conf}} configuration file: <br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
usershare path = /var/lib/samba/usershares<br />
usershare max shares = 100<br />
usershare allow guests = yes<br />
usershare owner only = yes<br />
}}<br />
<br />
Add the user to the ''sambashare'' group. Replace {{ic|''your_username''}} with the name of your user:<br />
<br />
# gpasswd sambashare -a ''your_username''<br />
<br />
[[Restart]] {{ic|smb.service}} and {{ic|nmb.service}} services.<br />
<br />
Log out and log back in.<br />
<br />
If you want to share paths inside your home directory you must make it accessible for the group ''others''.<br />
<br />
In the GUI, you can use [[Thunar]] or [[Dolphin]] - right click on any directory and share it on the network. <br />
<br />
In the CLI, use one of the following commands, replacing italic ''sharename'', ''user'', ... :<br />
<br />
# net usershare add ''sharename'' ''abspath'' [''comment''] [''user'':{R|D|F}] [guest_ok={y|n}]<br />
# net usershare delete ''sharename''<br />
# net usershare list ''wildcard-sharename''<br />
# net usershare info ''wildcard-sharename''<br />
<br />
==== Set and forcing permissions ====<br />
<br />
Permissions may be applied to both the server and shares:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
;inherit owner = unix only ; Inherit ownership of the parent directory for new files and directories<br />
;inherit permissions = yes ; Inherit permissions of the parent directory for new files and directories<br />
create mask = 0664<br />
directory mask = 2755<br />
force create mode = 0644<br />
force directory mode = 2755<br />
...<br />
<br />
[media]<br />
comment = Media share accessible by ''greg'' and ''pcusers''<br />
path = ''/path/to/media''<br />
valid users = ''greg @pcusers''<br />
force group = ''+pcusers''<br />
public = no<br />
writable = yes<br />
create mask = 0664<br />
directory mask = 2775<br />
force create mode = 0664<br />
force directory mode = 2775<br />
<br />
[public]<br />
comment = Public share where ''archie'' has write access<br />
path = ''/path/to/public''<br />
public = yes<br />
read only = yes<br />
write list = ''archie''<br />
printable = no<br />
<br />
[guests]<br />
comment = Allow all users to read/write<br />
path = ''/path/to/guests''<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
See {{man|5|smb.conf}} for a full overview of possible permission flags and settings.<br />
<br />
==== Restrict protocols for better security ====<br />
<br />
{{Warning|By default, Samba versions prior to 4.11 allow connections using the outdated and insecure SMB1 protocol. When using one these Samba versions, it is highly recommended to set {{ic|1=server min protocol = SMB2_02}} to protect yourself from ransomware attacks. In Samba 4.11 and newer, SMB2 is the default min protocol, so no changes are required there.}}<br />
<br />
[[Append]] {{ic|server min protocol}} and {{ic|server max protocol}} in {{ic|/etc/samba/smb.conf}} to force usage of a minimum and maximum protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server min protocol = SMB2_02<br />
; server max protocol = SMB3<br />
}}<br />
<br />
See {{ic|server max protocol}} in {{man|5|smb.conf}} for an overview of supported protocols.<br />
<br />
For compatibility with older clients and/or servers, you might need to set {{ic|1=client min protocol = CORE}} or {{ic|1=server min protocol = CORE}}, but please note that this makes you vulnerable to exploits in SMB1 including ransomware attacks.<br />
<br />
{{Tip|Use {{ic|1=server min protocol = SMB3_00}} when clients should only connect using the latest SMB3 protocol, e.g. on clients running Windows 8 and later.}}<br />
<br />
[[#Manual mounting|Clients]] using {{ic|mount.cifs}} may need to specify the correct {{ic|1=vers=*}}, e.g.:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',iocharset=''utf8'',vers=''3.1.1''<br />
<br />
See {{man|8|mount.cifs}} for more information.<br />
<br />
==== Use native SMB transport encryption ====<br />
<br />
Native SMB transport encryption is available in SMB version 3.0 or newer. Clients supporting this type of encryption include Windows 8 and newer, Windows server 2012 and newer, and smbclient of Samba 4.1 and newer.<br />
<br />
To use native SMB transport encryption by default, set the {{ic|server smb encrypt}} parameter globally and/or by share. Possible values are {{ic|off}}, {{ic|enabled}} (default value), {{ic|desired}}, or {{ic|required}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server smb encrypt = desired<br />
}}<br />
<br />
To configure encryption for on the client side, use the option {{ic|client smb encrypt}}.<br />
<br />
See {{man|5|smb.conf}} for more information, especially the paragraphs ''Effects for SMB1'' and ''Effects for SMB2''.<br />
<br />
{{Tip|When [[#Manual mounting|mounting]] a share, specify the {{ic|seal}} mount option to force usage of encryption.}}<br />
<br />
==== Disable printer sharing ====<br />
<br />
By default Samba shares printers configured using [[CUPS]].<br />
<br />
If you do not want printers to be shared, use the following settings:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = no<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = yes<br />
show add printer wizard = no<br />
}}<br />
<br />
==== Block certain file extensions on Samba share ====<br />
<br />
{{Note|Setting this parameter will affect the performance of Samba, as it will be forced to check all files and directories for a match as they are scanned.}}<br />
<br />
Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files. More information about this option can be found in {{man|5|smb.conf}}.<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[myshare]<br />
comment = Private<br />
path = /mnt/data<br />
read only = no<br />
veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/<br />
}}<br />
<br />
==== Improve throughput ====<br />
<br />
{{Warning|Beware this may lead to corruption/connection issues and potentially cripple your TCP/IP stack.}}<br />
<br />
The default settings should be sufficient for most users. However setting the 'socket options' correct can improve performance, but getting them wrong can degrade it by just as much. Test the effect before making any large changes.<br />
<br />
Read the {{man|5|smb.conf}} man page before applying any of the options listed below.<br />
<br />
The following settings should be [[Append|appended]] to the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}.<br />
<br />
SMB3 multi-channel may improve performance, however it may result in data corruption under some rare conditions. Future releases may improve this situation:<br />
<br />
server multi channel support = yes<br />
<br />
Setting a deadtime is useful to stop a server's resources from being exhausted by a large number of inactive connections:<br />
<br />
deadtime = 30<br />
<br />
The usage of sendfile may make more efficient use of the system CPU's and cause Samba to be faster:<br />
<br />
use sendfile = yes<br />
<br />
Setting min receivefile size allows zero-copy writes directly from network socket buffers into the filesystem buffer cache (if available). It may improve performance but user testing is recommended:<br />
<br />
min receivefile size = 16384<br />
<br />
Reading/writing files asynchronously may improve performance instead of using synchronous writes:<br />
<br />
aio read size = 1<br />
aio write size = 1<br />
<br />
Increasing the receive/send buffers size and socket optimize flags might be useful to improve throughput. It is recommended to test each flag separately as it may cause issues on some networks:<br />
<br />
socket options = IPTOS_LOWDELAY TCP_NODELAY IPTOS_THROUGHPUT SO_RCVBUF=131072 SO_SNDBUF=131072<br />
<br />
{{Note|Network-interface adjustments may be needed for some options to work, see [[Sysctl#Networking]].}}<br />
<br />
==== Enable access for old clients/devices ====<br />
<br />
Latest versions of Samba no longer offer older authentication methods and protocols which are still used by some older clients (IP cameras, etc). These devices usually require Samba server to allow NTMLv1 authentication and NT1 version of the protocol, known as CIFS. For these devices to work with latest Samba, you need to add these two configuration parameters into {{ic|[global]}} section:<br />
<br />
server min protocol = NT1<br />
ntlm auth = yes<br />
<br />
Anonymous/guest access to a share requires just the first parameter. If the old device will access with username and password, you also need the add the second line too.<br />
<br />
==== Enable Spotlight searching ====<br />
<br />
Spotlight allows supporting clients (e.g. MacOS Finder) to quickly search shared files.<br />
<br />
Install and start/enable [[OpenSearch]]. Install {{aur|fs2es-indexer}}, configure the directories you want to index in {{ic|/etc/fs2es-indexer/config.yml}}, and start/enable {{ic|fs2es-indexer.service}} for periodic indexing.<br />
<br />
Edit {{ic|smb.conf}} as described in the [https://wiki.samba.org/index.php/Spotlight_with_Elasticsearch_Backend#Samba Samba wiki] to enable Spotlight per share, and restart {{ic|smb.service}} to apply the changes.<br />
<br />
== Client ==<br />
<br />
Install {{Pkg|smbclient}} for an {{ic|ftp}}-like command line interface. See {{man|1|smbclient}} for commonly used commands.<br />
<br />
For a lightweight alternative (without support for listing public shares, etc.), [[install]] {{Pkg|cifs-utils}} that provides {{ic|/usr/bin/mount.cifs}}.<br />
<br />
Depending on the [[desktop environment]], GUI methods may be available. See [[#File manager configuration]] for use with a file manager.<br />
<br />
{{Note|<br />
* {{Pkg|smbclient}} requires a {{ic|/etc/samba/smb.conf}} file (see [[#Installation]]), which you can create as an empty file using the {{ic|touch}} utility.<br />
* After installing {{Pkg|cifs-utils}} or {{Pkg|smbclient}}, load the {{ic|cifs}} [[kernel module]] or reboot to prevent mount fails.<br />
}}<br />
<br />
=== List public shares ===<br />
<br />
The following command lists public shares on a server:<br />
<br />
$ smbclient -L ''hostname'' -U%<br />
<br />
Alternatively, running {{ic|$ smbtree -N}} will show a tree diagram of all the shares. It uses broadcast queries and is therefore not advisable on a network with a lot of computers, but can be helpful for diagnosing if you have the correct sharename. The {{ic|-N}} ({{ic|-no-pass}}) option suppresses the password prompt.<br />
<br />
=== NetBIOS/WINS host names ===<br />
<br />
Samba clients handle NetBIOS host names automatically by default (the behavior is controlled by the {{ic|name resolve order}} option in {{ic|smb.conf}}). Other programs (including {{ic|mount.cifs}}) typically use [[Domain name resolution#Name Service Switch|Name Service Switch]], which does not handle NetBIOS by default.<br />
<br />
The {{Pkg|smbclient}} package provides a libnss driver to resolve NetBIOS host names. To use it, [[install]] it along with the {{Pkg|samba}} package (which provides the ''winbindd'' daemon), [[start/enable]] {{ic|winbind.service}} and add {{ic|wins}} to the {{ic|hosts}} line in {{man|5|nsswitch.conf}}:<br />
<br />
{{hc|/etc/nsswitch.conf|2=<br />
...<br />
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns '''wins'''<br />
...<br />
}}<br />
<br />
{{Note|Due to a current mistake in {{ic|winbind.service}}, you may have to modify the unit file as described in this [https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1789097 bug-report]}}<br />
<br />
Now, during host resolving (e.g. when using {{ic|mount.cifs}} or just {{ic|ping ''netbios-name''}}), ''winbindd'' will resolve the host name by sending queries using NetBIOS Name Service (NBNS, also known as WINS) protocol.<br />
<br />
By default it sends a broadcast query to your local network. If you have a WINS server, you can add {{ic|1=wins server = ''wins-server-ip''}} to {{ic|smb.conf}} and [[restart]] {{ic|winbind.service}}, then ''winbindd'' and other Samba clients will send unicast queries to the specified IP.<br />
<br />
If you want to resolve your local host name (specified in the {{ic|netbios name}} option in {{ic|smb.conf}}), [[start/enable]] {{ic|nmb.service}}, which will handle incoming queries.<br />
<br />
You can test WINS resolution with {{ic|nmblookup}}. By default it sends broadcast queries to your local network regardless of the {{ic|wins server}} option.<br />
<br />
Note that WINS resolution requires incoming traffic originating from port 137.<br />
<br />
==== Disable NetBIOS/WINS support ====<br />
<br />
When not using NetBIOS/WINS host name resolution, it may be preferred to disable this protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
disable netbios = yes<br />
dns proxy = no<br />
}}<br />
<br />
Finally [[disable]]/[[stop]] {{ic|winbind.service}}.<br />
<br />
=== Manual mounting ===<br />
<br />
Create a mount point for the share:<br />
<br />
# mkdir /mnt/''mountpoint''<br />
<br />
Mount the share using {{ic|mount.cifs}} as {{ic|type}}. Not all the options listed below are needed or desirable:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',workgroup=''workgroup'',iocharset=''utf8'',uid=''username'',gid=''group''<br />
<br />
The options {{ic|uid}} and {{ic|gid}} corresponds to the local (e.g. client) [[user]]/[[user group]] to have read/write access on the given path.<br />
<br />
{{Note|<br />
* If the {{ic|uid}} and {{ic|gid}} being used does not match the user of the server, the {{ic|forceuid}} and {{ic|forcegid}} options may be helpful. However note permissions assigned to a file when {{ic|forceuid}} or {{ic|forcegid}} are in effect may not reflect the the real (server) permissions. See the ''File And Directory Ownership And Permissions'' section in {{man|8|mount.cifs|FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS}} for more information.<br />
* To allow users to mount it as long as the mount point resides in a directory controllable by the user; i.e. the user's home, append the {{ic|users}} mount option. The option is user'''s''' (plural). For other filesystem types handled by mount, this option is usually ''user''; sans the "'''s'''".<br />
* To mount a Windows share without authentication, use {{ic|1="username=*"}}.<br />
}}<br />
<br />
{{Warning|Using {{ic|uid}} and/or {{ic|gid}} as mount options may cause I/O errors, it is recommended to set/check correct [[File permissions and attributes]] instead.}}<br />
<br />
* {{ic|''SERVER''}} — The server name.<br />
* {{ic|''sharename''}} — The shared directory.<br />
* {{ic|''mountpoint''}} — The local directory where the share will be mounted.<br />
* {{ic|[-o ''options'']}} — See {{man|8|mount.cifs}} for more information.<br />
<br />
{{Note|<br />
* Abstain from using a trailing {{ic|/}}. {{ic|//''SERVER''/''sharename'''''/'''}} will not work.<br />
* If your mount does not work stable, stutters or freezes, try to enable different SMB protocol version with {{ic|1=vers=}} option. For example, {{ic|1=vers=2.0}} for Windows Vista mount.<br />
* If having timeouts on a mounted network share with cifs on a shutdown, see [[wpa_supplicant#Problem with mounted network shares (cifs) and shutdown]].<br />
}}<br />
<br />
==== Storing share passwords ====<br />
<br />
Storing passwords in a world readable file is not recommended. A safer method is to use a credentials file instead, e.g. inside {{ic|/etc/samba/credentials}}:<br />
<br />
{{hc|/etc/samba/credentials/share|2=<br />
username=''myuser''<br />
password=''mypass''<br />
}}<br />
<br />
For the mount command replace {{ic|1=username=myuser,password=mypass}} with {{ic|1=credentials=/etc/samba/credentials/share}}.<br />
<br />
The credential file should explicitly readable/writeable to root:<br />
<br />
# chown root:root /etc/samba/credentials<br />
# chmod 700 /etc/samba/credentials<br />
# chmod 600 /etc/samba/credentials/share<br />
<br />
=== Automatic mounting ===<br />
<br />
{{Note|You may need to [[enable]] {{ic|systemd-networkd-wait-online.service}} or {{ic| NetworkManager-wait-online.service}} (depending on your setup) to proper enable booting on start-up.}}<br />
<br />
==== Using NetworkManager and GIO/gvfs ====<br />
<br />
[[NetworkManager#Network services with NetworkManager dispatcher|NetworkManager]] can be configured to run a script on network status change. This script uses the ''gio'' command so that it mounts the Samba shares automatically, the same way your file manager does, as explained [[#File manager configuration|below]]. The script also safely unmounts the Samba shares before the relevant network connection is disabled by listening for the {{ic|pre-down}} and {{ic|vpn-pre-down}} events. Make the script is [[executable]] after creating it.<br />
<br />
{{hc|/etc/NetworkManager/dispatcher.d/30-samba.sh|<nowiki><br />
#!/bin/bash<br />
<br />
# Find the connection UUID with "nmcli con show" in terminal.<br />
# All NetworkManager connection types are supported: wireless, VPN, wired...<br />
WANTED_CON_UUID="CHANGE-ME-NOW-9c7eff15-010a-4b1c-a786-9b4efa218ba9"<br />
<br />
# The user the share will be mounted under<br />
USER="yourusername"<br />
# The path that appears in your file manager when you manually mount the share you want<br />
SMB_URL="smb://servername/share"<br />
<br />
if [[ "$CONNECTION_UUID" == "$WANTED_CON_UUID" ]]; then<br />
<br />
# Script parameter $1: NetworkManager connection name, not used<br />
# Script parameter $2: dispatched event<br />
<br />
case "$2" in<br />
"up")<br />
su $USER -c "DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus gio mount $SMB_URL"<br />
;;<br />
"pre-down");&<br />
"vpn-pre-down")<br />
su $USER -c "DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus gio mount -uf $SMB_URL"<br />
;;<br />
esac<br />
fi<br />
</nowiki>}}<br />
<br />
Create a symlink inside {{ic|/etc/NetworkManager/dispatcher.d/pre-down}} to catch the {{ic|pre-down}} events:<br />
<br />
# ln -s /etc/NetworkManager/dispatcher.d/30-samba.sh /etc/NetworkManager/dispatcher.d/pre-down.d/30-samba.sh<br />
<br />
==== As mount entry ====<br />
<br />
This is a simple example of a {{ic|cifs}} [[fstab|mount entry]] that requires authentication:<br />
<br />
{{hc|/etc/fstab|2=<br />
//''SERVER''/''sharename'' /mnt/''mountpoint'' cifs _netdev,nofail,username=''myuser'',password=''mypass'' 0 0<br />
}}<br />
<br />
{{Note|Spaces in sharename should be replaced by {{ic|\040}} (ASCII code for space in octal). For example, {{ic|//''SERVER''/share name}} on the command line should be {{ic|//''SERVER''/share\040name}} in {{ic|/etc/fstab}}.}}<br />
<br />
{{Tip|Use {{ic|x-systemd.automount}} if you want them to be mounted only upon access. See [[Fstab#Remote file system]] for details.}}<br />
<br />
==== As systemd unit ====<br />
<br />
Create a new {{ic|.mount}} file inside {{ic|/etc/systemd/system}}, e.g. {{ic|mnt-myshare.mount}}. See {{man|5|systemd.mount}} for details.<br />
<br />
{{Note|Make sure the filename corresponds to the mountpoint you want to use.<br />
E.g. the unit name {{ic|mnt-myshare.mount}} can only be used if are going to mount the share under {{ic|/mnt/myshare}}. Otherwise the following error might occur: {{ic|1=systemd[1]: mnt-myshare.mount: Where= setting does not match unit name. Refusing.}}.}}<br />
<br />
{{ic|1=What=}} path to share<br />
<br />
{{ic|1=Where=}} path to mount the share<br />
<br />
{{ic|1=Options=}} share mounting options<br />
<br />
{{Note|<br />
* Network mount units automatically acquire {{ic|After}} dependencies on {{ic|remote-fs-pre.target}}, {{ic|network.target}} and {{ic|network-online.target}}, and gain a {{ic|Before}} dependency on {{ic|remote-fs.target}} unless {{ic|nofail}} mount option is set. Towards the latter a {{ic|Wants}} unit is added as well.<br />
* [[Append]] {{ic|noauto}} to {{ic|Options}} preventing automatically mount during boot (unless it is pulled in by some other unit).<br />
* If you want to use a hostname for the server you want to share (instead of an IP address), add {{ic|1=nss-lookup.target}} to {{ic|1=After}}. This might avoid mount errors at boot time that do not arise when testing the unit.<br />
}} <br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.mount|2=<br />
[Unit]<br />
Description=Mount Share at boot<br />
<br />
[Mount]<br />
What=//server/share<br />
Where=/mnt/myshare<br />
Options=_netdev,credentials=/etc/samba/credentials/myshare,iocharset=utf8,rw<br />
Type=cifs<br />
TimeoutSec=30<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
{{Tip|<br />
* In case of an unreachable system, [[append]] {{ic|1=ForceUnmount=true}} to {{ic|[Mount]}}, allowing the share to be (force-)unmounted.<br />
* If your share has groups with read-only access, [[append]] {{ic|1=uid=''username''}} or {{ic|1=gid=''group''}} to {{ic|1=Options=}}, to specify your user / group allowing writing to the share.<br />
}}<br />
<br />
To use {{ic|mnt-myshare.mount}}, [[start]] the unit and [[enable]] it to run on system boot.<br />
<br />
===== automount =====<br />
<br />
To automatically mount a share (when accessed, like autofs), one may use the following automount unit:<br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.automount|2=<br />
[Unit]<br />
Description=Automount myshare<br />
<br />
[Automount]<br />
Where=/mnt/myshare<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
[[Disable]]/[[stop]] the {{ic|mnt-myshare.mount}} unit, and [[enable]]/[[start]] {{ic|mnt-myshare.automount}} to automount the share when the mount path is being accessed.<br />
<br />
{{Tip|[[Append]] {{ic|TimeoutIdleSec}} to enable auto unmount. See {{man|5|systemd.automount}} for details.}}<br />
<br />
==== smbnetfs ====<br />
<br />
{{Note|1=smbnetfs needs an intact Samba server setup.<br />
<br />
See above on how to do that.}}<br />
<br />
First, check if you can see all the shares you are interested in mounting:<br />
<br />
$ smbtree -U ''remote_user''<br />
<br />
If that does not work, find and modify the following line<br />
in {{ic|/etc/samba/smb.conf}} accordingly:<br />
<br />
domain master = auto<br />
<br />
Now [[restart]] {{ic|smb.service}} and {{ic|nmb.service}}.<br />
<br />
If everything works as expected, [[pacman#Installing specific packages|install]] {{Pkg|smbnetfs}} from the official repositories.<br />
<br />
Then, add the following line to {{ic|/etc/fuse.conf}}:<br />
<br />
user_allow_other<br />
<br />
Now copy the directory {{ic|/etc/smbnetfs/.smb}} to your home directory:<br />
<br />
$ cp -a /etc/smbnetfs/.smb ~<br />
<br />
Then create a link to {{ic|smb.conf}}:<br />
<br />
$ ln -sf /etc/samba/smb.conf ~/.smb/smb.conf<br />
<br />
If a username and a password are required to access some of the shared folders, edit {{ic|~/.smb/smbnetfs.auth}}<br />
to include one or more entries like this:<br />
<br />
{{hc|~/.smb/smbnetfs.auth|<br />
auth "hostname" "username" "password"<br />
}}<br />
<br />
It is also possible to add entries for specific hosts to be mounted by smbnetfs, if necessary.<br />
More details can be found in {{ic|~/.smb/smbnetfs.conf}}.<br />
<br />
If you are using the [[Dolphin]] or [[GNOME Files]], you may want to add the following to {{ic|~/.smb/smbnetfs.conf}} to avoid "Disk full" errors as smbnetfs by default will report 0 bytes of free space:<br />
<br />
{{hc|~/.smb/smbnetfs.conf|<br />
free_space_size 1073741824<br />
}}<br />
<br />
When you are done with the configuration, you need to run<br />
<br />
$ chmod 600 ~/.smb/smbnetfs.*<br />
<br />
Otherwise, smbnetfs complains about 'insecure config file permissions'.<br />
<br />
Finally, to mount your Samba network neighbourhood to a directory of your choice, call<br />
<br />
$ smbnetfs ''mount_point''<br />
<br />
===== Daemon =====<br />
<br />
The Arch Linux package also maintains an additional system-wide operation mode for smbnetfs. To enable it, you need to make the<br />
said modifications in the directory {{ic|/etc/smbnetfs/.smb}}.<br />
<br />
Then, you can start and/or enable the {{ic|smbnetfs}} [[daemon]] as usual. The system-wide mount point is at {{ic|/mnt/smbnet/}}.<br />
<br />
==== autofs ====<br />
<br />
See [[Autofs]] for information on the kernel-based automounter for Linux.<br />
<br />
=== File manager configuration ===<br />
<br />
==== GNOME Files, Nemo, Caja, Thunar and PCManFM ====<br />
<br />
In order to access samba shares through GNOME Files, Nemo, Caja, Thunar or PCManFM, install the {{Pkg|gvfs-smb}} package, available in the [[official repositories]].<br />
<br />
Press {{ic|Ctrl+l}} and enter {{ic|smb://''servername''/''share''}} in the location bar to access your share.<br />
<br />
The mounted share is likely to be present at {{ic|/run/user/''your_UID''/gvfs}} or {{ic|~/.gvfs}} in the filesystem.<br />
<br />
==== KDE ====<br />
<br />
KDE applications (like Dolphin) has the ability to browse Samba shares built in. Use the path {{ic|smb://''servername''/''share''}} to browse the files. If you want to access files from on non-KDE application, you can install {{Pkg|kio-fuse}}.<br />
<br />
To use a GUI in the KDE System Settings, you will need to install the {{Pkg|kdenetwork-filesharing}} package.<br />
<br />
==== Other graphical environments ====<br />
<br />
There are a number of useful programs, but they may need to have packages created for them. This can be done with the Arch package build system. The good thing about these others is that they do not require a particular environment to be installed to support them, and so they bring along less baggage.<br />
<br />
* {{AUR|pyneighborhood}} is available in the official repositories.<br />
* LinNeighborhood, RUmba, xffm-samba plugin for Xffm are not available in the official repositories or the AUR. As they are not officially (or even unofficially supported), they may be obsolete and may not work at all.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Discovering network shares ===<br />
<br />
If nothing is known about other systems on the local network, and automated tools such as [[#smbnetfs|smbnetfs]] are not available, the following methods allow one to manually probe for Samba shares.<br />
<br />
1. First, [[install]] the {{Pkg|nmap}} and {{Pkg|smbclient}} packages.<br />
<br />
2. {{ic|nmap}} checks which ports are open:<br />
<br />
# nmap -p 139 -sT "192.168.1.*"<br />
<br />
In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:<br />
<br />
{{hc|$ nmap -sT "192.168.1.*"|<nowiki><br />
Starting nmap 3.78 ( http://www.insecure.org/nmap/ ) at 2005-02-15 11:45 PHT<br />
Interesting ports on 192.168.1.1:<br />
(The 1661 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
'''139/tcp open netbios-ssn'''<br />
5000/tcp open UPnP<br />
<br />
Interesting ports on 192.168.1.5:<br />
(The 1662 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
6000/tcp open X11<br />
<br />
Nmap run completed -- 256 IP addresses (2 hosts up) scanned in 7.255 seconds<br />
</nowiki>}}<br />
<br />
The first result is another system; the second happens to be the client from where this scan was performed.<br />
<br />
3. Now that systems with port 139 open are revealed, use {{man|1|nmblookup}} to check for NetBIOS names: <br />
<br />
{{hc|$ nmblookup -A 192.168.1.1|<br />
Looking up status of 192.168.1.1<br />
PUTER <00> - B <ACTIVE><br />
HOMENET <00> - <GROUP> B <ACTIVE><br />
PUTER <03> - B <ACTIVE><br />
'''PUTER <20> - B <ACTIVE>'''<br />
HOMENET <1e> - <GROUP> B <ACTIVE><br />
USERNAME <03> - B <ACTIVE><br />
HOMENET <1d> - B <ACTIVE><br />
MSBROWSE <01> - <GROUP> B <ACTIVE><br />
}}<br />
<br />
Regardless of the output, look for '''<20>''', which shows the host with open services.<br />
<br />
4. Use {{ic|smbclient}} to list which services are shared on ''PUTER''. If prompted for a password, pressing enter should still display the list:<br />
<br />
{{hc|$ smbclient -L \\PUTER|<nowiki><br />
Sharename Type Comment<br />
--------- ---- -------<br />
MY_MUSIC Disk<br />
SHAREDDOCS Disk<br />
PRINTER$ Disk<br />
PRINTER Printer<br />
IPC$ IPC Remote Inter Process Communication<br />
<br />
Server Comment<br />
--------- -------<br />
PUTER<br />
<br />
Workgroup Master<br />
--------- -------<br />
HOMENET PUTER<br />
</nowiki>}}<br />
<br />
=== Remote control of Windows computer ===<br />
<br />
Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.<br />
<br />
Send shutdown command with a comment:<br />
<br />
$ net rpc shutdown -C "comment" -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.<br />
<br />
Stop and start services:<br />
<br />
$ net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
To see all possible net rpc command:<br />
<br />
$ net rpc<br />
<br />
== Troubleshooting ==<br />
<br />
=== Failed to start Samba SMB/CIFS server ===<br />
<br />
Possible solutions:<br />
<br />
* Check {{ic|smb.conf}} on syntactic errors with {{man|1|testparm}}.<br />
* Set correct permissions for {{ic|/var/cache/samba/}} and [[restart]] {{ic|smb.service}}:<br />
<br />
# chmod 0755 /var/cache/samba/msg<br />
<br />
=== Permission issues on SELinux ===<br />
<br />
[[SELinux]] not allow samba to access user home directories by default, to solve this, run:<br />
<br />
# setsebool -P samba_enable_home_dirs 1<br />
<br />
Similarly, {{ic|samba_export_all_ro}} and {{ic|samba_export_all_rw}} make [[Samba]] has the ability to read or "read and write" all files.<br />
<br />
=== Permission issues on AppArmor ===<br />
<br />
If using a [[#Creating an anonymous share|share path]] located outside of a home or usershares directory, whitelist it in {{ic|/etc/apparmor.d/local/usr.sbin.smbd}}. E.g.:<br />
<br />
{{hc|/etc/apparmor.d/local/usr.sbin.smbd|<br />
"/data/" rk,<br />
"/data/**" lrwk,<br />
}}<br />
<br />
=== No dialect specified on mount ===<br />
<br />
The client is using an unsupported SMB/CIFS version that is required by the server.<br />
<br />
See [[#Restrict protocols for better security]] for more information.<br />
<br />
=== Unable to overwrite files, permissions errors ===<br />
<br />
{{Accuracy|An user should set/check for server/client permissions, instead of using incorrect/possible insecure flags.}}<br />
<br />
Possible solutions:<br />
<br />
* Append the mount option {{ic|nodfs}} to the {{ic|/etc/fstab}} [[#As mount entry|entry]].<br />
* Add {{ic|1=msdfs root = no}} to the {{ic|[global]}} section of the server's {{ic|/etc/samba/smb.conf}}.<br />
<br />
=== Windows clients keep asking for password even if Samba shares are created with guest permissions ===<br />
<br />
Set {{ic|map to guest}} inside the {{ic|global}} section of {{ic|/etc/samba/smb.conf}}:<br />
<br />
map to guest = Bad User<br />
<br />
From Samba 4.10.10 you should use {{ic|Bad Password}} instead {{ic|Bad User}}.<br />
<br />
=== Windows 7 connectivity problems - mount error(12): cannot allocate memory ===<br />
<br />
A known Windows 7 bug that causes "mount error(12): cannot allocate memory" on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:<br />
<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache}} (set to {{ic|1}})<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size}} (set to {{ic|3}})<br />
<br />
Alternatively, start Command Prompt in Admin Mode and execute the following:<br />
<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f<br />
<br />
Do one of the following for the settings to take effect:<br />
<br />
* Restart Windows<br />
* Restart the Server service via services.msc<br />
* From the Command Prompt run: 'net stop lanmanserver' and 'net start lanmanserver' - The server may automatically restart after stopping it.<br />
<br />
{{Note|Googling will reveal another tweak recommending users to add a key modifying the "IRPStackSize" size. This is incorrect for fixing this issue under Windows 7. Do not attempt it.}}<br />
<br />
[https://web.archive.org/web/20150819153712/http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017/ Original article].<br />
<br />
=== Windows 10 1709 and up connectivity problems - "Windows cannot access" 0x80004005 ===<br />
<br />
This error affects some machines running Windows 10 version 1709 and later. It is not related to SMB1 being disabled in this version but to the fact that Microsoft disabled insecure logons for guests on this version for some, but not others.<br />
<br />
To fix, open Group Policy Editor ({{ic|gpedit.msc}}). Navigate to ''Computer configuration\administrative templates\network\Lanman Workstation > Enable insecure guest logons'' and enable it.<br />
Alternatively,change the following value in the registry:<br />
<br />
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]<br />
"AllowInsecureGuestAuth"=dword:1<br />
<br />
=== Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL ===<br />
<br />
If you are a home user and using samba purely for file sharing from a server or NAS, you are probably not interested in sharing printers through it. If so, you can prevent this error from occurring by adding the following lines to your {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = No<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = Yes<br />
}}<br />
<br />
[[Restart]] the samba service, {{ic|smb.service}}, and then check your logs:<br />
<br />
# cat /var/log/samba/smbd.log<br />
<br />
and the error should now no longer be appearing.<br />
<br />
=== Sharing a folder fails ===<br />
<br />
It means that while you are sharing a folder from ''Dolphin'' (file manager) and everything seems ok at first, after restarting ''Dolphin'' the share icon is gone from the shared folder, and also some output like this in terminal (''Konsole'') output:<br />
<br />
‘net usershare’ returned error 255: net usershare: usershares are currently disabled<br />
<br />
To fix it, enable usershare as described in [[#Enable Usershares]].<br />
<br />
=== "Browsing" network fails with "Failed to retrieve share list from server" ===<br />
<br />
And you are using a firewall (iptables) because you do not trust your local (school, university, hotel) network. This may be due to the following: When the smbclient is browsing the local network it sends out a broadcast request on udp port 137. The servers on the network then reply to your client but as the source address of this reply is different from the destination address iptables saw when sending the request for the listing out, iptables will not recognize the reply as being "ESTABLISHED" or "RELATED", and hence the packet is dropped. A possible solution is to add:<br />
<br />
iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns<br />
<br />
to your iptables setup.<br />
<br />
For [[Uncomplicated Firewall]], you need to add {{ic|nf_conntrack_netbios_ns}} to the end of the following line in {{ic|/etc/default/ufw}}<br />
<br />
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc"<br />
<br />
and then run the following commands as root:<br />
<br />
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper<br />
ufw allow CIFS<br />
ufw reload<br />
<br />
To make this change persistent across reboots, add the following line at the end of {{ic|/etc/ufw/sysctl.conf}}:<br />
<br />
net.netfilter.nf_conntrack_helper=1<br />
<br />
=== Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE ===<br />
<br />
The client probably does not have access to shares. Make sure clients' IP address is in {{ic|1=hosts allow =}} line in {{ic|/etc/samba/smb.conf}}.<br />
<br />
Another problem could be, that the client uses an invalid protocol version. To check this try to connect with the {{ic|smbclient}} where you specify the maximum protocol version manually:<br />
<br />
$ smbclient -U <user name> -L //<server name> -m <protocol version: e. g. SMB2> -W <domain name><br />
<br />
If the command was successful then create a configuration file:<br />
<br />
{{hc|~/.smb/smb.conf|output=<br />
[global]<br />
workgroup = <domain name><br />
client max protocol = SMB2<br />
}}<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL) ===<br />
<br />
You are probably passing a wrong server name to {{ic|smbclient}}. To find out the server name, run {{ic|hostnamectl}} on the server and look at "Transient hostname" line<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED) ===<br />
<br />
Make sure that the server has started. The shared directories should exist and be accessible.<br />
<br />
=== Protocol negotiation failed: NT_STATUS_CONNECTION_RESET ===<br />
<br />
Probably the server is configured not to accept protocol SMB1. Add option {{ic|1=client max protocol = SMB2}} in {{ic|/etc/samba/smb.conf}}.<br />
Or just pass argument {{ic|-m SMB2}} to {{ic|smbclient}}.<br />
<br />
=== Password Error when correct credentials are given (error 1326) ===<br />
<br />
[https://www.samba.org/samba/history/samba-4.5.0.html Samba 4.5] has NTLMv1 authentication disabled by default. It is recommend to install the latest available upgrades on clients and deny access for unsupported clients.<br />
<br />
If you still need support for very old clients without NTLMv2 support (e.g. Windows XP), it is possible force enable NTLMv1, although this is '''not recommend''' for security reasons:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
lanman auth = yes<br />
ntlm auth = yes<br />
}}<br />
<br />
If NTLMv2 clients are unable to authenticate when NTLMv1 has been enabled, create the following file on the client:<br />
{{hc|/home/user/.smb/smb.conf|2=<br />
[global]<br />
sec = ntlmv2<br />
client ntlmv2 auth = yes<br />
}}<br />
<br />
This change also affects samba shares mounted with '''mount.cifs'''. If after upgrade to Samba 4.5 your mount fails, add the '''sec=ntlmssp''' option to your mount command, e.g.<br />
<br />
mount.cifs //server/share /mnt/point -o sec=ntlmssp,...<br />
<br />
See the {{man|8|mount.cifs}} man page: '''ntlmssp''' - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message. The default in mainline kernel versions prior to v3.8 was '''sec=ntlm'''. In v3.8, the default was changed to '''sec=ntlmssp'''.<br />
<br />
=== Mapping reserved Windows characters ===<br />
<br />
Starting with kernel 3.18, the cifs module uses the [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2baa2682531ff02928e2d3904800696d9e7193db "mapposix" option by default].<br />
When mounting a share using unix extensions and a default Samba configuration, files and directories containing one of the seven reserved Windows characters {{ic|: \ * < > ? |}} are listed but cannot be accessed.<br />
<br />
Possible solutions are:<br />
<br />
* Use the undocumented {{ic|nomapposix}} mount option for cifs<br />
<br />
# mount.cifs //server/share /mnt/point -o nomapposix<br />
<br />
* Configure Samba to remap {{ic|mapposix}} ("SFM", Services for Mac) style characters to the correct native ones using [https://www.mankier.com/8/vfs_fruit fruit]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia fruit<br />
fruit:encoding = native<br />
}}<br />
<br />
* Manually remap forbidden characters using [https://www.mankier.com/8/vfs_catia catia]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia<br />
catia:mappings = 0x22:0xf022, 0x2a:0xf02a, 0x2f:0xf02f, 0x3a:0xf03a, 0x3c:0xf03c, 0x3e:0xf03e, 0x3f:0xf03f, 0x5c:0xf05c, 0x7c:0xf07c, 0x20:0xf020<br />
}}<br />
<br />
The latter approach (using catia or fruit) has the drawback of filtering files with unprintable characters.<br />
<br />
=== Folder shared inside graphical environment is not available to guests ===<br />
<br />
This section presupposes:<br />
<br />
# Usershares are configured following [[#Enable Usershares|previous section]]<br />
# A shared folder has been created as a non-root user from GUI<br />
# Guests access has been set to shared folder during creation<br />
# Samba service has been restarted at least once since last {{ic|/etc/samba/smb.conf}} file modification<br />
<br />
For clarification purpose only, in the following sub-sections is assumed:<br />
<br />
* Shared folder is located inside user home directory path ({{ic|/home/yourUser/Shared}})<br />
* Shared folder name is ''MySharedFiles''<br />
* Guest access is read-only.<br />
* Windows users will access shared folder content without login prompt<br />
<br />
==== Verify correct samba configuration ====<br />
<br />
Run the following command from a terminal to test configuration file correctness:<br />
<br />
$ testparm<br />
<br />
==== Verify correct shared folder creation ====<br />
<br />
Run the following commands from a terminal:<br />
<br />
$ cd /var/lib/samba/usershare<br />
$ ls<br />
<br />
If everything is fine, you will notice a file named {{ic|mysharedfiles}}<br />
<br />
Read the file contents using the following command:<br />
<br />
$ cat mysharedfiles<br />
<br />
The terminal output should display something like this:<br />
<br />
{{hc|/var/lib/samba/usershare/mysharedfiles|2=<br />
path=/home/yourUser/Shared<br />
comment=<br />
usershare_acl=S-1-1-0:r<br />
guest_ok=y<br />
sharename=MySharedFiles<br />
}}<br />
<br />
==== Verify folder access by guest ====<br />
<br />
Run the following command from a terminal. If prompted for a password, just press Enter:<br />
<br />
$ smbclient -L localhost<br />
<br />
If everything is fine, MySharedFiles should be displayed under {{ic|Sharename}} column<br />
<br />
Run the following command in order to access the shared folder as guest (anonymous login)<br />
<br />
$ smbclient -N //localhost/MySharedFiles<br />
<br />
If everything is fine samba client prompt will be displayed:<br />
<br />
smb: \><br />
<br />
From samba prompt verify guest can list directory contents:<br />
<br />
smb: \> ls<br />
<br />
If the {{ic|NTFS_STATUS_ACCESS_DENIED}} error is displayed, the issue is likely to be with Unix directory permissions. Ensure that your samba user has access to the folder and all parent folders. You can test this by sudoing to the user and attempting to list the mount directory, and all of its parents.<br />
<br />
=== Mount error: Host is down ===<br />
<br />
This error might be seen when mounting shares of Synology NAS servers. Use the mount option {{ic|1=vers=1.0}} to solve it.<br />
<br />
{{Note|SMB version 1 is known to have security vulnerabilities and was used in successful ransomware attacks.}}<br />
<br />
=== Software caused connection abort ===<br />
<br />
File managers that utilizes {{Pkg|gvfs-smb}} can show the error {{ic|Software caused connection abort}} when writing a file to a share/server. This may be due to the server running SMB/CIFS version 1, which many routers use for USB drive sharing (e.g. Belkin routers). To write to these shares specify the CIFS version with the option {{ic|1=vers=1.0}}. E.g.:<br />
<br />
{{hc|/etc/fstab|2=<br />
//SERVER/sharename /mnt/mountpoint cifs _netdev,guest,file_mode=0777,dir_mode=0777,vers=1.0 0 0<br />
}}<br />
<br />
This can also happen after updating Samba to version 4.11, which deactivates SMB1 as default, and accessing any Samba share. You can reenable it by adding<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
client min protocol = CORE<br />
}}<br />
<br />
=== Connection problem (due to authentification error) ===<br />
<br />
Be sure that you do not leave any space characters before your username in Samba client configuration file as follows:<br />
<br />
{{hc|~/.samba|2=<br />
username= user<br />
password=pass<br />
}}<br />
<br />
The correct format is:<br />
<br />
{{hc|~/.samba|2=<br />
username=user<br />
password=pass<br />
}}<br />
<br />
=== Windows 1709 or up does not discover the samba server in Network view ===<br />
<br />
With Windows 10 version 1511, support for SMBv1 and thus NetBIOS device discovery was disabled by default. Depending on the actual edition, later versions of Windows starting from version 1709 ("Fall Creators Update") do not allow the installation of the SMBv1 client anymore. This causes hosts running Samba not to be listed in the Explorer's "Network (Neighborhood)" views. While there is no connectivity problem and Samba will still run fine, users might want to have their Samba hosts to be listed by Windows automatically. {{AUR|wsdd}} implements a Web Service Discovery host daemon. This enables (Samba) hosts, like your local NAS device, to be found by Web Service Discovery Clients like Windows. The default settings should work for most installations, all you need to do is start enable {{ic|wsdd.service}}.<br />
<br />
If the default configuration (advertise itself as the machine hostname in group "WORKGROUP") should be all you need in most cases. If you need, you can change configuration options by passing additional arguments to wsdd by adding them in <code>/etc/conf.d/wsdd</code> (see the manual page for wsdd for details).<br />
<br />
{{AUR|wsdd2}} does the same thing, but is written in C instead of Python. By default, it will look for the <code>netbios name</code> and <code>workgroup</code> values in <code>smb.conf</code>.<br />
<br />
== See also ==<br />
<br />
* [https://www.samba.org/ Official website]<br />
* [https://www.samba.org/samba/docs/SambaIntro.html Samba: An Introduction]<br />
* [https://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf Samba 3.2.x HOWTO and Reference Guide] (outdated but still most extensive documentation)<br />
* [[Wikipedia:Samba (software)|Wikipedia]]<br />
* [[Gentoo:Samba/Guide]]<br />
* [[Debian:Samba/ServerSimple]]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Samba&diff=642212Samba2020-11-23T21:31:37Z<p>TPXP: /* Disable printer sharing */ My bad, it's actually spoolss</p>
<hr />
<div>[[Category:Network sharing]]<br />
[[Category:Servers]]<br />
[[cs:Samba]]<br />
[[da:Samba]]<br />
[[de:Samba]]<br />
[[es:Samba]]<br />
[[fr:Samba]]<br />
[[it:Samba]]<br />
[[ja:Samba]]<br />
[[ru:Samba]]<br />
[[sr:Samba]]<br />
[[zh-hans:Samba]]<br />
[[zh-hant:Samba]]<br />
{{Related articles start}}<br />
{{Related|Active Directory Integration}}<br />
{{Related|Samba/Active Directory domain controller}}<br />
{{Related|NFS}}<br />
{{Related articles end}}<br />
[https://www.samba.org/ Samba] is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the [[wikipedia:Server_Message_Block|SMB/CIFS]] protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.<br />
<br />
To share files through Samba, see [[#Server]] section; to access files shared through Samba on other machines, please see [[#Client]] section.<br />
<br />
== Server ==<br />
<br />
=== Installation ===<br />
<br />
[[Install]] the {{Pkg|samba}} package.<br />
<br />
Samba is configured in the {{ic|/etc/samba/smb.conf}} configuration file, which is extensively documented in {{man|5|smb.conf}}.<br />
<br />
Because the {{Pkg|samba}} package does not provide this file, one needs to create it '''before''' starting ''smb''.service.<br />
<br />
A documented example as in {{ic|smb.conf.default}} from the [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD Samba git repository] may be used to setup {{ic|/etc/samba/smb.conf}}. <br />
<br />
{{Note|<br />
* The default configuration sets {{ic|log file}} to a non-writable location, which will cause errors - apply one of the following workarounds:<br />
** Change the log file location to a writable path: {{ic|1=log file = /var/log/samba/%m.log}}<br />
** Change logging to a non-file backend solution: {{ic|1=logging = syslog}} with {{ic|1=syslog only = yes}}, or use {{ic|1=logging = systemd}}<br />
* If required; the {{ic|workgroup}} specified in the {{ic|[global]}} section has to match the Windows workgroup (default {{ic|WORKGROUP}}).<br />
}}<br />
<br />
{{Tip|Whenever you modify the {{ic|smb.conf}} file, run the {{man|1|testparm}} command to check for syntactic errors.}}<br />
<br />
==== Configure Firewall ====<br />
<br />
If you are using a [[firewall]], do not forget to open required ports (usually 137-139 + 445). For a complete list, see [https://www.samba.org/~tpot/articles/firewall.html Samba port usage].<br />
<br />
===== UFW Rule =====<br />
<br />
Since the UFW App Profile for Samba is not included by default, you may want to create it.<br />
<br />
Create/edit {{ic|/etc/ufw/applications.d/samba}} and add the following content:<br />
<br />
[Samba]<br />
title=LanManager-like file and printer server for Unix<br />
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve <br />
files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.<br />
ports=137,138/udp|139,445/tcp<br />
<br />
Then load the profile into UFW run {{ic|ufw app update Samba}} as root.<br />
<br />
Then finally, allow Samba by running {{ic|ufw allow Samba}} as root.<br />
<br />
=== Usage ===<br />
<br />
==== User Management ====<br />
<br />
===== Adding a user =====<br />
<br />
Samba requires a Linux user account - you may use an existing user account or create a [[Users and groups#User management|new one]].<br />
<br />
{{Note|The [[user]]/[[user group]] ''nobody'' should already exist on the system, it's used as the default {{ic|guest account}} and may be used for shares containing {{ic|1=guest ok = yes}}, thus preventing the need of user login on that share.}}<br />
<br />
Although the user name is shared with Linux system, Samba uses a password separate from that of the Linux user accounts. Replace {{ic|samba_user}} with the chosen Samba user account:<br />
<br />
# smbpasswd -a ''samba_user''<br />
<br />
Depending on the [https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#SERVERROLE server role], existing [[File permissions and attributes]] may need to be altered for the Samba user account.<br />
<br />
If you want the new user only to be allowed to remotely access the file server shares through Samba, you can restrict other login options:<br />
<br />
* disabling shell - {{ic|usermod --shell /usr/bin/nologin --lock ''samba_user''}}<br />
* disabling SSH logons - edit {{ic|/etc/ssh/sshd_conf}}, change option {{ic|AllowUsers}}<br />
<br />
Also see [[Security]] for hardening your system.<br />
<br />
===== Listing users =====<br />
<br />
Samba users can be listed using the {{man|8|pdbedit}} command:<br />
<br />
# pdbedit -L -v<br />
<br />
===== Changing user password =====<br />
<br />
To change a user password, use {{ic|smbpasswd}}:<br />
<br />
# smbpasswd ''samba_user''<br />
<br />
==== Creating a share ====<br />
<br />
{{Note|To allow the usage of ''guests'' on public shares, one will need to [[append]] {{ic|1=map to guest = Bad User}} in the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}. A different {{ic|1=guest account}} may be used instead of the default provided {{ic|nobody}}.}}<br />
<br />
Make sure shares have been properly defined as per the ''Share Definitions'' section of [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD smb.conf.default].<br />
<br />
==== Starting services ====<br />
<br />
To provide basic file sharing through SMB [[start/enable]] {{ic|smb.service}} and/or {{ic|nmb.service}} services. See the {{man|8|smbd}} and {{man|8|nmbd}} man pages for details, as the {{ic|nmb.service}} service may not always be required.<br />
<br />
=== Advanced Configuration ===<br />
<br />
==== Enable Usershares ====<br />
<br />
{{Note|This is an optional feature. Skip this section if you do not need it.}}<br />
<br />
[https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html Usershares]<br />
is a feature that gives non-root users the capability to add, modify, and delete their own share definitions. <br />
<br />
# Create a directory for usershares: {{bc|# mkdir /var/lib/samba/usershares}}<br />
# Create a [[user group]]: {{bc|# groupadd -r sambashare}}<br />
# Change the owner of the directory to {{ic|root}} and the group to {{ic|sambashare}}: {{bc|# chown root:sambashare /var/lib/samba/usershares}}<br />
# Change the permissions of the {{ic|usershares}} directory so that users in the group {{ic|sambashare}} can read, write and execute files: {{bc|# chmod 1770 /var/lib/samba/usershares}}<br />
<br />
Set the following parameters in the {{ic|smb.conf}} configuration file: <br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
usershare path = /var/lib/samba/usershares<br />
usershare max shares = 100<br />
usershare allow guests = yes<br />
usershare owner only = yes<br />
}}<br />
<br />
Add the user to the ''sambashare'' group. Replace {{ic|''your_username''}} with the name of your user:<br />
<br />
# gpasswd sambashare -a ''your_username''<br />
<br />
[[Restart]] {{ic|smb.service}} and {{ic|nmb.service}} services.<br />
<br />
Log out and log back in.<br />
<br />
If you want to share paths inside your home directory you must make it accessible for the group ''others''.<br />
<br />
In the GUI, for example in [[Thunar]], you can right click on any directory and share it on the network. <br />
<br />
In the CLI, use one of the following commands, replacing italic ''sharename'', ''user'', ... :<br />
<br />
# net usershare add ''sharename'' ''abspath'' [''comment''] [''user'':{R|D|F}] [guest_ok={y|n}]<br />
# net usershare delete ''sharename''<br />
# net usershare list ''wildcard-sharename''<br />
# net usershare info ''wildcard-sharename''<br />
<br />
==== Set and forcing permissions ====<br />
<br />
Permissions may be applied to both the server and shares:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
;inherit owner = unix only ; Inherit ownership of the parent directory for new files and directories<br />
;inherit permissions = yes ; Inherit permissions of the parent directory for new files and directories<br />
create mask = 0664<br />
directory mask = 2755<br />
force create mode = 0644<br />
force directory mode = 2755<br />
...<br />
<br />
[media]<br />
comment = Media share accessible by ''greg'' and ''pcusers''<br />
path = ''/path/to/media''<br />
valid users = ''greg @pcusers''<br />
force group = ''+pcusers''<br />
public = no<br />
writable = yes<br />
create mask = 0664<br />
directory mask = 2775<br />
force create mode = 0664<br />
force directory mode = 2775<br />
<br />
[public]<br />
comment = Public share where ''archie'' has write access<br />
path = ''/path/to/public''<br />
public = yes<br />
read only = yes<br />
write list = ''archie''<br />
printable = no<br />
<br />
[guests]<br />
comment = Allow all users to read/write<br />
path = ''/path/to/guests''<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
See {{man|5|smb.conf}} for a full overview of possible permission flags and settings.<br />
<br />
==== Restrict protocols for better security ====<br />
<br />
{{Warning|By default, Samba versions prior to 4.11 allow connections using the outdated and insecure SMB1 protocol. When using one these Samba versions, it is highly recommended to set {{ic|1=server min protocol = SMB2_02}} to protect yourself from ransomware attacks. In Samba 4.11 and newer, SMB2 is the default min protocol, so no changes are required there.}}<br />
<br />
[[Append]] {{ic|server min protocol}} and {{ic|server max protocol}} in {{ic|/etc/samba/smb.conf}} to force usage of a minimum and maximum protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server min protocol = SMB2_02<br />
; server max protocol = SMB3<br />
}}<br />
<br />
See {{ic|server max protocol}} in {{man|5|smb.conf}} for an overview of supported protocols.<br />
<br />
For compatibility with older clients and/or servers, you might need to set {{ic|1=client min protocol = CORE}} or {{ic|1=server min protocol = CORE}}, but please note that this makes you vulnerable to exploits in SMB1 including ransomware attacks.<br />
<br />
{{Tip|Use {{ic|1=server min protocol = SMB3_00}} when clients should only connect using the latest SMB3 protocol, e.g. on clients running Windows 8 and later.}}<br />
<br />
[[#Manual mounting|Clients]] using {{ic|mount.cifs}} may need to specify the correct {{ic|1=vers=*}}, e.g.:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',iocharset=''utf8'',vers=''3.1.1''<br />
<br />
See {{man|8|mount.cifs}} for more information.<br />
<br />
==== Use native SMB transport encryption ====<br />
<br />
Native SMB transport encryption is available in SMB version 3.0 or newer. Clients supporting this type of encryption include Windows 8 and newer, Windows server 2012 and newer, and smbclient of Samba 4.1 and newer.<br />
<br />
To use native SMB transport encryption by default, set the {{ic|smb encrypt}} parameter globally and/or by share. Possible values are {{ic|off}}, {{ic|enabled}} (default value), {{ic|desired}}, or {{ic|required}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
smb encrypt = desired<br />
}}<br />
<br />
See {{man|5|smb.conf}} for more information, especially the paragraphs ''Effects for SMB1'' and ''Effects for SMB2''.<br />
<br />
{{Tip|When [[#Manual mounting|mounting]] a share, specify the {{ic|seal}} mount option to force usage of encryption.}}<br />
<br />
==== Disable printer sharing ====<br />
<br />
By default Samba shares printers configured using [[CUPS]].<br />
<br />
If you do not want printers to be shared, use the following settings:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = no<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = yes<br />
show add printer wizard = no<br />
}}<br />
<br />
==== Block certain file extensions on Samba share ====<br />
<br />
{{Note|Setting this parameter will affect the performance of Samba, as it will be forced to check all files and directories for a match as they are scanned.}}<br />
<br />
Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files. More information about this option can be found in {{man|5|smb.conf}}.<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[myshare]<br />
comment = Private<br />
path = /mnt/data<br />
read only = no<br />
veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/<br />
}}<br />
<br />
==== Improve throughput ====<br />
<br />
{{Warning|Beware this may lead to corruption/connection issues and potentially cripple your TCP/IP stack.}}<br />
<br />
The default settings should be sufficient for most users. However setting the 'socket options' correct can improve performance, but getting them wrong can degrade it by just as much. Test the effect before making any large changes.<br />
<br />
Read the {{man|5|smb.conf}} man page before applying any of the options listed below.<br />
<br />
The following settings should be [[append]] to the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}.<br />
<br />
SMB3 multi-channel may improve performance, however it may result in data corruption under some race conditions. Future releases may improve this situation:<br />
<br />
server multi channel support = yes<br />
<br />
Setting a deadtime is useful to stop a server's resources being exhausted by a large number of inactive connections:<br />
<br />
deadtime = 30<br />
<br />
The usage of sendfile may make more efficient use of the system CPU's and cause Samba to be faster:<br />
<br />
use sendfile = yes<br />
<br />
Setting min receivefile size allows zero-copy writes directly from network socket buffers into the filesystem buffer cache (if available). It may improve performance but user testing is recommended:<br />
<br />
min receivefile size = 16384<br />
<br />
Reading/writing files asynchronously may improve performance instead of using synchronously writes:<br />
<br />
aio read size = 1<br />
aio write size = 1<br />
<br />
Increasing the receive/send buffers size and socket optimize flags might be useful to improve throughput. It is recommended to test each flag separately as it may cause issues on some networks:<br />
<br />
socket options = IPTOS_LOWDELAY TCP_NODELAY IPTOS_THROUGHPUT SO_RCVBUF=131072 SO_SNDBUF=131072<br />
<br />
{{Note|Network-interface adjustments may be needed for some options to work, see [[Sysctl#Networking]].}}<br />
<br />
==== Enable access for old clients/devices ====<br />
<br />
Latest versions of Samba no longer offer older authentication methods and protocols which are still used by some older clients (IP cameras, etc). These devices usually require Samba server to allow NTMLv1 authentication and NT1 version of the protocol, known as CIFS. For these devices to work with latest Samba, you need to add these two configuration parameters into {{ic|[global]}} section:<br />
<br />
server min protocol = NT1<br />
ntlm auth = yes<br />
<br />
Anonymous/guest access to a share requires just the first parameter. If the old device will access with username and password, you also need the add the second line too.<br />
<br />
== Client ==<br />
<br />
Install {{Pkg|smbclient}} for an {{ic|ftp}}-like command line interface. See {{man|1|smbclient}} for commonly used commands.<br />
<br />
For a lightweight alternative (without support for listing public shares, etc.), [[install]] {{Pkg|cifs-utils}} that provides {{ic|/usr/bin/mount.cifs}}.<br />
<br />
Depending on the [[desktop environment]], GUI methods may be available. See [[#File manager configuration]] for use with a file manager.<br />
<br />
{{Note|<br />
* {{Pkg|smbclient}} requires a {{ic|/etc/samba/smb.conf}} file (see [[#Installation]]), which you can create as an empty file using the {{ic|touch}} utility.<br />
* After installing {{Pkg|cifs-utils}} or {{Pkg|smbclient}}, load the {{ic|cifs}} [[kernel module]] or reboot to prevent mount fails.<br />
}}<br />
<br />
=== List public shares ===<br />
<br />
The following command lists public shares on a server:<br />
<br />
$ smbclient -L ''hostname'' -U%<br />
<br />
Alternatively, running ''smbtree'' will show a tree diagram of all the shares. This is not advisable on a network with a lot of computers, but can be helpful for diagnosing if you have the correct sharename.<br />
<br />
$ smbtree -b -N<br />
<br />
Where the options are {{ic|-b}} ({{ic|--broadcast}}) to use broadcast instead of using the master browser and {{ic|-N}} ({{ic|-no-pass}}) to not ask for a password.<br />
<br />
=== NetBIOS/WINS host names ===<br />
<br />
You may need to [[start]] {{ic|winbind.service}} and {{ic|nmb.service}} in order to resolve host names with e.g., {{ic|mount.cifs}}<br />
{{Note|Due to a current mistake in {{ic|winbind.service}}, you may have to modify the unit file as described in this [https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1789097 bug-report]}}<br />
<br />
The {{pkg|smbclient}} package provides a driver to resolve host names using WINS. To enable it, add {{ic|wins}} to the “hosts” line in {{ic|/etc/nsswitch.conf}}.<br />
<br />
If it is not already there, add it to look roughly like this:<br />
<br />
{{hc|/etc/nsswitch.conf|2=<br />
...<br />
hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns wins<br />
...<br />
}}<br />
<br />
You can test WINS resolution with {{ic|nmblookup}}. Note that WINS resolution requires incoming traffic originating from port 137.<br />
<br />
==== Disable NetBIOS/WINS support ====<br />
<br />
When not using NetBIOS/WINS host name resolution, it may be preferred to disable this protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
disable netbios = yes<br />
dns proxy = no<br />
}}<br />
<br />
Finally [[disable]]/[[stop]] {{ic|winbind.service}}.<br />
<br />
=== Manual mounting ===<br />
<br />
Create a mount point for the share:<br />
<br />
# mkdir /mnt/''mountpoint''<br />
<br />
Mount the share using {{ic|mount.cifs}} as {{ic|type}}. Not all the options listed below are needed or desirable:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',workgroup=''workgroup'',iocharset=''utf8'',uid=''username'',gid=''group''<br />
<br />
The options {{ic|uid}} and {{ic|gid}} corresponds to the local (e.g. client) [[user]]/[[user group]] to have read/write access on the given path.<br />
<br />
{{Note|<br />
* If the {{ic|uid}} and {{ic|gid}} being used does not match the user of the server, the {{ic|forceuid}} and {{ic|forcegid}} options may be helpful. However note permissions assigned to a file when {{ic|forceuid}} or {{ic|forcegid}} are in effect may not reflect the the real (server) permissions. See the ''File And Directory Ownership And Permissions'' section in {{man|8|mount.cifs|FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS}} for more information.<br />
* To allow users to mount it as long as the mount point resides in a directory controllable by the user; i.e. the user's home, append the {{ic|users}} mount option. The option is user'''s''' (plural). For other filesystem types handled by mount, this option is usually ''user''; sans the "'''s'''".<br />
* To mount a Windows share without authentication, use {{ic|1="username=*"}}.<br />
}}<br />
<br />
{{Warning|Using {{ic|uid}} and/or {{ic|gid}} as mount options may cause I/O errors, it is recommended to set/check correct [[File permissions and attributes]] instead.}}<br />
<br />
''SERVER''<br />
: The server name.<br />
<br />
''sharename''<br />
: The shared directory.<br />
<br />
''mountpoint''<br />
: The local directory where the share will be mounted.<br />
<br />
{{ic|<nowiki>-o [options]</nowiki>}}<br />
: See {{man|8|mount.cifs}} for more information.<br />
<br />
{{Note|<br />
* Abstain from using a trailing {{ic|/}}. {{ic|//''SERVER''/''sharename'''''/'''}} will not work.<br />
* If your mount does not work stable, stutters or freezes, try to enable different SMB protocol version with {{ic|1=vers=}} option. For example, {{ic|1=vers=2.0}} for Windows Vista mount.<br />
* If having timeouts on a mounted network share with cifs on a shutdown, see [[WPA supplicant#Problem with mounted network shares (cifs) and shutdown]].<br />
}}<br />
<br />
==== Storing share passwords ====<br />
<br />
Storing passwords in a world readable file is not recommended. A safer method is to use a credentials file instead, e.g. inside {{ic|/etc/samba/credentials}}:<br />
<br />
{{hc|/etc/samba/credentials/share|2=<br />
username=''myuser''<br />
password=''mypass''<br />
}}<br />
<br />
Replace {{ic|1=username=myuser,password=mypass}} with {{ic|1=credentials=/etc/samba/credentials/share}}.<br />
<br />
The credential file should explicitly readable/writeable to root:<br />
<br />
# chown root:root /etc/samba/credentials<br />
# chmod 700 /etc/samba/credentials<br />
# chmod 600 /etc/samba/credentials/share<br />
<br />
=== Automatic mounting ===<br />
<br />
{{Note|You may need to [[enable]] {{ic|systemd-networkd-wait-online.service}} or {{ic| NetworkManager-wait-online.service}} (depending on your setup) to proper enable booting on start-up.}}<br />
<br />
==== As mount entry ====<br />
<br />
This is a simple example of a {{ic|cifs}} [[fstab|mount entry]] that requires authentication:<br />
<br />
{{hc|/etc/fstab|2=<br />
//''SERVER''/''sharename'' /mnt/''mountpoint'' cifs _netdev,username=''myuser'',password=''mypass'' 0 0<br />
}}<br />
<br />
{{Note|Spaces in sharename should be replaced by {{ic|\040}} (ASCII code for space in octal). For example, {{ic|//''SERVER''/share name}} on the command line should be {{ic|//''SERVER''/share\040name}} in {{ic|/etc/fstab}}.}}<br />
<br />
{{Tip|Use {{ic|x-systemd.automount}} if you want them to be mounted only upon access. See [[Fstab#Remote filesystem]] for details.}}<br />
<br />
==== As systemd unit ====<br />
<br />
Create a new {{ic|.mount}} file inside {{ic|/etc/systemd/system}}, e.g. {{ic|mnt-myshare.mount}}. See {{man|5|systemd.mount}} for details.<br />
<br />
{{Note|Make sure the filename corresponds to the mountpoint you want to use.<br />
E.g. the unit name {{ic|mnt-myshare.mount}} can only be used if are going to mount the share under {{ic|/mnt/myshare}}. Otherwise the following error might occur: {{ic|1=systemd[1]: mnt-myshare.mount: Where= setting does not match unit name. Refusing.}}.}}<br />
<br />
{{ic|1=What=}} path to share<br />
<br />
{{ic|1=Where=}} path to mount the share<br />
<br />
{{ic|1=Options=}} share mounting options<br />
<br />
{{Note|<br />
* Network mount units automatically acquire {{ic|After}} dependencies on ''remote-fs-pre.target'', ''network.target'' and ''network-online.target'', and gain a {{ic|Before}} dependency on ''remote-fs.target'' unless {{ic|nofail}} mount option is set. Towards the latter a {{ic|Wants}} unit is added as well.<br />
* [[Append]] {{ic|noauto}} to {{ic|Options}} preventing automatically mount during boot (unless it is pulled in by some other unit).<br />
* If you want to use a hostname for the server you want to share (instead of an IP address), add {{ic|1=nss-lookup.target}} to {{ic|1=After}} and {{ic|1=Wants}}. This might avoid mount errors at boot time that do not arise when testing the unit.<br />
}} <br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.mount|2=<br />
[Unit]<br />
Description=Mount Share at boot<br />
<br />
[Mount]<br />
What=//server/share<br />
Where=/mnt/myshare<br />
Options=_netdev,credentials=/etc/samba/credentials/myshare,iocharset=utf8,rw<br />
Type=cifs<br />
TimeoutSec=30<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
{{Tip|In case of an unreachable system, [[append]] {{ic|1=ForceUnmount=true}} to {{ic|[Mount]}}, allowing the share to be (force-)unmounted.}}<br />
<br />
To use {{ic|mnt-myshare.mount}}, [[start]] the unit and [[enable]] it to run on system boot.<br />
<br />
===== automount =====<br />
<br />
To automatically mount a share, one may use the following automount unit:<br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.automount|2=<br />
[Unit]<br />
Description=Automount myshare<br />
<br />
[Automount]<br />
Where=/mnt/myshare<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
[[Disable]]/[[stop]] the {{ic|mnt-myshare.mount}} unit, and [[enable]]/[[start]] {{ic|mnt-myshare.automount}} to automount the share when the mount path is being accessed.<br />
<br />
{{Tip|[[Append]] {{ic|TimeoutIdleSec}} to enable auto unmount. See {{man|5|systemd.automount}} for details.}}<br />
<br />
==== smbnetfs ====<br />
<br />
{{Note|1=smbnetfs needs an intact Samba server setup.<br />
<br />
See above on how to do that.}}<br />
<br />
First, check if you can see all the shares you are interested in mounting:<br />
<br />
$ smbtree -U ''remote_user''<br />
<br />
If that does not work, find and modify the following line<br />
in {{ic|/etc/samba/smb.conf}} accordingly:<br />
<br />
domain master = auto<br />
<br />
Now [[restart]] {{ic|smb.service}} and {{ic|nmb.service}}.<br />
<br />
If everything works as expected, [[pacman#Installing specific packages|install]] {{Pkg|smbnetfs}} from the official repositories.<br />
<br />
Then, add the following line to {{ic|/etc/fuse.conf}}:<br />
<br />
user_allow_other<br />
<br />
Now copy the directory {{ic|/etc/smbnetfs/.smb}} to your home directory:<br />
<br />
$ cp -a /etc/smbnetfs/.smb ~<br />
<br />
Then create a link to {{ic|smb.conf}}:<br />
<br />
$ ln -sf /etc/samba/smb.conf ~/.smb/smb.conf<br />
<br />
If a username and a password are required to access some of the shared folders, edit {{ic|~/.smb/smbnetfs.auth}}<br />
to include one or more entries like this:<br />
<br />
{{hc|~/.smb/smbnetfs.auth|<br />
auth "hostname" "username" "password"<br />
}}<br />
<br />
It is also possible to add entries for specific hosts to be mounted by smbnetfs, if necessary.<br />
More details can be found in {{ic|~/.smb/smbnetfs.conf}}.<br />
<br />
If you are using the [[Dolphin]] or [[GNOME Files]], you may want to add the following to {{ic|~/.smb/smbnetfs.conf}} to avoid "Disk full" errors as smbnetfs by default will report 0 bytes of free space:<br />
<br />
{{hc|~/.smb/smbnetfs.conf|<br />
free_space_size 1073741824<br />
}}<br />
<br />
When you are done with the configuration, you need to run<br />
<br />
$ chmod 600 ~/.smb/smbnetfs.*<br />
<br />
Otherwise, smbnetfs complains about 'insecure config file permissions'.<br />
<br />
Finally, to mount your Samba network neighbourhood to a directory of your choice, call<br />
<br />
$ smbnetfs ''mount_point''<br />
<br />
===== Daemon =====<br />
<br />
The Arch Linux package also maintains an additional system-wide operation mode for smbnetfs. To enable it, you need to make the<br />
said modifications in the directory {{ic|/etc/smbnetfs/.smb}}.<br />
<br />
Then, you can start and/or enable the {{ic|smbnetfs}} [[daemon]] as usual. The system-wide mount point is at {{ic|/mnt/smbnet/}}.<br />
<br />
==== autofs ====<br />
<br />
See [[Autofs]] for information on the kernel-based automounter for Linux.<br />
<br />
=== File manager configuration ===<br />
<br />
==== GNOME Files, Nemo, Caja, Thunar and PCManFM ====<br />
<br />
In order to access samba shares through GNOME Files, Nemo, Caja, Thunar or PCManFM, install the {{Pkg|gvfs-smb}} package, available in the [[official repositories]].<br />
<br />
Press {{ic|Ctrl+l}} and enter {{ic|smb://''servername''/''share''}} in the location bar to access your share.<br />
<br />
The mounted share is likely to be present at {{ic|/run/user/''your_UID''/gvfs}} or {{ic|~/.gvfs}} in the filesystem.<br />
<br />
==== KDE ====<br />
<br />
KDE has the ability to browse Samba shares built in. To use a GUI in the KDE System Settings, you will need to install the {{Pkg|kdenetwork-filesharing}} package.<br />
<br />
==== Other graphical environments ====<br />
<br />
There are a number of useful programs, but they may need to have packages created for them. This can be done with the Arch package build system. The good thing about these others is that they do not require a particular environment to be installed to support them, and so they bring along less baggage.<br />
<br />
* {{AUR|pyneighborhood}} is available in the official repositories.<br />
* LinNeighborhood, RUmba, xffm-samba plugin for Xffm are not available in the official repositories or the AUR. As they are not officially (or even unofficially supported), they may be obsolete and may not work at all.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Discovering network shares ===<br />
<br />
If nothing is known about other systems on the local network, and automated tools such as [[#smbnetfs|smbnetfs]] are not available, the following methods allow one to manually probe for Samba shares.<br />
<br />
1. First, [[install]] the {{Pkg|nmap}} and {{Pkg|smbclient}} packages.<br />
<br />
2. {{ic|nmap}} checks which ports are open:<br />
<br />
# nmap -p 139 -sT "192.168.1.*"<br />
<br />
In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:<br />
<br />
{{hc|$ nmap -sT "192.168.1.*"|<br />
Starting nmap 3.78 ( http://www.insecure.org/nmap/ ) at 2005-02-15 11:45 PHT<br />
Interesting ports on 192.168.1.1:<br />
(The 1661 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
'''139/tcp open netbios-ssn'''<br />
5000/tcp open UPnP<br />
<br />
Interesting ports on 192.168.1.5:<br />
(The 1662 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
6000/tcp open X11<br />
<br />
Nmap run completed -- 256 IP addresses (2 hosts up) scanned in 7.255 seconds<br />
}}<br />
<br />
The first result is another system; the second happens to be the client from where this scan was performed.<br />
<br />
3. Now that systems with port 139 open are revealed, use {{man|1|nmblookup}} to check for NetBIOS names: <br />
<br />
{{hc|$ nmblookup -A 192.168.1.1|<br />
Looking up status of 192.168.1.1<br />
PUTER <00> - B <ACTIVE><br />
HOMENET <00> - <GROUP> B <ACTIVE><br />
PUTER <03> - B <ACTIVE><br />
'''PUTER <20> - B <ACTIVE>'''<br />
HOMENET <1e> - <GROUP> B <ACTIVE><br />
USERNAME <03> - B <ACTIVE><br />
HOMENET <1d> - B <ACTIVE><br />
MSBROWSE <01> - <GROUP> B <ACTIVE><br />
}}<br />
<br />
Regardless of the output, look for '''<20>''', which shows the host with open services.<br />
<br />
4. Use {{ic|smbclient}} to list which services are shared on ''PUTER''. If prompted for a password, pressing enter should still display the list:<br />
<br />
{{hc|$ smbclient -L \\PUTER|2=<br />
Sharename Type Comment<br />
--------- ---- -------<br />
MY_MUSIC Disk<br />
SHAREDDOCS Disk<br />
PRINTER$ Disk<br />
PRINTER Printer<br />
IPC$ IPC Remote Inter Process Communication<br />
<br />
Server Comment<br />
--------- -------<br />
PUTER<br />
<br />
Workgroup Master<br />
--------- -------<br />
HOMENET PUTER<br />
}}<br />
<br />
=== Remote control of Windows computer ===<br />
<br />
Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.<br />
<br />
Send shutdown command with a comment:<br />
<br />
$ net rpc shutdown -C "comment" -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.<br />
<br />
Stop and start services:<br />
<br />
$ net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
To see all possible net rpc command:<br />
<br />
$ net rpc<br />
<br />
== Troubleshooting ==<br />
<br />
=== Failed to start Samba SMB/CIFS server ===<br />
<br />
Possible solutions:<br />
<br />
* Check {{ic|smb.conf}} on syntactic errors with {{man|1|testparm}}.<br />
* Set correct permissions for {{ic|/var/cache/samba/}} and [[restart]] {{ic|smb.service}}:<br />
<br />
# chmod 0755 /var/cache/samba/msg<br />
<br />
=== Permission issues on AppArmor ===<br />
<br />
If using a [[#Creating a share|share path]] located outside of a home or usershares directory, whitelist it in {{ic|/etc/apparmor.d/local/usr.sbin.smbd}}. E.g.:<br />
<br />
{{hc|/etc/apparmor.d/local/usr.sbin.smbd|<br />
"/data/" rk,<br />
"/data/**" lrwk,<br />
}}<br />
<br />
=== No dialect specified on mount ===<br />
<br />
The client is using an unsupported SMB/CIFS version that is required by the server.<br />
<br />
See [[#Restrict protocols for better security]] for more information.<br />
<br />
=== Unable to overwrite files, permissions errors ===<br />
<br />
{{Accuracy|An user should set/check for server/client permissions, instead of using incorrect/possible insecure flags.}}<br />
<br />
Possible solutions:<br />
<br />
* Append the mount option {{ic|nodfs}} to the {{ic|/etc/fstab}} [[#As mount entry|entry]].<br />
* Add {{ic|1=msdfs root = no}} to the {{ic|[global]}} section of the server's {{ic|/etc/samba/smb.conf}}.<br />
<br />
=== Windows clients keep asking for password even if Samba shares are created with guest permissions ===<br />
<br />
Set {{ic|map to guest}} inside the {{ic|global}} section of {{ic|/etc/samba/smb.conf}}:<br />
<br />
map to guest = Bad User<br />
<br />
From Samba 4.10.10 you should use {{ic|Bad Password}} instead {{ic|Bad User}}.<br />
<br />
=== Windows 7 connectivity problems - mount error(12): cannot allocate memory ===<br />
<br />
A known Windows 7 bug that causes "mount error(12): cannot allocate memory" on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:<br />
<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache}} (set to {{ic|1}})<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size}} (set to {{ic|3}})<br />
<br />
Alternatively, start Command Prompt in Admin Mode and execute the following:<br />
<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f<br />
<br />
Do one of the following for the settings to take effect:<br />
<br />
* Restart Windows<br />
* Restart the Server service via services.msc<br />
* From the Command Prompt run: 'net stop lanmanserver' and 'net start lanmanserver' - The server may automatically restart after stopping it.<br />
<br />
{{Note|Googling will reveal another tweak recommending users to add a key modifying the "IRPStackSize" size. This is incorrect for fixing this issue under Windows 7. Do not attempt it.}}<br />
<br />
[http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017 Original article]{{Dead link|2020|04|03|status=domain name not resolved}}.<br />
<br />
=== Windows 10 1709 and up connectivity problems - "Windows cannot access" 0x80004005 ===<br />
<br />
This error affects some machines running Windows 10 version 1709 and later. It is not related to SMB1 being disabled in this version but to the fact that Microsoft disabled insecure logons for guests on this version for some, but not others.<br />
<br />
To fix, open Group Policy Editor ({{ic|gpedit.msc}}). Navigate to ''Computer configuration\administrative templates\network\Lanman Workstation > Enable insecure guest logons'' and enable it.<br />
Alternatively,change the following value in the registry:<br />
<br />
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]<br />
"AllowInsecureGuestAuth"=dword:1<br />
<br />
=== Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL ===<br />
<br />
If you are a home user and using samba purely for file sharing from a server or NAS, you are probably not interested in sharing printers through it. If so, you can prevent this error from occurring by adding the following lines to your {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = No<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = Yes<br />
}}<br />
<br />
[[Restart]] the samba service, {{ic|smb.service}}, and then check your logs:<br />
<br />
# cat /var/log/samba/smbd.log<br />
<br />
and the error should now no longer be appearing.<br />
<br />
=== Sharing a folder fails ===<br />
<br />
It means that while you are sharing a folder from ''Dolphin'' (file manager) and everything seems ok at first, after restarting ''Dolphin'' the share icon is gone from the shared folder, and also some output like this in terminal (''Konsole'') output:<br />
<br />
‘net usershare’ returned error 255: net usershare: usershares are currently disabled<br />
<br />
To fix it, enable usershare as described in [[#Enable Usershares]].<br />
<br />
=== "Browsing" network fails with "Failed to retrieve share list from server" ===<br />
<br />
And you are using a firewall (iptables) because you do not trust your local (school, university, hotel) network. This may be due to the following: When the smbclient is browsing the local network it sends out a broadcast request on udp port 137. The servers on the network then reply to your client but as the source address of this reply is different from the destination address iptables saw when sending the request for the listing out, iptables will not recognize the reply as being "ESTABLISHED" or "RELATED", and hence the packet is dropped. A possible solution is to add:<br />
<br />
iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns<br />
<br />
to your iptables setup.<br />
<br />
For [[Uncomplicated_Firewall]], you need to add {{ic|nf_conntrack_netbios_ns}} to the end of the following line in {{ic|/etc/default/ufw}}<br />
<br />
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc"<br />
<br />
and then run the following commands as root:<br />
<br />
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper<br />
ufw allow CIFS<br />
ufw reload<br />
<br />
=== Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE ===<br />
<br />
The client probably does not have access to shares. Make sure clients' IP address is in {{ic|1=hosts allow =}} line in {{ic|/etc/samba/smb.conf}}.<br />
<br />
Another problem could be, that the client uses an invalid protocol version. To check this try to connect with the {{ic|smbclient}} where you specify the maximum protocol version manually:<br />
<br />
$ smbclient -U <user name> -L //<server name> -m <protocol version: e. g. SMB2> -W <domain name><br />
<br />
If the command was successful then create a configuration file:<br />
<br />
{{hc|~/.smb/smb.conf|output=<br />
[global]<br />
workgroup = <domain name><br />
client max protocol = SMB2<br />
}}<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL) ===<br />
<br />
You are probably passing a wrong server name to {{ic|smbclient}}. To find out the server name, run {{ic|hostnamectl}} on the server and look at "Transient hostname" line<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED) ===<br />
<br />
Make sure that the server has started. The shared directories should exist and be accessible.<br />
<br />
=== Protocol negotiation failed: NT_STATUS_CONNECTION_RESET ===<br />
<br />
Probably the server is configured not to accept protocol SMB1. Add option {{ic|1=client max protocol = SMB2}} in {{ic|/etc/samba/smb.conf}}.<br />
Or just pass argument {{ic|-m SMB2}} to {{ic|smbclient}}.<br />
<br />
=== Password Error when correct credentials are given (error 1326) ===<br />
<br />
[https://www.samba.org/samba/history/samba-4.5.0.html Samba 4.5] has NTLMv1 authentication disabled by default. It is recommend to install the latest available upgrades on clients and deny access for unsupported clients.<br />
<br />
If you still need support for very old clients without NTLMv2 support (e.g. Windows XP), it is possible force enable NTLMv1, although this is '''not recommend''' for security reasons:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
lanman auth = yes<br />
ntlm auth = yes<br />
}}<br />
<br />
If NTLMv2 clients are unable to authenticate when NTLMv1 has been enabled, create the following file on the client:<br />
{{hc|/home/user/.smb/smb.conf|2=<br />
[global]<br />
sec = ntlmv2<br />
client ntlmv2 auth = yes<br />
}}<br />
<br />
This change also affects samba shares mounted with '''mount.cifs'''. If after upgrade to Samba 4.5 your mount fails, add the '''sec=ntlmssp''' option to your mount command, e.g.<br />
<br />
mount.cifs //server/share /mnt/point -o sec=ntlmssp,...<br />
<br />
See the {{man|8|mount.cifs}} man page: '''ntlmssp''' - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message. The default in mainline kernel versions prior to v3.8 was '''sec=ntlm'''. In v3.8, the default was changed to '''sec=ntlmssp'''.<br />
<br />
=== Mapping reserved Windows characters ===<br />
<br />
Starting with kernel 3.18, the cifs module uses the [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2baa2682531ff02928e2d3904800696d9e7193db "mapposix" option by default].<br />
When mounting a share using unix extensions and a default Samba configuration, files and directories containing one of the seven reserved Windows characters {{ic|: \ * < > ? |}} are listed but cannot be accessed.<br />
<br />
Possible solutions are:<br />
<br />
* Use the undocumented {{ic|nomapposix}} mount option for cifs<br />
<br />
# mount.cifs //server/share /mnt/point -o nomapposix<br />
<br />
* Configure Samba to remap {{ic|mapposix}} ("SFM", Services for Mac) style characters to the correct native ones using [https://www.mankier.com/8/vfs_fruit fruit]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia fruit<br />
fruit:encoding = native<br />
}}<br />
<br />
* Manually remap forbidden characters using [https://www.mankier.com/8/vfs_catia catia]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia<br />
catia:mappings = 0x22:0xf022, 0x2a:0xf02a, 0x2f:0xf02f, 0x3a:0xf03a, 0x3c:0xf03c, 0x3e:0xf03e, 0x3f:0xf03f, 0x5c:0xf05c, 0x7c:0xf07c, 0x20:0xf020<br />
}}<br />
<br />
The latter approach (using catia or fruit) has the drawback of filtering files with unprintable characters.<br />
<br />
=== Folder shared inside graphical environment is not available to guests ===<br />
<br />
This section presupposes:<br />
<br />
# Usershares are configured following [[#Enable Usershares|previous section]]<br />
# A shared folder has been created as a non-root user from GUI<br />
# Guests access has been set to shared folder during creation<br />
# Samba service has been restarted at least once since last {{ic|/etc/samba/smb.conf}} file modification<br />
<br />
For clarification purpose only, in the following sub-sections is assumed:<br />
<br />
* Shared folder is located inside user home directory path ({{ic|/home/yourUser/Shared}})<br />
* Shared folder name is ''MySharedFiles''<br />
* Guest access is read-only.<br />
* Windows users will access shared folder content without login prompt<br />
<br />
==== Verify correct samba configuration ====<br />
<br />
Run the following command from a terminal to test configuration file correctness:<br />
<br />
$ testparm<br />
<br />
==== Verify correct shared folder creation ====<br />
<br />
Run the following commands from a terminal:<br />
<br />
$ cd /var/lib/samba/usershare<br />
$ ls<br />
<br />
If everything is fine, you will notice a file named {{ic|mysharedfiles}}<br />
<br />
Read the file contents using the following command:<br />
<br />
$ cat mysharedfiles<br />
<br />
The terminal output should display something like this:<br />
<br />
{{hc|/var/lib/samba/usershare/mysharedfiles|2=<br />
path=/home/yourUser/Shared<br />
comment=<br />
usershare_acl=S-1-1-0:r<br />
guest_ok=y<br />
sharename=MySharedFiles<br />
}}<br />
<br />
==== Verify folder access by guest ====<br />
<br />
Run the following command from a terminal. If prompted for a password, just press Enter:<br />
<br />
$ smbclient -L localhost<br />
<br />
If everything is fine, MySharedFiles should be displayed under {{ic|Sharename}} column<br />
<br />
Run the following command in order to access the shared folder as guest (anonymous login)<br />
<br />
$ smbclient -N //localhost/MySharedFiles<br />
<br />
If everything is fine samba client prompt will be displayed:<br />
<br />
smb: \><br />
<br />
From samba prompt verify guest can list directory contents:<br />
<br />
smb: \> ls<br />
<br />
If the {{ic|NTFS_STATUS_ACCESS_DENIED}} error is displayed, the issue is likely to be with Unix directory permissions. Ensure that your samba user has access to the folder and all parent folders. You can test this by sudoing to the user and attempting to list the mount directory, and all of its parents.<br />
<br />
=== Mount error: Host is down ===<br />
This error might be seen when mounting shares of Synology NAS servers. Use the mount option {{ic|1=vers=1.0}} to solve it.<br />
<br />
{{Note|SMB version 1 is known to have security vulnerabilities and was used in successful ransomware attacks.}}<br />
<br />
=== Software caused connection abort ===<br />
<br />
File managers that utilizes {{Pkg|gvfs-smb}} can show the error {{ic|Software caused connection abort}} when writing a file to a share/server. This may be due to the server running SMB/CIFS version 1, which many routers use for USB drive sharing (e.g. Belkin routers). To write to these shares specify the CIFS version with the option {{ic|1=vers=1.0}}. E.g.:<br />
<br />
{{hc|/etc/fstab|2=<br />
//SERVER/sharename /mnt/mountpoint cifs _netdev,guest,file_mode=0777,dir_mode=0777,vers=1.0 0 0<br />
}}<br />
<br />
This can also happen after updating Samba to version 4.11, which deactivates SMB1 as default, and accessing any Samba share. You can reenable it by adding<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
client min protocol = CORE<br />
}}<br />
<br />
=== Connection problem (due to authentification error) ===<br />
<br />
Be sure that you do not leave any space characters before your username in Samba client configuration file as follows:<br />
<br />
{{hc|~/.samba|2=<br />
username= user<br />
password=pass<br />
}}<br />
<br />
The correct format is:<br />
<br />
{{hc|~/.samba|2=<br />
username=user<br />
password=pass<br />
}}<br />
<br />
== See also ==<br />
<br />
* [https://www.samba.org/ Official website]<br />
* [https://www.samba.org/samba/docs/SambaIntro.html Samba: An Introduction]<br />
* [https://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf Samba 3.2.x HOWTO and Reference Guide] (outdated but still most extensive documentation)<br />
* [[Wikipedia:Samba (software)|Wikipedia]]<br />
* [[Gentoo:Samba/Guide]]<br />
* [[Debian:SambaServerSimple]]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Samba&diff=642211Samba2020-11-23T21:25:17Z<p>TPXP: /* Disable printer sharing */ Fix typo in disable spools conf option</p>
<hr />
<div>[[Category:Network sharing]]<br />
[[Category:Servers]]<br />
[[cs:Samba]]<br />
[[da:Samba]]<br />
[[de:Samba]]<br />
[[es:Samba]]<br />
[[fr:Samba]]<br />
[[it:Samba]]<br />
[[ja:Samba]]<br />
[[ru:Samba]]<br />
[[sr:Samba]]<br />
[[zh-hans:Samba]]<br />
[[zh-hant:Samba]]<br />
{{Related articles start}}<br />
{{Related|Active Directory Integration}}<br />
{{Related|Samba/Active Directory domain controller}}<br />
{{Related|NFS}}<br />
{{Related articles end}}<br />
[https://www.samba.org/ Samba] is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the [[wikipedia:Server_Message_Block|SMB/CIFS]] protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.<br />
<br />
To share files through Samba, see [[#Server]] section; to access files shared through Samba on other machines, please see [[#Client]] section.<br />
<br />
== Server ==<br />
<br />
=== Installation ===<br />
<br />
[[Install]] the {{Pkg|samba}} package.<br />
<br />
Samba is configured in the {{ic|/etc/samba/smb.conf}} configuration file, which is extensively documented in {{man|5|smb.conf}}.<br />
<br />
Because the {{Pkg|samba}} package does not provide this file, one needs to create it '''before''' starting ''smb''.service.<br />
<br />
A documented example as in {{ic|smb.conf.default}} from the [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD Samba git repository] may be used to setup {{ic|/etc/samba/smb.conf}}. <br />
<br />
{{Note|<br />
* The default configuration sets {{ic|log file}} to a non-writable location, which will cause errors - apply one of the following workarounds:<br />
** Change the log file location to a writable path: {{ic|1=log file = /var/log/samba/%m.log}}<br />
** Change logging to a non-file backend solution: {{ic|1=logging = syslog}} with {{ic|1=syslog only = yes}}, or use {{ic|1=logging = systemd}}<br />
* If required; the {{ic|workgroup}} specified in the {{ic|[global]}} section has to match the Windows workgroup (default {{ic|WORKGROUP}}).<br />
}}<br />
<br />
{{Tip|Whenever you modify the {{ic|smb.conf}} file, run the {{man|1|testparm}} command to check for syntactic errors.}}<br />
<br />
==== Configure Firewall ====<br />
<br />
If you are using a [[firewall]], do not forget to open required ports (usually 137-139 + 445). For a complete list, see [https://www.samba.org/~tpot/articles/firewall.html Samba port usage].<br />
<br />
===== UFW Rule =====<br />
<br />
Since the UFW App Profile for Samba is not included by default, you may want to create it.<br />
<br />
Create/edit {{ic|/etc/ufw/applications.d/samba}} and add the following content:<br />
<br />
[Samba]<br />
title=LanManager-like file and printer server for Unix<br />
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve <br />
files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.<br />
ports=137,138/udp|139,445/tcp<br />
<br />
Then load the profile into UFW run {{ic|ufw app update Samba}} as root.<br />
<br />
Then finally, allow Samba by running {{ic|ufw allow Samba}} as root.<br />
<br />
=== Usage ===<br />
<br />
==== User Management ====<br />
<br />
===== Adding a user =====<br />
<br />
Samba requires a Linux user account - you may use an existing user account or create a [[Users and groups#User management|new one]].<br />
<br />
{{Note|The [[user]]/[[user group]] ''nobody'' should already exist on the system, it's used as the default {{ic|guest account}} and may be used for shares containing {{ic|1=guest ok = yes}}, thus preventing the need of user login on that share.}}<br />
<br />
Although the user name is shared with Linux system, Samba uses a password separate from that of the Linux user accounts. Replace {{ic|samba_user}} with the chosen Samba user account:<br />
<br />
# smbpasswd -a ''samba_user''<br />
<br />
Depending on the [https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#SERVERROLE server role], existing [[File permissions and attributes]] may need to be altered for the Samba user account.<br />
<br />
If you want the new user only to be allowed to remotely access the file server shares through Samba, you can restrict other login options:<br />
<br />
* disabling shell - {{ic|usermod --shell /usr/bin/nologin --lock ''samba_user''}}<br />
* disabling SSH logons - edit {{ic|/etc/ssh/sshd_conf}}, change option {{ic|AllowUsers}}<br />
<br />
Also see [[Security]] for hardening your system.<br />
<br />
===== Listing users =====<br />
<br />
Samba users can be listed using the {{man|8|pdbedit}} command:<br />
<br />
# pdbedit -L -v<br />
<br />
===== Changing user password =====<br />
<br />
To change a user password, use {{ic|smbpasswd}}:<br />
<br />
# smbpasswd ''samba_user''<br />
<br />
==== Creating a share ====<br />
<br />
{{Note|To allow the usage of ''guests'' on public shares, one will need to [[append]] {{ic|1=map to guest = Bad User}} in the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}. A different {{ic|1=guest account}} may be used instead of the default provided {{ic|nobody}}.}}<br />
<br />
Make sure shares have been properly defined as per the ''Share Definitions'' section of [https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD smb.conf.default].<br />
<br />
==== Starting services ====<br />
<br />
To provide basic file sharing through SMB [[start/enable]] {{ic|smb.service}} and/or {{ic|nmb.service}} services. See the {{man|8|smbd}} and {{man|8|nmbd}} man pages for details, as the {{ic|nmb.service}} service may not always be required.<br />
<br />
=== Advanced Configuration ===<br />
<br />
==== Enable Usershares ====<br />
<br />
{{Note|This is an optional feature. Skip this section if you do not need it.}}<br />
<br />
[https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html Usershares]<br />
is a feature that gives non-root users the capability to add, modify, and delete their own share definitions. <br />
<br />
# Create a directory for usershares: {{bc|# mkdir /var/lib/samba/usershares}}<br />
# Create a [[user group]]: {{bc|# groupadd -r sambashare}}<br />
# Change the owner of the directory to {{ic|root}} and the group to {{ic|sambashare}}: {{bc|# chown root:sambashare /var/lib/samba/usershares}}<br />
# Change the permissions of the {{ic|usershares}} directory so that users in the group {{ic|sambashare}} can read, write and execute files: {{bc|# chmod 1770 /var/lib/samba/usershares}}<br />
<br />
Set the following parameters in the {{ic|smb.conf}} configuration file: <br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
usershare path = /var/lib/samba/usershares<br />
usershare max shares = 100<br />
usershare allow guests = yes<br />
usershare owner only = yes<br />
}}<br />
<br />
Add the user to the ''sambashare'' group. Replace {{ic|''your_username''}} with the name of your user:<br />
<br />
# gpasswd sambashare -a ''your_username''<br />
<br />
[[Restart]] {{ic|smb.service}} and {{ic|nmb.service}} services.<br />
<br />
Log out and log back in.<br />
<br />
If you want to share paths inside your home directory you must make it accessible for the group ''others''.<br />
<br />
In the GUI, for example in [[Thunar]], you can right click on any directory and share it on the network. <br />
<br />
In the CLI, use one of the following commands, replacing italic ''sharename'', ''user'', ... :<br />
<br />
# net usershare add ''sharename'' ''abspath'' [''comment''] [''user'':{R|D|F}] [guest_ok={y|n}]<br />
# net usershare delete ''sharename''<br />
# net usershare list ''wildcard-sharename''<br />
# net usershare info ''wildcard-sharename''<br />
<br />
==== Set and forcing permissions ====<br />
<br />
Permissions may be applied to both the server and shares:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
;inherit owner = unix only ; Inherit ownership of the parent directory for new files and directories<br />
;inherit permissions = yes ; Inherit permissions of the parent directory for new files and directories<br />
create mask = 0664<br />
directory mask = 2755<br />
force create mode = 0644<br />
force directory mode = 2755<br />
...<br />
<br />
[media]<br />
comment = Media share accessible by ''greg'' and ''pcusers''<br />
path = ''/path/to/media''<br />
valid users = ''greg @pcusers''<br />
force group = ''+pcusers''<br />
public = no<br />
writable = yes<br />
create mask = 0664<br />
directory mask = 2775<br />
force create mode = 0664<br />
force directory mode = 2775<br />
<br />
[public]<br />
comment = Public share where ''archie'' has write access<br />
path = ''/path/to/public''<br />
public = yes<br />
read only = yes<br />
write list = ''archie''<br />
printable = no<br />
<br />
[guests]<br />
comment = Allow all users to read/write<br />
path = ''/path/to/guests''<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
printable = no<br />
}}<br />
<br />
See {{man|5|smb.conf}} for a full overview of possible permission flags and settings.<br />
<br />
==== Restrict protocols for better security ====<br />
<br />
{{Warning|By default, Samba versions prior to 4.11 allow connections using the outdated and insecure SMB1 protocol. When using one these Samba versions, it is highly recommended to set {{ic|1=server min protocol = SMB2_02}} to protect yourself from ransomware attacks. In Samba 4.11 and newer, SMB2 is the default min protocol, so no changes are required there.}}<br />
<br />
[[Append]] {{ic|server min protocol}} and {{ic|server max protocol}} in {{ic|/etc/samba/smb.conf}} to force usage of a minimum and maximum protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
server min protocol = SMB2_02<br />
; server max protocol = SMB3<br />
}}<br />
<br />
See {{ic|server max protocol}} in {{man|5|smb.conf}} for an overview of supported protocols.<br />
<br />
For compatibility with older clients and/or servers, you might need to set {{ic|1=client min protocol = CORE}} or {{ic|1=server min protocol = CORE}}, but please note that this makes you vulnerable to exploits in SMB1 including ransomware attacks.<br />
<br />
{{Tip|Use {{ic|1=server min protocol = SMB3_00}} when clients should only connect using the latest SMB3 protocol, e.g. on clients running Windows 8 and later.}}<br />
<br />
[[#Manual mounting|Clients]] using {{ic|mount.cifs}} may need to specify the correct {{ic|1=vers=*}}, e.g.:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',iocharset=''utf8'',vers=''3.1.1''<br />
<br />
See {{man|8|mount.cifs}} for more information.<br />
<br />
==== Use native SMB transport encryption ====<br />
<br />
Native SMB transport encryption is available in SMB version 3.0 or newer. Clients supporting this type of encryption include Windows 8 and newer, Windows server 2012 and newer, and smbclient of Samba 4.1 and newer.<br />
<br />
To use native SMB transport encryption by default, set the {{ic|smb encrypt}} parameter globally and/or by share. Possible values are {{ic|off}}, {{ic|enabled}} (default value), {{ic|desired}}, or {{ic|required}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
smb encrypt = desired<br />
}}<br />
<br />
See {{man|5|smb.conf}} for more information, especially the paragraphs ''Effects for SMB1'' and ''Effects for SMB2''.<br />
<br />
{{Tip|When [[#Manual mounting|mounting]] a share, specify the {{ic|seal}} mount option to force usage of encryption.}}<br />
<br />
==== Disable printer sharing ====<br />
<br />
By default Samba shares printers configured using [[CUPS]].<br />
<br />
If you do not want printers to be shared, use the following settings:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = no<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spools = yes<br />
show add printer wizard = no<br />
}}<br />
<br />
==== Block certain file extensions on Samba share ====<br />
<br />
{{Note|Setting this parameter will affect the performance of Samba, as it will be forced to check all files and directories for a match as they are scanned.}}<br />
<br />
Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files. More information about this option can be found in {{man|5|smb.conf}}.<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
...<br />
[myshare]<br />
comment = Private<br />
path = /mnt/data<br />
read only = no<br />
veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/<br />
}}<br />
<br />
==== Improve throughput ====<br />
<br />
{{Warning|Beware this may lead to corruption/connection issues and potentially cripple your TCP/IP stack.}}<br />
<br />
The default settings should be sufficient for most users. However setting the 'socket options' correct can improve performance, but getting them wrong can degrade it by just as much. Test the effect before making any large changes.<br />
<br />
Read the {{man|5|smb.conf}} man page before applying any of the options listed below.<br />
<br />
The following settings should be [[append]] to the {{ic|[global]}} section of {{ic|/etc/samba/smb.conf}}.<br />
<br />
SMB3 multi-channel may improve performance, however it may result in data corruption under some race conditions. Future releases may improve this situation:<br />
<br />
server multi channel support = yes<br />
<br />
Setting a deadtime is useful to stop a server's resources being exhausted by a large number of inactive connections:<br />
<br />
deadtime = 30<br />
<br />
The usage of sendfile may make more efficient use of the system CPU's and cause Samba to be faster:<br />
<br />
use sendfile = yes<br />
<br />
Setting min receivefile size allows zero-copy writes directly from network socket buffers into the filesystem buffer cache (if available). It may improve performance but user testing is recommended:<br />
<br />
min receivefile size = 16384<br />
<br />
Reading/writing files asynchronously may improve performance instead of using synchronously writes:<br />
<br />
aio read size = 1<br />
aio write size = 1<br />
<br />
Increasing the receive/send buffers size and socket optimize flags might be useful to improve throughput. It is recommended to test each flag separately as it may cause issues on some networks:<br />
<br />
socket options = IPTOS_LOWDELAY TCP_NODELAY IPTOS_THROUGHPUT SO_RCVBUF=131072 SO_SNDBUF=131072<br />
<br />
{{Note|Network-interface adjustments may be needed for some options to work, see [[Sysctl#Networking]].}}<br />
<br />
==== Enable access for old clients/devices ====<br />
<br />
Latest versions of Samba no longer offer older authentication methods and protocols which are still used by some older clients (IP cameras, etc). These devices usually require Samba server to allow NTMLv1 authentication and NT1 version of the protocol, known as CIFS. For these devices to work with latest Samba, you need to add these two configuration parameters into {{ic|[global]}} section:<br />
<br />
server min protocol = NT1<br />
ntlm auth = yes<br />
<br />
Anonymous/guest access to a share requires just the first parameter. If the old device will access with username and password, you also need the add the second line too.<br />
<br />
== Client ==<br />
<br />
Install {{Pkg|smbclient}} for an {{ic|ftp}}-like command line interface. See {{man|1|smbclient}} for commonly used commands.<br />
<br />
For a lightweight alternative (without support for listing public shares, etc.), [[install]] {{Pkg|cifs-utils}} that provides {{ic|/usr/bin/mount.cifs}}.<br />
<br />
Depending on the [[desktop environment]], GUI methods may be available. See [[#File manager configuration]] for use with a file manager.<br />
<br />
{{Note|<br />
* {{Pkg|smbclient}} requires a {{ic|/etc/samba/smb.conf}} file (see [[#Installation]]), which you can create as an empty file using the {{ic|touch}} utility.<br />
* After installing {{Pkg|cifs-utils}} or {{Pkg|smbclient}}, load the {{ic|cifs}} [[kernel module]] or reboot to prevent mount fails.<br />
}}<br />
<br />
=== List public shares ===<br />
<br />
The following command lists public shares on a server:<br />
<br />
$ smbclient -L ''hostname'' -U%<br />
<br />
Alternatively, running ''smbtree'' will show a tree diagram of all the shares. This is not advisable on a network with a lot of computers, but can be helpful for diagnosing if you have the correct sharename.<br />
<br />
$ smbtree -b -N<br />
<br />
Where the options are {{ic|-b}} ({{ic|--broadcast}}) to use broadcast instead of using the master browser and {{ic|-N}} ({{ic|-no-pass}}) to not ask for a password.<br />
<br />
=== NetBIOS/WINS host names ===<br />
<br />
You may need to [[start]] {{ic|winbind.service}} and {{ic|nmb.service}} in order to resolve host names with e.g., {{ic|mount.cifs}}<br />
{{Note|Due to a current mistake in {{ic|winbind.service}}, you may have to modify the unit file as described in this [https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1789097 bug-report]}}<br />
<br />
The {{pkg|smbclient}} package provides a driver to resolve host names using WINS. To enable it, add {{ic|wins}} to the “hosts” line in {{ic|/etc/nsswitch.conf}}.<br />
<br />
If it is not already there, add it to look roughly like this:<br />
<br />
{{hc|/etc/nsswitch.conf|2=<br />
...<br />
hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns wins<br />
...<br />
}}<br />
<br />
You can test WINS resolution with {{ic|nmblookup}}. Note that WINS resolution requires incoming traffic originating from port 137.<br />
<br />
==== Disable NetBIOS/WINS support ====<br />
<br />
When not using NetBIOS/WINS host name resolution, it may be preferred to disable this protocol:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
disable netbios = yes<br />
dns proxy = no<br />
}}<br />
<br />
Finally [[disable]]/[[stop]] {{ic|winbind.service}}.<br />
<br />
=== Manual mounting ===<br />
<br />
Create a mount point for the share:<br />
<br />
# mkdir /mnt/''mountpoint''<br />
<br />
Mount the share using {{ic|mount.cifs}} as {{ic|type}}. Not all the options listed below are needed or desirable:<br />
<br />
# mount -t cifs //''SERVER''/''sharename'' /mnt/''mountpoint'' -o username=''username'',password=''password'',workgroup=''workgroup'',iocharset=''utf8'',uid=''username'',gid=''group''<br />
<br />
The options {{ic|uid}} and {{ic|gid}} corresponds to the local (e.g. client) [[user]]/[[user group]] to have read/write access on the given path.<br />
<br />
{{Note|<br />
* If the {{ic|uid}} and {{ic|gid}} being used does not match the user of the server, the {{ic|forceuid}} and {{ic|forcegid}} options may be helpful. However note permissions assigned to a file when {{ic|forceuid}} or {{ic|forcegid}} are in effect may not reflect the the real (server) permissions. See the ''File And Directory Ownership And Permissions'' section in {{man|8|mount.cifs|FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS}} for more information.<br />
* To allow users to mount it as long as the mount point resides in a directory controllable by the user; i.e. the user's home, append the {{ic|users}} mount option. The option is user'''s''' (plural). For other filesystem types handled by mount, this option is usually ''user''; sans the "'''s'''".<br />
* To mount a Windows share without authentication, use {{ic|1="username=*"}}.<br />
}}<br />
<br />
{{Warning|Using {{ic|uid}} and/or {{ic|gid}} as mount options may cause I/O errors, it is recommended to set/check correct [[File permissions and attributes]] instead.}}<br />
<br />
''SERVER''<br />
: The server name.<br />
<br />
''sharename''<br />
: The shared directory.<br />
<br />
''mountpoint''<br />
: The local directory where the share will be mounted.<br />
<br />
{{ic|<nowiki>-o [options]</nowiki>}}<br />
: See {{man|8|mount.cifs}} for more information.<br />
<br />
{{Note|<br />
* Abstain from using a trailing {{ic|/}}. {{ic|//''SERVER''/''sharename'''''/'''}} will not work.<br />
* If your mount does not work stable, stutters or freezes, try to enable different SMB protocol version with {{ic|1=vers=}} option. For example, {{ic|1=vers=2.0}} for Windows Vista mount.<br />
* If having timeouts on a mounted network share with cifs on a shutdown, see [[WPA supplicant#Problem with mounted network shares (cifs) and shutdown]].<br />
}}<br />
<br />
==== Storing share passwords ====<br />
<br />
Storing passwords in a world readable file is not recommended. A safer method is to use a credentials file instead, e.g. inside {{ic|/etc/samba/credentials}}:<br />
<br />
{{hc|/etc/samba/credentials/share|2=<br />
username=''myuser''<br />
password=''mypass''<br />
}}<br />
<br />
Replace {{ic|1=username=myuser,password=mypass}} with {{ic|1=credentials=/etc/samba/credentials/share}}.<br />
<br />
The credential file should explicitly readable/writeable to root:<br />
<br />
# chown root:root /etc/samba/credentials<br />
# chmod 700 /etc/samba/credentials<br />
# chmod 600 /etc/samba/credentials/share<br />
<br />
=== Automatic mounting ===<br />
<br />
{{Note|You may need to [[enable]] {{ic|systemd-networkd-wait-online.service}} or {{ic| NetworkManager-wait-online.service}} (depending on your setup) to proper enable booting on start-up.}}<br />
<br />
==== As mount entry ====<br />
<br />
This is a simple example of a {{ic|cifs}} [[fstab|mount entry]] that requires authentication:<br />
<br />
{{hc|/etc/fstab|2=<br />
//''SERVER''/''sharename'' /mnt/''mountpoint'' cifs _netdev,username=''myuser'',password=''mypass'' 0 0<br />
}}<br />
<br />
{{Note|Spaces in sharename should be replaced by {{ic|\040}} (ASCII code for space in octal). For example, {{ic|//''SERVER''/share name}} on the command line should be {{ic|//''SERVER''/share\040name}} in {{ic|/etc/fstab}}.}}<br />
<br />
{{Tip|Use {{ic|x-systemd.automount}} if you want them to be mounted only upon access. See [[Fstab#Remote filesystem]] for details.}}<br />
<br />
==== As systemd unit ====<br />
<br />
Create a new {{ic|.mount}} file inside {{ic|/etc/systemd/system}}, e.g. {{ic|mnt-myshare.mount}}. See {{man|5|systemd.mount}} for details.<br />
<br />
{{Note|Make sure the filename corresponds to the mountpoint you want to use.<br />
E.g. the unit name {{ic|mnt-myshare.mount}} can only be used if are going to mount the share under {{ic|/mnt/myshare}}. Otherwise the following error might occur: {{ic|1=systemd[1]: mnt-myshare.mount: Where= setting does not match unit name. Refusing.}}.}}<br />
<br />
{{ic|1=What=}} path to share<br />
<br />
{{ic|1=Where=}} path to mount the share<br />
<br />
{{ic|1=Options=}} share mounting options<br />
<br />
{{Note|<br />
* Network mount units automatically acquire {{ic|After}} dependencies on ''remote-fs-pre.target'', ''network.target'' and ''network-online.target'', and gain a {{ic|Before}} dependency on ''remote-fs.target'' unless {{ic|nofail}} mount option is set. Towards the latter a {{ic|Wants}} unit is added as well.<br />
* [[Append]] {{ic|noauto}} to {{ic|Options}} preventing automatically mount during boot (unless it is pulled in by some other unit).<br />
* If you want to use a hostname for the server you want to share (instead of an IP address), add {{ic|1=nss-lookup.target}} to {{ic|1=After}} and {{ic|1=Wants}}. This might avoid mount errors at boot time that do not arise when testing the unit.<br />
}} <br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.mount|2=<br />
[Unit]<br />
Description=Mount Share at boot<br />
<br />
[Mount]<br />
What=//server/share<br />
Where=/mnt/myshare<br />
Options=_netdev,credentials=/etc/samba/credentials/myshare,iocharset=utf8,rw<br />
Type=cifs<br />
TimeoutSec=30<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
{{Tip|In case of an unreachable system, [[append]] {{ic|1=ForceUnmount=true}} to {{ic|[Mount]}}, allowing the share to be (force-)unmounted.}}<br />
<br />
To use {{ic|mnt-myshare.mount}}, [[start]] the unit and [[enable]] it to run on system boot.<br />
<br />
===== automount =====<br />
<br />
To automatically mount a share, one may use the following automount unit:<br />
<br />
{{hc|/etc/systemd/system/mnt-myshare.automount|2=<br />
[Unit]<br />
Description=Automount myshare<br />
<br />
[Automount]<br />
Where=/mnt/myshare<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
[[Disable]]/[[stop]] the {{ic|mnt-myshare.mount}} unit, and [[enable]]/[[start]] {{ic|mnt-myshare.automount}} to automount the share when the mount path is being accessed.<br />
<br />
{{Tip|[[Append]] {{ic|TimeoutIdleSec}} to enable auto unmount. See {{man|5|systemd.automount}} for details.}}<br />
<br />
==== smbnetfs ====<br />
<br />
{{Note|1=smbnetfs needs an intact Samba server setup.<br />
<br />
See above on how to do that.}}<br />
<br />
First, check if you can see all the shares you are interested in mounting:<br />
<br />
$ smbtree -U ''remote_user''<br />
<br />
If that does not work, find and modify the following line<br />
in {{ic|/etc/samba/smb.conf}} accordingly:<br />
<br />
domain master = auto<br />
<br />
Now [[restart]] {{ic|smb.service}} and {{ic|nmb.service}}.<br />
<br />
If everything works as expected, [[pacman#Installing specific packages|install]] {{Pkg|smbnetfs}} from the official repositories.<br />
<br />
Then, add the following line to {{ic|/etc/fuse.conf}}:<br />
<br />
user_allow_other<br />
<br />
Now copy the directory {{ic|/etc/smbnetfs/.smb}} to your home directory:<br />
<br />
$ cp -a /etc/smbnetfs/.smb ~<br />
<br />
Then create a link to {{ic|smb.conf}}:<br />
<br />
$ ln -sf /etc/samba/smb.conf ~/.smb/smb.conf<br />
<br />
If a username and a password are required to access some of the shared folders, edit {{ic|~/.smb/smbnetfs.auth}}<br />
to include one or more entries like this:<br />
<br />
{{hc|~/.smb/smbnetfs.auth|<br />
auth "hostname" "username" "password"<br />
}}<br />
<br />
It is also possible to add entries for specific hosts to be mounted by smbnetfs, if necessary.<br />
More details can be found in {{ic|~/.smb/smbnetfs.conf}}.<br />
<br />
If you are using the [[Dolphin]] or [[GNOME Files]], you may want to add the following to {{ic|~/.smb/smbnetfs.conf}} to avoid "Disk full" errors as smbnetfs by default will report 0 bytes of free space:<br />
<br />
{{hc|~/.smb/smbnetfs.conf|<br />
free_space_size 1073741824<br />
}}<br />
<br />
When you are done with the configuration, you need to run<br />
<br />
$ chmod 600 ~/.smb/smbnetfs.*<br />
<br />
Otherwise, smbnetfs complains about 'insecure config file permissions'.<br />
<br />
Finally, to mount your Samba network neighbourhood to a directory of your choice, call<br />
<br />
$ smbnetfs ''mount_point''<br />
<br />
===== Daemon =====<br />
<br />
The Arch Linux package also maintains an additional system-wide operation mode for smbnetfs. To enable it, you need to make the<br />
said modifications in the directory {{ic|/etc/smbnetfs/.smb}}.<br />
<br />
Then, you can start and/or enable the {{ic|smbnetfs}} [[daemon]] as usual. The system-wide mount point is at {{ic|/mnt/smbnet/}}.<br />
<br />
==== autofs ====<br />
<br />
See [[Autofs]] for information on the kernel-based automounter for Linux.<br />
<br />
=== File manager configuration ===<br />
<br />
==== GNOME Files, Nemo, Caja, Thunar and PCManFM ====<br />
<br />
In order to access samba shares through GNOME Files, Nemo, Caja, Thunar or PCManFM, install the {{Pkg|gvfs-smb}} package, available in the [[official repositories]].<br />
<br />
Press {{ic|Ctrl+l}} and enter {{ic|smb://''servername''/''share''}} in the location bar to access your share.<br />
<br />
The mounted share is likely to be present at {{ic|/run/user/''your_UID''/gvfs}} or {{ic|~/.gvfs}} in the filesystem.<br />
<br />
==== KDE ====<br />
<br />
KDE has the ability to browse Samba shares built in. To use a GUI in the KDE System Settings, you will need to install the {{Pkg|kdenetwork-filesharing}} package.<br />
<br />
==== Other graphical environments ====<br />
<br />
There are a number of useful programs, but they may need to have packages created for them. This can be done with the Arch package build system. The good thing about these others is that they do not require a particular environment to be installed to support them, and so they bring along less baggage.<br />
<br />
* {{AUR|pyneighborhood}} is available in the official repositories.<br />
* LinNeighborhood, RUmba, xffm-samba plugin for Xffm are not available in the official repositories or the AUR. As they are not officially (or even unofficially supported), they may be obsolete and may not work at all.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Discovering network shares ===<br />
<br />
If nothing is known about other systems on the local network, and automated tools such as [[#smbnetfs|smbnetfs]] are not available, the following methods allow one to manually probe for Samba shares.<br />
<br />
1. First, [[install]] the {{Pkg|nmap}} and {{Pkg|smbclient}} packages.<br />
<br />
2. {{ic|nmap}} checks which ports are open:<br />
<br />
# nmap -p 139 -sT "192.168.1.*"<br />
<br />
In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:<br />
<br />
{{hc|$ nmap -sT "192.168.1.*"|<br />
Starting nmap 3.78 ( http://www.insecure.org/nmap/ ) at 2005-02-15 11:45 PHT<br />
Interesting ports on 192.168.1.1:<br />
(The 1661 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
'''139/tcp open netbios-ssn'''<br />
5000/tcp open UPnP<br />
<br />
Interesting ports on 192.168.1.5:<br />
(The 1662 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
6000/tcp open X11<br />
<br />
Nmap run completed -- 256 IP addresses (2 hosts up) scanned in 7.255 seconds<br />
}}<br />
<br />
The first result is another system; the second happens to be the client from where this scan was performed.<br />
<br />
3. Now that systems with port 139 open are revealed, use {{man|1|nmblookup}} to check for NetBIOS names: <br />
<br />
{{hc|$ nmblookup -A 192.168.1.1|<br />
Looking up status of 192.168.1.1<br />
PUTER <00> - B <ACTIVE><br />
HOMENET <00> - <GROUP> B <ACTIVE><br />
PUTER <03> - B <ACTIVE><br />
'''PUTER <20> - B <ACTIVE>'''<br />
HOMENET <1e> - <GROUP> B <ACTIVE><br />
USERNAME <03> - B <ACTIVE><br />
HOMENET <1d> - B <ACTIVE><br />
MSBROWSE <01> - <GROUP> B <ACTIVE><br />
}}<br />
<br />
Regardless of the output, look for '''<20>''', which shows the host with open services.<br />
<br />
4. Use {{ic|smbclient}} to list which services are shared on ''PUTER''. If prompted for a password, pressing enter should still display the list:<br />
<br />
{{hc|$ smbclient -L \\PUTER|2=<br />
Sharename Type Comment<br />
--------- ---- -------<br />
MY_MUSIC Disk<br />
SHAREDDOCS Disk<br />
PRINTER$ Disk<br />
PRINTER Printer<br />
IPC$ IPC Remote Inter Process Communication<br />
<br />
Server Comment<br />
--------- -------<br />
PUTER<br />
<br />
Workgroup Master<br />
--------- -------<br />
HOMENET PUTER<br />
}}<br />
<br />
=== Remote control of Windows computer ===<br />
<br />
Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.<br />
<br />
Send shutdown command with a comment:<br />
<br />
$ net rpc shutdown -C "comment" -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.<br />
<br />
Stop and start services:<br />
<br />
$ net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
To see all possible net rpc command:<br />
<br />
$ net rpc<br />
<br />
== Troubleshooting ==<br />
<br />
=== Failed to start Samba SMB/CIFS server ===<br />
<br />
Possible solutions:<br />
<br />
* Check {{ic|smb.conf}} on syntactic errors with {{man|1|testparm}}.<br />
* Set correct permissions for {{ic|/var/cache/samba/}} and [[restart]] {{ic|smb.service}}:<br />
<br />
# chmod 0755 /var/cache/samba/msg<br />
<br />
=== Permission issues on AppArmor ===<br />
<br />
If using a [[#Creating a share|share path]] located outside of a home or usershares directory, whitelist it in {{ic|/etc/apparmor.d/local/usr.sbin.smbd}}. E.g.:<br />
<br />
{{hc|/etc/apparmor.d/local/usr.sbin.smbd|<br />
"/data/" rk,<br />
"/data/**" lrwk,<br />
}}<br />
<br />
=== No dialect specified on mount ===<br />
<br />
The client is using an unsupported SMB/CIFS version that is required by the server.<br />
<br />
See [[#Restrict protocols for better security]] for more information.<br />
<br />
=== Unable to overwrite files, permissions errors ===<br />
<br />
{{Accuracy|An user should set/check for server/client permissions, instead of using incorrect/possible insecure flags.}}<br />
<br />
Possible solutions:<br />
<br />
* Append the mount option {{ic|nodfs}} to the {{ic|/etc/fstab}} [[#As mount entry|entry]].<br />
* Add {{ic|1=msdfs root = no}} to the {{ic|[global]}} section of the server's {{ic|/etc/samba/smb.conf}}.<br />
<br />
=== Windows clients keep asking for password even if Samba shares are created with guest permissions ===<br />
<br />
Set {{ic|map to guest}} inside the {{ic|global}} section of {{ic|/etc/samba/smb.conf}}:<br />
<br />
map to guest = Bad User<br />
<br />
From Samba 4.10.10 you should use {{ic|Bad Password}} instead {{ic|Bad User}}.<br />
<br />
=== Windows 7 connectivity problems - mount error(12): cannot allocate memory ===<br />
<br />
A known Windows 7 bug that causes "mount error(12): cannot allocate memory" on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:<br />
<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache}} (set to {{ic|1}})<br />
* {{ic|HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size}} (set to {{ic|3}})<br />
<br />
Alternatively, start Command Prompt in Admin Mode and execute the following:<br />
<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f<br />
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f<br />
<br />
Do one of the following for the settings to take effect:<br />
<br />
* Restart Windows<br />
* Restart the Server service via services.msc<br />
* From the Command Prompt run: 'net stop lanmanserver' and 'net start lanmanserver' - The server may automatically restart after stopping it.<br />
<br />
{{Note|Googling will reveal another tweak recommending users to add a key modifying the "IRPStackSize" size. This is incorrect for fixing this issue under Windows 7. Do not attempt it.}}<br />
<br />
[http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017 Original article]{{Dead link|2020|04|03|status=domain name not resolved}}.<br />
<br />
=== Windows 10 1709 and up connectivity problems - "Windows cannot access" 0x80004005 ===<br />
<br />
This error affects some machines running Windows 10 version 1709 and later. It is not related to SMB1 being disabled in this version but to the fact that Microsoft disabled insecure logons for guests on this version for some, but not others.<br />
<br />
To fix, open Group Policy Editor ({{ic|gpedit.msc}}). Navigate to ''Computer configuration\administrative templates\network\Lanman Workstation > Enable insecure guest logons'' and enable it.<br />
Alternatively,change the following value in the registry:<br />
<br />
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]<br />
"AllowInsecureGuestAuth"=dword:1<br />
<br />
=== Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL ===<br />
<br />
If you are a home user and using samba purely for file sharing from a server or NAS, you are probably not interested in sharing printers through it. If so, you can prevent this error from occurring by adding the following lines to your {{ic|/etc/samba/smb.conf}}:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
load printers = No<br />
printing = bsd<br />
printcap name = /dev/null<br />
disable spoolss = Yes<br />
}}<br />
<br />
[[Restart]] the samba service, {{ic|smb.service}}, and then check your logs:<br />
<br />
# cat /var/log/samba/smbd.log<br />
<br />
and the error should now no longer be appearing.<br />
<br />
=== Sharing a folder fails ===<br />
<br />
It means that while you are sharing a folder from ''Dolphin'' (file manager) and everything seems ok at first, after restarting ''Dolphin'' the share icon is gone from the shared folder, and also some output like this in terminal (''Konsole'') output:<br />
<br />
‘net usershare’ returned error 255: net usershare: usershares are currently disabled<br />
<br />
To fix it, enable usershare as described in [[#Enable Usershares]].<br />
<br />
=== "Browsing" network fails with "Failed to retrieve share list from server" ===<br />
<br />
And you are using a firewall (iptables) because you do not trust your local (school, university, hotel) network. This may be due to the following: When the smbclient is browsing the local network it sends out a broadcast request on udp port 137. The servers on the network then reply to your client but as the source address of this reply is different from the destination address iptables saw when sending the request for the listing out, iptables will not recognize the reply as being "ESTABLISHED" or "RELATED", and hence the packet is dropped. A possible solution is to add:<br />
<br />
iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns<br />
<br />
to your iptables setup.<br />
<br />
For [[Uncomplicated_Firewall]], you need to add {{ic|nf_conntrack_netbios_ns}} to the end of the following line in {{ic|/etc/default/ufw}}<br />
<br />
IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_irc nf_nat_irc"<br />
<br />
and then run the following commands as root:<br />
<br />
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper<br />
ufw allow CIFS<br />
ufw reload<br />
<br />
=== Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE ===<br />
<br />
The client probably does not have access to shares. Make sure clients' IP address is in {{ic|1=hosts allow =}} line in {{ic|/etc/samba/smb.conf}}.<br />
<br />
Another problem could be, that the client uses an invalid protocol version. To check this try to connect with the {{ic|smbclient}} where you specify the maximum protocol version manually:<br />
<br />
$ smbclient -U <user name> -L //<server name> -m <protocol version: e. g. SMB2> -W <domain name><br />
<br />
If the command was successful then create a configuration file:<br />
<br />
{{hc|~/.smb/smb.conf|output=<br />
[global]<br />
workgroup = <domain name><br />
client max protocol = SMB2<br />
}}<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL) ===<br />
<br />
You are probably passing a wrong server name to {{ic|smbclient}}. To find out the server name, run {{ic|hostnamectl}} on the server and look at "Transient hostname" line<br />
<br />
=== Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED) ===<br />
<br />
Make sure that the server has started. The shared directories should exist and be accessible.<br />
<br />
=== Protocol negotiation failed: NT_STATUS_CONNECTION_RESET ===<br />
<br />
Probably the server is configured not to accept protocol SMB1. Add option {{ic|1=client max protocol = SMB2}} in {{ic|/etc/samba/smb.conf}}.<br />
Or just pass argument {{ic|-m SMB2}} to {{ic|smbclient}}.<br />
<br />
=== Password Error when correct credentials are given (error 1326) ===<br />
<br />
[https://www.samba.org/samba/history/samba-4.5.0.html Samba 4.5] has NTLMv1 authentication disabled by default. It is recommend to install the latest available upgrades on clients and deny access for unsupported clients.<br />
<br />
If you still need support for very old clients without NTLMv2 support (e.g. Windows XP), it is possible force enable NTLMv1, although this is '''not recommend''' for security reasons:<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
lanman auth = yes<br />
ntlm auth = yes<br />
}}<br />
<br />
If NTLMv2 clients are unable to authenticate when NTLMv1 has been enabled, create the following file on the client:<br />
{{hc|/home/user/.smb/smb.conf|2=<br />
[global]<br />
sec = ntlmv2<br />
client ntlmv2 auth = yes<br />
}}<br />
<br />
This change also affects samba shares mounted with '''mount.cifs'''. If after upgrade to Samba 4.5 your mount fails, add the '''sec=ntlmssp''' option to your mount command, e.g.<br />
<br />
mount.cifs //server/share /mnt/point -o sec=ntlmssp,...<br />
<br />
See the {{man|8|mount.cifs}} man page: '''ntlmssp''' - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message. The default in mainline kernel versions prior to v3.8 was '''sec=ntlm'''. In v3.8, the default was changed to '''sec=ntlmssp'''.<br />
<br />
=== Mapping reserved Windows characters ===<br />
<br />
Starting with kernel 3.18, the cifs module uses the [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2baa2682531ff02928e2d3904800696d9e7193db "mapposix" option by default].<br />
When mounting a share using unix extensions and a default Samba configuration, files and directories containing one of the seven reserved Windows characters {{ic|: \ * < > ? |}} are listed but cannot be accessed.<br />
<br />
Possible solutions are:<br />
<br />
* Use the undocumented {{ic|nomapposix}} mount option for cifs<br />
<br />
# mount.cifs //server/share /mnt/point -o nomapposix<br />
<br />
* Configure Samba to remap {{ic|mapposix}} ("SFM", Services for Mac) style characters to the correct native ones using [https://www.mankier.com/8/vfs_fruit fruit]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia fruit<br />
fruit:encoding = native<br />
}}<br />
<br />
* Manually remap forbidden characters using [https://www.mankier.com/8/vfs_catia catia]<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
vfs objects = catia<br />
catia:mappings = 0x22:0xf022, 0x2a:0xf02a, 0x2f:0xf02f, 0x3a:0xf03a, 0x3c:0xf03c, 0x3e:0xf03e, 0x3f:0xf03f, 0x5c:0xf05c, 0x7c:0xf07c, 0x20:0xf020<br />
}}<br />
<br />
The latter approach (using catia or fruit) has the drawback of filtering files with unprintable characters.<br />
<br />
=== Folder shared inside graphical environment is not available to guests ===<br />
<br />
This section presupposes:<br />
<br />
# Usershares are configured following [[#Enable Usershares|previous section]]<br />
# A shared folder has been created as a non-root user from GUI<br />
# Guests access has been set to shared folder during creation<br />
# Samba service has been restarted at least once since last {{ic|/etc/samba/smb.conf}} file modification<br />
<br />
For clarification purpose only, in the following sub-sections is assumed:<br />
<br />
* Shared folder is located inside user home directory path ({{ic|/home/yourUser/Shared}})<br />
* Shared folder name is ''MySharedFiles''<br />
* Guest access is read-only.<br />
* Windows users will access shared folder content without login prompt<br />
<br />
==== Verify correct samba configuration ====<br />
<br />
Run the following command from a terminal to test configuration file correctness:<br />
<br />
$ testparm<br />
<br />
==== Verify correct shared folder creation ====<br />
<br />
Run the following commands from a terminal:<br />
<br />
$ cd /var/lib/samba/usershare<br />
$ ls<br />
<br />
If everything is fine, you will notice a file named {{ic|mysharedfiles}}<br />
<br />
Read the file contents using the following command:<br />
<br />
$ cat mysharedfiles<br />
<br />
The terminal output should display something like this:<br />
<br />
{{hc|/var/lib/samba/usershare/mysharedfiles|2=<br />
path=/home/yourUser/Shared<br />
comment=<br />
usershare_acl=S-1-1-0:r<br />
guest_ok=y<br />
sharename=MySharedFiles<br />
}}<br />
<br />
==== Verify folder access by guest ====<br />
<br />
Run the following command from a terminal. If prompted for a password, just press Enter:<br />
<br />
$ smbclient -L localhost<br />
<br />
If everything is fine, MySharedFiles should be displayed under {{ic|Sharename}} column<br />
<br />
Run the following command in order to access the shared folder as guest (anonymous login)<br />
<br />
$ smbclient -N //localhost/MySharedFiles<br />
<br />
If everything is fine samba client prompt will be displayed:<br />
<br />
smb: \><br />
<br />
From samba prompt verify guest can list directory contents:<br />
<br />
smb: \> ls<br />
<br />
If the {{ic|NTFS_STATUS_ACCESS_DENIED}} error is displayed, the issue is likely to be with Unix directory permissions. Ensure that your samba user has access to the folder and all parent folders. You can test this by sudoing to the user and attempting to list the mount directory, and all of its parents.<br />
<br />
=== Mount error: Host is down ===<br />
This error might be seen when mounting shares of Synology NAS servers. Use the mount option {{ic|1=vers=1.0}} to solve it.<br />
<br />
{{Note|SMB version 1 is known to have security vulnerabilities and was used in successful ransomware attacks.}}<br />
<br />
=== Software caused connection abort ===<br />
<br />
File managers that utilizes {{Pkg|gvfs-smb}} can show the error {{ic|Software caused connection abort}} when writing a file to a share/server. This may be due to the server running SMB/CIFS version 1, which many routers use for USB drive sharing (e.g. Belkin routers). To write to these shares specify the CIFS version with the option {{ic|1=vers=1.0}}. E.g.:<br />
<br />
{{hc|/etc/fstab|2=<br />
//SERVER/sharename /mnt/mountpoint cifs _netdev,guest,file_mode=0777,dir_mode=0777,vers=1.0 0 0<br />
}}<br />
<br />
This can also happen after updating Samba to version 4.11, which deactivates SMB1 as default, and accessing any Samba share. You can reenable it by adding<br />
<br />
{{hc|/etc/samba/smb.conf|2=<br />
[global]<br />
client min protocol = CORE<br />
}}<br />
<br />
=== Connection problem (due to authentification error) ===<br />
<br />
Be sure that you do not leave any space characters before your username in Samba client configuration file as follows:<br />
<br />
{{hc|~/.samba|2=<br />
username= user<br />
password=pass<br />
}}<br />
<br />
The correct format is:<br />
<br />
{{hc|~/.samba|2=<br />
username=user<br />
password=pass<br />
}}<br />
<br />
== See also ==<br />
<br />
* [https://www.samba.org/ Official website]<br />
* [https://www.samba.org/samba/docs/SambaIntro.html Samba: An Introduction]<br />
* [https://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf Samba 3.2.x HOWTO and Reference Guide] (outdated but still most extensive documentation)<br />
* [[Wikipedia:Samba (software)|Wikipedia]]<br />
* [[Gentoo:Samba/Guide]]<br />
* [[Debian:SambaServerSimple]]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=555635Dell XPS 13 2-in-1 (9365)2018-11-18T06:29:17Z<p>TPXP: /* Suspend issues */ Precise what is required</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 to 2.1.2 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/10/06<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Suspend issues ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]]. '''Note:''' As of 2018/11/18, this does not seem required anymore: the kernel automatically sets it correctly.<br />
<br />
The system might wake up a few seconds after going to sleep due to ACPI EC. [https://bugzilla.kernel.org/show_bug.cgi?id=192591] Also, the computer might not wake up automatically when pressing a key. To prevent all these issues, you need to adjust some parameters on sysfs:<br />
<br />
{{hc|/etc/tmpfiles.d/suspend-dell-9365.conf|2=<br />
# Syntax: Type Path Mode UID GID Age Argument<br />
# man tmpfiles.d for more details<br />
<br />
# Kernel bug: https://bugzilla.kernel.org/show_bug.cgi?id=192591<br />
<br />
# Use s2idle (not deep) for suspend.<br />
w /sys/power/mem_sleep - - - - s2idle<br />
<br />
# Enable key press to wakeup<br />
w /sys/devices/platform/i8042/serio0/power/wakeup - - - - enabled<br />
<br />
# Make sure we don't wake up the computer while sleeping<br />
w /sys/module/acpi/parameters/ec_no_wakeup - - - - Y<br />
}}<br />
<br />
The two first parameters should be correct by default, so you might want not to set them. As of 2018/11/18, the third parameter (<code>/sys/module/acpi/parameters/ec_no_wakeup</code>) is required or the computer wakes up after a few seconds in suspend mode.<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=555634Dell XPS 13 2-in-1 (9365)2018-11-18T06:27:36Z<p>TPXP: /* Not waking from suspend */ Fixes for suspend</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 to 2.1.2 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/10/06<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Suspend issues ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]]. '''Note:''' As of 2018/11/18, this does not seem required anymore: the kernel automatically sets it correctly.<br />
<br />
The system might wake up a few seconds after going to sleep due to ACPI EC. [https://bugzilla.kernel.org/show_bug.cgi?id=192591] Also, the computer might not wake up automatically when pressing a key. To prevent all these issues, you need to adjust some parameters on sysfs:<br />
<br />
{{hc|/etc/tmpfiles.d/suspend-dell-9365.conf|2=<br />
# Syntax: Type Path Mode UID GID Age Argument<br />
# man tmpfiles.d for more details<br />
<br />
# Kernel bug: https://bugzilla.kernel.org/show_bug.cgi?id=192591<br />
<br />
# Use s2idle (not deep) for suspend.<br />
w /sys/power/mem_sleep - - - - s2idle<br />
<br />
# Enable key press to wakeup<br />
w /sys/devices/platform/i8042/serio0/power/wakeup - - - - enabled<br />
<br />
# Make sure we don't wake up the computer while sleeping<br />
w /sys/module/acpi/parameters/ec_no_wakeup - - - - Y<br />
}}<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=User:TPXP&diff=553196User:TPXP2018-11-05T06:26:53Z<p>TPXP: Fixes</p>
<hr />
<div>Hi, I'm TPXP ! :-)<br />
<br />
Machines running ArchLinux I have:<br />
* [[Dell XPS 13 2-in-1 (9365)]] - that's the computer I use daily !<br />
* Dell XPS 17 (L701X) - pretty old model, big and heavy. I don't use it anymore<br />
<br />
Languages:<br />
* '''French''': Native speaker<br />
* '''English''': Good level<br />
* Spanish: Average level<br />
<br />
[https://gitlab.com/TPXP/ Gitlab] - [https://github.com/TPXP Github] - [https://aur.archlinux.org/packages/?SeB=m&K=TPXP AUR] - [https://pgp.mit.edu/pks/lookup?op=get&search=0x722E1405F9F15F5E PGP Key] - [https://tpxp.ddns.net Personal website]</div>TPXPhttps://wiki.archlinux.org/index.php?title=User:TPXP&diff=553195User:TPXP2018-11-05T06:25:47Z<p>TPXP: Create my user page :-)</p>
<hr />
<div>Hi, I'm TPXP ! :-)<br />
<br />
Machines running ArchLinux I have:<br />
* Dell XPS 13 2-in-1 (9365) - that's the computer I use daily !<br />
* Dell XPS 17 (L701X) - pretty old model, and big as well. I don't use it anymore<br />
<br />
Languages:<br />
* **French**: Native speaker<br />
* **English**: Good level<br />
* Spanish: Average level<br />
<br />
[https://gitlab.com/TPXP/ Gitlab] - [https://github.com/TPXP Github] - [https://aur.archlinux.org/packages/?SeB=m&K=TPXP AUR] - [https://pgp.mit.edu/pks/lookup?op=get&search=0x722E1405F9F15F5E PGP Key] - [https://tpxp.ddns.net Personal website]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=553194Dell XPS 13 2-in-1 (9365)2018-11-05T06:16:25Z<p>TPXP: /* Not waking from suspend */ Add a not to highlight that this workaround is not needed anymore</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 to 2.1.2 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/10/06<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
'''Note:''' As of 2018/11/5, this does not seem required anymore.<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=552970Dell XPS 13 2-in-1 (9365)2018-11-04T10:58:22Z<p>TPXP: /* Instant wake up from sleep when folding the screen */ In fact, it does not seem to work</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 to 2.1.2 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/10/06<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=552337Dell XPS 13 2-in-1 (9365)2018-11-01T14:16:24Z<p>TPXP: /* Troubleshooting */ Add a fix for instant waking up when going to sleep</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 to 2.1.2 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/10/06<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Instant wake up from sleep when folding the screen ===<br />
Recent kernels might go to sleep whhen you fold the screen but wake up very shortly after. Upgrading your BIOS to [https://www.dell.com/support/home/us/en/04/drivers/driversdetails?driverId=THDDP&osCode=BIOSA&productCode=xps-13-9365-2-in-1-laptop version 2.2.0] (requires Windows) seems to fix the issue.<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=541708Dell XPS 13 2-in-1 (9365)2018-09-17T03:04:58Z<p>TPXP: /* Fingerprint sensor */ Update the issue link</p>
<hr />
<div>[[Category:Dell]]<br />
{{Related articles start}}<br />
{{Related|Dell XPS 13 (9333)}}<br />
{{Related|Dell XPS 13 (9343)}}<br />
{{Related|Dell XPS 13 (9350)}}<br />
{{Related|Dell XPS 13 (9360)}}<br />
{{Related|Dell XPS 13 (9370)}}<br />
{{Related articles end}}<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/02/16<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Screen not rotating ===<br />
You need to install {{Pkg|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://gitlab.freedesktop.org/libfprint/libfprint/issues/52]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=RTorrent&diff=532771RTorrent2018-08-08T08:13:26Z<p>TPXP: /* Systemd services using tmux or screen */ Add a note about rTorrent's daemon mode</p>
<hr />
<div>{{DISPLAYTITLE:rTorrent}}<br />
[[Category:BitTorrent clients]]<br />
[[es:RTorrent]]<br />
[[ja:RTorrent]]<br />
[[ru:RTorrent]]<br />
[[zh-hans:RTorrent]]<br />
[https://rakshasa.github.io/rtorrent/ rTorrent] is a quick and efficient BitTorrent client that uses, and is in development alongside, the libTorrent (not to be confused with {{Pkg|libtorrent-rasterbar}}) library. It is written in C++ and uses the [[Wikipedia:ncurses|ncurses]] programming library, which means it uses a text user interface. When combined with a terminal multiplexer (e.g. [[GNU Screen]] or [[Tmux]]) and [[Secure Shell]], it becomes a convenient remote [[Wikipedia:BitTorrent (protocol)#Operation|BitTorrent client]].<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|rtorrent}} package.<br />
<br />
=== Unofficial packages ===<br />
<br />
* {{AUR|rtorrent-git}} - Git [https://github.com/rakshasa/rtorrent master branch] package<br />
* {{AUR|rtorrent-ps}} - Release package with [https://github.com/pyroscope/rtorrent-ps rtorrent-ps patchset]<br />
* {{AUR|rtorrent-pyro-git}} - Git [https://github.com/rakshasa/rtorrent/tree/feature-bind feature-bind branch] package with [https://github.com/pyroscope/rtorrent-ps rtorrent-ps patchset]<br />
* {{AUR|rtorrent-vi-color}} - Release package with vi-like key bindings<br />
<br />
== Configuration ==<br />
<br />
{{Out of date|This section especially, and others that use config/XMLRPC commands, should be refactored to "new syntax", see [https://github.com/rakshasa/rtorrent/wiki/RPC-Migration-0.9 this rTorrent wiki page] for details, including a ''sed'' script that helps with that.}}<br />
<br />
{{Note|<br />
* See the rTorrent wiki article on this subject for more information: [https://github.com/rakshasa/rtorrent/wiki/Common-Tasks-in-rTorrent Common Tasks in rTorrent for Dummies].<br />
* Vim may mistake the syntax of the config file, causing errors in the highlighting. To resolve this you can [[append]] a modeline {{ic|1=# vim: set syntax=conf:}} to {{ic|~/.rtorrent.rc}}, or install [https://github.com/vim-scripts/rtorrent-syntax-file rtorrent-syntax-file].}}<br />
<br />
Before running rTorrent, copy the example configuration file {{ic|/usr/share/doc/rtorrent/rtorrent.rc}} to {{ic|~/.rtorrent.rc}}, and check out [https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template the related rTorrent wiki page] that has a ''modern'' basic configuration file.<br />
<br />
=== Performance ===<br />
<br />
{{Note|See the rTorrent wiki article on this subject for more information: [https://github.com/rakshasa/rtorrent/wiki/Performance-Tuning Performance Tuning]}}<br />
<br />
The values for the following options are dependent on the system's hardware and Internet connection speed. To find the optimal values read: [http://torrentfreak.com/optimize-your-BitTorrent-download-speed Optimize Your BitTorrent Download Speed]<br />
{{bc|<nowiki><br />
throttle.min_peers.normal.set = 40<br />
throttle.max_peers.normal.set = 52<br />
<br />
throttle.min_peers.seed.set = 10<br />
throttle.max_peers.seed.set = 52<br />
<br />
throttle.max_uploads.set = 8<br />
<br />
throttle.global_down.max_rate.set = 200<br />
throttle.global_up.max_rate.set = 28<br />
</nowiki>}}<br />
<br />
The {{ic|pieces.hash.on_completion.set}} option executes a hash check when rTorrent is started. It checks for errors in your completed files. <br />
pieces.hash.on_completion.set = yes<br />
<br />
=== Create and manage files ===<br />
<br />
The {{ic|directory.default.set}} option will determine where your torrent data will be saved (could be a relative path):<br />
directory.default.set = ~/downloaded<br />
<br />
The {{ic|session.path.set}} option allows rTorrent to save the progess of your torrents. It is recommended to create a directory in home directory (e.g. {{ic|mkdir ~/.rtorrent.session}}).<br />
session.path.set = ~/.rtorrent.session<br />
<br />
The {{ic|schedule2}} option has rTorrent watch a particular directory for new torrent files. Saving a torrent file to this directory will automatically start the download. Remember to create the directory that will be watched (e.g. {{ic|mkdir ~/watch}}). Also, be careful when using this option as rTorrent will move the torrent file to your session folder and rename it to its hash value.<br />
schedule2 = watch_directory,5,5,load_start=/home/''user''/watch/*.torrent<br />
schedule2 = untied_directory,5,5,stop_untied=<br />
schedule2 = tied_directory,5,5,start_tied=<br />
<br />
The following {{ic|schedule2}} option is intended to stop rTorrent from downloading data when disk space is low.<br />
schedule2 = low_diskspace,5,60,((close_low_diskspace,100M))<br />
<br />
=== Port configuration ===<br />
<br />
The {{ic|network.port_range.set}} option sets which port(s) to use for listening. It is recommended to use a port that is higher than 49152 (see: [[Wikipedia:List of TCP and UDP port numbers|List of port numbers]]). Although, rTorrent allows a range of ports, a single port is recommended.<br />
network.port_range.set = 49164-49164<br />
<br />
Additionally, make sure port forwarding is enabled for the proper port(s) (see: [http://portforward.com/english/routers/port_forwarding/routerindex.htm Port Forward guides]).<br />
<br />
=== Additional settings ===<br />
<br />
The {{ic|protocol.encryption.set}} option enables or disables encryption. It is very important to enable this option, not only for yourself, but also for your peers in the torrent swarm. Some users need to obscure their bandwidth usage from their ISP. And it does not hurt to enable it even if you do not need the added security.<br />
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry<br />
It is also possible to force all connections to use encryption. However, be aware that this stricter rule will reduce your client's availability:<br />
protocol.encryption.set = require,require_RC4,allow_incoming,try_outgoing<br />
<br />
See also [[Wikipedia:BitTorrent Protocol Encryption]].<br />
<br />
This final {{ic|dht.mode.set}} option enables [[Wikipedia:Distributed hash table|DHT]] support. DHT is common among public trackers and will allow the client to acquire more peers.<br />
{{bc|<nowiki><br />
dht.mode.set = auto<br />
dht.port.set = 6881<br />
protocol.pex.set= yes<br />
</nowiki>}}<br />
<br />
== Key bindings ==<br />
<br />
rTorrent relies exclusively on keyboard shortcuts for user input. A quick reference is available in the table below. A complete guide is available on the rTorrent wiki (see: [https://github.com/rakshasa/rtorrent/wiki/User-Guide rTorrent User Guide]).<br />
<br />
{{Note|Striking {{ic|Ctrl-q}} twice in quick succession will make rTorrent shutdown without waiting to send a stop announce to the connected trackers.}}<br />
<br />
{| class="wikitable"<br />
|-<br />
!width="75" |Cmd<br />
!Action<br />
|-<br />
|Ctrl-q<br />
|Quit application<br />
|-<br />
|Ctrl-s<br />
|Start download. Runs hash first unless already done.<br />
|-<br />
|Ctrl-d<br />
|Stop an active download or remove a stopped download<br />
|-<br />
|Ctrl-k<br />
|Stop and close the files of an active download.<br />
|-<br />
|Ctrl-r<br />
|Initiate hash check of torrent. Starts downloading if file is not available.<br />
|-<br />
|Ctrl-o<br />
|Specify the download directory for a added, but not started torrent.<br />
|-<br />
|Left<br />
|Returns to the previous screen<br />
|-<br />
|Right<br />
|Goes to the next screen<br />
|-<br />
|Backspace<br />
|Adds and starts the specified *.torrent<br />
|-<br />
|Return<br />
|Adds and doesn't start the specified *.torrent<br />
|-<br />
|<nowiki>a|s|d</nowiki><br />
|<nowiki>Increase global upload throttle about 1|5|50 KB/s</nowiki><br />
|-<br />
|<nowiki>A|S|D</nowiki><br />
|<nowiki>Increase global download throttle about 1|5|50 KB/s</nowiki><br />
|-<br />
|<nowiki>z|x|c</nowiki><br />
|<nowiki>Decrease global upload throttle about 1|5|50 KB/s</nowiki><br />
|-<br />
|<nowiki>Z|X|C</nowiki><br />
|<nowiki>Decrease global download throttle about 1|5|50 KB/s</nowiki><br />
|}<br />
<br />
=== Redundant mapping ===<br />
<br />
{{ic|Ctrl-s}} is often used for terminal control to stop screen output while {{ic|Ctrl-q}} is used to start it. These mappings may interfere with rTorrent. Check to see if these terminal options are bound to a mapping:<br />
{{hc|$ stty -a|<nowiki>...<br />
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;<br />
...<br />
</nowiki>}}<br />
<br />
To remove the mappings, change the terminal characteristics to undefine the aforementioned special characters (i.e. {{ic|stop}} and {{ic|start}}):<br />
# stty stop undef<br />
# stty start undef<br />
<br />
To remove these mappings automatically at startup you may add the two preceding commands to your {{ic|~/.bashrc}} file.<br />
<br />
== Additional tips ==<br />
<br />
=== Systemd services using tmux or screen ===<br />
{{Out of date|rTorrent 0.9.7+ includes [https://github.com/rakshasa/rtorrent/wiki/Daemon_Mode a daemon mode]. See [https://github.com/rakshasa/rtorrent/pull/446 this issue] for more details on how to use it, especially [https://github.com/rakshasa/rtorrent/pull/446#issuecomment-410493583 this comment] for the configuration syntax.}}<br />
<br />
Usage of the following services depends on type of service unit.<br />
<br />
'''For system services''' (in /etc/systemd/system/):<br />
<br />
To start at boot time:<br />
# systemctl enable rtorrent<br />
Start manually:<br />
# systemctl start rtorrent<br />
Stop:<br />
# systemctl stop rtorrent<br />
<br />
Make sure 'rtorrent' user is created with the appropriate home directory with your rtorrent.rc placed in.<br />
<br />
'''For user services''' (in /etc/systemd/user/):<br />
$ systemctl --user enable rtorrent<br />
Start manually:<br />
$ systemctl --user start rtorrent<br />
Stop:<br />
$ systemctl --user stop rtorrent<br />
<br />
==== With screen ====<br />
*As system service unit<br />
<br />
{{hc|/etc/systemd/system/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rTorrent<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
KillMode=none<br />
User=rtorrent<br />
ExecStartPre=/usr/bin/bash -c "if test -e %h/.rtorrent_session/rtorrent.lock && test -z `pidof rtorrent`; then rm -f %h/.rtorrent_session/rtorrent.lock; fi"<br />
ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent<br />
ExecStop=/usr/bin/bash -c "test `pidof rtorrent` && killall -w -s 2 /usr/bin/rtorrent"<br />
WorkingDirectory=%h<br />
Restart=on-failure<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
*As user service unit<br />
<br />
{{hc|/etc/systemd/user/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rTorrent<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
KillMode=none<br />
ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent<br />
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent<br />
WorkingDirectory=%h<br />
<br />
[Install]<br />
WantedBy=default.target<br />
</nowiki>}}<br />
<br />
Attach to rtorrent's session:<br />
screen -D -r rtorrent<br />
<br />
Detach:<br />
Ctrl-a d<br />
<br />
==== with tmux ====<br />
*With independent tmux server (restart rtorrent if crashed)<br />
{{hc|~/.config/systemd/user/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rtorrent<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
ExecStartPre=/usr/bin/bash -c "if test -e ~/.session/rtorrent.lock && test -z `pidof rtorrent`; then rm -f ~/.session/rtorrent.lock; fi"<br />
ExecStart=/usr/bin/tmux -L rt new-session -s rt -n rtorrent -d rtorrent <br />
ExecStop=/usr/bin/bash -c "/usr/bin/tmux -L rt send-keys -t rt:rtorrent.0 C-q; while pidof rtorrent > /dev/null; do echo stopping rtorrent...; sleep 1; done"<br />
Restart=on-failure<br />
<br />
[Install]<br />
WantedBy=default.target<br />
</nowiki>}}<br />
<br />
*With tmux running as user rtorrent (restart rtorrent if crashed)<br />
{{hc|/etc/systemd/system/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rTorrent Daemon<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
KillMode=none<br />
User=rtorrent<br />
ExecStart=/usr/bin/tmux new-session -c /mnt/storage/rtorrent -s rtorrent -n rtorrent -d rtorrent<br />
ExecStop=/usr/bin/bash -c "/usr/bin/tmux send-keys -t rtorrent C-q && while pidof rtorrent > /dev/null; do sleep 0.5; done"<br />
WorkingDirectory=%h<br />
Restart=on-failure<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Attach to rtorrent's session:<br />
tmux -L rt attach -t rt<br />
tmux attach -t rt<br />
<br />
Detach:<br />
Ctrl-b d<br />
<br />
=== systemd service file with dtach ===<br />
<br />
{{Style|Creating multiple rtorrent sessions this way is far from perfect, why don't we just assume for simplicity that there is only one session? This is assumed in [[#systemd service file with tmux or screen]] anyway.}}<br />
<br />
When running dtach from systemd unit, the {{ic|TERM}} environment variable [[systemd/User#Environment_variables|has to be set explicitly]] for rtorrent to work.<br />
<br />
This service file has no restart because the author occasionally takes the drive in question offline, and rtorrent fails, shall we say, "suboptimally" when started in this scenario and loses many torrent specific settings such as the specific directories each torrent is stored in. In fact the symlinks that kick off rtorrent live on the relevant drive; if it is unmounted rtorrent cannot start. This use case of blocking rtorrent from starting is relevant to users who put the downloaded files on removable media such as NAS, USB or eSATA drives.<br />
<br />
{{hc|~/.config/systemd/user/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rTorrent<br />
#After=network.target<br />
<br />
[Service]<br />
# set TERM according to your terminal<br />
Environment="TERM=xterm"<br />
#Environment="TERM=linux" <br />
Type=forking<br />
KillMode=none<br />
ExecStart=-/usr/bin/dtach -n /home/sam/run/dtach_fifos/fifo -e "^T" /home/sam/bin/rtr_new -n -o import=/home/sam/.config/rtorrent/new_.rc <br />
# dtach -n <separate filename for each instance><br />
# <br />
# rtr_new -n to ignore the default .rtorrent.rc<br />
# rtr_new -o import to load the instance-specific rc<br />
ExecStop=-/usr/bin/killall -u sam -e -w -s INT /home/sam/bin/rtr_new<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Note some other issues exposed in this service file other than just dtach:<br />
<br />
{{ic|/home/sam/bin/rtr_new}} is a symlink to {{ic|/usr/bin/rtorrent}}<br />
<br />
This lets us run several instances and kill each one independently with a different version of the ExecStop, to wit:<br />
<br />
{{bc|1=ExecStop=-/usr/bin/killall -u sam -e -w -s INT /home/sam/bin/rtr_new<br />
ExecStop=-/usr/bin/killall -u sam -e -w -s INT /home/sam/bin/rtr_academic<br />
ExecStop=-/usr/bin/killall -u sam -e -w -s INT /home/sam/bin/rtr_other_stuff}}<br />
<br />
These are each in a different service file, each of which controls one instance.<br />
<br />
Without this step, when running multiple instances a killall solution would kill all the running rtorrent instances. <br />
<br />
If multiple rtorrent instances are not needed and the rtorrent rc file is in the default location the above service file may be simplified. The entire file is included but only the ExecStart and <br />
ExecStop lines change. <br />
<br />
{{hc|~/.config/systemd/user/rtorrent.service|<nowiki><br />
[Unit]<br />
Description=rTorrent<br />
#After=network.target<br />
<br />
[Service]<br />
# set TERM according to your terminal<br />
Environment="TERM=xterm"<br />
#Environment="TERM=linux" <br />
Type=forking<br />
KillMode=none<br />
ExecStart=-/usr/bin/dtach -n /home/sam/run/dtach_fifos/fifo -e "^T" /usr/bin/rtorrent <br />
# dtach -n <user specified FIFO name> -e <user specified character> /usr/bin/rtorrent <br />
ExecStop=/usr/bin/killall -w -s INT /usr/bin/rtorrent<br />
# -e (exact match) and -u (user name) were added above to stop specific processes<br />
# and may be omitted here because only one rtorrent will be running<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
The service can be controlled with [[systemctl --user]]. When it is started, you can attach to the session:<br />
<br />
$ dtach -a /home/sam/run/dtach_fifos/fifo -e "^T"<br />
<br />
=== Pre-allocation ===<br />
<br />
The rTorrent package in the community repository lacks pre-allocation. Compiling rTorrent with pre-allocation allows files to be allocated before downloading the torrent. The major benefit is that it limits and avoids fragmentation of the filesystem. However, this introduces a delay during the pre-allocation if the filesystem does not support the fallocate syscall natively.<br />
<br />
Therefore this switch is recommended for xfs, ext4 and btrfs filesystems, which have native fallocate syscall support. They will see no delay during preallocation and no fragmented filesystem. Pre-allocation on others filesystems will cause a delay but will not fragment the files.<br />
<br />
To make pre-allocation available, recompile libTorrent from the [[ABS]] tree with the following new switch:<br />
$ ./configure --prefix=/usr --disable-debug --with-posix-fallocate<br />
<br />
To enable it, add the following to your {{ic|~/rtorrent.rc}}:<br />
{{hc|~/rtorrent.rc|<nowiki><br />
# Preallocate files; reduces defragmentation on filesystems.<br />
system.file.allocate = 1<br />
</nowiki>}}<br />
<br />
=== Manage completed files ===<br />
<br />
{{Note|If you are having trouble with this tip, it may be easier to follow the [https://github.com/rakshasa/rtorrent/wiki/Common-Tasks-in-rTorrent#move-completed-torrents-to-a-fixed-location docs].}}<br />
<br />
It is possible to have rtorrent organize completed torrent data to specific folders based on which 'watch' folder you drop the *.torrent into while continuing to seed.<br />
<br />
As a solution, use the following example in your {{ic|~/.rtorrent.rc}}.<br />
Make sure to change the paths.<br />
<br />
{{bc|1=<br />
# default path for in progress downloads<br />
directory = /home/user/torrents/incomplete<br />
<br />
# schedule a timer event named 'watch_directory_1':<br />
# 1) triggers 10 seconds after rtorrent starts<br />
# 2) triggers at 10 second intervals thereafter<br />
# 3) Upon trigger, attempt to load (and start) new *.torrent files found in /home/user/torrents/watch/<br />
# 4) set a variable named 'custom1' with the value "/home/user/torrents/complete"<br />
# NOTE: if you do not want it to automatically start the torrent, change 'load.start' to 'load.normal'<br />
schedule2 = watch_directory_1,10,10,"load.start=/home/user/torrents/watch/*.torrent,d.custom1.set=/home/user/torrents/complete"<br />
<br />
# upon completion, move content to path specified above via custom1<br />
method.insert = d.data_path, simple, "if=(d.is_multi_file), (cat,(d.directory),/), (cat,(d.directory),/,(d.name))"<br />
method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-u,$argument.0=,$argument.1=; d.save_full_session="<br />
method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.custom1="<br />
}}<br />
<br />
You can add additional watch directories and corresponding completion directories like so:<br />
<br />
{{bc|1=<br />
directory = /home/user/torrents/incomplete<br />
<br />
schedule2 = watch_directory_1,10,10,"load.start=/home/user/torrents/watch/*.torrent,d.custom1.set=/home/user/torrents/complete"<br />
schedule2 = watch_directory_2,10,10,"load.start=/home/user/torrents/watch/iso/*.torrent,d.custom1.set=/home/user/torrents/complete/iso"<br />
schedule2 = watch_directory_3,10,10,"load.start=/home/user/torrents/watch/music/*.torrent,d.custom1.set=/home/user/torrents/complete/music"<br />
<br />
method.insert = d.data_path, simple, "if=(d.is_multi_file), (cat,(d.directory),/), (cat,(d.directory),/,(d.name))"<br />
method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-u,$argument.0=,$argument.1=; d.save_full_session="<br />
method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.custom1="<br />
}}<br />
<br />
You can also specify incomplete directories per watch directory:<br />
<br />
{{bc|1=<br />
directory = /home/user/torrents/incomplete<br />
<br />
schedule2 = watch_directory_1,10,10,"load.start=/home/user/torrents/watch/*.torrent,d.directory.set=/home/user/torrents/incomplete,d.custom1.set=/home/user/torrents/complete"<br />
schedule2 = watch_directory_2,10,10,"load.start=/home/user/torrents/watch/iso/*.torrent,d.directory.set=/home/user/torrents/incomplete/iso,d.custom1.set=/home/user/torrents/complete/iso"<br />
schedule2 = watch_directory_3,10,10,"load.start=/home/user/torrents/watch/music/*.torrent,d.directory.set=/home/user/torrents/incomplete/music,d.custom1.set=/home/user/torrents/complete/music"<br />
<br />
method.insert = d.data_path, simple, "if=(d.is_multi_file), (cat,(d.directory),/), (cat,(d.directory),/,(d.name))"<br />
method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-u,$argument.0=,$argument.1=; d.save_full_session="<br />
method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.custom1="<br />
}}<br />
<br />
Also see [https://rtorrent-docs.readthedocs.io/en/latest/use-cases.html#versatile-move-on-completion completion moving via a bash script], and via [https://pyrocore.readthedocs.io/en/latest/howto.html#moving-all-data-for-selected-items-to-a-new-location pyrocore's rtcontrol] (there is an AUR package).<br />
<br />
==== Notification with Google Mail ====<br />
<br />
Cell phone providers allow you to "email" your phone:<br />
{{bc|<nowiki><br />
Verizon: 10digitphonenumber@vtext.com<br />
AT&T: 10digitphonenumber@txt.att.net<br />
Former AT&T customers: 10digitphonenumber@mmode.com<br />
Sprint: 10digitphonenumber@messaging.sprintpcs.com<br />
T-Mobile: 10digitphonenumber@tmomail.net<br />
Nextel: 10digitphonenumber@messaging.nextel.com<br />
Cingular: 10digitphonenumber@cingularme.com<br />
Virgin Mobile: 10digitphonenumber@vmobl.com<br />
Alltel: 10digitphonenumber@alltelmessage.com OR<br />
10digitphonenumber@message.alltel.com<br />
CellularOne: 10digitphonenumber@mobile.celloneusa.com<br />
Omnipoint: 10digitphonenumber@omnipointpcs.com<br />
Qwest: 10digitphonenumber@qwestmp.com<br />
Telus: 10digitphonenumber@msg.telus.com<br />
Rogers Wireless: 10digitphonenumber@pcs.rogers.com<br />
Fido: 10digitphonenumber@fido.ca<br />
Bell Mobility: 10digitphonenumber@txt.bell.ca<br />
Koodo Mobile: 10digitphonenumber@msg.koodomobile.com<br />
MTS: 10digitphonenumber@text.mtsmobility.com<br />
President's Choice: 10digitphonenumber@txt.bell.ca<br />
Sasktel: 10digitphonenumber@sms.sasktel.com<br />
Solo: 10digitphonenumber@txt.bell.ca<br />
</nowiki>}}<br />
<br />
*Install mailx which is provided by the {{Pkg|s-nail}} package that is found in the [[official repositories]].<br />
<br />
*Clear the {{ic|/etc/mail.rc}} file and enter:<br />
<br />
{{bc|<nowiki><br />
set sendmail="/usr/bin/mailx"<br />
set smtp=smtp.gmail.com:587<br />
set smtp-use-starttls<br />
set ssl-verify=ignore<br />
set ssl-auth=login<br />
set smtp-auth-user=USERNAME@gmail.com<br />
set smtp-auth-password=PASSWORD<br />
</nowiki>}}<br />
<br />
Now to send the text, we must pipe a message to the mailx program.<br />
*Make a Bash script:<br />
{{hc|/path/to/mail.sh|<nowiki><br />
echo "$@: Done" | mailx 5551234567@vtext.com<br />
</nowiki>}}<br />
Where the $@ is a variable holding all the arguments passed to our script.<br />
<br />
*And finally, add the important {{ic|~/.rtorrent.rc}} line:<br />
system.method.set_key = event.download.finished,notify_me,"execute=/path/to/mail.sh,$d.get_name="<br />
<br />
Breaking it down:<br />
<br />
{{ic|notify_me}} is the command id, which may be used by other commands, it can be just about anything you like, so long as it is unique.<br />
<br />
{{ic|1=execute=}} is the rtorrent command, in this case to execute a shell command.<br />
<br />
{{ic|/path/to/mail.sh}} is the name of our script (or whatever command you want to execute) followed by a comma separated list of all the switches/arguments to be passed.<br />
<br />
{{ic|1=$d.get_name=}} 'd' is an alias to whatever download triggered the command, get_name is a function which returns the name of our download, and the '$' tells rTorrent to replace the command with its output before it calls execute.<br />
<br />
The end result? When that torrent, 'All Live Nudibranches', that we started before leaving for work finishes, we will be texted:<br />
All Live Nudibranches: Done<br />
<br />
=== UI Tricks ===<br />
<br />
rTorrent does not list the active tab properly by default, add this line to your {{ic|.rtorrent.rc}} to show only active torrents<br />
schedule2 = filter_active,30,30,"view.filter = active,\"or={d.up.rate=,d.down.rate=}\""<br />
<br />
Then press {{ic|9}} in your rTorrent client to see the changes in action.<br />
<br />
To sort the seeding view by the upload rate and only show torrents with peers:<br />
<br />
# Sort the seeding view by the upload rate and only show torrents with peers<br />
view.sort_current = seeding,greater=d.up.rate=<br />
view.filter = seeding,"and=d.complete=,d.peers_connected="<br />
view.sort_new = seeding,less=d.up.rate=<br />
view.sort = seeding<br />
<br />
To sort the complete view by the upload rate:<br />
<br />
# Sort the complete view by the upload rate<br />
view.sort_current = complete,greater=d.up.rate=<br />
view.filter = seeding,"and=d.complete="<br />
view.sort_new = seeding,less=d.up.rate=<br />
view.sort = seeding<br />
<br />
=== Manually adding trackers to torrents ===<br />
<br />
# Select torrent to edit from rTorrent console view.<br />
# Hit {{ic|Ctrl+x}}.<br />
# If you had four trackers type following lines one at a time (always press {{ic|Ctrl+x}} first) to add four more for example:<br />
<br />
d.tracker.insert="5","udp://tracker.publicbt.com:80"<br />
d.tracker.insert="6","udp://tracker.openbittorrent.com:80"<br />
d.tracker.insert="7","udp://tracker.istole.it:80"<br />
d.tracker.insert="8","udp://tracker.ccc.de:80"<br />
<br />
== Troubleshooting ==<br />
<br />
=== CA certificates ===<br />
<br />
By default rTorrent will work with trackers that use HTTPS with valid certificates. If an HTTPS tracker is being rejected because it has a custom or unusual certificate you may need to download it and validate it separately.<br />
<br />
Once you have done that you can inform rTorrent of the new certificate via<br />
<br />
$ rtorrent -o http_capath=/etc/ssl/certs/www.your-tracker.com.pem<br />
<br />
For more information see:<br />
* [https://forums.gentoo.org/viewtopic-t-710876-start-0.html rTorrent + SSL guide] Full instructions for downloading and validating a new HTTPS certificate.<br />
* [https://bbs.archlinux.org/viewtopic.php?pid=331850 rTorrent Error & CA Certificate]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=45800 rTorrent Certificates Problem]<br />
* [https://github.com/pyroscope/rtorrent-ps/blob/master/docs/DebianInstallFromSource.md#optional-root-setup-steps rtorrent setup]<br />
<br />
In rTorrent 0.8.9 and up you can disable HTTPS checking completely by setting {{ic|<nowiki>network.http.ssl_verify_peer.set=0</nowiki>}} and {{ic|<nowiki>network.http.ssl_verify_host.set=0</nowiki>}}, [https://bbs.archlinux.org/viewtopic.php?pid=981832#p981832 source].<br />
<br />
=== Locked directories ===<br />
<br />
rTorrent can sometimes lock up after a crash or incorrect shutdown, and will complain about a lock file.<br />
<br />
Per the error message, the file called "'''rtorrent.lock'''" can be found within the hidden folder {{ic|.rtorrentsession}} for your download directory and manually removed.<br />
<br />
=== Event failed: bad return code ===<br />
<br />
This is most often caused by there being spaces in your ''system.method.*'' lines, or by event handlers that call out to external scripts which are either simply not installed, or return a non-zero exit code. <br />
<br />
For the first, remove any spurious spaces, or else quote path etc. where they are intentional, and it will work.<br />
<br />
== Web interface ==<br />
<br />
There are numerous web interfaces and front ends for rTorrent including:<br />
* [[WTorrent]] is a web interface to rtorrent programmed in php using Smarty templates and XMLRPC for PHP library.<br />
* [http://code.google.com/p/ntorrent/ nTorrent] is a graphical user interface client to rtorrent written in Java.<br />
* [https://rtwi.jmk.hu/ rTWi] is a simple rTorrent web interface written in PHP.<br />
* [[Rtgui]] is a web based front end for rTorrent written in PHP and uses XML-RPC to communicate with the rTorrent client.<br />
* [https://github.com/Novik/ruTorrent rutorrent] - A web-based front-end with an interface very similar to uTorrent which supports many plugins and advanced features (see also: [[ruTorrent]] and [https://bbs.archlinux.org/viewtopic.php?pid=897577#p897577 Guide on forum]).<br />
* [https://github.com/jfurrow/flood flood] is a web interface for rtorrent written in Node.js using XMLRPC.<br />
<br />
{{Note|rTorrent is currently built using [http://xmlrpc-c.sourceforge.net/ XML-RPC for C/C++], which is required for some web interfaces (e.g. ruTorrent).}}<br />
<br />
=== XMLRPC interface ===<br />
<br />
If you want to use rtorrent with some web interfaces (e.g. rutorrent) you need to add the following line to the configuration file:<br />
scgi_port = localhost:5000<br />
<br />
For more information see: [https://github.com/rakshasa/rtorrent/wiki/RPC-Setup-XMLRPC Using XMLRPC with rtorrent]<br />
<br />
{{Note| '''SECURITY HINT'''<br />
<br />
Using TCP allows '''any''' ''local'' user to '''execute arbitrary commands''' as the user owning the rTorrent process. Use UNIX domain sockets for sane opsec, by way of setting UNIX permissions on the socket file.<br />
}}<br />
<br />
=== Saving magnet links as torrent files in watch folder ===<br />
<br />
{{Note| Rtorrent natively supports downloading torrents through magnet links. At the main view (reached by starting Rtorrent and pressing 1), press enter. At "load.normal>" paste the magnet link and press enter again. This will start the download.}}<br />
<br />
If you wish to have magnet links automatically added to your watch folder, here is a script that will do the trick:<br />
<br />
<nowiki><br />
#!/bin/bash<br />
watch_folder=~/.rtorrent/watch<br />
cd $watch_folder<br />
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;<br />
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"</nowiki><br />
<br />
(adapted from http://blog.gonzih.org/blog/2012/02/17/how-to-use-magnet-links-with-rtorrent/).<br />
<br />
Save it, for instance as rtorrent-magnet, give it execution permission, and place it somewhere under your $PATH. Then in Firefox:<br />
# Type {{ic|about:config}} into the Location Bar (address bar) and press {{ic|Enter}}.<br />
# Right-click: ''New > Boolean > Name: '''network.protocol-handler.expose.magnet''' > Value > false''.<br />
# Next time you click a magnet link you will be asked which application to open it with. Select the script we just created and you will be done.<br />
<br />
If you want xdg-open to handle this, which you need if you are using chrome instead of firefox, (though gnome and other DE might have their own programs overriding xdg-open) you need to create the desktop entry for the rtorrent-magnet script in {{ic|~/.local/share/applications/rtorrent-magnet.desktop}} with the following content:<br />
<br />
<nowiki><br />
[Desktop Entry]<br />
Type=Application<br />
Name=rtorrent-magnet<br />
Exec=rtorrent-magnet %U<br />
MimeType=x-scheme-handler/magnet;<br />
NoDisplay=true</nowiki><br />
<br />
Then all you need to do is to register the mimetype using<br />
$ xdg-mime default rtorrent-magnet.desktop x-scheme-handler/magnet<br />
<br />
== Magnet to Torrent ==<br />
You could also use the {{AUR|magnet2torrent-git}} package which downloads the metadata and creates a torrent file.<br />
<br />
How to use:<br />
$ magnet2torrent -m <magnet link> -o [torrent file]<br />
<br />
== rtorrent-ps ==<br />
<br />
[https://github.com/pyroscope/rtorrent-ps rTorrent-PS] is an rTorrent distribution in form of a patchset with UI enhancements, colorization, and some added features.<br />
<br />
=== Installation ===<br />
<br />
Use the various packages available in the AUR, or alternatively create a package using the build script from the GitHub repository, which additionally builds pre-tested dependency versions and may help avoid known issues. See [https://rtorrent-ps.readthedocs.io/en/latest/install.html#installation-on-arch-linux the docs] for details.<br />
<br />
=== Configuration ===<br />
<br />
Set "pyro.extended" to 1 in your rTorrent configuration file to activate rTorrent-PS features.<br />
{{bc|<nowiki>method.insert = pyro.extended, value|const, 1</nowiki>}}<br />
<br />
See rtorrent-ps templates of the [https://github.com/pyroscope/pimp-my-box/tree/master/roles/rtorrent-ps/templates/rtorrent/rtorrent.d pimp-my-box] repository for additional configuration examples. Be aware they may require PyroScope command line utilities to work.<br />
<br />
== PyroScope command line utilities ==<br />
<br />
[https://github.com/pyroscope/pyrocore/ PyroScope command line utilities] are a collection of tools for the the rTorrent client that work well together with the [[#rtorrent-ps]] patchset.<br />
Amongst other things, they provide automation for common tasks and a queue manager for rTorrent.<br />
<br />
Follow the [https://pyrocore.readthedocs.io/ official documentation] for installation and configuration. See rtorrent-ps templates of the [https://github.com/pyroscope/pimp-my-box/tree/master/roles/rtorrent-ps/templates/rtorrent/rtorrent.d pimp-my-box] repository for additional configuration examples.<br />
<br />
== See also ==<br />
<br />
* [[RTorrent/RuTorrent]]<br />
* [[GNU Screen]]<br />
* [http://rtorrent-docs.rtfd.io/ The rTorrent Handbook] - Includes an explanation of basic and advanced configuration, a scripting guide, and a (not yet) complete command reference with an auto-generated index.<br />
* [http://linux.die.net/man/1/rtorrent Manpage for rtorrent]<br />
* [[Wikipedia:Comparison of BitTorrent clients|Comparison of BitTorrent clients]] on Wikipedia<br />
* [https://github.com/rtorrent-community/rtorrent-community.github.io/wiki rTorrent Community Wiki] - Public place for information on rTorrent and any project related to rTorrent, regarding setup, configuration, operations, and development.<br />
* [https://github.com/pyroscope/pyrocore pyrocore] - Collection of command line tools for rTorrent. It provides commands for creating and modifying torrent files, moving data on completion without having multiple watch folders, and mass-controlling download items via rTorrent's XML-RPC interface: searching, start/stop, deleting items with or without their data, etc. It also offers a documented [[Python]] API.<br />
* [https://rtorrent-ps.readthedocs.io/en/latest/install.html#manual-turn-key-system-setup Installation guide for rTorrent and Pyroscope on Linux] - Collection of tools for the BitTorrent protocol and especially the rTorrent client<br />
* [https://github.com/Rudde/mktorrent mktorrent] - Command line application used to generate torrent files, which is available as {{Pkg|mktorrent}} in the [[official repositories]].<br />
* [https://github.com/kfei/docktorrent docktorrent] - Using Docker, rTorrent and ruTorrent to run a full-featured BitTorrent box.<br />
* [https://github.com/nelhage/reptyr reptyr] - another tool to take over a program's TTY (it is in the standard repos). The process may have started being attached to a terminal or to a socket in tmux, screen or dtach.<br />
* [http://caca.zoy.org/wiki/neercs neercs] - a more screen/tmux like tool than reptyr, but, like reptyr, neercs can also "steal" a process that may have started slaved to a terminal or to a socket in tmux, screen or dtach.<br />
<br />
'''Forum threads'''<br />
* 2009-03-11 - Arch Linux - [https://bbs.archlinux.org/viewtopic.php?id=67304 HOWTO: rTorrent stats in Conky]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=517613Dell XPS 13 2-in-1 (9365)2018-04-15T16:15:04Z<p>TPXP: /* Troubleshooting */ Coil whine fix</p>
<hr />
<div>[[Category:Dell]]<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/02/16<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Screen not rotating ===<br />
You need to install {{aur|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://bugs.freedesktop.org/show_bug.cgi?id=99462]<br />
<br />
=== Soundcard turning off and coil whine ===<br />
By default, the soundcard automatically turns of which leads to delays when there is a song to play (or distortion). This can also cause coil whine especially while scrolling with headphones plugged and sound muted. To solve this, you can force the soundcard to always stay awake :<br />
<br />
{{hc|/etc/modprobe.d/audio_no_powersave.conf|2=options snd_hda_intel power_save=0}}</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=517398Dell XPS 13 2-in-1 (9365)2018-04-14T14:36:40Z<p>TPXP: Add a note about the fingerprint reader</p>
<hr />
<div>[[Category:Dell]]<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/02/16<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Screen not rotating ===<br />
You need to install {{aur|iio-sensor-proxy}} for automatic screen rotation to work.<br />
<br />
=== Fingerprint sensor ===<br />
The fingerprint sensor on this computer is not yet supported. [https://www.dell.com/community/Linux-Developer-Systems/XPS-13-Fingerprint-reader-Linux-support/td-p/5090723] .<br />
There is an open [[fprint]] bug opened to track progress on this issue [https://bugs.freedesktop.org/show_bug.cgi?id=99462]</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=517385Dell XPS 13 2-in-1 (9365)2018-04-14T12:51:44Z<p>TPXP: /* Troubleshooting */ Add a tip about screen rotation</p>
<hr />
<div>[[Category:Dell]]<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/02/16<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].<br />
<br />
=== Screen not rotating ===<br />
You need to install {{aur|iio-sensor-proxy}} for automatic screen rotation to work.</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dell_XPS_13_2-in-1_(9365)&diff=517384Dell XPS 13 2-in-1 (9365)2018-04-14T12:49:55Z<p>TPXP: Minor grammar fixes and split in a separate section to prepare addition of another section with additional tips</p>
<hr />
<div>[[Category:Dell]]<br />
The Dell XPS 13 2-in-1 (9365) is the early 2017 model. It can be used like a tablet when folding the display on the back. The touchscreen works out of the box.<br />
<br />
== Installation ==<br />
<br />
=== BIOS configuration ===<br />
<br />
Bios can be accessed with F2 or F12 on DELL logo boot screen.<br />
<br />
With Bios version 1.1.0 or 1.3.1 you have to set sata operation to AHCI first and then uncheck in Advanced Boot options -> Legacy ROM.[http://en.community.dell.com/support-forums/laptop/f/3518/t/20004529?pi41097=1]<br />
{{Note|<br />
* In RAID mode the BIOS/UEFI is able to see the internal drive and is able to boot from it. It is possible to boot Archiso in RAID mode, but it can't see the internal drive. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM activated is not able to see the internal drive. If you try to boot it will fail and display an error that no harddrive is installed. <br />
* In AHCI mode the BIOS/UEFI with Legacy ROM deactivated is able to see the internal drive and therefore boot from it and Archiso is able to see the drive too. With these settings you can install and boot arch.<br />
}}<br />
<br />
It is also needed to set the following settings [https://www.dell.com/community/General/Dell-XPS-13-9365-Won-t-boot-USB-in-SATA-Mode-AHCI-Trying-to/m-p/5119127/highlight/true#M918191] :<br />
* UEFI network stack - disabled<br />
* Secure Boot - disabled<br />
* SATA operations - AHCI<br />
* Legacy ROM - disabled<br />
* POST Behaviour : Fastboot - ''minimal'' (if not, BIOS is really slow, and cannot boot to any mediums)<br />
<br />
{{Note|<br />
* Some changes in BIOS might reset other settings. Check your BIOS settings twice.<br />
* Those settings are working as of 2018/02/16<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not waking from suspend ===<br />
<br />
This model only supports the S0 (s2idle) sleep mode. [https://patchwork.kernel.org/patch/9758513/] Change the suspend mode to {{ic|s2idle}} by adding the {{ic|1=mem_sleep_default=s2idle}} to the [[kernel parameters]].</div>TPXPhttps://wiki.archlinux.org/index.php?title=Spotify&diff=499872Spotify2017-11-27T17:25:30Z<p>TPXP: Add another method to block ads in Spotify : hosts file</p>
<hr />
<div>[[Category:Multimedia players]]<br />
[[Category:Wine]]<br />
[[ja:Spotify]]<br />
[https://www.spotify.com/ Spotify] is a digital music service that gives you access to millions of songs. This Internet music service allows you to select any song in its database and stream for free.<br />
<br />
Spotify also offers free users the ability to create playlist which can be shuffled, and set to repeat tracks. Content provided by Spotify comes in explicit versions as well as censored.<br />
<br />
== Installation ==<br />
<br />
Choose which client you would prefer. The Linux client is receiving good reviews. However, if you are comfortable with wine and its configuration, you might want to choose the windows client. Please note that you do '''not''' need to install both. There is also the online player at https://open.spotify.com/.<br />
<br />
=== Third-party clients ===<br />
<br />
* {{App|[[Wikipedia:Clementine (software)|Clementine]]|Able to stream from Spotify with a premium account after activating (downloading) a plugin in the settings.|https://www.clementine-player.org/|{{Pkg|clementine}}}}<br />
* {{App|Mopidy|An alternative plug-in based implementation of [[Music Player Daemon]] is able to stream from Spotify with an extension.|https://www.mopidy.com/|{{Pkg|mopidy}}+ {{AUR|mopidy-spotify}} or {{AUR|despotify-svn}}{{Broken package link|package not found}}}}<br />
* {{App|Librespot|An open source client library for Spotify. It enables applications to use Spotify's service (streaming), without using the official closed-source ''libspotify''.|https://github.com/plietar/librespot|{{AUR|librespot-git}}}}<br />
* {{App|Tomahawk|A Music Player App written in C++/Qt|https://www.tomahawk-player.org/|{{AUR|tomahawk}} {{AUR|tomahawk-git}} {{AUR|tomahawk-qt5}}}}<br />
<br />
=== Official Linux client ===<br />
<br />
[[Install]] it with the {{AUR|spotify}} package. If you wish to play local files you will need to install {{Pkg|zenity}} and {{AUR|ffmpeg0.10}} as well.<br />
<br />
=== Official Windows client through Wine ===<br />
<br />
First, install [[Wine]].<br />
<br />
Obtaining Spotify can be done by registering for an account on their website, the application does not offer in-app registration. Obtain the application from https://www.spotify.com/us/download/windows/.<br />
<br />
After you have registered and downloaded your copy of the installer you will need to run the application through Wine, depending on your setup you may be able to run the application by right clicking the file. If not terminal will work just fine, as long as you run the below command in the directory of your download.<br />
<br />
$ wine SpotifySetup.exe<br />
<br />
Once the application is successfully installed you may run Spotify by using one of the following commands in terminal, or in the ALT+F2 launcher:<br />
<br />
If you use a x86_64 copy of Arch Linux, you will have to run it like this:<br />
<br />
$ wine "$HOME/.wine/drive_c/Program Files (x86)/Spotify/spotify.exe"<br />
<br />
If you use a x86 copy of Arch Linux, you can use this command just fine:<br />
<br />
$ wine "$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe"<br />
<br />
If you have any additional problems, I recommend setting the winecfg to Windows XP or Windows 7 emulation.<br />
<br />
== Tips & tricks ==<br />
<br />
=== Global media hotkeys ===<br />
<br />
The official Linux client has support for media keys like {{ic|XF86AudioPlay}}, but out of the box they only work inside Spotify. We can use for example [[xbindkeys]] to catch the global media keypresses, and then forward them to Spotify using one of the methods below. If you use xbindkeys, ensure that Spotify is restarted after installation and key configuration otherwise the key events will not be properly caught.<br />
<br />
==== MPRIS ====<br />
<br />
The Spotify client implements the [https://specifications.freedesktop.org/mpris-spec/latest/ MPRIS2] D-Bus interface which allows external control.<br />
<br />
===== Playerctl =====<br />
<br />
The {{Pkg|playerctl}} utility provides a command line tool to send commands to MPRIS clients. The only commands you will likely need to bind globally are {{ic|play-pause}}, {{ic|next}} and {{ic|previous}}<br />
<br />
$ playerctl play-pause<br />
$ playerctl next<br />
$ playerctl previous<br />
<br />
Playerctl will send the command to the first player it finds, so this method will also work with others players such as [[vlc]]. To ignore other players, pass {{ic|--player&#61;spotify}} as an argument.<br />
<br />
===== D-Bus =====<br />
<br />
An alternative to the above is to manually use [[D-Bus]], which should be available by default as it is a dependency of [[systemd]].<br />
<br />
To play or pause the current song in Spotify:<br />
<br />
$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause<br />
<br />
In order to bind this and the other commands to the media keys you need to install [[Xbindkeys]] and edit your .xbindkeysrc and add the following lines:<br />
<br />
# Play/Pause<br />
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"<br />
XF86AudioPlay<br />
<br />
# Next<br />
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"<br />
XF86AudioNext<br />
<br />
# Previous<br />
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"<br />
XF86AudioPrev<br />
<br />
# Stop<br />
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"<br />
XF86AudioStop<br />
<br />
If the above commands do not work, try setting the dbus address:<br />
<br />
USER=`whoami`<br />
PROCESS=spotify<br />
PID=`pgrep -o -u $USER $PROCESS`<br />
ENVIRON=/proc/$PID/environ<br />
if [ -e $ENVIRON ]<br />
then<br />
export `grep -z DBUS_SESSION_BUS_ADDRESS $ENVIRON`<br />
else<br />
echo "Unable to set DBUS_SESSION_BUS_ADDRESS."<br />
exit 1<br />
fi<br />
<br />
==== xdotool ====<br />
<br />
With the help of {{ic|xdotool}} it is possible to send your hotkeys to the application. The following script is an example of how to control Spotify from the outside:<br />
<br />
#!/bin/sh<br />
<br />
case $1 in<br />
"play")<br />
key="XF86AudioPlay"<br />
;;<br />
"next")<br />
key="XF86AudioNext"<br />
;;<br />
"prev")<br />
key="XF86AudioPrev"<br />
;;<br />
*)<br />
echo "Usage: $0 play|next|prev"<br />
exit 1<br />
;;<br />
esac<br />
xdotool key --window $(xdotool search --name "Spotify (Premium |Unlimited |Free )?- Linux Preview"|head -n1) $key<br />
exit 0<br />
<br />
Let us call it {{ic|musickeys.sh}}. Make the script executable:<br />
<br />
$ chmod +x musickeys.sh<br />
<br />
By executing {{ic|./musickeys.sh play}} you can now toggle playing a song. Now you can bind this script to any tool that catches keypresses, such as [[xbindkeys]].<br />
<br />
=== Disable track notifications===<br />
<br />
{{note|It is worth noting that if you have a {{AUR|SpotCommander}} [http://olejon.github.io/spotcommander/ Server] running alongside Spotify, and you disable track notifications by following the instructions below, the [https://play.google.com/store/apps/details?id&#61;net.olejon.spotcommander&hl&#61;en SpotCommander Client] running on your mobile device will display that “No Music is Playing” and will [http://askubuntu.com/questions/472325/remove-spotify-pop-up-notification-when-a-song-starts/472329#472329 fail to display track info] such as title, artist, album art, etc. Apart from that, the mobile client still works fine though, and is still able to skip, play, pause, control volume, etc.}}<br />
<br />
After version 0.9.10, track change notifications were enabled by default. They can be quite intrusive. To disable them, add the following line to {{ic|~/.config/spotify/Users/<spotifylogin>-user/prefs}}<br />
<br />
ui.track_notifications_enabled=false<br />
<br />
It is also possible to launch spotify with the {{ic|--ui.track_notifications_enabled&#61;false}} option.<br />
<br />
=== Show track notifications===<br />
<br />
{{Pkg|playerctl}} provides a library you can use with {{pkg|python-gobject}} and a notification daemon such as {{pkg|dunst}} to show the artist and title in a notification when the track changes.<br />
<br />
#!/usr/bin/env python3<br />
<br />
from gi.repository import Playerctl, GLib<br />
from subprocess import Popen<br />
<br />
player = Playerctl.Player()<br />
<br />
def on_track_change(player, e):<br />
track_info = '{artist} - {title}'.format(artist=player.get_artist(), title=player.get_title())<br />
Popen(['notify-send', track_info])<br />
<br />
player.on('metadata', on_track_change)<br />
<br />
GLib.MainLoop().run()<br />
<br />
=== Skip overplayed radio tracks===<br />
<br />
Another use of the {{Pkg|playerctl}} library is to skip tracks that are played too much on radio when you do not necessarily want to downvote these tracks because you may want to hear them again later on that station.<br />
<br />
#!/usr/bin/env python3<br />
<br />
from gi.repository import Playerctl, GLib<br />
<br />
player = Playerctl.Player()<br />
<br />
played_out = ['Zu Fuss', 'Walk And Talk', 'Neuland']<br />
<br />
def on_track_change(player, e):<br />
if player.get_title() in played_out:<br />
player.next()<br />
<br />
player.on('metadata', on_track_change)<br />
<br />
GLib.MainLoop().run()<br />
<br />
=== Mute commercials ===<br />
<br />
==== blockify ====<br />
<br />
With [https://github.com/mikar/blockify blockify] you can mute commercials. It is available in the [[AUR]] as {{AUR|blockify}}.<br />
<br />
To have this start and run in the background every time Spotify starts you will need to automate this yourself:<br />
<br />
{{bc|<nowiki><br />
#!/bin/sh<br />
<br />
spotify=/usr/bin/spotify<br />
<br />
if [[ -x $spotify && -x /usr/bin/blockify ]];<br />
then<br />
blockify &<br />
block_pid=$!<br />
$spotify<br />
trap "kill -9 $block_pid" SIGINT SIGTERM EXIT<br />
fi<br />
</nowiki>}}<br />
<br />
By placing this script at {{ic|/usr/local/bin/spotify}}, it gets preferred to {{ic|/usr/bin/spotify}} everytime you start Spotify, so there's nothing else to change and updates won't break it.<br />
<br />
==== spotblock ====<br />
<br />
[https://github.com/mahkoh/spotblock spotblock] ({{AUR|spotblock-git}}) is a resource-efficient ad blocker that runs as a systemd daemon.<br />
<br />
==== Spotify-AdKiller ====<br />
<br />
[https://github.com/SecUpwN/Spotify-AdKiller Spotify-AdKiller] ({{AUR|spotify-adkiller-git}}) is another alternative to block Spotify ads.<br />
<br />
==== Hosts file ====<br />
<br />
You may also add the following lines to your hosts file to block ads in Spotify :<br />
<br />
{{hc|/etc/hosts|<nowiki><br />
# Block spotify ads<br />
127.0.0.1 media-match.com<br />
127.0.0.1 adclick.g.doublecklick.net<br />
127.0.0.1 www.googleadservices.com<br />
127.0.0.1 open.spotify.com<br />
127.0.0.1 pagead2.googlesyndication.com<br />
127.0.0.1 desktop.spotify.com<br />
127.0.0.1 googleads.g.doubleclick.net<br />
127.0.0.1 pubads.g.doubleclick.net<br />
127.0.0.1 audio2.spotify.com<br />
127.0.0.1 www.omaze.com<br />
127.0.0.1 omaze.com<br />
127.0.0.1 bounceexchange.com<br />
127.0.0.1 spclient.wg.spotify.com<br />
127.0.0.1 securepubads.g.doubleclick.net<br />
</nowiki>}}<br />
<br />
=== Remote Control ===<br />
<br />
==== Send commands via SSH ====<br />
<br />
If you set up ssh on the server, you can send controls from a client to a remote Spotify instance with<br />
<br />
$ ssh user@host ''yourcommand''<br />
<br />
where ''yourcommand'' can be [https://code.google.com/p/spotifycmd/ spotifycmd] that you installed on the server, or a dbus script for the linux version, as described above.<br />
<br />
==== Grab the Spotify window via SSH ====<br />
<br />
Aside from grabbing the whole desktop with TeamViewer or VNC to remotely control your server, you can also only grab the Spotify Window from the server to your client.<br />
<br />
To do that, you need to configure sshd on your server and install x11vnc on both server and client as well as tigervnc on the client. Then you can use these scripts to grab either the complete dektop or only the Spotify window, which essentially gets you GUI client-like behavior as with MPD.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
# vncget.sh<br />
<br />
if [[ $1 == all ]];then<br />
ssh -f -t -L 5900:localhost:5900 user@host "x11vnc -q -display :0 -auth .Xauthority"<br />
else<br />
ssh -f -t -L 5900:localhost:5900 user@host ".bin/vncgetspotify.sh"<br />
fi<br />
<br />
for i in {1..4}; do<br />
sleep 2<br />
if vncviewer localhost:0; then break; fi<br />
done<br />
</nowiki>}}<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
# vncgetspotify.sh<br />
<br />
export DISPLAY=:0<br />
<br />
id=$(wmctrl -lx | awk '/spotify.exe.Wine/ {print $1}')<br />
[[ -z $id ]] && id=$(wmctrl -lx | awk '/spotify.Spotify/ {print $1}')<br />
<br />
x11vnc -sid $id -display :0 -auth .Xauthority<br />
</nowiki>}}<br />
<br />
You will need to copy the second script to ~/.bin/vncgetspotify.sh on the server and the first script to any place on your client.<br />
<br />
Finally, to grab the spotify window, run on the client:<br />
<br />
$ sh vncget.sh<br />
<br />
or, for the whole desktop:<br />
<br />
$ sh vncget.sh all<br />
<br />
===HiDPI Mode===<br />
As the current Spotify build is not DPI aware, the amount to scale the interface by can be specified using the terminal command:<br />
$ spotify --force-device-scale-factor='''X'''<br />
<br />
where X is the amount to scale the interface by, e.g 2.<br />
<br />
This change can be added to the {{ic|spotify.desktop}} file in order to apply the scaling when launching from the desktop.<br />
<br />
To make sure the file does not get overwritten when the package is updated, copy it to you local applications folder:<br />
$ cp /usr/share/applications/spotify.desktop ~/.local/share/applications/<br />
<br />
Now edit {{ic|~/.local/share/applications/spotify.desktop}} and add the {{ic|--force-device-scale-factor}} option:<br />
<br />
{{hc|spotify.desktop|2=<br />
[Desktop Entry]<br />
Name=Spotify<br />
GenericName=Music Player<br />
Comment=Spotify streaming music client<br />
Icon=spotify-client<br />
Exec=spotify '''--force-device-scale-factor=2''' %U<br />
TryExec=spotify<br />
Terminal=false<br />
Type=Application<br />
Categories=Audio;Music;Player;AudioVideo<br />
MimeType=x-scheme-handler/spotify<br />
}}<br />
<br />
You might need to relaunch your Desktop Manager, before these override changes will be effective.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Desktop Environment alerts (beeps) mutes Spotify ===<br />
<br />
Comment out "module-role-cork" in pulse audio configuration file.<br />
<br />
Open {{ic|/etc/pulse/default.pa}} with your text editor and comment out:<br />
<br />
load-module module-role-cork <br />
<br />
Or simply unload it with:<br />
<br />
pactl unload-module module-role-cork<br />
<br />
=== Using search causes the whole interface to blink and then crash ===<br />
<br />
Spotify is using an old version of Chromium Embedded Framework and hits a bug causing it to crash repeatedly when trying to use the search. This can be worked around by using the following command line option:<br />
<br />
--force-device-scale-factor=1.0000001<br />
<br />
=== Blinking images and improper rendering while using Spotify Linux with DWM ===<br />
Start spotify as a floating window.<br />
<br />
You can add this rule to the rules array in your {{ic|config.h}}:<br />
{ "Spotify", NULL, NULL, 2, True, -1 },<br />
<br />
This will tell dwm to start spotify as a floating window associated with the tag "2" no matter what window mode you are in. Recompile and install dwm to apply your new settings.<br />
<br />
=== Broken search, browsing or radio ===<br />
<br />
: Spotify [http://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Bug-Desktop-Linux-0-9-0-133-gd18ed589-Having-mixed-locale-breaks/td-p/418270 bug report] concerning non-english locales<br />
If various tabs like browsing only show a blank screen, the search field doesn't seem to do anything or the radio page is broken (stuck when starting and unsresponsive to input) you might be using a custom locale.<br />
<br />
Try setting the environment variable {{ic|LC_NUMERIC}} to {{ic|en_US.utf8}} before starting Spotify.<br />
<br />
=== SpotifyHelper.exe crashes (Windows client) ===<br />
<br />
If SpotifyHelper.exe crashes when starting Spotify, disable the d3d9 library with {{ic|winecfg}}. Go to the "Libraries" tab, choose "d3d9" and click Add. To disable it, click edit and select the "Disable" option.<br />
<br />
=== Wrong launcher icon (Windows client) ===<br />
<br />
If the Spotify icon does not show up correctly in your launcher, add the following line to {{ic|~/.local/share/applications/wine/Programs/Spotify.desktop}}:<br />
<br />
StartupWMClass=spotify.exe<br />
<br />
=== Deadlock GUI Thread ===<br />
<br />
Can occur under tiling window managers, such as Awesome, when double-clicking new song or playlist. Edit the file {{ic|~/.config/spotify/Users/[1-9]*-user/prefs}} to add or change the following:<br />
<br />
ui.track_notifications_enabled=false<br />
<br />
Restart Spotify. Note that several causes appear to exist for this problem, and this particular fix only applies to select versions of Spotify client, i3 and Awesome, and it may be that additional root causes exist for the Debian and Ubuntu users reporting this issue. Observed with Spotify 0.9.17.1.g9b85d436 and Awesome 3.4.15 and i3-gaps 4.13-2 and Spotify 1.0.64.407.g9bd02c2d.<br />
<br />
{{Note|As of Spotify 1.0.17.75-2, {{ic|1=ui.track_notifications_enabled=false}} seems to be ignored. On the other hand some, users report not experimenting the deadlock anymore as of Awesome 3.5.6. Deadlocks could be caused by scripts called by Awesome, which rely on buggy spotify dbus properties. See [https://github.com/acrisci/playerctl/issues/20].}}<br />
<br />
'''Note:''' This issue has multiple causes, so keep track of what you change while researching this. Update this section with additional scenarios and fixes.<br />
<br />
=== PulseAudio ===<br />
<br />
See [[PulseAudio/Troubleshooting]] and [https://bbs.archlinux.org/viewtopic.php?pid=1393465#p1393465]<br />
<br />
=== Album art and images are missing, show up as squares ===<br />
<br />
Quit spotify, then open spotify preferences {{ic|~/.config/spotify/prefs}}<br />
<br />
Change @https to @http:<br />
<br />
network.proxy.addr="your-proxy.com:80<strong>@http</strong>"<br />
network.proxy.mode=2<br />
<br />
See original form post [http://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Mac-Windows-0-9-0-128-Apps-can-t-connect-anywhere-behind-proxy/m-p/448704#M52332 here].<br />
<br />
{{Note|As of 1.0.17 it looks like replacing https with http as suggested above can result in no connectivity at all. If this happens an alternative solution is to set 'no proxy' in the GUI use {{Pkg|proxychains-ng}} to force all TCP connection coming from the app through a proxy. Even with HTTP proxies that reject connections on port 80 (and only work for port 443) this works reliably.}}<br />
<br />
=== Spotify does not detect other devices on local network ===<br />
<br />
If a firewall is in place, open ports 57621 for UDP and TCP. If you use a variant of the [[iptables]] [[Simple stateful firewall]], the following should do it:<br />
<br />
iptables -A TCP -p tcp --dport 57621 -j ACCEPT -m comment --comment spotify<br />
iptables -A UDP -p udp --dport 57621 -j ACCEPT -m comment --comment spotify<br />
<br />
It is also possible to restrict the source and destination to the local network.<br />
<br />
If you are using Spotify Connect to play music on a wireless speaker or AVR, your firewall needs to be configured for Spotify's mDNS lookup of those. Sadly, it uses a random unprivileged port [https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Spotify-Connect-and-iptables-netfilter/td-p/1235049] which makes these firewall rules rather nasty. Fortunately, you can restrict the rules to source port 1900 or 5353.<br />
<br />
iptables -A UDP -p udp --sport 1900 --dport 1025:65535 -j ACCEPT -m comment --comment spotify<br />
iptables -A UDP -p udp --sport 5353 --dport 1025:65535 -j ACCEPT -m comment --comment spotify<br />
<br />
=== Search Bar text is invisible when using a dark theme ===<br />
<br />
The text in the search bar appears to be hardcoded to be white, making it invisible when using a dark Qt theme. To fix this, you'll need to make an override.<br />
<br />
First create a css file somewhere your account has permission to read/write from (such as your home folder). Call it whatever you like (eg. '''spotify-override.css''').<br />
<br />
Open the newly created css file and add the following:<br />
<br />
QLineEdit { color: #000 }<br />
<br />
Save the file and exit. Next, you need to add the following to the end of your Spotify launcher (substitute the path with the actual path of your css file):<br />
<br />
-stylesheet=/home/user/spotify-overide.css<br />
<br />
So your full launch path should look something like this:<br />
<br />
/usr/share/spotify/spotify-client/spotify -stylesheet=/home/user/spotify-override.css<br />
<br />
=== Can't play local files ===<br />
<br />
If you get a segmentation fault or error message when trying to play local files e.g.<br />
<br />
This song is not available. If you have the file on your computer you can import it.<br />
<br />
- it's caused by a missing libavcodec dependency. For PulseAudio users, installing {{aur|ffmpeg-compat-54}} should fix it.<br />
<br />
=== Not respecting window manager rules ===<br />
<br />
Window manager that try to apply specific rules like starting it on a determined workspace or maximizing it on startup, has no effect, as Spotify doesn't set the ''WM_CLASS'' property before creating the window, violating the ICCCM specifications. One solution is to use [https://github.com/dasJ/spotifywm spotifywm].<br />
<br />
==See also==<br />
*[https://github.com/acrisci/playerctl playerctl]: A command-line utility and library for controlling media players<br />
*[[SpotCommander]]: A web based remote control for Spotify<br />
*http://www.spotify.com/int/help/faq/wine/{{Dead link|2017|10|19}}<br />
*http://www.spotify.com/int/download/previews/</div>TPXPhttps://wiki.archlinux.org/index.php?title=Dynamic_DNS&diff=467203Dynamic DNS2017-01-30T15:29:25Z<p>TPXP: DuckDNS is not open source, you can't get the code they run on their servers</p>
<hr />
<div>[[Category:Domain Name System]]<br />
[[ja:ダイナミック DNS]]<br />
'''Dynamic DNS''' or '''DDNS''' is a method of updating, in real time, a [[DNS]] to point to a changing IP address on the Internet. This is used to provide a persistent domain name for a resource lacking a static IP. To use DDNS, you need to both sign up with a DDNS provider and set up an automatic update tool that will notify the provider when your IP address changes.<br />
<br />
== Update tools ==<br />
<br />
=== Router ===<br />
<br />
If the device needing DDNS sits behind a router, you should first check if the router itself can update any DDNS services. Although the selection of services may be limited, there are several advantages to using the router: it will probably be easier to set up, will require little to no maintenance, and will have no downtime (if the router is down you won't have Internet anyway).<br />
<br />
=== ddclient ===<br />
<br />
{{Pkg|ddclient}} is compatible with many DDNS services and is the recommended tool for updating DDNS if your [[#Router|router]] is not an option. It includes [[systemd]] support.<br />
<br />
After installing, edit the default config {{ic|/etc/ddclient/ddclient.conf}} to set up your DDNS provider (it includes many examples). Then [[enable]] and [[start]] {{ic|ddclient.service}}.<br />
<br />
Some of the compatible services are listed below, but you can also check the [http://sourceforge.net/p/ddclient/code/HEAD/tree/trunk/sample-etc_ddclient.conf examples] and [http://sourceforge.net/p/ddclient/wiki/protocols/ protocols] for more.<br />
<br />
{| class="wikitable"<br />
|+ ddclient compatible services<br />
! Service<br />
! Cost<br />
! Available Records<br />
! Hostname Limit<br />
! Config Notes<br />
! Alternative tools<br />
|-<br />
! [http://now-dns.com/ Now-DNS]<br />
| Free || A, AAAA || unlimited || Use protocol {{ic|dyndns2}}, server {{ic|now-dns.com/update}} || <br />
|-<br />
! [http://www.changeip.com/ ChangeIP]<br />
| Free or paid || A, AAAA, CNAME, MX, codomains || 7 free || || <br />
|-<br />
! [http://www.dnsdynamic.org/ DNSdynamic]<br />
| Free || || || [https://www.dnsdynamic.org/api.php example] ||<br />
|-<br />
! [https://www.duckdns.org/ Duck DNS]<br />
| Free || || || || {{aur|duckdns}}<br />
|-<br />
! [http://freedns.afraid.org/ FreeDNS]<br />
| Free or paid || CNAME, A, AAAA, MX, NS, TXT, LOC, RP, HINFO, SRV || 5 free || [http://freedns.afraid.org/scripts/freedns.clients.php example] || {{aur|afraid-dyndns-uv}}, {{aur|petrified}}<br />
|-<br />
! [http://www.noip.com/ No-IP]<br />
| Free or paid || || 3 free, 25+ paid || Use protocol {{ic|noip}}, server {{ic|dynupdate.no-ip.com}} || {{aur|noip}}<br />
|-<br />
! [https://www.nsupdate.info/ nsupdate.info]<br />
| Free and open source || A, AAAA || || Use protocol {{ic|dyndns2}} || {{aur|inadyn-fork}}<br />
|-<br />
|}<br />
{{Note| Free users of no-ip are required to manually confirm their domain(s) every 30 days. Domain confirmation is not required for Enhanced users though. More info at [http://www.noip.com/support/knowledgebase/why-is-my-hostname-pending-deletion/ Why is My Hostname Pending Deletion?]}} <br />
<br />
==== Starting ddclient after networking is up ====<br />
<br />
If you find that ddclient is unable to update your IP properly, it may be that the ddclient process is starting before networking is up. To fix it, you can edit the unit file to depend on {{ic|network-online.target}}:<br />
<br />
{{hc|# systemctl edit ddclient.service|2=<br />
[Unit]<br />
After=network-online.target<br />
Wants=network-online.target<br />
}}<br />
<br />
Additional configuration for {{ic|network-online.target}} may be necessary, see [https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget#cutthecraphowdoimakenetwork.targetworkforme].<br />
<br />
=== Other tools ===<br />
<br />
Other DDNS updaters that work with several providers are {{AUR|inadyn-mt}} ([http://sourceforge.net/projects/inadyn-mt supported providers]) and {{AUR|ndyndns}} (supports DynDNS and Namecheap).<br />
<br />
== Other providers ==<br />
<br />
The following DDNS providers are not compatible with [[#ddclient|ddclient]] so updating your IP with them may require a special tool or some custom scripting. Remember that if the service allows you to update your IP using the command line, you can automate the process using tools such as [[cron]] or [[systemd/Timers]].<br />
<br />
=== duiadns === <br />
[https://www.duiadns.net Duiadns.org] is a free service which can be automated with {{AUR|duiadns}}{{Broken package link|{{aur-mirror|duiadns}}}}.<br />
<br />
=== FreeDns.io ===<br />
<br />
[https://freedns.io FreeDns.io] provides free A and AAAA DNS records and CNAME, TXT and MX records with a premium membership. You can update your IP using their HTTP API (with a 60 requests-per-hour limit). They provide [https://github.com/nkovacne/freedns-samples several example scripts].<br />
<br />
=== Now-DNS ===<br />
[https://now-dns.com Now-DNS.com] is a free service which is easy and uncomplicated to set up.<br />
<br />
=== System-NS ===<br />
<br />
[http://system-ns.com/ System-NS] is a free service which can be updated via the command line. See [https://system-ns.com/services/dynamic the official documentation].</div>TPXPhttps://wiki.archlinux.org/index.php?title=S.M.A.R.T.&diff=454511S.M.A.R.T.2016-10-20T08:35:07Z<p>TPXP: /* Email potential problems */ Desktop notifications</p>
<hr />
<div>[[Category:Storage]]<br />
[[ja:S.M.A.R.T.]]<br />
S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is a supplementary component built into many modern storage devices through which devices monitor, store, and analyze the health of their operation. Statistics are collected (temperature, number of reallocated sectors, seek errors...) which software can use to measure the health of a device, predict possible device failure, and provide notifications on unsafe values.<br />
<br />
== Smartmontools ==<br />
<br />
The smartmontools package contains two utility programs for analyzing and monitoring storage devices: {{ic|smartctl}} and {{ic|smartd}}. [[Install]] the {{Pkg|smartmontools}} package to use these tools.<br />
<br />
SMART support must be available and enabled on each storage device to effectively use these tools. You can use [[#smartctl]] to check for and enable SMART support. That done, you can manually [[#Run a test]] and [[#View test results]], or you can use [[#smartd]] to automatically run tests and email notifications.<br />
<br />
=== smartctl ===<br />
<br />
smartctl is a command-line tools that "controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into most ATA/SATA and SCSI/SAS hard drives and solid-state drives."<br />
<br />
The {{ic|--info}} (or {{ic|-i}}) option prints a variety of information about a device, including whether SMART is available and enabled:<br />
<br />
# smartctl --info /dev/sda | grep 'SMART support is:'<br />
SMART support is: Available - device has SMART capability.<br />
SMART support is: Enabled<br />
<br />
If SMART is available but not enabled, you can enable it:<br />
<br />
# smartctl --smart=on /dev/<device><br />
<br />
You may need to specify a device type. For example, specifying {{ic|1=--device=ata}} tells smartctl that the device type is ATA, and this prevents smartctl from issuing SCSI commands to that device.<br />
<br />
==== Run a test ====<br />
<br />
There are three types of self-tests that a device can execute (all are safe to user data):<br />
<br />
* Short (runs tests that have a high probability of detecting device problems)<br />
* Extended (or Long; a short check with complete disk surface examination)<br />
* Conveyance (identifies if damage incurred during transportation of the device)<br />
<br />
The {{ic|-c}} (or {{ic|--capabilities}}) flag prints which tests a device supports and the approximate execution time of each test. For example:<br />
<br />
# smartctl -c /dev/sda<br />
[…]<br />
Short self-test routine<br />
recommended polling time: ( 1) minutes.<br />
Extended self-test routine<br />
recommended polling time: ( 74) minutes.<br />
Conveyance self-test routine<br />
recommended polling time: ( 2) minutes.<br />
[…]<br />
<br />
Use {{ic|-t}} (or {{ic|1=--test=<test_name>}}) flag to run a test:<br />
<br />
# smartctl -t short /dev/<device><br />
# smartctl -t long /dev/<device><br />
# smartctl -t conveyance /dev/<device><br />
<br />
==== View test results ====<br />
<br />
You can view a device's overall health with the {{ic|-H}} flag. "If the device reports failing health status, this means either that the device has already failed, or that it is predicting its own failure within the next 24 hours. If this happens […] get your data off the disk and to someplace safe as soon as you can."<br />
<br />
# smartctl -H /dev/<device><br />
<br />
You can also view a list of recent test results and detailed information about a device:<br />
<br />
# smartctl -l selftest /dev/<device><br />
# smartctl -a /dev/<device><br />
<br />
=== smartd ===<br />
<br />
The smartd daemon monitors SMART statuses and emits notifications when something goes wrong. It can be managed with systemd and configured using the {{ic|/etc/smartd.conf}} configuration file. The configuration file syntax is esoteric, and this wiki page provides only a quick reference. For more complete information, read the examples and comments within the configuration file, or read the smartd.conf (5) man page. (Execute {{ic|man 5 smartd.conf}} or visit [http://www.smartmontools.org/browser/trunk/smartmontools/smartd.conf.5.in this page].)<br />
<br />
==== daemon management ====<br />
<br />
To start the daemon, check its status, make it auto-start on system boot and read recent log file entries, simply [[start/enable]] the {{ic|smartd.service}} systemd unit.<br />
<br />
smartd respects all the usual systemctl and journalctl commands. For more information on using systemctl and journalctl, see [[Systemd#Using units]] and [[Systemd#Journal]].<br />
<br />
==== Define the devices to monitor ====<br />
<br />
To monitor for all possible SMART errors on all disks:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -a}}<br />
<br />
To monitor for all possible SMART errors on {{ic|/dev/sda}} and {{ic|/dev/sdb}}, and ignore all other devices:<br />
<br />
{{hc|/etc/smartd.conf|<br />
/dev/sda -a<br />
/dev/sdb -a<br />
}}<br />
<br />
To monitor for all possible SMART errors on externally connected disks (USB-backup disks spring to mind) it is prudent to tell SMARTd the UUID of the device since the /dev/sdX of the drive might change during a reboot.<br />
<br />
First, you will have to get the UUID of the disk to monitor: {{ic|ls -lah /dev/disk/by-uuid/}} now look for the disk you want to Monitor<br />
{{hc|ls -lah /dev/disk/by-uuid/|<br />
lrwxrwxrwx 1 root root 9 Nov 5 22:41 820cdd8a-866a-444d-833c-1edb0f4becac -> ../../sde<br />
lrwxrwxrwx 1 root root 10 Nov 5 22:41 b51b87f3-425e-4fe7-883f-f4ff1689189e -> ../../sdf2<br />
lrwxrwxrwx 1 root root 9 Nov 5 22:42 ea2199dd-8f9f-4065-a7ba-71bde11a462c -> ../../sda<br />
lrwxrwxrwx 1 root root 10 Nov 5 22:41 fe9e886a-8031-439f-a909-ad06c494fadb -> ../../sdf1<br />
}}<br />
<br />
I know that my USB disk attached to /dev/sde during boot. Now to tell SMARTd to monitor that disk simply use the {{ic|/dev/disk/by-uuid/}} path.<br />
<br />
{{hc|/etc/smartd.conf|<br />
/dev/disk/by-uuid/820cdd8a-866a-444d-833c-1edb0f4becac -a<br />
}}<br />
<br />
Now your USB disk will be monitored even if the /dev/sdX path changes during reboot.<br />
<br />
==== Email potential problems ====<br />
<br />
To have an email sent when a failure or new error occurs, use the {{ic|-m}} option:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -m address@domain.com}}<br />
<br />
To be able to send the email externally (i.e. not to the root mail account) a MTA (Mail Transport Agent) or a MUA (Mail User Agent) will need to be installed and configured. Common MTAs are [[Msmtp]] and [[SSMTP]]. Common MTUs are sendmail and [[Postfix]]. It is enough to simply configure [[S-nail]] if you do not want anything else.<br />
<br />
The {{ic|-M test}} option causes a test email to be sent each time the smartd daemon starts:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -m address@domain.com -M test}}<br />
<br />
E-Mail can take quite a long time to be delivered, but when your hard drive fails you want to be informed immediately to take the appropriate actions. Hence you should rather define a script to be executed instead of only emailing the problem:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -m address@domain.com -M exec /usr/local/bin/smartdnotify}}<br />
<br />
To send an e-mail and a system notification, put something like this into {{ic|/usr/local/bin/smartdnotify}}:<br />
<br />
#! /bin/sh<br />
<br />
# Send mail<br />
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"<br />
<br />
# Notify user<br />
wall "$SMARTD_MESSAGE"<br />
<br />
If you are running a desktop environment, you might also prefer having a popup to appear on your desktop. In this case, you can use this script (replace {{ic|''X_user''}} and {{ic|''X_userid''}} with the user and userid running X respectively) :<br />
{{hc|/usr/local/bin/smartdnotify|2=<br />
#!/bin/sh<br />
<br />
sudo -u ''X_user'' DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/''X_userid''/bus notify-send "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning<br />
}}<br />
This requires {{Pkg|libnotify}} and a compatible desktop environment. See [[Desktop notifications]] for more details.<br />
<br />
==== Power management ====<br />
<br />
If you use a computer under control of power management, you should instruct smartd how to handle disks in low power mode. Usually, in response to SMART commands issued by smartd, the disk platters are spun up. So if this option is not used, then a disk which is in a low-power mode may be spun up and put into a higher-power mode when it is periodically polled by smartd.<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -n standby,15,q}}<br />
<br />
More info on [http://www.smartmontools.org/wiki/Powermode smartmontools wiki].<br />
<br />
On some devices the -n does not work. You get the following error message in syslog:<br />
<br />
{{<br />
hc|journalctl -u smartd|<br />
CHECK POWER MODE: incomplete response, ATA output registers missing<br />
Device: /dev/sdb [SAT], no ATA CHECK POWER STATUS support, ignoring -n Directive<br />
}}<br />
<br />
As an alternative you can user -i option of smartd. It controls how often smartd spins the disks up to check their status. Default is 30 minutes. To change it create and edit /etc/default/smartmontools.<br />
<br />
{{<br />
hc|<br />
head=/etc/default/smartmontools|<br />
output=SMARTD_ARGS="-i 21600" Check status every 21600 seconds (3 hours)<br />
}}<br />
<br />
Mori info on [http://www.smartmontools.org/browser/trunk/smartmontools/smartd.8.in smartd manpage]<br />
<br />
==== Schedule self-tests ====<br />
<br />
smartd can tell disks to perform self-tests on a schedule. The following {{ic|/etc/smartd.conf}} configuration will start a short self-test every day between 2-3am, and an extended self test weekly on Saturdays between 3-4am:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -s (S/../.././02&#124;L/../../6/03)}}<br />
<br />
==== Alert on temperature changes ====<br />
<br />
smartd can track disk temperatures and alert if they rise too quickly or hit a high limit. The following will log changes of 4 degrees or more, log when temp reaches 35 degrees, and log/email a warning when temp reaches 40:<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -W 4,35,40}}<br />
<br />
{{Tip|You can determine the current disk temperature with the command {{ic|smartctl -A /dev/<device> &#124; grep Temperature_Celsius}}}}<br />
<br />
{{Tip|If you have some disks that run a lot hotter/cooler than others, remove {{ic|DEVICESCAN}} and define a separate configuration for each device with appropriate temperature settings.}}<br />
<br />
==== Complete {{ic|smartd.conf}} example ====<br />
<br />
Putting together all of the above gives the following example configuration:<br />
<br />
* {{ic|DEVICESCAN}} (smartd scans for disks and monitors all it finds)<br />
* {{ic|-a}} (monitor all attributes)<br />
* {{ic|-o on}} (enable automatic online data collection)<br />
* {{ic|-S on}} (enable automatic attribute autosave)<br />
* {{ic|-n standby,q}} (do not check if disk is in standby, and suppress log message to that effect so as not to cause a write to disk)<br />
* {{ic|-s ...}} (schedule short and long self-tests)<br />
* {{ic|-W ...}} (monitor temperature)<br />
* {{ic|-m ...}} (mail alerts)<br />
<br />
{{hc|/etc/smartd.conf|DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02&#124;L/../../6/03) -W 4,35,40 -m <username or email>}}<br />
<br />
== GUI Applications ==<br />
<br />
* {{App|Gsmartcontrol|A GNOME frontend for the smartctl hard disk drive health inspection tool|http://gsmartcontrol.sourceforge.net|{{Pkg|gsmartcontrol}} or {{AUR|gsmartcontrol-svn}}}}<br />
<br />
== Resources ==<br />
<br />
* [http://www.smartmontools.org/ Smartmontools Homepage]<br />
* [https://help.ubuntu.com/community/Smartmontools Smartmontools on Ubuntu Wiki]</div>TPXPhttps://wiki.archlinux.org/index.php?title=GNOME&diff=443530GNOME2016-07-28T07:40:26Z<p>TPXP: Fix an incorrect link</p>
<hr />
<div>[[Category:GNOME]]<br />
[[cs:GNOME]]<br />
[[de:GNOME]]<br />
[[es:GNOME]]<br />
[[fr:GNOME]]<br />
[[it:GNOME]]<br />
[[ja:GNOME]]<br />
[[nl:GNOME]]<br />
[[pl:GNOME]]<br />
[[pt:GNOME]]<br />
[[ru:GNOME]]<br />
[[sr:GNOME]]<br />
[[th:GNOME]]<br />
[[tr:Gnome Masaüstü Ortamı]]<br />
[[uk:GNOME]]<br />
[[zh-CN:GNOME]]<br />
[[zh-TW:GNOME]]<br />
{{Related articles start}}<br />
{{Related|Desktop environment}}<br />
{{Related|Display manager}}<br />
{{Related|Window manager}}<br />
{{Related|GTK+}}<br />
{{Related|GDM}}<br />
{{Related|GNOME/Tips and tricks}}<br />
{{Related|GNOME/Troubleshooting}}<br />
{{Related|GNOME/Files}}<br />
{{Related|GNOME/Gedit}}<br />
{{Related|GNOME/Web}}<br />
{{Related|GNOME/Evolution}}<br />
{{Related|GNOME/Flashback}}<br />
{{Related|GNOME/Keyring}}<br />
{{Related|Cinnamon}}<br />
{{Related|MATE}}<br />
{{Related|Official repositories#gnome-unstable}}<br />
{{Related articles end}}<br />
<br />
GNOME (pronounced ''gah-nohm'' or ''nohm'') is a [[desktop environment]] that aims to be simple and easy to use. It is designed by [[Wikipedia:The GNOME Project|The GNOME Project]] and is composed entirely of free and open-source software. GNOME is a part of the [[Wikipedia:GNU Project|GNU Project]].<br />
<br />
== Installation ==<br />
<br />
Two groups are available:<br />
<br />
* {{Grp|gnome}} contains the base GNOME desktop and a subset of well-integrated [https://wiki.gnome.org/Apps applications];<br />
* {{Grp|gnome-extra}} contains further GNOME applications, including an archive manager, disk manager, [[Gedit|text editor]], and a set of games. Note that this group builds on the {{Grp|gnome}} group.<br />
<br />
The base desktop consists of [[Wikipedia:GNOME_Shell|GNOME Shell]], a plugin for the [[Wikipedia:Mutter_(software)|Mutter]] window manager. It can be installed separately with {{Pkg|gnome-shell}}.<br />
<br />
{{Note|''mutter'' acts as a composite manager for the desktop, employing hardware graphics acceleration to provide effects aimed at reducing screen clutter. The GNOME session manager automatically detects if your video driver is capable of running GNOME Shell and if not, falls back to software rendering using ''llvmpipe''.}} <br />
<br />
=== Additional packages ===<br />
<br />
These packages are not in the above mentioned groups:<br />
<br />
* {{App|[[Wikipedia:GNOME Boxes|Boxes]]|A simple user interface to access [[libvirt]] virtual machines.|https://wiki.gnome.org/Apps/Boxes|{{Pkg|gnome-boxes}}}}<br />
* {{App|GNOME Initial Setup|A simple, easy, and safe way to prepare a new system.|https://github.com/GNOME/gnome-initial-setup|{{Pkg|gnome-initial-setup}}}}<br />
* {{App|GNOME PackageKit|Collection of graphical tools for PackageKit to be used in the GNOME desktop.|https://github.com/GNOME/gnome-packagekit|{{Pkg|gnome-packagekit}}}}<br />
* {{App|[[Wikipedia:Nemiver|Nemiver]]|A C/C++ debugger.|https://wiki.gnome.org/Apps/Nemiver|{{Pkg|nemiver}}}}<br />
* {{App|[[Wikipedia:GNOME Software|Software]]|Lets you install and update applications and system extensions.|https://wiki.gnome.org/Apps/Software/|{{Pkg|gnome-software}}}}<br />
<br />
== GNOME Sessions ==<br />
<br />
GNOME has three available sessions, all using GNOME Shell.<br />
<br />
*'''GNOME''' is the default, innovative layout.<br />
*'''GNOME Classic''' is a traditional desktop layout with a similar interface to GNOME 2, using pre-activated extensions and parameters. [http://worldofgnome.org/welcome-to-gnome-3-8-flintstones-mode/] Hence it is more a customized GNOME Shell than a truly distinct mode.<br />
*'''GNOME on Wayland''' runs GNOME Shell using the new Wayland protocol. Traditional X applications are run through Xwayland.<br />
<br />
== Starting GNOME ==<br />
<br />
GNOME can be started either graphically, using a [[display manager]], or manually from the console. For optimal desktop integration, using [[GDM]] (the GNOME Display manager) is recommended. Note that [[enabling]] a display manager (such as GDM) means that Xorg will run with root rights. <br />
<br />
{{Note|Support for screen locking in GNOME is provided by GDM. If GNOME is not started using GDM, you will have to use another screen locker to provide this functionality - see [[List of applications/Security#Screen lockers]].}}<br />
<br />
=== Graphically ===<br />
<br />
Select the session: ''GNOME'', ''GNOME Classic'' or ''GNOME on Wayland'' from the display manager's session menu.<br />
<br />
=== Manually ===<br />
<br />
* For the standard GNOME session, add to the {{ic|~/.xinitrc}} file: {{ic|exec gnome-session}}.<br />
* For the GNOME Classic session, add to the {{ic|~/.xinitrc}} file: {{bc|<nowiki>export XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME<br />
export GNOME_SHELL_SESSION_MODE=classic<br />
exec gnome-session --session=gnome-classic</nowiki>}}<br />
<br />
After editing the {{ic|~/.xinitrc}} file, GNOME can be launched with the {{ic|startx}} command (see [[xinitrc]] for additional details, such as preserving the logind session). After setting up the {{ic|~/.xinitrc}} file it can also be arranged to [[Start X at login]].<br />
<br />
{{Note|GNOME on Wayland requires the {{Pkg|xorg-server-xwayland}} package, and '''cannot''' be started using ''startx'' and {{ic|~/.xinitrc}}. Instead, run {{ic|gnome-session --session&#61;gnome-wayland}}. For more information, see [[Wayland]].}}<br />
<br />
=== GNOME applications in Wayland ===<br />
<br />
Currently, by default, GNOME applications will be run as traditional X applications through Xwayland. To test GNOME applications with Wayland, use the command line to run the application and prefix the command with {{ic|env GDK_BACKEND&#61;'wayland,x11' <command>}}.<br />
<br />
{{Note|Setting a global Wayland environment, by running {{ic|env GDK_BACKEND&#61;wayland gnome-session --session&#61;gnome-wayland}}, currently does not work. For workarounds, see [[GNOME/Troubleshooting#Setting global Wayland environment with an environment variable]].}}<br />
<br />
See the current status of Wayland on GNOME at [https://wiki.gnome.org/Initiatives/Wayland/Applications/ GNOME Applications under Wayland].<br />
<br />
== Navigation ==<br />
<br />
To learn how to use the GNOME shell effectively read the [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell Cheat Sheet]; it highlights GNOME shell features and keyboard shortcuts. Features include task switching, keyboard use, window control, the panel, overview mode, and more. A few of the shortcuts are:<br />
<br />
* {{ic|Super}} + {{ic|m}}: show message tray<br />
* {{ic|Super}} + {{ic|a}}: show applications menu<br />
* {{ic|Alt-}} + {{ic|Tab}}: cycle active applications <br />
* {{ic|Alt-}} + {{ic|`}} (the key above {{ic|Tab}} on US keyboard layouts): cycle windows of the application in the foreground <br />
* {{ic|Alt}} + {{ic|F2}}, then enter {{ic|r}} or {{ic|restart}}: restart the shell in case of graphical shell problems. <br />
<br />
=== Legacy names ===<br />
<br />
{{Note|<br />
Some GNOME programs have undergone name changes where the application's name in documentation and about dialogs has been changed but the executable name has not. A few such applications are listed in the table below.}}<br />
<br />
{{Tip|Searching for the legacy name of an application in the Shell search bar will successfully return the application in question. For instance, searching for ''nautilus'' will return ''Files''.}}<br />
<br />
{| class="wikitable"<br />
! Current<br />
! Legacy<br />
|-<br />
| [[Files]]<br />
| Nautilus<br />
|-<br />
| [[GNOME Web|Web]]<br />
| Epiphany<br />
|-<br />
| Videos<br />
| Totem<br />
|-<br />
| Main Menu<br />
| Alacarte<br />
|-<br />
| Document Viewer<br />
| Evince<br />
|-<br />
| Disk Usage Analyser<br />
| Baobab<br />
|-<br />
| Image Viewer<br />
| EoG (Eye of GNOME)<br />
|-<br />
| [[GNOME Keyring|Passwords and Keys]]<br />
| Seahorse<br />
|}<br />
<br />
== Configuration ==<br />
<br />
The GNOME desktop relies on a configuration database backend (DConf) to store system and application settings. The desktop comes with default configuration settings, installed applications add their own to the database. The basic configuration is done either via the GNOME System Settings panel (''gnome-control-center'') or the preferences of the individual applications. A direct configuration of the DConf database is always possible as well and performed with the ''gsettings'' command line tool. In particular it can be used to configure settings which are not exposed via the user interface.<br />
<br />
GNOME settings are then applied by the GNOME Settings Daemon. Note that the daemon can be run outside of a GNOME session in order to apply GNOME configuration in a non-GNOME environment. Execute {{ic|nohup /usr/lib/gnome-settings-daemon/gnome-settings-daemon > /dev/null &}} to do so.<br />
<br />
The configuration is usually performed per user and the rest of this section does not cover how to create configuration templates for a multi-user-system. <br />
<br />
=== System settings ===<br />
<br />
Control panel settings of note.<br />
<br />
==== Color ====<br />
<br />
The daemon {{ic|colord}} reads the display's EDID and extracts the appropriate color profile. Most color profiles are accurate and no setup is required; however for those that are not accurate, or for older displays, color profiles can be put in {{ic|~/.local/share/icc/}} and directed to.<br />
<br />
==== Date & time ====<br />
<br />
If the system has a configured [[Network Time Protocol daemon]], it will be effective for GNOME as well. The synchronization can be set to manual control from the menu, if required. <br />
<br />
To show the date in the top bar, execute:<br />
<br />
$ gsettings set org.gnome.desktop.interface clock-show-date true<br />
<br />
Additionally, to show week numbers in the Shell calendar, execute:<br />
$ gsettings set org.gnome.shell.calendar show-weekdate true<br />
<br />
==== Default applications ====<br />
<br />
Upon installing GNOME for the first time, you may find that the wrong applications are handling certain protocols. For example, ''totem'' opens videos instead of a previously used [[VLC]]. Some of the associations can be set from system settings via: ''System'' > ''Details'' > ''Default applications''. <br />
<br />
For other protocols and methods see [[Default applications]] for configuration. <br />
<br />
==== Mouse and touchpad ====<br />
<br />
To help reduce touchpad interference you may wish to implement the settings below:<br />
<br />
* Disable touchpad while typing<br />
* Disable scrolling<br />
* Disable tap-to-click<br />
<br />
{{Note|1=The [[synaptics]] driver is not supported by GNOME. Instead, you should use [[libinput]]. See [https://bugzilla.gnome.org/show_bug.cgi?id=764257#c12 this bug report].}}<br />
<br />
==== Network ====<br />
<br />
[[NetworkManager]] is the native tool of the GNOME project to control network settings from the shell. It is installed by default as a dependency for {{Pkg|tracker}} package, which is a part of {{Grp|gnome}} group, and just needs to be [[NetworkManager#Enable NetworkManager|enabled]].<br />
<br />
While any other [[List_of_applications/Internet#Network_managers|network manager]] can be used as well, NetworkManager provides the full integration via the shell network settings and a status indicator applet {{Pkg|network-manager-applet}} (not required for GNOME).<br />
<br />
==== Online accounts ====<br />
<br />
Backends for the GNOME messaging application {{Pkg|empathy}} as well as the GNOME Online Accounts section of the System Settings panel are provided in a separate group: {{Grp|telepathy}}. See [[#Unable to add accounts in Empathy and GNOME Online Accounts]]. Some online accounts, such as [[ownCloud]], require {{Pkg|gvfs-goa}} to be installed for full functionality in GNOME applications such as [[GNOME Files]] and GNOME Documents [https://wiki.gnome.org/ThreePointSeven/Features/Owncloud].<br />
<br />
==== Search ====<br />
<br />
The GNOME shell has a search that can be quickly accessed by pressing the {{ic|Super}} key and starting to type. The {{Pkg|tracker}} package is installed by default as a part of {{Grp|gnome}} group and provides an indexing application and metadata database. It can be configured with the ''Search and Indexing'' menu item; monitor status with ''tracker-control''. It is started automatically by ''gnome-session'' when the user logs in. Indexing can be started manually with {{ic|tracker-control -s}}. Search settings can also be configured in the ''System Settings'' panel.<br />
<br />
The Tracker database can be queried using the ''tracker-sparql'' command. View its manual page {{ic|man tracker-sparql}} for more information.<br />
<br />
=== Advanced settings ===<br />
<br />
As noted above, many configuration options such as changing the [[GTK+]] theme or the [[window manager]] theme are not exposed in the GNOME System Settings panel (''gnome-control-center''). Those users that want to configure these settings may wish to use the GNOME Tweak Tool ({{Pkg|gnome-tweak-tool}}), a convenient graphical tool which exposes many of these settings. <br />
<br />
GNOME settings (which are stored in the DConf database) can also be configured using the [https://developer.gnome.org/dconf/unstable/dconf-editor.html ''dconf-editor''] (a graphical DConf configuration tool) or the [https://developer.gnome.org/gio/stable/GSettings.html ''gsettings''] command line tool. The GNOME Tweak Tool does not do anything else in the background of the GUI; note though that you will not find all settings described in the following sections in it. <br />
<br />
==== Appearance ====<br />
<br />
===== GTK+ themes and icon themes =====<br />
<br />
To install a new theme or icon set, add the relevant {{ic|~/.local/share/themes}} or {{ic|~/.local/share/icons}} respectively (add to {{ic|/usr/share/}} instead of {{ic|~/.local/share/}} for the themes to be available systemwide.) They and other GUI settings can also be defined in {{ic|~/.config/gtk-3.0/settings.ini}}:<br />
<br />
{{hc|~/.config/gtk-3.0/settings.ini|<nowiki><br />
[Settings]<br />
gtk-theme-name = Adwaita<br />
# next option is applicable only if selected theme supports it<br />
gtk-application-prefer-dark-theme = true<br />
# set font name and dimension<br />
gtk-font-name = Sans 10<br />
</nowiki>}}<br />
<br />
Additional theme locations:<br />
* [http://www.deviantart.com/browse/all/customization/skins/linuxutil/desktopenv/gnome/gtk3/ DeviantArt].<br />
* [http://gnome-look.org/index.php?xcontentmode=167 gnome-look.org].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=gtk3&do_Search=Go GTK3 themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=xcursor&do_Search=Go&PP=50&SB=v&SO=d Cursor themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=icon-theme&do_Search=Go&PP=50&SB=v&SO=d Icon themes in the AUR].<br />
<br />
Once installed, they can be selected using the GNOME Tweak Tool or GSettings - see below for GSettings commands:<br />
<br />
For the GTK+ theme:<br />
$ gsettings set org.gnome.desktop.interface gtk-theme ''theme-name''<br />
<br />
For the icon theme<br />
$ gsettings set org.gnome.desktop.interface icon-theme ''theme-name''<br />
<br />
====== Global dark theme ======<br />
<br />
GNOME will use the Adwaita light theme by default however a dark variant of this theme (called the Global Dark Theme) also exists and can be selected using the Tweak Tool or by editing the GTK+ 3 settings file - see [[GTK+#Dark theme variant]]. Some applications such as Image Viewer (''eog'') use the dark theme by default. It should be noted that the Global Dark Theme only works with GTK+ 3 applications; some GTK+ 3 applications may only have partial support for the Global Dark theme. Qt and GTK+ 2 support for the Global Dark Theme may be added in the future.<br />
<br />
===== Window manager themes =====<br />
<br />
The window manager theme (the style of the window titlebars) can be set using the GNOME Tweak Tool or the following GSettings command:<br />
$ gsettings set org.gnome.desktop.wm.preferences theme ''theme-name''<br />
<br />
====== Titlebar height ======<br />
<br />
{{Note|Applying this configuration shrinks the titlebar of the GNOME-terminal and Chromium, but does not appear to affect the Nautilus titlebar height.}}<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<br />
headerbar.default-decoration {<br />
padding-top: 0px;<br />
padding-bottom: 0px;<br />
min-height: 0px;<br />
font-size: 0.6em;<br />
}<br />
<br />
headerbar.default-decoration button.titlebutton {<br />
padding: 0px;<br />
min-height: 0px;<br />
}<br />
}}<br />
See [https://ask.fedoraproject.org/en/question/10035/shrink-title-bar/?answer=86149#post-id-86149] for more information.<br />
<br />
====== Titlebar button order ======<br />
<br />
To set the order for the GNOME window manager (Mutter, Metacity): <br />
$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'<br />
<br />
{{Tip|The colon indicates which side of the titlebar the window buttons will appear.}}<br />
<br />
====== Hide titlebar when maximized ======<br />
<br />
*[[Install]] {{AUR|gnome-shell-extension-pixel-saver-git}} or {{AUR|gnome-shell-extension-pixel-saver}}. Maximized windows get the title bar merged into the activity bar, saving precious pixels.<br />
<br />
*[[Install]] {{AUR|mutter-hide-legacy-decorations}}. It changes a default setting in the window manager, so as to automatically hide the titlebar on legacy (non-headerbar) apps when they are maximized or tiled to the side.<br />
<br />
*[[Install]] {{AUR|maximus}}. To start the application, execute ''maximus'' from a terminal. When running, the daemon will automatically maximize windows. It will undecorate maximized windows and redecorate them when they are unmaximized. If you do not want all windows to start maximized, run {{ic|maximus -m}} instead. Note that this will only work with windows decorated by the window manager; applications that use client-side decoration such as [[GNOME Files]] will not be undecorated when maximized.<br />
<br />
===== GNOME Shell themes =====<br />
<br />
The theme of GNOME Shell itself is configurable. To use a Shell theme, firstly ensure that you have the {{Pkg|gnome-shell-extensions}} package installed. Then enable the ''User Themes'' extension, either through GNOME Tweak Tool or through the [https://extensions.gnome.org GNOME Shell Extensions] webpage. Shell themes can then be loaded and selected using the GNOME Tweak Tool.<br />
<br />
There are a number of GNOME Shell themes available [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-theme&do_Search=Go&PP=50&SB=v&SO=d in the AUR].<br />
<br />
Shell themes can also be downloaded from [http://gnome-look.org/index.php?xcontentmode=191 gnome-look.org].<br />
<br />
==== Desktop ====<br />
<br />
Various Desktop settings can be applied.<br />
<br />
===== Icons on the Desktop =====<br />
<br />
See [[GNOME/Files#Desktop Icons]].<br />
<br />
===== Lock screen and background =====<br />
<br />
When setting the Desktop or Lock screen background, it is important to note that the Pictures tab will only display pictures located in {{ic|/home/''username''/Pictures}} folder. If you wish to use a picture not located in this folder, use the commands indicated below.<br />
<br />
For the desktop background:<br />
$ gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
For the lock screen background<br />
$ gsettings set org.gnome.desktop.screensaver picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
==== Extensions ====<br />
<br />
{{Note|The GNOME Shell browser plugin which allows users to install extensions from [https://extensions.gnome.org extensions.gnome.org] is not compatible with Chrome/Chromium. Users wishing to install extensions from the webpage will have to use a compatible browser such as [[Firefox]] or [[GNOME/Web]].}}<br />
<br />
GNOME Shell can be customized with extensions per user or system-wide. <br />
<br />
The catalogue of extensions is available at [https://extensions.gnome.org extensions.gnome.org]. By a user they can be installed and activated in the browser by setting the switch in the top left of the screen to '''ON''' and clicking '''Install''' on the resulting dialog (if the extension in question is not installed). After installation it is shown in the [https://extensions.gnome.org/local/ extensions.gnome.org/local/] tab, which has to be visited as well to check for available updates. Installed extensions can also be enabled or disabled using {{Pkg|gnome-tweak-tool}}. <br />
<br />
More information about GNOME shell extensions is available on the [https://extensions.gnome.org/about/ GNOME Shell Extensions about page].<br />
<br />
[[Installing]] extensions via a package makes them available for all users of the system and automates the update process. <br />
<br />
The {{Pkg|gnome-shell-extensions}} package provides a set of extensions maintained as part of the GNOME project (many of the included extensions are used by the GNOME Classic session). <br />
<br />
Users who want a taskbar but do not wish to use the GNOME Classic session may want to enable the ''Window list'' extension (provided by the {{Pkg|gnome-shell-extensions}} package).<br />
<br />
==== Input methods ====<br />
<br />
GNOME has integrated support for input methods through [[IBus]], only {{Pkg|ibus}} and the wanted input method engine (e.g. {{Pkg|ibus-libpinyin}} for Intelligent Pinyin) needed to be installed, after installation the input method engine can be added as a keyboard layout in GNOME's Regional & Language Settings.<br />
<br />
==== Fonts ====<br />
<br />
{{Tip|If you set the ''Scaling factor'' to a value above 1.00, the Accessibility menu will be automatically enabled.}}<br />
<br />
Fonts can be set for Window titles, Interface (applications), Documents and Monospace. See the Fonts tab in the Tweak Tool for the relevant options.<br />
<br />
For hinting, RGBA will likely be desired as this fits most monitors types, and if fonts appear too blocked reduce hinting to ''Slight'' or ''None''.<br />
<br />
==== Startup applications ====<br />
<br />
To start certain applications on login, copy the relevant {{ic|.desktop}} file from {{ic|/usr/share/applications/}} to {{ic|~/.config/autostart/}}.<br />
<br />
The {{Pkg|gnome-tweak-tool}} allows managing autostart-entries.<br />
<br />
{{Tip|If the plus sign button in the Tweak Tool's Startup Applications section is unresponsive, try start the Tweak Tool from the terminal using the following command: {{ic|gnome-tweak-tool}}. See the following [https://bbs.archlinux.org/viewtopic.php?pid&#61;1413631#p1413631 forum thread].}}<br />
<br />
{{Note|The deprecated ''gnome-session-properties'' dialog can be added by [[install]]ing the {{AUR|gnome-session-properties}} package.}}<br />
<br />
==== Power ====<br />
<br />
The basic power settings that may want to be altered (these example settings assume the user is using a laptop - change them as desired):<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.power button-power ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout ''3600''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout ''1800''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type ''hibernate''<br />
$ gsettings set org.gnome.desktop.lockdown disable-lock-screen ''true''<br />
<br />
To keep a monitor active on lid close: <br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup do-nothing<br />
<br />
===== Configure behaviour on lid switch close =====<br />
<br />
The GNOME Tweak Tool can optionally ''inhibit'' the ''systemd'' setting for the lid close ACPI event.[http://ftp.gnome.org/pub/GNOME/sources/gnome-tweak-tool/3.17/gnome-tweak-tool-3.17.1.news] To ''inhibit'' the setting, start the Tweak Tool and, under the power tab, check the ''Don't suspend on lid close'' option. This means that the system will do nothing on lid close instead of suspending - the default behaviour. Checking the setting creates {{ic|~/.config/autostart/ignore-lid-switch-tweak.desktop}} which will autostart the Tweak Tool's inhibitor.<br />
<br />
If you do not want the system to suspend or do nothing on lid close, you will need to ensure that the setting described above is '''not''' checked and then configure ''systemd'' with {{ic|1=HandleLidSwitch=''preferred_behaviour''}} as described in [[Power management#ACPI events]].<br />
<br />
===== Change critical battery level action =====<br />
<br />
The settings panel does not provide an option for changing the critical battery level action. These settings have been removed from dconf as well. They are now managed by upower. Edit the upower settings in {{ic|/etc/UPower/UPower.conf}}. Find these settings and adjust to your needs.<br />
<br />
{{hc|head=/etc/UPower/UPower.conf|output=<br />
PercentageLow=10<br />
PercentageCritical=3<br />
PercentageAction=2<br />
CriticalPowerAction=HybridSleep<br />
}}<br />
<br />
==== Sort applications into application (app) folders ====<br />
<br />
{{Tip|The [https://github.com/prurigro/gnome-catgen gnome-catgen] ({{AUR|gnome-catgen-git}}) script allows you to manage folders through the creation of files in {{ic|~/.local/share/applications-categories}} named after each category and containing a list of the desktop files belonging to apps you would like to have inside. Optionally, you can have it cycle through each app without a folder and input the desired category until you ctrl-c or run out of apps.}}<br />
<br />
In the '''dconf-editor''' navigate to {{ic|org.gnome.desktop.app-folders}} and set the value of {{ic|folder-children}} to an array of comma separated folder names:<br />
<br />
['Utilities', 'Sundry']<br />
<br />
Add applications using {{ic|gsettings}}:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ apps "['alacarte.desktop', 'dconf-editor.desktop']"<br />
<br />
This adds the applications {{ic|alacarte.desktop}} and {{ic|dconf-editor.desktop}} to the Sundry folder. This will also create the folder {{ic|org.gnome.desktop.app-folders.folders.Sundry}}.<br />
<br />
To name the folder (if it has no name that appears at the top of the applications):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ name "Sundry"<br />
<br />
Applications can also be sorted by their category (specified in their ''.desktop'' file):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ categories "['Office']"<br />
<br />
If certain applications matching a category are not wanted in a certain folder, exclusions can be set:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ excluded-apps "['libreoffice-draw.desktop']"<br />
<br />
For further information, refer to the [https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.app-folders.gschema.xml.in app-folders schema].<br />
<br />
== See also ==<br />
<br />
* [http://www.gnome.org/ The Official Website of GNOME]<br />
* [https://extensions.gnome.org/ Extensions for GNOME-shell]<br />
* [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell Cheat Sheet], commands, keyboard shortcuts and other tips for using GNOME Shell.<br />
* Themes, icons, and backgrounds:<br />
** [http://art.gnome.org/ GNOME Art]<br />
** [http://www.gnome-look.org/ GNOME Look]<br />
* GTK/GNOME programs:<br />
** [http://www.gnomefiles.org/ GNOME Files]<br />
** [http://www.gnome.org/projects/ GNOME Project Listing]<br />
* [http://blog.fpmurphy.com/2011/03/customizing-the-gnome-3-shell.html Customizing the GNOME Shell]</div>TPXP